@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
| 260 | 273 | // Bring in any changes we want to make before the query. |
| 261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
| 262 | 275 | |
| 263 | - foreach ($sort_methods as $key => $val) |
|
| 264 | - $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>'; |
|
| 276 | + foreach ($sort_methods as $key => $val) { |
|
| 277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 278 | + } |
|
| 265 | 279 | |
| 266 | 280 | // Calculate the fastest way to get the topics. |
| 267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
| 271 | 285 | $fake_ascending = true; |
| 272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
| 273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
| 288 | + } else { |
|
| 289 | + $fake_ascending = false; |
|
| 274 | 290 | } |
| 275 | - else |
|
| 276 | - $fake_ascending = false; |
|
| 277 | 291 | |
| 278 | 292 | // Setup the default topic icons... |
| 279 | 293 | $context['icon_sources'] = array(); |
| 280 | - foreach ($context['stable_icons'] as $icon) |
|
| 281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 294 | + foreach ($context['stable_icons'] as $icon) { |
|
| 295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 296 | + } |
|
| 282 | 297 | |
| 283 | 298 | $topic_ids = array(); |
| 284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
| 316 | 331 | $message_pre_index_parameters |
| 317 | 332 | ); |
| 318 | 333 | $topic_ids = array(); |
| 319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 320 | - $topic_ids[] = $row['id_topic']; |
|
| 334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 335 | + $topic_ids[] = $row['id_topic']; |
|
| 336 | + } |
|
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | // Grab the appropriate topic information... |
@@ -375,11 +391,13 @@ discard block |
||
| 375 | 391 | // Begin 'printing' the message index for current board. |
| 376 | 392 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 377 | 393 | { |
| 378 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 379 | - continue; |
|
| 394 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 395 | + continue; |
|
| 396 | + } |
|
| 380 | 397 | |
| 381 | - if (!$pre_query) |
|
| 382 | - $topic_ids[] = $row['id_topic']; |
|
| 398 | + if (!$pre_query) { |
|
| 399 | + $topic_ids[] = $row['id_topic']; |
|
| 400 | + } |
|
| 383 | 401 | |
| 384 | 402 | // Reference the main color class. |
| 385 | 403 | $colorClass = 'windowbg'; |
@@ -389,8 +407,9 @@ discard block |
||
| 389 | 407 | { |
| 390 | 408 | // Limit them to $modSettings['preview_characters'] characters |
| 391 | 409 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 392 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 393 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 410 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 411 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 412 | + } |
|
| 394 | 413 | |
| 395 | 414 | // Censor the subject and message preview. |
| 396 | 415 | censorText($row['first_subject']); |
@@ -401,27 +420,27 @@ discard block |
||
| 401 | 420 | { |
| 402 | 421 | $row['last_subject'] = $row['first_subject']; |
| 403 | 422 | $row['last_body'] = $row['first_body']; |
| 404 | - } |
|
| 405 | - else |
|
| 423 | + } else |
|
| 406 | 424 | { |
| 407 | 425 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 408 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 409 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 426 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 427 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 428 | + } |
|
| 410 | 429 | |
| 411 | 430 | censorText($row['last_subject']); |
| 412 | 431 | censorText($row['last_body']); |
| 413 | 432 | } |
| 414 | - } |
|
| 415 | - else |
|
| 433 | + } else |
|
| 416 | 434 | { |
| 417 | 435 | $row['first_body'] = ''; |
| 418 | 436 | $row['last_body'] = ''; |
| 419 | 437 | censorText($row['first_subject']); |
| 420 | 438 | |
| 421 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 422 | - $row['last_subject'] = $row['first_subject']; |
|
| 423 | - else |
|
| 424 | - censorText($row['last_subject']); |
|
| 439 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 440 | + $row['last_subject'] = $row['first_subject']; |
|
| 441 | + } else { |
|
| 442 | + censorText($row['last_subject']); |
|
| 443 | + } |
|
| 425 | 444 | } |
| 426 | 445 | |
| 427 | 446 | // Decide how many pages the topic should have. |
@@ -432,42 +451,50 @@ discard block |
||
| 432 | 451 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 433 | 452 | |
| 434 | 453 | // If we can use all, show all. |
| 435 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 436 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 454 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 455 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 456 | + } |
|
| 457 | + } else { |
|
| 458 | + $pages = ''; |
|
| 437 | 459 | } |
| 438 | - else |
|
| 439 | - $pages = ''; |
|
| 440 | 460 | |
| 441 | 461 | // We need to check the topic icons exist... |
| 442 | 462 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 443 | 463 | { |
| 444 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 445 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 446 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 447 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 448 | - } |
|
| 449 | - else |
|
| 464 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 465 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 466 | + } |
|
| 467 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 468 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 469 | + } |
|
| 470 | + } else |
|
| 450 | 471 | { |
| 451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 452 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 454 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 473 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 474 | + } |
|
| 475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 476 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 477 | + } |
|
| 455 | 478 | } |
| 456 | 479 | |
| 457 | - if (!empty($board_info['recycle'])) |
|
| 458 | - $row['first_icon'] = 'recycled'; |
|
| 480 | + if (!empty($board_info['recycle'])) { |
|
| 481 | + $row['first_icon'] = 'recycled'; |
|
| 482 | + } |
|
| 459 | 483 | |
| 460 | 484 | // Is this topic pending approval, or does it have any posts pending approval? |
| 461 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 462 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 485 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 486 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 487 | + } |
|
| 463 | 488 | |
| 464 | 489 | // Sticky topics should get a different color, too. |
| 465 | - if ($row['is_sticky']) |
|
| 466 | - $colorClass .= ' sticky'; |
|
| 490 | + if ($row['is_sticky']) { |
|
| 491 | + $colorClass .= ' sticky'; |
|
| 492 | + } |
|
| 467 | 493 | |
| 468 | 494 | // Locked topics get special treatment as well. |
| 469 | - if ($row['locked']) |
|
| 470 | - $colorClass .= ' locked'; |
|
| 495 | + if ($row['locked']) { |
|
| 496 | + $colorClass .= ' locked'; |
|
| 497 | + } |
|
| 471 | 498 | |
| 472 | 499 | // 'Print' the topic info. |
| 473 | 500 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -548,8 +575,9 @@ discard block |
||
| 548 | 575 | $smcFunc['db_free_result']($result); |
| 549 | 576 | |
| 550 | 577 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 551 | - if ($fake_ascending) |
|
| 552 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 578 | + if ($fake_ascending) { |
|
| 579 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 580 | + } |
|
| 553 | 581 | |
| 554 | 582 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 555 | 583 | { |
@@ -566,8 +594,9 @@ discard block |
||
| 566 | 594 | 'limit' => count($topic_ids), |
| 567 | 595 | ) |
| 568 | 596 | ); |
| 569 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 570 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 597 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 598 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 599 | + } |
|
| 571 | 600 | $smcFunc['db_free_result']($result); |
| 572 | 601 | } |
| 573 | 602 | } |
@@ -592,9 +621,9 @@ discard block |
||
| 592 | 621 | // Can we restore topics? |
| 593 | 622 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 594 | 623 | |
| 595 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 596 | - $context['can_move_any'] = true; |
|
| 597 | - else |
|
| 624 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 625 | + $context['can_move_any'] = true; |
|
| 626 | + } else |
|
| 598 | 627 | { |
| 599 | 628 | // We'll use this in a minute |
| 600 | 629 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -621,11 +650,13 @@ discard block |
||
| 621 | 650 | } |
| 622 | 651 | |
| 623 | 652 | // Can we use quick moderation checkboxes? |
| 624 | - if ($options['display_quick_mod'] == 1) |
|
| 625 | - $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']; |
|
| 653 | + if ($options['display_quick_mod'] == 1) { |
|
| 654 | + $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']; |
|
| 655 | + } |
|
| 626 | 656 | // Or the icons? |
| 627 | - else |
|
| 628 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 657 | + else { |
|
| 658 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 659 | + } |
|
| 629 | 660 | } |
| 630 | 661 | |
| 631 | 662 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -659,13 +690,15 @@ discard block |
||
| 659 | 690 | ); |
| 660 | 691 | |
| 661 | 692 | // We've seen all these boards now! |
| 662 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 663 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 693 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 694 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 664 | 695 | unset($_SESSION['topicseen_cache'][$k]); |
| 696 | + } |
|
| 665 | 697 | } |
| 666 | 698 | |
| 667 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 668 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 699 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 700 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 701 | + } |
|
| 669 | 702 | |
| 670 | 703 | $request = $smcFunc['db_query']('', ' |
| 671 | 704 | SELECT id_topic, id_board, sent |
@@ -686,8 +719,9 @@ discard block |
||
| 686 | 719 | $context['is_marked_notify'] = true; |
| 687 | 720 | $board_sent = $row['sent']; |
| 688 | 721 | } |
| 689 | - if (!empty($row['id_topic'])) |
|
| 690 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 722 | + if (!empty($row['id_topic'])) { |
|
| 723 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 724 | + } |
|
| 691 | 725 | } |
| 692 | 726 | $smcFunc['db_free_result']($request); |
| 693 | 727 | |
@@ -711,8 +745,7 @@ discard block |
||
| 711 | 745 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 712 | 746 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 713 | 747 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 714 | - } |
|
| 715 | - else |
|
| 748 | + } else |
|
| 716 | 749 | { |
| 717 | 750 | $context['is_marked_notify'] = false; |
| 718 | 751 | $context['board_notification_mode'] = 1; |
@@ -725,23 +758,27 @@ discard block |
||
| 725 | 758 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 726 | 759 | |
| 727 | 760 | // Don't want to show this forever... |
| 728 | - if ($context['becomesUnapproved']) |
|
| 729 | - unset($_SESSION['becomesUnapproved']); |
|
| 761 | + if ($context['becomesUnapproved']) { |
|
| 762 | + unset($_SESSION['becomesUnapproved']); |
|
| 763 | + } |
|
| 730 | 764 | |
| 731 | 765 | // Build the message index button array. |
| 732 | 766 | $context['normal_buttons'] = array(); |
| 733 | 767 | |
| 734 | - if ($context['can_post_new']) |
|
| 735 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 768 | + if ($context['can_post_new']) { |
|
| 769 | + $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); |
|
| 770 | + } |
|
| 736 | 771 | |
| 737 | - if ($context['can_post_poll']) |
|
| 738 | - $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'); |
|
| 772 | + if ($context['can_post_poll']) { |
|
| 773 | + $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'); |
|
| 774 | + } |
|
| 739 | 775 | |
| 740 | - if (!$context['user']['is_logged']) |
|
| 741 | - $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']); |
|
| 776 | + if (!$context['user']['is_logged']) { |
|
| 777 | + $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']); |
|
| 778 | + } |
|
| 742 | 779 | |
| 743 | - if ($context['can_mark_notify']) |
|
| 744 | - $context['normal_buttons']['notify'] = array( |
|
| 780 | + if ($context['can_mark_notify']) { |
|
| 781 | + $context['normal_buttons']['notify'] = array( |
|
| 745 | 782 | 'lang' => true, |
| 746 | 783 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 747 | 784 | 'sub_buttons' => array( |
@@ -759,6 +796,7 @@ discard block |
||
| 759 | 796 | ), |
| 760 | 797 | ), |
| 761 | 798 | ); |
| 799 | + } |
|
| 762 | 800 | |
| 763 | 801 | // Javascript for inline editing. |
| 764 | 802 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -780,18 +818,21 @@ discard block |
||
| 780 | 818 | checkSession('request'); |
| 781 | 819 | |
| 782 | 820 | // Lets go straight to the restore area. |
| 783 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 784 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 821 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 822 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 823 | + } |
|
| 785 | 824 | |
| 786 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 787 | - $_SESSION['topicseen_cache'] = array(); |
|
| 825 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 826 | + $_SESSION['topicseen_cache'] = array(); |
|
| 827 | + } |
|
| 788 | 828 | |
| 789 | 829 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 790 | 830 | require_once($sourcedir . '/Subs-Post.php'); |
| 791 | 831 | |
| 792 | 832 | // Remember the last board they moved things to. |
| 793 | - if (isset($_REQUEST['move_to'])) |
|
| 794 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 833 | + if (isset($_REQUEST['move_to'])) { |
|
| 834 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 835 | + } |
|
| 795 | 836 | |
| 796 | 837 | // Only a few possible actions. |
| 797 | 838 | $possibleActions = array(); |
@@ -811,8 +852,7 @@ discard block |
||
| 811 | 852 | ); |
| 812 | 853 | |
| 813 | 854 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 814 | - } |
|
| 815 | - else |
|
| 855 | + } else |
|
| 816 | 856 | { |
| 817 | 857 | /** |
| 818 | 858 | * @todo Ugly. There's no getting around this, is there? |
@@ -830,8 +870,7 @@ discard block |
||
| 830 | 870 | if (!empty($board)) |
| 831 | 871 | { |
| 832 | 872 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 833 | - } |
|
| 834 | - else |
|
| 873 | + } else |
|
| 835 | 874 | { |
| 836 | 875 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 837 | 876 | } |
@@ -842,55 +881,67 @@ discard block |
||
| 842 | 881 | } |
| 843 | 882 | } |
| 844 | 883 | |
| 845 | - if (!$user_info['is_guest']) |
|
| 846 | - $possibleActions[] = 'markread'; |
|
| 847 | - if (!empty($boards_can['make_sticky'])) |
|
| 848 | - $possibleActions[] = 'sticky'; |
|
| 849 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 850 | - $possibleActions[] = 'move'; |
|
| 851 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 852 | - $possibleActions[] = 'remove'; |
|
| 853 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 854 | - $possibleActions[] = 'lock'; |
|
| 855 | - if (!empty($boards_can['merge_any'])) |
|
| 856 | - $possibleActions[] = 'merge'; |
|
| 857 | - if (!empty($boards_can['approve_posts'])) |
|
| 858 | - $possibleActions[] = 'approve'; |
|
| 884 | + if (!$user_info['is_guest']) { |
|
| 885 | + $possibleActions[] = 'markread'; |
|
| 886 | + } |
|
| 887 | + if (!empty($boards_can['make_sticky'])) { |
|
| 888 | + $possibleActions[] = 'sticky'; |
|
| 889 | + } |
|
| 890 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 891 | + $possibleActions[] = 'move'; |
|
| 892 | + } |
|
| 893 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 894 | + $possibleActions[] = 'remove'; |
|
| 895 | + } |
|
| 896 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 897 | + $possibleActions[] = 'lock'; |
|
| 898 | + } |
|
| 899 | + if (!empty($boards_can['merge_any'])) { |
|
| 900 | + $possibleActions[] = 'merge'; |
|
| 901 | + } |
|
| 902 | + if (!empty($boards_can['approve_posts'])) { |
|
| 903 | + $possibleActions[] = 'approve'; |
|
| 904 | + } |
|
| 859 | 905 | |
| 860 | 906 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 861 | 907 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 862 | 908 | if (!empty($_REQUEST['topics'])) |
| 863 | 909 | { |
| 864 | 910 | // If the action isn't valid, just quit now. |
| 865 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 866 | - redirectexit($redirect_url); |
|
| 911 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 912 | + redirectexit($redirect_url); |
|
| 913 | + } |
|
| 867 | 914 | |
| 868 | 915 | // Merge requires all topics as one parameter and can be done at once. |
| 869 | 916 | if ($_REQUEST['qaction'] == 'merge') |
| 870 | 917 | { |
| 871 | 918 | // Merge requires at least two topics. |
| 872 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 873 | - redirectexit($redirect_url); |
|
| 919 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 920 | + redirectexit($redirect_url); |
|
| 921 | + } |
|
| 874 | 922 | |
| 875 | 923 | require_once($sourcedir . '/SplitTopics.php'); |
| 876 | 924 | return MergeExecute($_REQUEST['topics']); |
| 877 | 925 | } |
| 878 | 926 | |
| 879 | 927 | // Just convert to the other method, to make it easier. |
| 880 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 881 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 928 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 929 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 930 | + } |
|
| 882 | 931 | } |
| 883 | 932 | |
| 884 | 933 | // Weird... how'd you get here? |
| 885 | - if (empty($_REQUEST['actions'])) |
|
| 886 | - redirectexit($redirect_url); |
|
| 934 | + if (empty($_REQUEST['actions'])) { |
|
| 935 | + redirectexit($redirect_url); |
|
| 936 | + } |
|
| 887 | 937 | |
| 888 | 938 | // Validate each action. |
| 889 | 939 | $temp = array(); |
| 890 | 940 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 891 | 941 | { |
| 892 | - if (in_array($action, $possibleActions)) |
|
| 893 | - $temp[(int) $topic] = $action; |
|
| 942 | + if (in_array($action, $possibleActions)) { |
|
| 943 | + $temp[(int) $topic] = $action; |
|
| 944 | + } |
|
| 894 | 945 | } |
| 895 | 946 | $_REQUEST['actions'] = $temp; |
| 896 | 947 | |
@@ -911,27 +962,31 @@ discard block |
||
| 911 | 962 | { |
| 912 | 963 | if (!empty($board)) |
| 913 | 964 | { |
| 914 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 916 | - } |
|
| 917 | - else |
|
| 965 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 967 | + } |
|
| 968 | + } else |
|
| 918 | 969 | { |
| 919 | 970 | // Don't allow them to act on unapproved posts they can't see... |
| 920 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 971 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 973 | + } |
|
| 922 | 974 | // Goodness, this is fun. We need to validate the action. |
| 923 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 924 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 925 | - 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'])))) |
|
| 926 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 927 | - 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'])))) |
|
| 928 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 977 | + } 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'])))) { |
|
| 978 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 979 | + } 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'])))) { |
|
| 980 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 981 | + } |
|
| 929 | 982 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 930 | - 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'])))) |
|
| 931 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 983 | + 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'])))) { |
|
| 984 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 985 | + } |
|
| 932 | 986 | // If the topic is approved then you need permission to approve the posts within. |
| 933 | - 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'])))) |
|
| 934 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 987 | + 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'])))) { |
|
| 988 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 989 | + } |
|
| 935 | 990 | } |
| 936 | 991 | } |
| 937 | 992 | $smcFunc['db_free_result']($request); |
@@ -949,11 +1004,11 @@ discard block |
||
| 949 | 1004 | { |
| 950 | 1005 | $topic = (int) $topic; |
| 951 | 1006 | |
| 952 | - if ($action == 'markread') |
|
| 953 | - $markCache[] = $topic; |
|
| 954 | - elseif ($action == 'sticky') |
|
| 955 | - $stickyCache[] = $topic; |
|
| 956 | - elseif ($action == 'move') |
|
| 1007 | + if ($action == 'markread') { |
|
| 1008 | + $markCache[] = $topic; |
|
| 1009 | + } elseif ($action == 'sticky') { |
|
| 1010 | + $stickyCache[] = $topic; |
|
| 1011 | + } elseif ($action == 'move') |
|
| 957 | 1012 | { |
| 958 | 1013 | require_once($sourcedir . '/MoveTopic.php'); |
| 959 | 1014 | moveTopicConcurrence(); |
@@ -961,23 +1016,25 @@ discard block |
||
| 961 | 1016 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 962 | 1017 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 963 | 1018 | |
| 964 | - if (empty($moveCache[1][$topic])) |
|
| 965 | - continue; |
|
| 1019 | + if (empty($moveCache[1][$topic])) { |
|
| 1020 | + continue; |
|
| 1021 | + } |
|
| 966 | 1022 | |
| 967 | 1023 | $moveCache[0][] = $topic; |
| 1024 | + } elseif ($action == 'remove') { |
|
| 1025 | + $removeCache[] = $topic; |
|
| 1026 | + } elseif ($action == 'lock') { |
|
| 1027 | + $lockCache[] = $topic; |
|
| 1028 | + } elseif ($action == 'approve') { |
|
| 1029 | + $approveCache[] = $topic; |
|
| 968 | 1030 | } |
| 969 | - elseif ($action == 'remove') |
|
| 970 | - $removeCache[] = $topic; |
|
| 971 | - elseif ($action == 'lock') |
|
| 972 | - $lockCache[] = $topic; |
|
| 973 | - elseif ($action == 'approve') |
|
| 974 | - $approveCache[] = $topic; |
|
| 975 | 1031 | } |
| 976 | 1032 | |
| 977 | - if (empty($board)) |
|
| 978 | - $affectedBoards = array(); |
|
| 979 | - else |
|
| 980 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1033 | + if (empty($board)) { |
|
| 1034 | + $affectedBoards = array(); |
|
| 1035 | + } else { |
|
| 1036 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1037 | + } |
|
| 981 | 1038 | |
| 982 | 1039 | // Do all the stickies... |
| 983 | 1040 | if (!empty($stickyCache)) |
@@ -1037,14 +1094,16 @@ discard block |
||
| 1037 | 1094 | { |
| 1038 | 1095 | $to = $moveCache[1][$row['id_topic']]; |
| 1039 | 1096 | |
| 1040 | - if (empty($to)) |
|
| 1041 | - continue; |
|
| 1097 | + if (empty($to)) { |
|
| 1098 | + continue; |
|
| 1099 | + } |
|
| 1042 | 1100 | |
| 1043 | 1101 | // Does this topic's board count the posts or not? |
| 1044 | 1102 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1045 | 1103 | |
| 1046 | - if (!isset($moveTos[$to])) |
|
| 1047 | - $moveTos[$to] = array(); |
|
| 1104 | + if (!isset($moveTos[$to])) { |
|
| 1105 | + $moveTos[$to] = array(); |
|
| 1106 | + } |
|
| 1048 | 1107 | |
| 1049 | 1108 | $moveTos[$to][] = $row['id_topic']; |
| 1050 | 1109 | |
@@ -1058,8 +1117,9 @@ discard block |
||
| 1058 | 1117 | require_once($sourcedir . '/MoveTopic.php'); |
| 1059 | 1118 | |
| 1060 | 1119 | // Do the actual moves... |
| 1061 | - foreach ($moveTos as $to => $topics) |
|
| 1062 | - moveTopics($topics, $to); |
|
| 1120 | + foreach ($moveTos as $to => $topics) { |
|
| 1121 | + moveTopics($topics, $to); |
|
| 1122 | + } |
|
| 1063 | 1123 | |
| 1064 | 1124 | // Does the post counts need to be updated? |
| 1065 | 1125 | if (!empty($moveTos)) |
@@ -1108,20 +1168,23 @@ discard block |
||
| 1108 | 1168 | |
| 1109 | 1169 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1110 | 1170 | { |
| 1111 | - if (!isset($members[$row['id_member']])) |
|
| 1112 | - $members[$row['id_member']] = 0; |
|
| 1171 | + if (!isset($members[$row['id_member']])) { |
|
| 1172 | + $members[$row['id_member']] = 0; |
|
| 1173 | + } |
|
| 1113 | 1174 | |
| 1114 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1115 | - $members[$row['id_member']] += 1; |
|
| 1116 | - else |
|
| 1117 | - $members[$row['id_member']] -= 1; |
|
| 1175 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1176 | + $members[$row['id_member']] += 1; |
|
| 1177 | + } else { |
|
| 1178 | + $members[$row['id_member']] -= 1; |
|
| 1179 | + } |
|
| 1118 | 1180 | } |
| 1119 | 1181 | |
| 1120 | 1182 | $smcFunc['db_free_result']($request); |
| 1121 | 1183 | |
| 1122 | 1184 | // And now update them member's post counts |
| 1123 | - foreach ($members as $id_member => $post_adj) |
|
| 1124 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1185 | + foreach ($members as $id_member => $post_adj) { |
|
| 1186 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1187 | + } |
|
| 1125 | 1188 | |
| 1126 | 1189 | } |
| 1127 | 1190 | } |
@@ -1201,8 +1264,9 @@ discard block |
||
| 1201 | 1264 | approveTopics($approveCache); |
| 1202 | 1265 | |
| 1203 | 1266 | // Time for some logging! |
| 1204 | - foreach ($approveCache as $topic) |
|
| 1205 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1267 | + foreach ($approveCache as $topic) { |
|
| 1268 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1269 | + } |
|
| 1206 | 1270 | } |
| 1207 | 1271 | } |
| 1208 | 1272 | |
@@ -1237,8 +1301,7 @@ discard block |
||
| 1237 | 1301 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1238 | 1302 | } |
| 1239 | 1303 | $smcFunc['db_free_result']($result); |
| 1240 | - } |
|
| 1241 | - else |
|
| 1304 | + } else |
|
| 1242 | 1305 | { |
| 1243 | 1306 | $result = $smcFunc['db_query']('', ' |
| 1244 | 1307 | SELECT id_topic, locked, id_board |
@@ -1288,13 +1351,15 @@ discard block |
||
| 1288 | 1351 | ) |
| 1289 | 1352 | ); |
| 1290 | 1353 | $logged_topics = array(); |
| 1291 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1292 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1354 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1355 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1356 | + } |
|
| 1293 | 1357 | $smcFunc['db_free_result']($request); |
| 1294 | 1358 | |
| 1295 | 1359 | $markArray = array(); |
| 1296 | - foreach ($markCache as $topic) |
|
| 1297 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1360 | + foreach ($markCache as $topic) { |
|
| 1361 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1362 | + } |
|
| 1298 | 1363 | |
| 1299 | 1364 | $smcFunc['db_insert']('replace', |
| 1300 | 1365 | '{db_prefix}log_topics', |
@@ -1307,8 +1372,9 @@ discard block |
||
| 1307 | 1372 | foreach ($moveCache as $topic) |
| 1308 | 1373 | { |
| 1309 | 1374 | // Didn't actually move anything! |
| 1310 | - if (!isset($topic[0])) |
|
| 1311 | - break; |
|
| 1375 | + if (!isset($topic[0])) { |
|
| 1376 | + break; |
|
| 1377 | + } |
|
| 1312 | 1378 | |
| 1313 | 1379 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1314 | 1380 | sendNotifications($topic[0], 'move'); |
@@ -1330,8 +1396,9 @@ discard block |
||
| 1330 | 1396 | 'calendar_updated' => time(), |
| 1331 | 1397 | )); |
| 1332 | 1398 | |
| 1333 | - if (!empty($affectedBoards)) |
|
| 1334 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1399 | + if (!empty($affectedBoards)) { |
|
| 1400 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1401 | + } |
|
| 1335 | 1402 | |
| 1336 | 1403 | redirectexit($redirect_url); |
| 1337 | 1404 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | static $timezone_array = array(); |
| 134 | 136 | require_once($sourcedir . '/Subs.php'); |
| 135 | 137 | |
| 136 | - if (empty($timezone_array['default'])) |
|
| 137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 138 | + if (empty($timezone_array['default'])) { |
|
| 139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 140 | + } |
|
| 138 | 141 | |
| 139 | 142 | $low_object = date_create($low_date); |
| 140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
| 161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 162 | 165 | { |
| 163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 165 | - continue; |
|
| 167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 168 | + continue; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | // Force a censor of the title - as often these are used by others. |
| 168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
| 170 | 174 | // Get the various time and date properties for this event |
| 171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 172 | 176 | |
| 173 | - if (empty($timezone_array[$tz])) |
|
| 174 | - $timezone_array[$tz] = timezone_open($tz); |
|
| 177 | + if (empty($timezone_array[$tz])) { |
|
| 178 | + $timezone_array[$tz] = timezone_open($tz); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | // Sanity check |
| 177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 178 | - continue; |
|
| 182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | // Get set up for the loop |
| 181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
| 239 | 245 | ); |
| 240 | 246 | |
| 241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 242 | - if ($use_permissions) |
|
| 243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 248 | + if ($use_permissions) { |
|
| 249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
| 248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 250 | 256 | )); |
| 257 | + } |
|
| 251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 252 | - else |
|
| 253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 259 | + else { |
|
| 260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
| 260 | 267 | 'poster' => $row['id_member'], |
| 261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 262 | 269 | )); |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 270 | 278 | if ($use_permissions) |
| 271 | 279 | { |
| 272 | - foreach ($events as $mday => $array) |
|
| 273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 280 | + foreach ($events as $mday => $array) { |
|
| 281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 282 | + } |
|
| 274 | 283 | } |
| 275 | 284 | |
| 276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
| 290 | 299 | global $smcFunc; |
| 291 | 300 | |
| 292 | 301 | // Get the lowest and highest dates for "all years". |
| 293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 296 | - else |
|
| 297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 305 | + } else { |
|
| 306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Find some holidays... ;). |
| 300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
| 314 | 324 | $holidays = array(); |
| 315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 316 | 326 | { |
| 317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 319 | - else |
|
| 320 | - $event_year = substr($low_date, 0, 4); |
|
| 327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 329 | + } else { |
|
| 330 | + $event_year = substr($low_date, 0, 4); |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
| 343 | 354 | isAllowedTo('calendar_post'); |
| 344 | 355 | |
| 345 | 356 | // No board? No topic?!? |
| 346 | - if (empty($board)) |
|
| 347 | - fatal_lang_error('missing_board_id', false); |
|
| 348 | - if (empty($topic)) |
|
| 349 | - fatal_lang_error('missing_topic_id', false); |
|
| 357 | + if (empty($board)) { |
|
| 358 | + fatal_lang_error('missing_board_id', false); |
|
| 359 | + } |
|
| 360 | + if (empty($topic)) { |
|
| 361 | + fatal_lang_error('missing_topic_id', false); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Administrator, Moderator, or owner. Period. |
| 352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
| 364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 378 | { |
| 366 | 379 | // Not the owner of the topic. |
| 367 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 368 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 381 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 382 | + } |
|
| 369 | 383 | } |
| 370 | 384 | // Topic/Board doesn't exist..... |
| 371 | - else |
|
| 372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 385 | + else { |
|
| 386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 387 | + } |
|
| 373 | 388 | $smcFunc['db_free_result']($result); |
| 374 | 389 | } |
| 375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
| 457 | 472 | if (!empty($calendarOptions['start_day'])) |
| 458 | 473 | { |
| 459 | 474 | $nShift -= $calendarOptions['start_day']; |
| 460 | - if ($nShift < 0) |
|
| 461 | - $nShift = 7 + $nShift; |
|
| 475 | + if ($nShift < 0) { |
|
| 476 | + $nShift = 7 + $nShift; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Number of rows required to fit the month. |
| 465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 467 | - $nRows++; |
|
| 482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 483 | + $nRows++; |
|
| 484 | + } |
|
| 468 | 485 | |
| 469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
| 477 | 494 | { |
| 478 | 495 | $calendarGrid['week_days'][] = $count; |
| 479 | 496 | $count++; |
| 480 | - if ($count == 7) |
|
| 481 | - $count = 0; |
|
| 497 | + if ($count == 7) { |
|
| 498 | + $count = 0; |
|
| 499 | + } |
|
| 482 | 500 | } |
| 483 | 501 | |
| 484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
| 495 | 513 | { |
| 496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 497 | 515 | |
| 498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 499 | - $nDay = 0; |
|
| 516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 517 | + $nDay = 0; |
|
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
| 514 | 533 | } |
| 515 | 534 | |
| 516 | 535 | // What is the last day of the month? |
| 517 | - if ($is_previous === true) |
|
| 518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 536 | + if ($is_previous === true) { |
|
| 537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 538 | + } |
|
| 519 | 539 | |
| 520 | 540 | // We'll use the shift in the template. |
| 521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
| 549 | 569 | { |
| 550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
| 551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 552 | - if ($date_diff < 0) |
|
| 553 | - $date_diff += 7; |
|
| 572 | + if ($date_diff < 0) { |
|
| 573 | + $date_diff += 7; |
|
| 574 | + } |
|
| 554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
| 556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
| 680 | 701 | { |
| 681 | 702 | foreach ($date_events as $event_key => $event_val) |
| 682 | 703 | { |
| 683 | - if (in_array($event_val['id'], $temp)) |
|
| 684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 685 | - else |
|
| 686 | - $temp[] = $event_val['id']; |
|
| 704 | + if (in_array($event_val['id'], $temp)) { |
|
| 705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 706 | + } else { |
|
| 707 | + $temp[] = $event_val['id']; |
|
| 708 | + } |
|
| 687 | 709 | } |
| 688 | 710 | } |
| 689 | 711 | |
| 690 | 712 | // Give birthdays and holidays a friendly format, without the year |
| 691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 692 | - $date_format = '%b %d'; |
|
| 693 | - else |
|
| 694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 714 | + $date_format = '%b %d'; |
|
| 715 | + } else { |
|
| 716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 717 | + } |
|
| 695 | 718 | |
| 696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
| 697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
| 790 | 813 | // Holidays between now and now + days. |
| 791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 792 | 815 | { |
| 793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 818 | + } |
|
| 795 | 819 | } |
| 796 | 820 | } |
| 797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
| 803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
| 804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
| 805 | 829 | { |
| 806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 832 | + } |
|
| 808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 809 | 834 | } |
| 810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
| 819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
| 820 | 845 | |
| 821 | 846 | // No events today? Check the next day. |
| 822 | - if (empty($cached_data['events'][$loop_date])) |
|
| 823 | - continue; |
|
| 847 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 824 | 850 | |
| 825 | 851 | // Loop through all events to add a few last-minute values. |
| 826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
| 833 | 859 | { |
| 834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
| 835 | 861 | continue; |
| 862 | + } else { |
|
| 863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 836 | 864 | } |
| 837 | - else |
|
| 838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 839 | 865 | |
| 840 | 866 | // Might be set to true afterwards, depending on the permissions. |
| 841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
| 843 | 869 | $this_event['date'] = $loop_date; |
| 844 | 870 | } |
| 845 | 871 | |
| 846 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 874 | + } |
|
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 851 | 878 | // Mark the last item so that a list separator can be used in the template. |
| 852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 881 | + } |
|
| 882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 884 | + } |
|
| 856 | 885 | |
| 857 | 886 | return array( |
| 858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
| 900 | 929 | if (isset($_POST['start_date'])) |
| 901 | 930 | { |
| 902 | 931 | $d = date_parse($_POST['start_date']); |
| 903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 904 | - fatal_lang_error('invalid_date', false); |
|
| 905 | - if (empty($d['year'])) |
|
| 906 | - fatal_lang_error('event_year_missing', false); |
|
| 907 | - if (empty($d['month'])) |
|
| 908 | - fatal_lang_error('event_month_missing', false); |
|
| 909 | - } |
|
| 910 | - elseif (isset($_POST['start_datetime'])) |
|
| 932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 933 | + fatal_lang_error('invalid_date', false); |
|
| 934 | + } |
|
| 935 | + if (empty($d['year'])) { |
|
| 936 | + fatal_lang_error('event_year_missing', false); |
|
| 937 | + } |
|
| 938 | + if (empty($d['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + } elseif (isset($_POST['start_datetime'])) |
|
| 911 | 942 | { |
| 912 | 943 | $d = date_parse($_POST['start_datetime']); |
| 913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 914 | - fatal_lang_error('invalid_date', false); |
|
| 915 | - if (empty($d['year'])) |
|
| 916 | - fatal_lang_error('event_year_missing', false); |
|
| 917 | - if (empty($d['month'])) |
|
| 918 | - fatal_lang_error('event_month_missing', false); |
|
| 944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 945 | + fatal_lang_error('invalid_date', false); |
|
| 946 | + } |
|
| 947 | + if (empty($d['year'])) { |
|
| 948 | + fatal_lang_error('event_year_missing', false); |
|
| 949 | + } |
|
| 950 | + if (empty($d['month'])) { |
|
| 951 | + fatal_lang_error('event_month_missing', false); |
|
| 952 | + } |
|
| 919 | 953 | } |
| 920 | 954 | // The 2.0 way |
| 921 | 955 | else |
| 922 | 956 | { |
| 923 | 957 | // No month? No year? |
| 924 | - if (!isset($_POST['month'])) |
|
| 925 | - fatal_lang_error('event_month_missing', false); |
|
| 926 | - if (!isset($_POST['year'])) |
|
| 927 | - fatal_lang_error('event_year_missing', false); |
|
| 958 | + if (!isset($_POST['month'])) { |
|
| 959 | + fatal_lang_error('event_month_missing', false); |
|
| 960 | + } |
|
| 961 | + if (!isset($_POST['year'])) { |
|
| 962 | + fatal_lang_error('event_year_missing', false); |
|
| 963 | + } |
|
| 928 | 964 | |
| 929 | 965 | // Check the month and year... |
| 930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 931 | - fatal_lang_error('invalid_month', false); |
|
| 932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 933 | - fatal_lang_error('invalid_year', false); |
|
| 966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 967 | + fatal_lang_error('invalid_month', false); |
|
| 968 | + } |
|
| 969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 970 | + fatal_lang_error('invalid_year', false); |
|
| 971 | + } |
|
| 934 | 972 | } |
| 935 | 973 | } |
| 936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
| 940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 941 | 979 | if (isset($_POST['span'])) |
| 942 | 980 | { |
| 943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 944 | - fatal_lang_error('invalid_days_numb', false); |
|
| 981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 982 | + fatal_lang_error('invalid_days_numb', false); |
|
| 983 | + } |
|
| 945 | 984 | } |
| 946 | 985 | |
| 947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
| 951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 952 | 991 | { |
| 953 | 992 | // No day? |
| 954 | - if (!isset($_POST['day'])) |
|
| 955 | - fatal_lang_error('event_day_missing', false); |
|
| 993 | + if (!isset($_POST['day'])) { |
|
| 994 | + fatal_lang_error('event_day_missing', false); |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Bad day? |
| 958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 959 | - fatal_lang_error('invalid_date', false); |
|
| 998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 999 | + fatal_lang_error('invalid_date', false); |
|
| 1000 | + } |
|
| 960 | 1001 | } |
| 961 | 1002 | |
| 962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 963 | - fatal_lang_error('event_title_missing', false); |
|
| 964 | - elseif (!isset($_POST['evtitle'])) |
|
| 965 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 1004 | + fatal_lang_error('event_title_missing', false); |
|
| 1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 1007 | + } |
|
| 966 | 1008 | |
| 967 | 1009 | // No title? |
| 968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 969 | - fatal_lang_error('no_event_title', false); |
|
| 970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1011 | + fatal_lang_error('no_event_title', false); |
|
| 1012 | + } |
|
| 1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1015 | + } |
|
| 972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 973 | 1017 | } |
| 974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
| 995 | 1039 | ); |
| 996 | 1040 | |
| 997 | 1041 | // No results, return false. |
| 998 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 999 | - return false; |
|
| 1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1000 | 1045 | |
| 1001 | 1046 | // Grab the results and return. |
| 1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
| 1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1131 | 1176 | |
| 1132 | 1177 | $column_clauses = array(); |
| 1133 | - foreach ($event_columns as $col => $crit) |
|
| 1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1178 | + foreach ($event_columns as $col => $crit) { |
|
| 1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1180 | + } |
|
| 1135 | 1181 | |
| 1136 | 1182 | $smcFunc['db_query']('', ' |
| 1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
| 1216 | 1262 | ); |
| 1217 | 1263 | |
| 1218 | 1264 | // If nothing returned, we are in poo, poo. |
| 1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1220 | - return false; |
|
| 1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
| 1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1226 | 1273 | |
| 1227 | 1274 | // Sanity check |
| 1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1229 | - return false; |
|
| 1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1276 | + return false; |
|
| 1277 | + } |
|
| 1230 | 1278 | |
| 1231 | 1279 | $return_value = array( |
| 1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
| 1363 | 1411 | |
| 1364 | 1412 | // Set $span, in case we need it |
| 1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1366 | - if ($span > 0) |
|
| 1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1414 | + if ($span > 0) { |
|
| 1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1416 | + } |
|
| 1368 | 1417 | |
| 1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
| 1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1371 | - $tz = $eventOptions['tz']; |
|
| 1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1373 | - $tz = $_POST['tz']; |
|
| 1374 | - else |
|
| 1375 | - $tz = getUserTimezone(); |
|
| 1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1420 | + $tz = $eventOptions['tz']; |
|
| 1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1422 | + $tz = $_POST['tz']; |
|
| 1423 | + } else { |
|
| 1424 | + $tz = getUserTimezone(); |
|
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1378 | - if (isset($eventOptions['allday'])) |
|
| 1379 | - $allday = $eventOptions['allday']; |
|
| 1380 | - elseif (empty($_POST['allday'])) |
|
| 1381 | - $allday = false; |
|
| 1382 | - else |
|
| 1383 | - $allday = true; |
|
| 1428 | + if (isset($eventOptions['allday'])) { |
|
| 1429 | + $allday = $eventOptions['allday']; |
|
| 1430 | + } elseif (empty($_POST['allday'])) { |
|
| 1431 | + $allday = false; |
|
| 1432 | + } else { |
|
| 1433 | + $allday = true; |
|
| 1434 | + } |
|
| 1384 | 1435 | |
| 1385 | 1436 | // Input might come as individual parameters... |
| 1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
| 1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1408 | 1459 | |
| 1409 | 1460 | // If the date and time were given in separate strings, combine them |
| 1410 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1412 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1463 | + } |
|
| 1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1466 | + } |
|
| 1414 | 1467 | |
| 1415 | 1468 | // If some form of string input was given, override individually defined options with it |
| 1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
| 1501 | 1554 | if ($start_object >= $end_object) |
| 1502 | 1555 | { |
| 1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1504 | - if ($span > 0) |
|
| 1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1506 | - else |
|
| 1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1557 | + if ($span > 0) { |
|
| 1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1559 | + } else { |
|
| 1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1561 | + } |
|
| 1508 | 1562 | } |
| 1509 | 1563 | |
| 1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
| 1517 | 1571 | { |
| 1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1574 | + } else { |
|
| 1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1520 | 1576 | } |
| 1521 | - else |
|
| 1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1523 | 1577 | } |
| 1524 | 1578 | } |
| 1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | $start_time = null; |
| 1533 | 1587 | $end_time = null; |
| 1534 | 1588 | $tz = null; |
| 1535 | - } |
|
| 1536 | - else |
|
| 1589 | + } else |
|
| 1537 | 1590 | { |
| 1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
| 1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
| 1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
| 1560 | 1613 | if (empty($date_format)) |
| 1561 | 1614 | { |
| 1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1563 | - $date_format = '%F'; |
|
| 1564 | - else |
|
| 1565 | - $date_format = $matches[0]; |
|
| 1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1616 | + $date_format = '%F'; |
|
| 1617 | + } else { |
|
| 1618 | + $date_format = $matches[0]; |
|
| 1619 | + } |
|
| 1566 | 1620 | } |
| 1567 | 1621 | |
| 1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1569 | 1623 | if (empty($time_format)) |
| 1570 | 1624 | { |
| 1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1572 | - $time_format = '%k:%M'; |
|
| 1573 | - else |
|
| 1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1626 | + $time_format = '%k:%M'; |
|
| 1627 | + } else { |
|
| 1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1629 | + } |
|
| 1575 | 1630 | } |
| 1576 | 1631 | |
| 1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
| 1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1582 | 1637 | |
| 1583 | 1638 | // We need to have a defined timezone in the steps below |
| 1584 | - if (empty($row['timezone'])) |
|
| 1585 | - $row['timezone'] = getUserTimezone(); |
|
| 1639 | + if (empty($row['timezone'])) { |
|
| 1640 | + $row['timezone'] = getUserTimezone(); |
|
| 1641 | + } |
|
| 1586 | 1642 | |
| 1587 | - if (empty($timezone_array[$row['timezone']])) |
|
| 1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
| 1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1645 | + } |
|
| 1589 | 1646 | |
| 1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
| 1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
| 1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1634 | 1691 | static $member_cache = array(); |
| 1635 | 1692 | |
| 1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1637 | - $id_member = $context['user']['id']; |
|
| 1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1694 | + $id_member = $context['user']['id']; |
|
| 1695 | + } |
|
| 1638 | 1696 | |
| 1639 | 1697 | //check if the cache got the data |
| 1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
| 1663 | 1721 | $smcFunc['db_free_result']($request); |
| 1664 | 1722 | } |
| 1665 | 1723 | |
| 1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1726 | + } |
|
| 1668 | 1727 | |
| 1669 | - if (isset($id_member)) |
|
| 1670 | - $member_cache[$id_member] = $timezone; |
|
| 1728 | + if (isset($id_member)) { |
|
| 1729 | + $member_cache[$id_member] = $timezone; |
|
| 1730 | + } |
|
| 1671 | 1731 | |
| 1672 | 1732 | return $timezone; |
| 1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
| 1696 | 1756 | ) |
| 1697 | 1757 | ); |
| 1698 | 1758 | $holidays = array(); |
| 1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1700 | - $holidays[] = $row; |
|
| 1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1760 | + $holidays[] = $row; |
|
| 1761 | + } |
|
| 1701 | 1762 | $smcFunc['db_free_result']($request); |
| 1702 | 1763 | |
| 1703 | 1764 | return $holidays; |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Initialize the array that'll be returned later on. |
| 52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
| 63 | 65 | // Get any spiders if enabled. |
| 64 | 66 | $spiders = array(); |
| 65 | 67 | $spider_finds = array(); |
| 66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Load the users online right now. |
| 70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
| 92 | 95 | $membersOnlineStats['num_guests']++; |
| 93 | 96 | |
| 94 | 97 | continue; |
| 95 | - } |
|
| 96 | - |
|
| 97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | 99 | { |
| 99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
| 100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // Some basic color coding... |
| 105 | - if (!empty($row['online_color'])) |
|
| 106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 107 | - else |
|
| 108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 106 | + if (!empty($row['online_color'])) { |
|
| 107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 108 | + } else { |
|
| 109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | // Buddies get counted and highlighted. |
| 111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
| 132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 133 | 135 | |
| 134 | 136 | // Store all distinct (primary) membergroups that are shown. |
| 135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | 139 | 'id' => $row['id_group'], |
| 138 | 140 | 'name' => $row['group_name'], |
| 139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
| 141 | 143 | 'type' => $row['group_type'], |
| 142 | 144 | 'parent' => $row['id_parent'], |
| 143 | 145 | ); |
| 146 | + } |
|
| 144 | 147 | } |
| 145 | 148 | $smcFunc['db_free_result']($request); |
| 146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
| 201 | 204 | $settingsToUpdate = array(); |
| 202 | 205 | |
| 203 | 206 | // More members on now than ever were? Update it! |
| 204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 205 | - $settingsToUpdate = array( |
|
| 207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 208 | + $settingsToUpdate = array( |
|
| 206 | 209 | 'mostOnline' => $total_users_online, |
| 207 | 210 | 'mostDate' => time() |
| 208 | 211 | ); |
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
| 237 | 241 | { |
| 238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 239 | 243 | |
| 240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 241 | - trackStats(array('most_on' => $total_users_online)); |
|
| 244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 245 | + trackStats(array('most_on' => $total_users_online)); |
|
| 246 | + } |
|
| 242 | 247 | |
| 243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
| 255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | - if (!empty($settingsToUpdate)) |
|
| 259 | - updateSettings($settingsToUpdate); |
|
| 260 | -} |
|
| 263 | + if (!empty($settingsToUpdate)) { |
|
| 264 | + updateSettings($settingsToUpdate); |
|
| 265 | + } |
|
| 266 | + } |
|
| 261 | 267 | |
| 262 | 268 | ?> |
| 263 | 269 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 215 | + if (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 216 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 217 | + } |
|
| 218 | + } else { |
|
| 219 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 212 | 220 | } |
| 213 | - else |
|
| 214 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 215 | 221 | |
| 216 | 222 | if (!empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) && !in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
| 217 | 223 | { |
@@ -219,8 +225,9 @@ discard block |
||
| 219 | 225 | |
| 220 | 226 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachmentUploadDir'])) |
| 221 | 227 | { |
| 222 | - if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) |
|
| 223 | - $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 228 | + if (!automanage_attachments_create_directory($_POST['basedirectory_for_attachments'])) { |
|
| 229 | + $_POST['basedirectory_for_attachments'] = $modSettings['basedirectory_for_attachments']; |
|
| 230 | + } |
|
| 224 | 231 | } |
| 225 | 232 | |
| 226 | 233 | if (!in_array($_POST['basedirectory_for_attachments'], $modSettings['attachment_basedirectories'])) |
@@ -336,8 +343,9 @@ discard block |
||
| 336 | 343 | |
| 337 | 344 | call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); |
| 338 | 345 | |
| 339 | - if ($return_config) |
|
| 340 | - return $config_vars; |
|
| 346 | + if ($return_config) { |
|
| 347 | + return $config_vars; |
|
| 348 | + } |
|
| 341 | 349 | |
| 342 | 350 | // We need this file for the settings template. |
| 343 | 351 | require_once($sourcedir . '/ManageServer.php'); |
@@ -348,17 +356,21 @@ discard block |
||
| 348 | 356 | checkSession(); |
| 349 | 357 | |
| 350 | 358 | // These settings cannot be left empty! |
| 351 | - if (empty($_POST['custom_avatar_dir'])) |
|
| 352 | - $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
| 359 | + if (empty($_POST['custom_avatar_dir'])) { |
|
| 360 | + $_POST['custom_avatar_dir'] = $boarddir . '/custom_avatar'; |
|
| 361 | + } |
|
| 353 | 362 | |
| 354 | - if (empty($_POST['custom_avatar_url'])) |
|
| 355 | - $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
| 363 | + if (empty($_POST['custom_avatar_url'])) { |
|
| 364 | + $_POST['custom_avatar_url'] = $boardurl . '/custom_avatar'; |
|
| 365 | + } |
|
| 356 | 366 | |
| 357 | - if (empty($_POST['avatar_directory'])) |
|
| 358 | - $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
| 367 | + if (empty($_POST['avatar_directory'])) { |
|
| 368 | + $_POST['avatar_directory'] = $boarddir . '/avatars'; |
|
| 369 | + } |
|
| 359 | 370 | |
| 360 | - if (empty($_POST['avatar_url'])) |
|
| 361 | - $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
| 371 | + if (empty($_POST['avatar_url'])) { |
|
| 372 | + $_POST['avatar_url'] = $boardurl . '/avatars'; |
|
| 373 | + } |
|
| 362 | 374 | |
| 363 | 375 | call_integration_hook('integrate_save_avatar_settings'); |
| 364 | 376 | |
@@ -406,11 +418,13 @@ discard block |
||
| 406 | 418 | $list_title = $txt['attachment_manager_browse_files'] . ': '; |
| 407 | 419 | foreach ($titles as $browse_type => $details) |
| 408 | 420 | { |
| 409 | - if ($browse_type != 'attachments') |
|
| 410 | - $list_title .= ' | '; |
|
| 421 | + if ($browse_type != 'attachments') { |
|
| 422 | + $list_title .= ' | '; |
|
| 423 | + } |
|
| 411 | 424 | |
| 412 | - if ($context['browse_type'] == $browse_type) |
|
| 413 | - $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 425 | + if ($context['browse_type'] == $browse_type) { |
|
| 426 | + $list_title .= '<img src="' . $settings['images_url'] . '/selected.png" alt=">"> '; |
|
| 427 | + } |
|
| 414 | 428 | |
| 415 | 429 | $list_title .= '<a href="' . $scripturl . $details[0] . '">' . $details[1] . '</a>'; |
| 416 | 430 | } |
@@ -446,28 +460,33 @@ discard block |
||
| 446 | 460 | $link = '<a href="'; |
| 447 | 461 | |
| 448 | 462 | // In case of a custom avatar URL attachments have a fixed directory. |
| 449 | - if ($rowData['attachment_type'] == 1) |
|
| 450 | - $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 463 | + if ($rowData['attachment_type'] == 1) { |
|
| 464 | + $link .= sprintf('%1$s/%2$s', $modSettings['custom_avatar_url'], $rowData['filename']); |
|
| 465 | + } |
|
| 451 | 466 | |
| 452 | 467 | // By default avatars are downloaded almost as attachments. |
| 453 | - elseif ($context['browse_type'] == 'avatars') |
|
| 454 | - $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 468 | + elseif ($context['browse_type'] == 'avatars') { |
|
| 469 | + $link .= sprintf('%1$s?action=dlattach;type=avatar;attach=%2$d', $scripturl, $rowData['id_attach']); |
|
| 470 | + } |
|
| 455 | 471 | |
| 456 | 472 | // Normal attachments are always linked to a topic ID. |
| 457 | - else |
|
| 458 | - $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 473 | + else { |
|
| 474 | + $link .= sprintf('%1$s?action=dlattach;topic=%2$d.0;attach=%3$d', $scripturl, $rowData['id_topic'], $rowData['id_attach']); |
|
| 475 | + } |
|
| 459 | 476 | |
| 460 | 477 | $link .= '"'; |
| 461 | 478 | |
| 462 | 479 | // Show a popup on click if it's a picture and we know its dimensions. |
| 463 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 464 | - $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 480 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 481 | + $link .= sprintf(' onclick="return reqWin(this.href' . ($rowData['attachment_type'] == 1 ? '' : ' + \';image\'') . ', %1$d, %2$d, true);"', $rowData['width'] + 20, $rowData['height'] + 20); |
|
| 482 | + } |
|
| 465 | 483 | |
| 466 | 484 | $link .= sprintf('>%1$s</a>', preg_replace('~&#(\\\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\\\1;', $smcFunc['htmlspecialchars']($rowData['filename']))); |
| 467 | 485 | |
| 468 | 486 | // Show the dimensions. |
| 469 | - if (!empty($rowData['width']) && !empty($rowData['height'])) |
|
| 470 | - $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 487 | + if (!empty($rowData['width']) && !empty($rowData['height'])) { |
|
| 488 | + $link .= sprintf(' <span class="smalltext">%1$dx%2$d</span>', $rowData['width'], $rowData['height']); |
|
| 489 | + } |
|
| 471 | 490 | |
| 472 | 491 | return $link; |
| 473 | 492 | }, |
@@ -500,12 +519,14 @@ discard block |
||
| 500 | 519 | 'function' => function($rowData) use ($scripturl, $smcFunc) |
| 501 | 520 | { |
| 502 | 521 | // In case of an attachment, return the poster of the attachment. |
| 503 | - if (empty($rowData['id_member'])) |
|
| 504 | - return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 522 | + if (empty($rowData['id_member'])) { |
|
| 523 | + return $smcFunc['htmlspecialchars']($rowData['poster_name']); |
|
| 524 | + } |
|
| 505 | 525 | |
| 506 | 526 | // Otherwise it must be an avatar, return the link to the owner of it. |
| 507 | - else |
|
| 508 | - return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 527 | + else { |
|
| 528 | + return sprintf('<a href="%1$s?action=profile;u=%2$d">%3$s</a>', $scripturl, $rowData['id_member'], $rowData['poster_name']); |
|
| 529 | + } |
|
| 509 | 530 | }, |
| 510 | 531 | ), |
| 511 | 532 | 'sort' => array( |
@@ -524,8 +545,9 @@ discard block |
||
| 524 | 545 | $date = empty($rowData['poster_time']) ? $txt['never'] : timeformat($rowData['poster_time']); |
| 525 | 546 | |
| 526 | 547 | // Add a link to the topic in case of an attachment. |
| 527 | - if ($context['browse_type'] !== 'avatars') |
|
| 528 | - $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 548 | + if ($context['browse_type'] !== 'avatars') { |
|
| 549 | + $date .= sprintf('<br>%1$s <a href="%2$s?topic=%3$d.msg%4$d#msg%4$d">%5$s</a>', $txt['in'], $scripturl, $rowData['id_topic'], $rowData['id_msg'], $rowData['subject']); |
|
| 550 | + } |
|
| 529 | 551 | |
| 530 | 552 | return $date; |
| 531 | 553 | }, |
@@ -610,8 +632,8 @@ discard block |
||
| 610 | 632 | global $smcFunc, $txt; |
| 611 | 633 | |
| 612 | 634 | // Choose a query depending on what we are viewing. |
| 613 | - if ($browse_type === 'avatars') |
|
| 614 | - $request = $smcFunc['db_query']('', ' |
|
| 635 | + if ($browse_type === 'avatars') { |
|
| 636 | + $request = $smcFunc['db_query']('', ' |
|
| 615 | 637 | SELECT |
| 616 | 638 | {string:blank_text} AS id_msg, COALESCE(mem.real_name, {string:not_applicable_text}) AS poster_name, |
| 617 | 639 | mem.last_login AS poster_time, 0 AS id_topic, a.id_member, a.id_attach, a.filename, a.file_hash, a.attachment_type, |
@@ -630,8 +652,8 @@ discard block |
||
| 630 | 652 | 'per_page' => $items_per_page, |
| 631 | 653 | ) |
| 632 | 654 | ); |
| 633 | - else |
|
| 634 | - $request = $smcFunc['db_query']('', ' |
|
| 655 | + } else { |
|
| 656 | + $request = $smcFunc['db_query']('', ' |
|
| 635 | 657 | SELECT |
| 636 | 658 | m.id_msg, COALESCE(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_topic, m.id_member, |
| 637 | 659 | a.id_attach, a.filename, a.file_hash, a.attachment_type, a.size, a.width, a.height, a.downloads, mf.subject, t.id_board |
@@ -650,9 +672,11 @@ discard block |
||
| 650 | 672 | 'per_page' => $items_per_page, |
| 651 | 673 | ) |
| 652 | 674 | ); |
| 675 | + } |
|
| 653 | 676 | $files = array(); |
| 654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 655 | - $files[] = $row; |
|
| 677 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 678 | + $files[] = $row; |
|
| 679 | + } |
|
| 656 | 680 | $smcFunc['db_free_result']($request); |
| 657 | 681 | |
| 658 | 682 | return $files; |
@@ -670,8 +694,8 @@ discard block |
||
| 670 | 694 | global $smcFunc; |
| 671 | 695 | |
| 672 | 696 | // Depending on the type of file, different queries are used. |
| 673 | - if ($browse_type === 'avatars') |
|
| 674 | - $request = $smcFunc['db_query']('', ' |
|
| 697 | + if ($browse_type === 'avatars') { |
|
| 698 | + $request = $smcFunc['db_query']('', ' |
|
| 675 | 699 | SELECT COUNT(*) |
| 676 | 700 | FROM {db_prefix}attachments |
| 677 | 701 | WHERE id_member != {int:guest_id_member}', |
@@ -679,8 +703,8 @@ discard block |
||
| 679 | 703 | 'guest_id_member' => 0, |
| 680 | 704 | ) |
| 681 | 705 | ); |
| 682 | - else |
|
| 683 | - $request = $smcFunc['db_query']('', ' |
|
| 706 | + } else { |
|
| 707 | + $request = $smcFunc['db_query']('', ' |
|
| 684 | 708 | SELECT COUNT(*) AS num_attach |
| 685 | 709 | FROM {db_prefix}attachments AS a |
| 686 | 710 | INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg) |
@@ -693,6 +717,7 @@ discard block |
||
| 693 | 717 | 'guest_id_member' => 0, |
| 694 | 718 | ) |
| 695 | 719 | ); |
| 720 | + } |
|
| 696 | 721 | |
| 697 | 722 | list ($num_files) = $smcFunc['db_fetch_row']($request); |
| 698 | 723 | $smcFunc['db_free_result']($request); |
@@ -775,12 +800,14 @@ discard block |
||
| 775 | 800 | $current_dir_size /= 1024; |
| 776 | 801 | |
| 777 | 802 | // If they specified a limit only.... |
| 778 | - if (!empty($modSettings['attachmentDirSizeLimit'])) |
|
| 779 | - $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 803 | + if (!empty($modSettings['attachmentDirSizeLimit'])) { |
|
| 804 | + $context['attachment_space'] = comma_format(max($modSettings['attachmentDirSizeLimit'] - $current_dir_size, 0), 2); |
|
| 805 | + } |
|
| 780 | 806 | $context['attachment_current_size'] = comma_format($current_dir_size, 2); |
| 781 | 807 | |
| 782 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
| 783 | - $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 808 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
| 809 | + $context['attachment_files'] = comma_format(max($modSettings['attachmentDirFileLimit'] - $current_dir_files, 0), 0); |
|
| 810 | + } |
|
| 784 | 811 | $context['attachment_current_files'] = comma_format($current_dir_files, 0); |
| 785 | 812 | |
| 786 | 813 | $context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; |
@@ -817,8 +844,8 @@ discard block |
||
| 817 | 844 | $messages = removeAttachments(array('attachment_type' => 0, 'poster_time' => (time() - 24 * 60 * 60 * $_POST['age'])), 'messages', true); |
| 818 | 845 | |
| 819 | 846 | // Update the messages to reflect the change. |
| 820 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 821 | - $smcFunc['db_query']('', ' |
|
| 847 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 848 | + $smcFunc['db_query']('', ' |
|
| 822 | 849 | UPDATE {db_prefix}messages |
| 823 | 850 | SET body = CONCAT(body, {string:notice}) |
| 824 | 851 | WHERE id_msg IN ({array_int:messages})', |
@@ -827,8 +854,8 @@ discard block |
||
| 827 | 854 | 'notice' => '<br><br>' . $_POST['notice'], |
| 828 | 855 | ) |
| 829 | 856 | ); |
| 830 | - } |
|
| 831 | - else |
|
| 857 | + } |
|
| 858 | + } else |
|
| 832 | 859 | { |
| 833 | 860 | // Remove all the old avatars. |
| 834 | 861 | removeAttachments(array('not_id_member' => 0, 'last_login' => (time() - 24 * 60 * 60 * $_POST['age'])), 'members'); |
@@ -853,8 +880,8 @@ discard block |
||
| 853 | 880 | $messages = removeAttachments(array('attachment_type' => 0, 'size' => 1024 * $_POST['size']), 'messages', true); |
| 854 | 881 | |
| 855 | 882 | // And make a note on the post. |
| 856 | - if (!empty($messages) && !empty($_POST['notice'])) |
|
| 857 | - $smcFunc['db_query']('', ' |
|
| 883 | + if (!empty($messages) && !empty($_POST['notice'])) { |
|
| 884 | + $smcFunc['db_query']('', ' |
|
| 858 | 885 | UPDATE {db_prefix}messages |
| 859 | 886 | SET body = CONCAT(body, {string:notice}) |
| 860 | 887 | WHERE id_msg IN ({array_int:messages})', |
@@ -863,6 +890,7 @@ discard block |
||
| 863 | 890 | 'notice' => '<br><br>' . $_POST['notice'], |
| 864 | 891 | ) |
| 865 | 892 | ); |
| 893 | + } |
|
| 866 | 894 | |
| 867 | 895 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 868 | 896 | } |
@@ -882,16 +910,17 @@ discard block |
||
| 882 | 910 | { |
| 883 | 911 | $attachments = array(); |
| 884 | 912 | // There must be a quicker way to pass this safety test?? |
| 885 | - foreach ($_POST['remove'] as $removeID => $dummy) |
|
| 886 | - $attachments[] = (int) $removeID; |
|
| 913 | + foreach ($_POST['remove'] as $removeID => $dummy) { |
|
| 914 | + $attachments[] = (int) $removeID; |
|
| 915 | + } |
|
| 887 | 916 | |
| 888 | 917 | // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. |
| 889 | 918 | $filesRemoved = false; |
| 890 | 919 | call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); |
| 891 | 920 | |
| 892 | - if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) |
|
| 893 | - removeAttachments(array('id_attach' => $attachments)); |
|
| 894 | - else if (!empty($attachments)) |
|
| 921 | + if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { |
|
| 922 | + removeAttachments(array('id_attach' => $attachments)); |
|
| 923 | + } else if (!empty($attachments)) |
|
| 895 | 924 | { |
| 896 | 925 | $messages = removeAttachments(array('id_attach' => $attachments), 'messages', true); |
| 897 | 926 | |
@@ -930,12 +959,13 @@ discard block |
||
| 930 | 959 | |
| 931 | 960 | $messages = removeAttachments(array('attachment_type' => 0), '', true); |
| 932 | 961 | |
| 933 | - if (!isset($_POST['notice'])) |
|
| 934 | - $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 962 | + if (!isset($_POST['notice'])) { |
|
| 963 | + $_POST['notice'] = $txt['attachment_delete_admin']; |
|
| 964 | + } |
|
| 935 | 965 | |
| 936 | 966 | // Add the notice on the end of the changed messages. |
| 937 | - if (!empty($messages)) |
|
| 938 | - $smcFunc['db_query']('', ' |
|
| 967 | + if (!empty($messages)) { |
|
| 968 | + $smcFunc['db_query']('', ' |
|
| 939 | 969 | UPDATE {db_prefix}messages |
| 940 | 970 | SET body = CONCAT(body, {string:deleted_message}) |
| 941 | 971 | WHERE id_msg IN ({array_int:messages})', |
@@ -944,6 +974,7 @@ discard block |
||
| 944 | 974 | 'deleted_message' => '<br><br>' . $_POST['notice'], |
| 945 | 975 | ) |
| 946 | 976 | ); |
| 977 | + } |
|
| 947 | 978 | |
| 948 | 979 | redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
| 949 | 980 | } |
@@ -982,24 +1013,26 @@ discard block |
||
| 982 | 1013 | $is_not = substr($real_type, 0, 4) == 'not_'; |
| 983 | 1014 | $type = $is_not ? substr($real_type, 4) : $real_type; |
| 984 | 1015 | |
| 985 | - if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) |
|
| 986 | - $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 987 | - elseif ($type == 'attachment_type') |
|
| 988 | - $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 989 | - elseif ($type == 'poster_time') |
|
| 990 | - $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 991 | - elseif ($type == 'last_login') |
|
| 992 | - $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 993 | - elseif ($type == 'size') |
|
| 994 | - $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 995 | - elseif ($type == 'id_topic') |
|
| 996 | - $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1016 | + if (in_array($type, array('id_member', 'id_attach', 'id_msg'))) { |
|
| 1017 | + $new_condition[] = 'a.' . $type . ($is_not ? ' NOT' : '') . ' IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1018 | + } elseif ($type == 'attachment_type') { |
|
| 1019 | + $new_condition[] = 'a.attachment_type = {int:' . $real_type . '}'; |
|
| 1020 | + } elseif ($type == 'poster_time') { |
|
| 1021 | + $new_condition[] = 'm.poster_time < {int:' . $real_type . '}'; |
|
| 1022 | + } elseif ($type == 'last_login') { |
|
| 1023 | + $new_condition[] = 'mem.last_login < {int:' . $real_type . '}'; |
|
| 1024 | + } elseif ($type == 'size') { |
|
| 1025 | + $new_condition[] = 'a.size > {int:' . $real_type . '}'; |
|
| 1026 | + } elseif ($type == 'id_topic') { |
|
| 1027 | + $new_condition[] = 'm.id_topic IN (' . (is_array($restriction) ? '{array_int:' . $real_type . '}' : '{int:' . $real_type . '}') . ')'; |
|
| 1028 | + } |
|
| 997 | 1029 | |
| 998 | 1030 | // Add the parameter! |
| 999 | 1031 | $query_parameter[$real_type] = $restriction; |
| 1000 | 1032 | |
| 1001 | - if ($type == 'do_logging') |
|
| 1002 | - $do_logging = $condition['id_attach']; |
|
| 1033 | + if ($type == 'do_logging') { |
|
| 1034 | + $do_logging = $condition['id_attach']; |
|
| 1035 | + } |
|
| 1003 | 1036 | } |
| 1004 | 1037 | $condition = implode(' AND ', $new_condition); |
| 1005 | 1038 | } |
@@ -1031,15 +1064,15 @@ discard block |
||
| 1031 | 1064 | // wasn't it obvious? :P |
| 1032 | 1065 | // @todo look again at this. |
| 1033 | 1066 | @unlink($modSettings['custom_avatar_dir'] . '/' . $row['filename']); |
| 1034 | - } |
|
| 1035 | - else |
|
| 1067 | + } else |
|
| 1036 | 1068 | { |
| 1037 | 1069 | $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
| 1038 | 1070 | @unlink($filename); |
| 1039 | 1071 | |
| 1040 | 1072 | // If this was a thumb, the parent attachment should know about it. |
| 1041 | - if (!empty($row['id_parent'])) |
|
| 1042 | - $parents[] = $row['id_parent']; |
|
| 1073 | + if (!empty($row['id_parent'])) { |
|
| 1074 | + $parents[] = $row['id_parent']; |
|
| 1075 | + } |
|
| 1043 | 1076 | |
| 1044 | 1077 | // If this attachments has a thumb, remove it as well. |
| 1045 | 1078 | if (!empty($row['id_thumb']) && $autoThumbRemoval) |
@@ -1051,8 +1084,9 @@ discard block |
||
| 1051 | 1084 | } |
| 1052 | 1085 | |
| 1053 | 1086 | // Make a list. |
| 1054 | - if ($return_affected_messages && empty($row['attachment_type'])) |
|
| 1055 | - $msgs[] = $row['id_msg']; |
|
| 1087 | + if ($return_affected_messages && empty($row['attachment_type'])) { |
|
| 1088 | + $msgs[] = $row['id_msg']; |
|
| 1089 | + } |
|
| 1056 | 1090 | |
| 1057 | 1091 | $attach[] = $row['id_attach']; |
| 1058 | 1092 | } |
@@ -1060,8 +1094,8 @@ discard block |
||
| 1060 | 1094 | |
| 1061 | 1095 | // Removed attachments don't have to be updated anymore. |
| 1062 | 1096 | $parents = array_diff($parents, $attach); |
| 1063 | - if (!empty($parents)) |
|
| 1064 | - $smcFunc['db_query']('', ' |
|
| 1097 | + if (!empty($parents)) { |
|
| 1098 | + $smcFunc['db_query']('', ' |
|
| 1065 | 1099 | UPDATE {db_prefix}attachments |
| 1066 | 1100 | SET id_thumb = {int:no_thumb} |
| 1067 | 1101 | WHERE id_attach IN ({array_int:parent_attachments})', |
@@ -1070,6 +1104,7 @@ discard block |
||
| 1070 | 1104 | 'no_thumb' => 0, |
| 1071 | 1105 | ) |
| 1072 | 1106 | ); |
| 1107 | + } |
|
| 1073 | 1108 | |
| 1074 | 1109 | if (!empty($do_logging)) |
| 1075 | 1110 | { |
@@ -1086,31 +1121,34 @@ discard block |
||
| 1086 | 1121 | ) |
| 1087 | 1122 | ); |
| 1088 | 1123 | |
| 1089 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1090 | - logAction( |
|
| 1124 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1125 | + logAction( |
|
| 1091 | 1126 | 'remove_attach', |
| 1092 | 1127 | array( |
| 1093 | 1128 | 'message' => $row['id_msg'], |
| 1094 | 1129 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1095 | 1130 | ) |
| 1096 | 1131 | ); |
| 1132 | + } |
|
| 1097 | 1133 | $smcFunc['db_free_result']($request); |
| 1098 | 1134 | } |
| 1099 | 1135 | |
| 1100 | - if (!empty($attach)) |
|
| 1101 | - $smcFunc['db_query']('', ' |
|
| 1136 | + if (!empty($attach)) { |
|
| 1137 | + $smcFunc['db_query']('', ' |
|
| 1102 | 1138 | DELETE FROM {db_prefix}attachments |
| 1103 | 1139 | WHERE id_attach IN ({array_int:attachment_list})', |
| 1104 | 1140 | array( |
| 1105 | 1141 | 'attachment_list' => $attach, |
| 1106 | 1142 | ) |
| 1107 | 1143 | ); |
| 1144 | + } |
|
| 1108 | 1145 | |
| 1109 | 1146 | call_integration_hook('integrate_remove_attachments', array($attach)); |
| 1110 | 1147 | |
| 1111 | - if ($return_affected_messages) |
|
| 1112 | - return array_unique($msgs); |
|
| 1113 | -} |
|
| 1148 | + if ($return_affected_messages) { |
|
| 1149 | + return array_unique($msgs); |
|
| 1150 | + } |
|
| 1151 | + } |
|
| 1114 | 1152 | |
| 1115 | 1153 | /** |
| 1116 | 1154 | * This function should find attachments in the database that no longer exist and clear them, and fix filesize issues. |
@@ -1122,8 +1160,9 @@ discard block |
||
| 1122 | 1160 | checkSession('get'); |
| 1123 | 1161 | |
| 1124 | 1162 | // If we choose cancel, redirect right back. |
| 1125 | - if (isset($_POST['cancel'])) |
|
| 1126 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1163 | + if (isset($_POST['cancel'])) { |
|
| 1164 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1165 | + } |
|
| 1127 | 1166 | |
| 1128 | 1167 | // Try give us a while to sort this out... |
| 1129 | 1168 | @set_time_limit(600); |
@@ -1140,13 +1179,15 @@ discard block |
||
| 1140 | 1179 | if (isset($_GET['fixErrors'])) |
| 1141 | 1180 | { |
| 1142 | 1181 | // Nothing? |
| 1143 | - if (empty($_POST['to_fix'])) |
|
| 1144 | - redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1182 | + if (empty($_POST['to_fix'])) { |
|
| 1183 | + redirectexit('action=admin;area=manageattachments;sa=maintenance'); |
|
| 1184 | + } |
|
| 1145 | 1185 | |
| 1146 | 1186 | $_SESSION['attachments_to_fix'] = array(); |
| 1147 | 1187 | // @todo No need to do this I think. |
| 1148 | - foreach ($_POST['to_fix'] as $value) |
|
| 1149 | - $_SESSION['attachments_to_fix'][] = $value; |
|
| 1188 | + foreach ($_POST['to_fix'] as $value) { |
|
| 1189 | + $_SESSION['attachments_to_fix'][] = $value; |
|
| 1190 | + } |
|
| 1150 | 1191 | } |
| 1151 | 1192 | } |
| 1152 | 1193 | |
@@ -1213,13 +1254,14 @@ discard block |
||
| 1213 | 1254 | } |
| 1214 | 1255 | } |
| 1215 | 1256 | } |
| 1216 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1217 | - $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1257 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1258 | + $to_fix[] = 'missing_thumbnail_parent'; |
|
| 1259 | + } |
|
| 1218 | 1260 | $smcFunc['db_free_result']($result); |
| 1219 | 1261 | |
| 1220 | 1262 | // Do we need to delete what we have? |
| 1221 | - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) |
|
| 1222 | - $smcFunc['db_query']('', ' |
|
| 1263 | + if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { |
|
| 1264 | + $smcFunc['db_query']('', ' |
|
| 1223 | 1265 | DELETE FROM {db_prefix}attachments |
| 1224 | 1266 | WHERE id_attach IN ({array_int:to_remove}) |
| 1225 | 1267 | AND attachment_type = {int:attachment_type}', |
@@ -1228,6 +1270,7 @@ discard block |
||
| 1228 | 1270 | 'attachment_type' => 3, |
| 1229 | 1271 | ) |
| 1230 | 1272 | ); |
| 1273 | + } |
|
| 1231 | 1274 | |
| 1232 | 1275 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1233 | 1276 | } |
@@ -1272,13 +1315,14 @@ discard block |
||
| 1272 | 1315 | $to_update[] = $row['id_attach']; |
| 1273 | 1316 | $context['repair_errors']['parent_missing_thumbnail']++; |
| 1274 | 1317 | } |
| 1275 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1276 | - $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1318 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1319 | + $to_fix[] = 'parent_missing_thumbnail'; |
|
| 1320 | + } |
|
| 1277 | 1321 | $smcFunc['db_free_result']($result); |
| 1278 | 1322 | |
| 1279 | 1323 | // Do we need to delete what we have? |
| 1280 | - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) |
|
| 1281 | - $smcFunc['db_query']('', ' |
|
| 1324 | + if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { |
|
| 1325 | + $smcFunc['db_query']('', ' |
|
| 1282 | 1326 | UPDATE {db_prefix}attachments |
| 1283 | 1327 | SET id_thumb = {int:no_thumb} |
| 1284 | 1328 | WHERE id_attach IN ({array_int:to_update})', |
@@ -1287,6 +1331,7 @@ discard block |
||
| 1287 | 1331 | 'no_thumb' => 0, |
| 1288 | 1332 | ) |
| 1289 | 1333 | ); |
| 1334 | + } |
|
| 1290 | 1335 | |
| 1291 | 1336 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1292 | 1337 | } |
@@ -1324,10 +1369,11 @@ discard block |
||
| 1324 | 1369 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 1325 | 1370 | { |
| 1326 | 1371 | // Get the filename. |
| 1327 | - if ($row['attachment_type'] == 1) |
|
| 1328 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1329 | - else |
|
| 1330 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1372 | + if ($row['attachment_type'] == 1) { |
|
| 1373 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1374 | + } else { |
|
| 1375 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1376 | + } |
|
| 1331 | 1377 | |
| 1332 | 1378 | // File doesn't exist? |
| 1333 | 1379 | if (!file_exists($filename)) |
@@ -1339,15 +1385,16 @@ discard block |
||
| 1339 | 1385 | $attachment_name = $row['id_attach'] . '_' . $row['file_hash'] . '.dat'; |
| 1340 | 1386 | |
| 1341 | 1387 | // Loop through the other folders. |
| 1342 | - foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
|
| 1343 | - if (file_exists($dir . '/' . $attachment_name)) |
|
| 1388 | + foreach ($modSettings['attachmentUploadDir'] as $id => $dir) { |
|
| 1389 | + if (file_exists($dir . '/' . $attachment_name)) |
|
| 1344 | 1390 | { |
| 1345 | 1391 | $context['repair_errors']['wrong_folder']++; |
| 1392 | + } |
|
| 1346 | 1393 | $errors_found[] = 'wrong_folder'; |
| 1347 | 1394 | |
| 1348 | 1395 | // Are we going to fix this now? |
| 1349 | - if ($fix_errors && in_array('wrong_folder', $to_fix)) |
|
| 1350 | - $smcFunc['db_query']('', ' |
|
| 1396 | + if ($fix_errors && in_array('wrong_folder', $to_fix)) { |
|
| 1397 | + $smcFunc['db_query']('', ' |
|
| 1351 | 1398 | UPDATE {db_prefix}attachments |
| 1352 | 1399 | SET id_folder = {int:new_folder} |
| 1353 | 1400 | WHERE id_attach = {int:id_attach}', |
@@ -1356,6 +1403,7 @@ discard block |
||
| 1356 | 1403 | 'id_attach' => $row['id_attach'], |
| 1357 | 1404 | ) |
| 1358 | 1405 | ); |
| 1406 | + } |
|
| 1359 | 1407 | |
| 1360 | 1408 | continue 2; |
| 1361 | 1409 | } |
@@ -1364,8 +1412,7 @@ discard block |
||
| 1364 | 1412 | $to_remove[] = $row['id_attach']; |
| 1365 | 1413 | $context['repair_errors']['file_missing_on_disk']++; |
| 1366 | 1414 | $errors_found[] = 'file_missing_on_disk'; |
| 1367 | - } |
|
| 1368 | - elseif (filesize($filename) == 0) |
|
| 1415 | + } elseif (filesize($filename) == 0) |
|
| 1369 | 1416 | { |
| 1370 | 1417 | $context['repair_errors']['file_size_of_zero']++; |
| 1371 | 1418 | $errors_found[] = 'file_size_of_zero'; |
@@ -1376,8 +1423,7 @@ discard block |
||
| 1376 | 1423 | $to_remove[] = $row['id_attach']; |
| 1377 | 1424 | @unlink($filename); |
| 1378 | 1425 | } |
| 1379 | - } |
|
| 1380 | - elseif (filesize($filename) != $row['size']) |
|
| 1426 | + } elseif (filesize($filename) != $row['size']) |
|
| 1381 | 1427 | { |
| 1382 | 1428 | $context['repair_errors']['file_wrong_size']++; |
| 1383 | 1429 | $errors_found[] = 'file_wrong_size'; |
@@ -1398,14 +1444,18 @@ discard block |
||
| 1398 | 1444 | } |
| 1399 | 1445 | } |
| 1400 | 1446 | |
| 1401 | - if (in_array('file_missing_on_disk', $errors_found)) |
|
| 1402 | - $to_fix[] = 'file_missing_on_disk'; |
|
| 1403 | - if (in_array('file_size_of_zero', $errors_found)) |
|
| 1404 | - $to_fix[] = 'file_size_of_zero'; |
|
| 1405 | - if (in_array('file_wrong_size', $errors_found)) |
|
| 1406 | - $to_fix[] = 'file_wrong_size'; |
|
| 1407 | - if (in_array('wrong_folder', $errors_found)) |
|
| 1408 | - $to_fix[] = 'wrong_folder'; |
|
| 1447 | + if (in_array('file_missing_on_disk', $errors_found)) { |
|
| 1448 | + $to_fix[] = 'file_missing_on_disk'; |
|
| 1449 | + } |
|
| 1450 | + if (in_array('file_size_of_zero', $errors_found)) { |
|
| 1451 | + $to_fix[] = 'file_size_of_zero'; |
|
| 1452 | + } |
|
| 1453 | + if (in_array('file_wrong_size', $errors_found)) { |
|
| 1454 | + $to_fix[] = 'file_wrong_size'; |
|
| 1455 | + } |
|
| 1456 | + if (in_array('wrong_folder', $errors_found)) { |
|
| 1457 | + $to_fix[] = 'wrong_folder'; |
|
| 1458 | + } |
|
| 1409 | 1459 | $smcFunc['db_free_result']($result); |
| 1410 | 1460 | |
| 1411 | 1461 | // Do we need to delete what we have? |
@@ -1475,20 +1525,22 @@ discard block |
||
| 1475 | 1525 | // If we are repairing remove the file from disk now. |
| 1476 | 1526 | if ($fix_errors && in_array('avatar_no_member', $to_fix)) |
| 1477 | 1527 | { |
| 1478 | - if ($row['attachment_type'] == 1) |
|
| 1479 | - $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1480 | - else |
|
| 1481 | - $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1528 | + if ($row['attachment_type'] == 1) { |
|
| 1529 | + $filename = $modSettings['custom_avatar_dir'] . '/' . $row['filename']; |
|
| 1530 | + } else { |
|
| 1531 | + $filename = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']); |
|
| 1532 | + } |
|
| 1482 | 1533 | @unlink($filename); |
| 1483 | 1534 | } |
| 1484 | 1535 | } |
| 1485 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1486 | - $to_fix[] = 'avatar_no_member'; |
|
| 1536 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1537 | + $to_fix[] = 'avatar_no_member'; |
|
| 1538 | + } |
|
| 1487 | 1539 | $smcFunc['db_free_result']($result); |
| 1488 | 1540 | |
| 1489 | 1541 | // Do we need to delete what we have? |
| 1490 | - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) |
|
| 1491 | - $smcFunc['db_query']('', ' |
|
| 1542 | + if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { |
|
| 1543 | + $smcFunc['db_query']('', ' |
|
| 1492 | 1544 | DELETE FROM {db_prefix}attachments |
| 1493 | 1545 | WHERE id_attach IN ({array_int:to_remove}) |
| 1494 | 1546 | AND id_member != {int:no_member} |
@@ -1499,6 +1551,7 @@ discard block |
||
| 1499 | 1551 | 'no_msg' => 0, |
| 1500 | 1552 | ) |
| 1501 | 1553 | ); |
| 1554 | + } |
|
| 1502 | 1555 | |
| 1503 | 1556 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1504 | 1557 | } |
@@ -1558,13 +1611,14 @@ discard block |
||
| 1558 | 1611 | @unlink($filename); |
| 1559 | 1612 | } |
| 1560 | 1613 | } |
| 1561 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1562 | - $to_fix[] = 'attachment_no_msg'; |
|
| 1614 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1615 | + $to_fix[] = 'attachment_no_msg'; |
|
| 1616 | + } |
|
| 1563 | 1617 | $smcFunc['db_free_result']($result); |
| 1564 | 1618 | |
| 1565 | 1619 | // Do we need to delete what we have? |
| 1566 | - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) |
|
| 1567 | - $smcFunc['db_query']('', ' |
|
| 1620 | + if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { |
|
| 1621 | + $smcFunc['db_query']('', ' |
|
| 1568 | 1622 | DELETE FROM {db_prefix}attachments |
| 1569 | 1623 | WHERE id_attach IN ({array_int:to_remove}) |
| 1570 | 1624 | AND id_member = {int:no_member} |
@@ -1575,6 +1629,7 @@ discard block |
||
| 1575 | 1629 | 'attach_thumb' => array(0,3), |
| 1576 | 1630 | ) |
| 1577 | 1631 | ); |
| 1632 | + } |
|
| 1578 | 1633 | |
| 1579 | 1634 | pauseAttachmentMaintenance($to_fix, $thumbnails); |
| 1580 | 1635 | } |
@@ -1598,8 +1653,9 @@ discard block |
||
| 1598 | 1653 | { |
| 1599 | 1654 | while ($file = readdir($dir)) |
| 1600 | 1655 | { |
| 1601 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 1602 | - continue; |
|
| 1656 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 1657 | + continue; |
|
| 1658 | + } |
|
| 1603 | 1659 | |
| 1604 | 1660 | if ($files_checked <= $current_check) |
| 1605 | 1661 | { |
@@ -1607,8 +1663,9 @@ discard block |
||
| 1607 | 1663 | if (strpos($file, 'post_tmp_') !== false) |
| 1608 | 1664 | { |
| 1609 | 1665 | // Temp file is more than 5 hours old! |
| 1610 | - if (filemtime($attach_dir . '/' . $file) < time() - 18000) |
|
| 1611 | - @unlink($attach_dir . '/' . $file); |
|
| 1666 | + if (filemtime($attach_dir . '/' . $file) < time() - 18000) { |
|
| 1667 | + @unlink($attach_dir . '/' . $file); |
|
| 1668 | + } |
|
| 1612 | 1669 | } |
| 1613 | 1670 | // That should be an attachment, let's check if we have it in the database |
| 1614 | 1671 | elseif (strpos($file, '_') !== false) |
@@ -1630,8 +1687,7 @@ discard block |
||
| 1630 | 1687 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1631 | 1688 | { |
| 1632 | 1689 | @unlink($attach_dir . '/' . $file); |
| 1633 | - } |
|
| 1634 | - else |
|
| 1690 | + } else |
|
| 1635 | 1691 | { |
| 1636 | 1692 | $context['repair_errors']['files_without_attachment']++; |
| 1637 | 1693 | $to_fix[] = 'files_without_attachment'; |
@@ -1639,14 +1695,12 @@ discard block |
||
| 1639 | 1695 | } |
| 1640 | 1696 | $smcFunc['db_free_result']($request); |
| 1641 | 1697 | } |
| 1642 | - } |
|
| 1643 | - else |
|
| 1698 | + } else |
|
| 1644 | 1699 | { |
| 1645 | 1700 | if ($fix_errors && in_array('files_without_attachment', $to_fix)) |
| 1646 | 1701 | { |
| 1647 | 1702 | @unlink($attach_dir . '/' . $file); |
| 1648 | - } |
|
| 1649 | - else |
|
| 1703 | + } else |
|
| 1650 | 1704 | { |
| 1651 | 1705 | $context['repair_errors']['files_without_attachment']++; |
| 1652 | 1706 | $to_fix[] = 'files_without_attachment'; |
@@ -1655,8 +1709,9 @@ discard block |
||
| 1655 | 1709 | } |
| 1656 | 1710 | $current_check++; |
| 1657 | 1711 | $_GET['substep'] = $current_check; |
| 1658 | - if ($current_check - $files_checked >= $max_checks) |
|
| 1659 | - pauseAttachmentMaintenance($to_fix); |
|
| 1712 | + if ($current_check - $files_checked >= $max_checks) { |
|
| 1713 | + pauseAttachmentMaintenance($to_fix); |
|
| 1714 | + } |
|
| 1660 | 1715 | } |
| 1661 | 1716 | closedir($dir); |
| 1662 | 1717 | } |
@@ -1692,12 +1747,14 @@ discard block |
||
| 1692 | 1747 | |
| 1693 | 1748 | // Try get more time... |
| 1694 | 1749 | @set_time_limit(600); |
| 1695 | - if (function_exists('apache_reset_timeout')) |
|
| 1696 | - @apache_reset_timeout(); |
|
| 1750 | + if (function_exists('apache_reset_timeout')) { |
|
| 1751 | + @apache_reset_timeout(); |
|
| 1752 | + } |
|
| 1697 | 1753 | |
| 1698 | 1754 | // Have we already used our maximum time? |
| 1699 | - if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) |
|
| 1700 | - return; |
|
| 1755 | + if ((time() - $time_start) < 3 || $context['starting_substep'] == $_GET['substep']) { |
|
| 1756 | + return; |
|
| 1757 | + } |
|
| 1701 | 1758 | |
| 1702 | 1759 | $context['continue_get_data'] = '?action=admin;area=manageattachments;sa=repair' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1703 | 1760 | $context['page_title'] = $txt['not_done_title']; |
@@ -1709,10 +1766,11 @@ discard block |
||
| 1709 | 1766 | $context[$context['admin_menu_name']]['current_subsection'] = 'maintenance'; |
| 1710 | 1767 | |
| 1711 | 1768 | // Change these two if more steps are added! |
| 1712 | - if (empty($max_substep)) |
|
| 1713 | - $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1714 | - else |
|
| 1715 | - $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1769 | + if (empty($max_substep)) { |
|
| 1770 | + $context['continue_percent'] = round(($_GET['step'] * 100) / 25); |
|
| 1771 | + } else { |
|
| 1772 | + $context['continue_percent'] = round(($_GET['step'] * 100 + ($_GET['substep'] * 100) / $max_substep) / 25); |
|
| 1773 | + } |
|
| 1716 | 1774 | |
| 1717 | 1775 | // Never more than 100%! |
| 1718 | 1776 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -1754,15 +1812,17 @@ discard block |
||
| 1754 | 1812 | 'attachment_type' => 0, |
| 1755 | 1813 | ) |
| 1756 | 1814 | ); |
| 1757 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1758 | - $attachments[] = $row['id_attach']; |
|
| 1815 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1816 | + $attachments[] = $row['id_attach']; |
|
| 1817 | + } |
|
| 1759 | 1818 | $smcFunc['db_free_result']($request); |
| 1819 | + } elseif (!empty($_GET['aid'])) { |
|
| 1820 | + $attachments[] = (int) $_GET['aid']; |
|
| 1760 | 1821 | } |
| 1761 | - elseif (!empty($_GET['aid'])) |
|
| 1762 | - $attachments[] = (int) $_GET['aid']; |
|
| 1763 | 1822 | |
| 1764 | - if (empty($attachments)) |
|
| 1765 | - fatal_lang_error('no_access', false); |
|
| 1823 | + if (empty($attachments)) { |
|
| 1824 | + fatal_lang_error('no_access', false); |
|
| 1825 | + } |
|
| 1766 | 1826 | |
| 1767 | 1827 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
| 1768 | 1828 | $allowed_boards = boardsAllowedTo('approve_posts'); |
@@ -1795,17 +1855,18 @@ discard block |
||
| 1795 | 1855 | } |
| 1796 | 1856 | $smcFunc['db_free_result']($request); |
| 1797 | 1857 | |
| 1798 | - if (empty($attachments)) |
|
| 1799 | - fatal_lang_error('no_access', false); |
|
| 1858 | + if (empty($attachments)) { |
|
| 1859 | + fatal_lang_error('no_access', false); |
|
| 1860 | + } |
|
| 1800 | 1861 | |
| 1801 | 1862 | // Finally, we are there. Follow through! |
| 1802 | 1863 | if ($is_approve) |
| 1803 | 1864 | { |
| 1804 | 1865 | // Checked and deemed worthy. |
| 1805 | 1866 | ApproveAttachments($attachments); |
| 1867 | + } else { |
|
| 1868 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1806 | 1869 | } |
| 1807 | - else |
|
| 1808 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
| 1809 | 1870 | |
| 1810 | 1871 | // Return to the topic.... |
| 1811 | 1872 | redirectexit($redirect); |
@@ -1821,8 +1882,9 @@ discard block |
||
| 1821 | 1882 | { |
| 1822 | 1883 | global $smcFunc; |
| 1823 | 1884 | |
| 1824 | - if (empty($attachments)) |
|
| 1825 | - return 0; |
|
| 1885 | + if (empty($attachments)) { |
|
| 1886 | + return 0; |
|
| 1887 | + } |
|
| 1826 | 1888 | |
| 1827 | 1889 | // For safety, check for thumbnails... |
| 1828 | 1890 | $request = $smcFunc['db_query']('', ' |
@@ -1841,15 +1903,17 @@ discard block |
||
| 1841 | 1903 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1842 | 1904 | { |
| 1843 | 1905 | // Update the thumbnail too... |
| 1844 | - if (!empty($row['id_thumb'])) |
|
| 1845 | - $attachments[] = $row['id_thumb']; |
|
| 1906 | + if (!empty($row['id_thumb'])) { |
|
| 1907 | + $attachments[] = $row['id_thumb']; |
|
| 1908 | + } |
|
| 1846 | 1909 | |
| 1847 | 1910 | $attachments[] = $row['id_attach']; |
| 1848 | 1911 | } |
| 1849 | 1912 | $smcFunc['db_free_result']($request); |
| 1850 | 1913 | |
| 1851 | - if (empty($attachments)) |
|
| 1852 | - return 0; |
|
| 1914 | + if (empty($attachments)) { |
|
| 1915 | + return 0; |
|
| 1916 | + } |
|
| 1853 | 1917 | |
| 1854 | 1918 | // Approving an attachment is not hard - it's easy. |
| 1855 | 1919 | $smcFunc['db_query']('', ' |
@@ -1875,14 +1939,15 @@ discard block |
||
| 1875 | 1939 | ) |
| 1876 | 1940 | ); |
| 1877 | 1941 | |
| 1878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1879 | - logAction( |
|
| 1942 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1943 | + logAction( |
|
| 1880 | 1944 | 'approve_attach', |
| 1881 | 1945 | array( |
| 1882 | 1946 | 'message' => $row['id_msg'], |
| 1883 | 1947 | 'filename' => preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($row['filename'])), |
| 1884 | 1948 | ) |
| 1885 | 1949 | ); |
| 1950 | + } |
|
| 1886 | 1951 | $smcFunc['db_free_result']($request); |
| 1887 | 1952 | |
| 1888 | 1953 | // Remove from the approval queue. |
@@ -1905,11 +1970,11 @@ discard block |
||
| 1905 | 1970 | global $modSettings, $scripturl, $context, $txt, $sourcedir, $boarddir, $smcFunc, $settings; |
| 1906 | 1971 | |
| 1907 | 1972 | // Since this needs to be done eventually. |
| 1908 | - if (!isset($modSettings['attachment_basedirectories'])) |
|
| 1909 | - $modSettings['attachment_basedirectories'] = array(); |
|
| 1910 | - |
|
| 1911 | - elseif (!is_array($modSettings['attachment_basedirectories'])) |
|
| 1912 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 1973 | + if (!isset($modSettings['attachment_basedirectories'])) { |
|
| 1974 | + $modSettings['attachment_basedirectories'] = array(); |
|
| 1975 | + } elseif (!is_array($modSettings['attachment_basedirectories'])) { |
|
| 1976 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 1977 | + } |
|
| 1913 | 1978 | |
| 1914 | 1979 | $errors = array(); |
| 1915 | 1980 | |
@@ -1924,8 +1989,9 @@ discard block |
||
| 1924 | 1989 | { |
| 1925 | 1990 | $error = ''; |
| 1926 | 1991 | $id = (int) $id; |
| 1927 | - if ($id < 1) |
|
| 1928 | - continue; |
|
| 1992 | + if ($id < 1) { |
|
| 1993 | + continue; |
|
| 1994 | + } |
|
| 1929 | 1995 | |
| 1930 | 1996 | // Sorry, these dirs are NOT valid |
| 1931 | 1997 | $invalid_dirs = array($boarddir, $settings['default_theme_dir'], $sourcedir); |
@@ -1944,8 +2010,7 @@ discard block |
||
| 1944 | 2010 | { |
| 1945 | 2011 | $errors[] = $path . ': ' . $txt['attach_dir_duplicate_msg']; |
| 1946 | 2012 | continue; |
| 1947 | - } |
|
| 1948 | - elseif (empty($path)) |
|
| 2013 | + } elseif (empty($path)) |
|
| 1949 | 2014 | { |
| 1950 | 2015 | // Ignore this and set $id to one less |
| 1951 | 2016 | continue; |
@@ -1953,10 +2018,11 @@ discard block |
||
| 1953 | 2018 | |
| 1954 | 2019 | // OK, so let's try to create it then. |
| 1955 | 2020 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1956 | - if (automanage_attachments_create_directory($path)) |
|
| 1957 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 1958 | - else |
|
| 1959 | - $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2021 | + if (automanage_attachments_create_directory($path)) { |
|
| 2022 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2023 | + } else { |
|
| 2024 | + $errors[] = $path . ': ' . $txt[$context['dir_creation_error']]; |
|
| 2025 | + } |
|
| 1960 | 2026 | } |
| 1961 | 2027 | |
| 1962 | 2028 | // Changing a directory name? |
@@ -1969,8 +2035,7 @@ discard block |
||
| 1969 | 2035 | $errors[] = $path . ': ' . $txt['attach_dir_no_rename']; |
| 1970 | 2036 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1971 | 2037 | } |
| 1972 | - } |
|
| 1973 | - else |
|
| 2038 | + } else |
|
| 1974 | 2039 | { |
| 1975 | 2040 | $errors[] = $path . ': ' . $txt['attach_dir_exists_msg']; |
| 1976 | 2041 | $path = $modSettings['attachmentUploadDir'][$id]; |
@@ -1995,12 +2060,13 @@ discard block |
||
| 1995 | 2060 | $path = $modSettings['attachmentUploadDir'][$id]; |
| 1996 | 2061 | |
| 1997 | 2062 | // It's not a good idea to delete the current directory. |
| 1998 | - if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) |
|
| 1999 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2063 | + if ($id == (!empty($_POST['current_dir']) ? $_POST['current_dir'] : $modSettings['currentAttachmentUploadDir'])) { |
|
| 2064 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current']; |
|
| 2065 | + } |
|
| 2000 | 2066 | // Or the current base directory |
| 2001 | - elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) |
|
| 2002 | - $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2003 | - else |
|
| 2067 | + elseif (!empty($modSettings['basedirectory_for_attachments']) && $modSettings['basedirectory_for_attachments'] == $modSettings['attachmentUploadDir'][$id]) { |
|
| 2068 | + $errors[] = $path . ': ' . $txt['attach_dir_is_current_bd']; |
|
| 2069 | + } else |
|
| 2004 | 2070 | { |
| 2005 | 2071 | // Let's not try to delete a path with files in it. |
| 2006 | 2072 | $request = $smcFunc['db_query']('', ' |
@@ -2019,17 +2085,18 @@ discard block |
||
| 2019 | 2085 | if (!empty($modSettings['attachment_basedirectories'])) |
| 2020 | 2086 | { |
| 2021 | 2087 | // Count any sub-folders. |
| 2022 | - foreach ($modSettings['attachmentUploadDir'] as $sub) |
|
| 2023 | - if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2088 | + foreach ($modSettings['attachmentUploadDir'] as $sub) { |
|
| 2089 | + if (strpos($sub, $path . DIRECTORY_SEPARATOR) !== false) |
|
| 2024 | 2090 | $num_attach++; |
| 2091 | + } |
|
| 2025 | 2092 | } |
| 2026 | 2093 | |
| 2027 | 2094 | // It's safe to delete. So try to delete the folder also |
| 2028 | 2095 | if ($num_attach == 0) |
| 2029 | 2096 | { |
| 2030 | - if (is_dir($path)) |
|
| 2031 | - $doit = true; |
|
| 2032 | - elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2097 | + if (is_dir($path)) { |
|
| 2098 | + $doit = true; |
|
| 2099 | + } elseif (is_dir($boarddir . DIRECTORY_SEPARATOR . $path)) |
|
| 2033 | 2100 | { |
| 2034 | 2101 | $doit = true; |
| 2035 | 2102 | $path = $boarddir . DIRECTORY_SEPARATOR . $path; |
@@ -2039,8 +2106,9 @@ discard block |
||
| 2039 | 2106 | { |
| 2040 | 2107 | unlink($path . '/.htaccess'); |
| 2041 | 2108 | unlink($path . '/index.php'); |
| 2042 | - if (!@rmdir($path)) |
|
| 2043 | - $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2109 | + if (!@rmdir($path)) { |
|
| 2110 | + $error = $path . ': ' . $txt['attach_dir_no_delete']; |
|
| 2111 | + } |
|
| 2044 | 2112 | } |
| 2045 | 2113 | |
| 2046 | 2114 | // Remove it from the base directory list. |
@@ -2050,14 +2118,15 @@ discard block |
||
| 2050 | 2118 | updateSettings(array('attachment_basedirectories' => $smcFunc['json_encode']($modSettings['attachment_basedirectories']))); |
| 2051 | 2119 | $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
| 2052 | 2120 | } |
| 2121 | + } else { |
|
| 2122 | + $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2053 | 2123 | } |
| 2054 | - else |
|
| 2055 | - $error = $path . ': ' . $txt['attach_dir_no_remove']; |
|
| 2056 | 2124 | |
| 2057 | - if (empty($error)) |
|
| 2058 | - continue; |
|
| 2059 | - else |
|
| 2060 | - $errors[] = $error; |
|
| 2125 | + if (empty($error)) { |
|
| 2126 | + continue; |
|
| 2127 | + } else { |
|
| 2128 | + $errors[] = $error; |
|
| 2129 | + } |
|
| 2061 | 2130 | } |
| 2062 | 2131 | } |
| 2063 | 2132 | |
@@ -2065,23 +2134,26 @@ discard block |
||
| 2065 | 2134 | } |
| 2066 | 2135 | |
| 2067 | 2136 | // We need to make sure the current directory is right. |
| 2068 | - if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) |
|
| 2069 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2137 | + if (empty($_POST['current_dir']) && !empty($modSettings['currentAttachmentUploadDir'])) { |
|
| 2138 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2139 | + } |
|
| 2070 | 2140 | |
| 2071 | 2141 | // Find the current directory if there's no value carried, |
| 2072 | 2142 | if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) |
| 2073 | 2143 | { |
| 2074 | - if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) |
|
| 2075 | - $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2076 | - else |
|
| 2077 | - $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2144 | + if (array_key_exists($modSettings['currentAttachmentUploadDir'], $modSettings['attachmentUploadDir'])) { |
|
| 2145 | + $_POST['current_dir'] = $modSettings['currentAttachmentUploadDir']; |
|
| 2146 | + } else { |
|
| 2147 | + $_POST['current_dir'] = max(array_keys($modSettings['attachmentUploadDir'])); |
|
| 2148 | + } |
|
| 2078 | 2149 | } |
| 2079 | 2150 | |
| 2080 | 2151 | // If the user wishes to go back, update the last_dir array |
| 2081 | 2152 | if ($_POST['current_dir'] != $modSettings['currentAttachmentUploadDir'] && !empty($modSettings['last_attachments_directory']) && (isset($modSettings['last_attachments_directory'][$_POST['current_dir']]) || isset($modSettings['last_attachments_directory'][0]))) |
| 2082 | 2153 | { |
| 2083 | - if (!is_array($modSettings['last_attachments_directory'])) |
|
| 2084 | - $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
| 2154 | + if (!is_array($modSettings['last_attachments_directory'])) { |
|
| 2155 | + $modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true); |
|
| 2156 | + } |
|
| 2085 | 2157 | $num = substr(strrchr($modSettings['attachmentUploadDir'][$_POST['current_dir']], '_'), 1); |
| 2086 | 2158 | |
| 2087 | 2159 | if (is_numeric($num)) |
@@ -2089,16 +2161,18 @@ discard block |
||
| 2089 | 2161 | // Need to find the base folder. |
| 2090 | 2162 | $bid = -1; |
| 2091 | 2163 | $use_subdirectories_for_attachments = 0; |
| 2092 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2093 | - foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2164 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2165 | + foreach ($modSettings['attachment_basedirectories'] as $bid => $base) |
|
| 2094 | 2166 | if (strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $base . DIRECTORY_SEPARATOR) !== false) |
| 2095 | 2167 | { |
| 2096 | 2168 | $use_subdirectories_for_attachments = 1; |
| 2169 | + } |
|
| 2097 | 2170 | break; |
| 2098 | 2171 | } |
| 2099 | 2172 | |
| 2100 | - if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) |
|
| 2101 | - $bid = 0; |
|
| 2173 | + if ($use_subdirectories_for_attachments == 0 && strpos($modSettings['attachmentUploadDir'][$_POST['current_dir']], $boarddir . DIRECTORY_SEPARATOR) !== false) { |
|
| 2174 | + $bid = 0; |
|
| 2175 | + } |
|
| 2102 | 2176 | |
| 2103 | 2177 | $modSettings['last_attachments_directory'][$bid] = (int) $num; |
| 2104 | 2178 | $modSettings['basedirectory_for_attachments'] = !empty($modSettings['basedirectory_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : ''; |
@@ -2117,8 +2191,8 @@ discard block |
||
| 2117 | 2191 | // We might need to reset the paths. This loop will just loop through once. |
| 2118 | 2192 | foreach ($new_dirs as $id => $dir) |
| 2119 | 2193 | { |
| 2120 | - if ($id != 1) |
|
| 2121 | - $smcFunc['db_query']('', ' |
|
| 2194 | + if ($id != 1) { |
|
| 2195 | + $smcFunc['db_query']('', ' |
|
| 2122 | 2196 | UPDATE {db_prefix}attachments |
| 2123 | 2197 | SET id_folder = {int:default_folder} |
| 2124 | 2198 | WHERE id_folder = {int:current_folder}', |
@@ -2127,14 +2201,14 @@ discard block |
||
| 2127 | 2201 | 'current_folder' => $id, |
| 2128 | 2202 | ) |
| 2129 | 2203 | ); |
| 2204 | + } |
|
| 2130 | 2205 | |
| 2131 | 2206 | $update = array( |
| 2132 | 2207 | 'currentAttachmentUploadDir' => 1, |
| 2133 | 2208 | 'attachmentUploadDir' => $smcFunc['json_encode'](array(1 => $dir)), |
| 2134 | 2209 | ); |
| 2135 | 2210 | } |
| 2136 | - } |
|
| 2137 | - else |
|
| 2211 | + } else |
|
| 2138 | 2212 | { |
| 2139 | 2213 | // Save it to the database. |
| 2140 | 2214 | $update = array( |
@@ -2143,11 +2217,13 @@ discard block |
||
| 2143 | 2217 | ); |
| 2144 | 2218 | } |
| 2145 | 2219 | |
| 2146 | - if (!empty($update)) |
|
| 2147 | - updateSettings($update); |
|
| 2220 | + if (!empty($update)) { |
|
| 2221 | + updateSettings($update); |
|
| 2222 | + } |
|
| 2148 | 2223 | |
| 2149 | - if (!empty($errors)) |
|
| 2150 | - $_SESSION['errors']['dir'] = $errors; |
|
| 2224 | + if (!empty($errors)) { |
|
| 2225 | + $_SESSION['errors']['dir'] = $errors; |
|
| 2226 | + } |
|
| 2151 | 2227 | |
| 2152 | 2228 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2153 | 2229 | } |
@@ -2161,10 +2237,11 @@ discard block |
||
| 2161 | 2237 | $_POST['current_base_dir'] = isset($_POST['current_base_dir']) ? (int) $_POST['current_base_dir'] : 1; |
| 2162 | 2238 | if (empty($_POST['new_base_dir']) && !empty($_POST['current_base_dir'])) |
| 2163 | 2239 | { |
| 2164 | - if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) |
|
| 2165 | - $update = (array( |
|
| 2240 | + if ($modSettings['basedirectory_for_attachments'] != $modSettings['attachmentUploadDir'][$_POST['current_base_dir']]) { |
|
| 2241 | + $update = (array( |
|
| 2166 | 2242 | 'basedirectory_for_attachments' => $modSettings['attachmentUploadDir'][$_POST['current_base_dir']], |
| 2167 | 2243 | )); |
| 2244 | + } |
|
| 2168 | 2245 | } |
| 2169 | 2246 | |
| 2170 | 2247 | if (isset($_POST['base_dir'])) |
@@ -2212,13 +2289,15 @@ discard block |
||
| 2212 | 2289 | |
| 2213 | 2290 | if (!in_array($_POST['new_base_dir'], $modSettings['attachmentUploadDir'])) |
| 2214 | 2291 | { |
| 2215 | - if (!automanage_attachments_create_directory($_POST['new_base_dir'])) |
|
| 2216 | - $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2292 | + if (!automanage_attachments_create_directory($_POST['new_base_dir'])) { |
|
| 2293 | + $errors[] = $_POST['new_base_dir'] . ': ' . $txt['attach_dir_base_no_create']; |
|
| 2294 | + } |
|
| 2217 | 2295 | } |
| 2218 | 2296 | |
| 2219 | 2297 | $modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], $modSettings['attachmentUploadDir']); |
| 2220 | - if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) |
|
| 2221 | - $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2298 | + if (!in_array($_POST['new_base_dir'], $modSettings['attachment_basedirectories'])) { |
|
| 2299 | + $modSettings['attachment_basedirectories'][$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; |
|
| 2300 | + } |
|
| 2222 | 2301 | ksort($modSettings['attachment_basedirectories']); |
| 2223 | 2302 | |
| 2224 | 2303 | $update = (array( |
@@ -2228,11 +2307,13 @@ discard block |
||
| 2228 | 2307 | )); |
| 2229 | 2308 | } |
| 2230 | 2309 | |
| 2231 | - if (!empty($errors)) |
|
| 2232 | - $_SESSION['errors']['base'] = $errors; |
|
| 2310 | + if (!empty($errors)) { |
|
| 2311 | + $_SESSION['errors']['base'] = $errors; |
|
| 2312 | + } |
|
| 2233 | 2313 | |
| 2234 | - if (!empty($update)) |
|
| 2235 | - updateSettings($update); |
|
| 2314 | + if (!empty($update)) { |
|
| 2315 | + updateSettings($update); |
|
| 2316 | + } |
|
| 2236 | 2317 | |
| 2237 | 2318 | redirectexit('action=admin;area=manageattachments;sa=attachpaths;' . $context['session_var'] . '=' . $context['session_id']); |
| 2238 | 2319 | } |
@@ -2242,13 +2323,15 @@ discard block |
||
| 2242 | 2323 | if (is_array($_SESSION['errors'])) |
| 2243 | 2324 | { |
| 2244 | 2325 | $errors = array(); |
| 2245 | - if (!empty($_SESSION['errors']['dir'])) |
|
| 2246 | - foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2326 | + if (!empty($_SESSION['errors']['dir'])) { |
|
| 2327 | + foreach ($_SESSION['errors']['dir'] as $error) |
|
| 2247 | 2328 | $errors['dir'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2329 | + } |
|
| 2248 | 2330 | |
| 2249 | - if (!empty($_SESSION['errors']['base'])) |
|
| 2250 | - foreach ($_SESSION['errors']['base'] as $error) |
|
| 2331 | + if (!empty($_SESSION['errors']['base'])) { |
|
| 2332 | + foreach ($_SESSION['errors']['base'] as $error) |
|
| 2251 | 2333 | $errors['base'][] = $smcFunc['htmlspecialchars']($error, ENT_QUOTES); |
| 2334 | + } |
|
| 2252 | 2335 | } |
| 2253 | 2336 | unset($_SESSION['errors']); |
| 2254 | 2337 | } |
@@ -2458,8 +2541,9 @@ discard block |
||
| 2458 | 2541 | foreach ($modSettings['attachmentUploadDir'] as $id => $dir) |
| 2459 | 2542 | { |
| 2460 | 2543 | // If there aren't any attachments in this directory this won't exist. |
| 2461 | - if (!isset($expected_files[$id])) |
|
| 2462 | - $expected_files[$id] = 0; |
|
| 2544 | + if (!isset($expected_files[$id])) { |
|
| 2545 | + $expected_files[$id] = 0; |
|
| 2546 | + } |
|
| 2463 | 2547 | |
| 2464 | 2548 | // Check if the directory is doing okay. |
| 2465 | 2549 | list ($status, $error, $files) = attachDirStatus($dir, $expected_files[$id]); |
@@ -2472,10 +2556,11 @@ discard block |
||
| 2472 | 2556 | $is_base_dir = in_array($dir, $modSettings['attachment_basedirectories']); |
| 2473 | 2557 | |
| 2474 | 2558 | // Count any sub-folders. |
| 2475 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2476 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2559 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2560 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2477 | 2561 | { |
| 2478 | 2562 | $expected_files[$id]++; |
| 2563 | + } |
|
| 2479 | 2564 | $sub_dirs++; |
| 2480 | 2565 | } |
| 2481 | 2566 | } |
@@ -2493,8 +2578,8 @@ discard block |
||
| 2493 | 2578 | } |
| 2494 | 2579 | |
| 2495 | 2580 | // Just stick a new directory on at the bottom. |
| 2496 | - if (isset($_REQUEST['new_path'])) |
|
| 2497 | - $attachdirs[] = array( |
|
| 2581 | + if (isset($_REQUEST['new_path'])) { |
|
| 2582 | + $attachdirs[] = array( |
|
| 2498 | 2583 | 'id' => max(array_merge(array_keys($expected_files), array_keys($modSettings['attachmentUploadDir']))) + 1, |
| 2499 | 2584 | 'current' => false, |
| 2500 | 2585 | 'path' => '', |
@@ -2502,6 +2587,7 @@ discard block |
||
| 2502 | 2587 | 'num_files' => '', |
| 2503 | 2588 | 'status' => '', |
| 2504 | 2589 | ); |
| 2590 | + } |
|
| 2505 | 2591 | |
| 2506 | 2592 | return $attachdirs; |
| 2507 | 2593 | } |
@@ -2514,8 +2600,9 @@ discard block |
||
| 2514 | 2600 | { |
| 2515 | 2601 | global $modSettings, $txt; |
| 2516 | 2602 | |
| 2517 | - if (empty($modSettings['attachment_basedirectories'])) |
|
| 2518 | - return; |
|
| 2603 | + if (empty($modSettings['attachment_basedirectories'])) { |
|
| 2604 | + return; |
|
| 2605 | + } |
|
| 2519 | 2606 | |
| 2520 | 2607 | $basedirs = array(); |
| 2521 | 2608 | // Get a list of the base directories. |
@@ -2523,16 +2610,18 @@ discard block |
||
| 2523 | 2610 | { |
| 2524 | 2611 | // Loop through the attach directory array to count any sub-directories |
| 2525 | 2612 | $expected_dirs = 0; |
| 2526 | - foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) |
|
| 2527 | - if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2613 | + foreach ($modSettings['attachmentUploadDir'] as $sid => $sub) { |
|
| 2614 | + if (strpos($sub, $dir . DIRECTORY_SEPARATOR) !== false) |
|
| 2528 | 2615 | $expected_dirs++; |
| 2616 | + } |
|
| 2529 | 2617 | |
| 2530 | - if (!is_dir($dir)) |
|
| 2531 | - $status = 'does_not_exist'; |
|
| 2532 | - elseif (!is_writeable($dir)) |
|
| 2533 | - $status = 'not_writable'; |
|
| 2534 | - else |
|
| 2535 | - $status = 'ok'; |
|
| 2618 | + if (!is_dir($dir)) { |
|
| 2619 | + $status = 'does_not_exist'; |
|
| 2620 | + } elseif (!is_writeable($dir)) { |
|
| 2621 | + $status = 'not_writable'; |
|
| 2622 | + } else { |
|
| 2623 | + $status = 'ok'; |
|
| 2624 | + } |
|
| 2536 | 2625 | |
| 2537 | 2626 | $basedirs[] = array( |
| 2538 | 2627 | 'id' => $id, |
@@ -2543,14 +2632,15 @@ discard block |
||
| 2543 | 2632 | ); |
| 2544 | 2633 | } |
| 2545 | 2634 | |
| 2546 | - if (isset($_REQUEST['new_base_path'])) |
|
| 2547 | - $basedirs[] = array( |
|
| 2635 | + if (isset($_REQUEST['new_base_path'])) { |
|
| 2636 | + $basedirs[] = array( |
|
| 2548 | 2637 | 'id' => '', |
| 2549 | 2638 | 'current' => false, |
| 2550 | 2639 | 'path' => '<input type="text" name="new_base_dir" value="" size="40">', |
| 2551 | 2640 | 'num_dirs' => '', |
| 2552 | 2641 | 'status' => '', |
| 2553 | 2642 | ); |
| 2643 | + } |
|
| 2554 | 2644 | |
| 2555 | 2645 | return $basedirs; |
| 2556 | 2646 | } |
@@ -2566,10 +2656,11 @@ discard block |
||
| 2566 | 2656 | */ |
| 2567 | 2657 | function attachDirStatus($dir, $expected_files) |
| 2568 | 2658 | { |
| 2569 | - if (!is_dir($dir)) |
|
| 2570 | - return array('does_not_exist', true, ''); |
|
| 2571 | - elseif (!is_writable($dir)) |
|
| 2572 | - return array('not_writable', true, ''); |
|
| 2659 | + if (!is_dir($dir)) { |
|
| 2660 | + return array('does_not_exist', true, ''); |
|
| 2661 | + } elseif (!is_writable($dir)) { |
|
| 2662 | + return array('not_writable', true, ''); |
|
| 2663 | + } |
|
| 2573 | 2664 | |
| 2574 | 2665 | // Everything is okay so far, start to scan through the directory. |
| 2575 | 2666 | $num_files = 0; |
@@ -2577,22 +2668,26 @@ discard block |
||
| 2577 | 2668 | while ($file = $dir_handle->read()) |
| 2578 | 2669 | { |
| 2579 | 2670 | // Now do we have a real file here? |
| 2580 | - if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) |
|
| 2581 | - continue; |
|
| 2671 | + if (in_array($file, array('.', '..', '.htaccess', 'index.php'))) { |
|
| 2672 | + continue; |
|
| 2673 | + } |
|
| 2582 | 2674 | |
| 2583 | 2675 | $num_files++; |
| 2584 | 2676 | } |
| 2585 | 2677 | $dir_handle->close(); |
| 2586 | 2678 | |
| 2587 | - if ($num_files < $expected_files) |
|
| 2588 | - return array('files_missing', true, $num_files); |
|
| 2679 | + if ($num_files < $expected_files) { |
|
| 2680 | + return array('files_missing', true, $num_files); |
|
| 2681 | + } |
|
| 2589 | 2682 | // Empty? |
| 2590 | - elseif ($expected_files == 0) |
|
| 2591 | - return array('unused', false, $num_files); |
|
| 2683 | + elseif ($expected_files == 0) { |
|
| 2684 | + return array('unused', false, $num_files); |
|
| 2685 | + } |
|
| 2592 | 2686 | // All good! |
| 2593 | - else |
|
| 2594 | - return array('ok', false, $num_files); |
|
| 2595 | -} |
|
| 2687 | + else { |
|
| 2688 | + return array('ok', false, $num_files); |
|
| 2689 | + } |
|
| 2690 | + } |
|
| 2596 | 2691 | |
| 2597 | 2692 | /** |
| 2598 | 2693 | * Maintance function to move attachments from one directory to another |
@@ -2604,10 +2699,11 @@ discard block |
||
| 2604 | 2699 | checkSession(); |
| 2605 | 2700 | |
| 2606 | 2701 | $modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true); |
| 2607 | - if (!empty($modSettings['attachment_basedirectories'])) |
|
| 2608 | - $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 2609 | - else |
|
| 2610 | - $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2702 | + if (!empty($modSettings['attachment_basedirectories'])) { |
|
| 2703 | + $modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true); |
|
| 2704 | + } else { |
|
| 2705 | + $modSettings['basedirectory_for_attachments'] = array(); |
|
| 2706 | + } |
|
| 2611 | 2707 | |
| 2612 | 2708 | $_POST['from'] = (int) $_POST['from']; |
| 2613 | 2709 | $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0; |
@@ -2621,11 +2717,13 @@ discard block |
||
| 2621 | 2717 | $total_moved = 0; |
| 2622 | 2718 | $total_not_moved = 0; |
| 2623 | 2719 | |
| 2624 | - if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) |
|
| 2625 | - $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2720 | + if (empty($_POST['from']) || (empty($_POST['auto']) && empty($_POST['to']))) { |
|
| 2721 | + $results[] = $txt['attachment_transfer_no_dir']; |
|
| 2722 | + } |
|
| 2626 | 2723 | |
| 2627 | - if ($_POST['from'] == $_POST['to']) |
|
| 2628 | - $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2724 | + if ($_POST['from'] == $_POST['to']) { |
|
| 2725 | + $results[] = $txt['attachment_transfer_same_dir']; |
|
| 2726 | + } |
|
| 2629 | 2727 | |
| 2630 | 2728 | if (empty($results)) |
| 2631 | 2729 | { |
@@ -2644,8 +2742,9 @@ discard block |
||
| 2644 | 2742 | $smcFunc['db_free_result']($request); |
| 2645 | 2743 | $total_progress -= $start; |
| 2646 | 2744 | |
| 2647 | - if ($total_progress < 1) |
|
| 2648 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2745 | + if ($total_progress < 1) { |
|
| 2746 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2747 | + } |
|
| 2649 | 2748 | } |
| 2650 | 2749 | |
| 2651 | 2750 | if (empty($results)) |
@@ -2661,9 +2760,9 @@ discard block |
||
| 2661 | 2760 | |
| 2662 | 2761 | automanage_attachments_check_directory(); |
| 2663 | 2762 | $new_dir = $modSettings['currentAttachmentUploadDir']; |
| 2763 | + } else { |
|
| 2764 | + $new_dir = $_POST['to']; |
|
| 2664 | 2765 | } |
| 2665 | - else |
|
| 2666 | - $new_dir = $_POST['to']; |
|
| 2667 | 2766 | |
| 2668 | 2767 | $modSettings['currentAttachmentUploadDir'] = $new_dir; |
| 2669 | 2768 | |
@@ -2671,8 +2770,9 @@ discard block |
||
| 2671 | 2770 | while ($break == false) |
| 2672 | 2771 | { |
| 2673 | 2772 | @set_time_limit(300); |
| 2674 | - if (function_exists('apache_reset_timeout')) |
|
| 2675 | - @apache_reset_timeout(); |
|
| 2773 | + if (function_exists('apache_reset_timeout')) { |
|
| 2774 | + @apache_reset_timeout(); |
|
| 2775 | + } |
|
| 2676 | 2776 | |
| 2677 | 2777 | // If limits are set, get the file count and size for the destination folder |
| 2678 | 2778 | if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) |
@@ -2708,13 +2808,15 @@ discard block |
||
| 2708 | 2808 | |
| 2709 | 2809 | if ($smcFunc['db_num_rows']($request) === 0) |
| 2710 | 2810 | { |
| 2711 | - if (empty($current_progress)) |
|
| 2712 | - $results[] = $txt['attachment_transfer_no_find']; |
|
| 2811 | + if (empty($current_progress)) { |
|
| 2812 | + $results[] = $txt['attachment_transfer_no_find']; |
|
| 2813 | + } |
|
| 2713 | 2814 | break; |
| 2714 | 2815 | } |
| 2715 | 2816 | |
| 2716 | - if ($smcFunc['db_num_rows']($request) < $limit) |
|
| 2717 | - $break = true; |
|
| 2817 | + if ($smcFunc['db_num_rows']($request) < $limit) { |
|
| 2818 | + $break = true; |
|
| 2819 | + } |
|
| 2718 | 2820 | |
| 2719 | 2821 | // Move them |
| 2720 | 2822 | $moved = array(); |
@@ -2738,8 +2840,9 @@ discard block |
||
| 2738 | 2840 | automanage_attachments_by_space(); |
| 2739 | 2841 | |
| 2740 | 2842 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2741 | - if (!empty($total_not_moved)) |
|
| 2742 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2843 | + if (!empty($total_not_moved)) { |
|
| 2844 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2845 | + } |
|
| 2743 | 2846 | |
| 2744 | 2847 | $dir_files = 0; |
| 2745 | 2848 | $total_moved = 0; |
@@ -2747,8 +2850,7 @@ discard block |
||
| 2747 | 2850 | |
| 2748 | 2851 | $break = false; |
| 2749 | 2852 | break; |
| 2750 | - } |
|
| 2751 | - else |
|
| 2853 | + } else |
|
| 2752 | 2854 | { |
| 2753 | 2855 | // Hmm, not in auto. Time to bail out then... |
| 2754 | 2856 | $results[] = $txt['attachment_transfer_no_room']; |
@@ -2763,9 +2865,9 @@ discard block |
||
| 2763 | 2865 | $total_moved++; |
| 2764 | 2866 | $current_progress++; |
| 2765 | 2867 | $moved[] = $row['id_attach']; |
| 2868 | + } else { |
|
| 2869 | + $total_not_moved++; |
|
| 2766 | 2870 | } |
| 2767 | - else |
|
| 2768 | - $total_not_moved++; |
|
| 2769 | 2871 | } |
| 2770 | 2872 | $smcFunc['db_free_result']($request); |
| 2771 | 2873 | |
@@ -2803,13 +2905,15 @@ discard block |
||
| 2803 | 2905 | } |
| 2804 | 2906 | |
| 2805 | 2907 | $results[] = sprintf($txt['attachments_transferred'], $total_moved, $modSettings['attachmentUploadDir'][$new_dir]); |
| 2806 | - if (!empty($total_not_moved)) |
|
| 2807 | - $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2908 | + if (!empty($total_not_moved)) { |
|
| 2909 | + $results[] = sprintf($txt['attachments_not_transferred'], $total_not_moved); |
|
| 2910 | + } |
|
| 2808 | 2911 | } |
| 2809 | 2912 | |
| 2810 | 2913 | $_SESSION['results'] = $results; |
| 2811 | - if (file_exists($boarddir . '/progress.php')) |
|
| 2812 | - unlink($boarddir . '/progress.php'); |
|
| 2914 | + if (file_exists($boarddir . '/progress.php')) { |
|
| 2915 | + unlink($boarddir . '/progress.php'); |
|
| 2916 | + } |
|
| 2813 | 2917 | |
| 2814 | 2918 | redirectexit('action=admin;area=manageattachments;sa=maintenance#transfer'); |
| 2815 | 2919 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
| 106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 107 | 108 | |
| 108 | 109 | // We do not want to output debug information here. |
| 109 | - if ($this->_js) |
|
| 110 | - $db_show_debug = false; |
|
| 110 | + if ($this->_js) { |
|
| 111 | + $db_show_debug = false; |
|
| 112 | + } |
|
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
| 141 | 143 | $call = $this->_sa; |
| 142 | 144 | |
| 143 | 145 | // Guest can only view likes. |
| 144 | - if ($call != 'view') |
|
| 145 | - is_not_guest(); |
|
| 146 | + if ($call != 'view') { |
|
| 147 | + is_not_guest(); |
|
| 148 | + } |
|
| 146 | 149 | |
| 147 | 150 | checkSession('get'); |
| 148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
| 180 | 183 | global $smcFunc, $modSettings; |
| 181 | 184 | |
| 182 | 185 | // This feature is currently disable. |
| 183 | - if (empty($modSettings['enable_likes'])) |
|
| 184 | - return $this->_error = 'like_disable'; |
|
| 186 | + if (empty($modSettings['enable_likes'])) { |
|
| 187 | + return $this->_error = 'like_disable'; |
|
| 188 | + } |
|
| 185 | 189 | |
| 186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
| 187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 189 | 193 | |
| 190 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 191 | - return $this->_error = 'cannot_'; |
|
| 194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 195 | + return $this->_error = 'cannot_'; |
|
| 196 | + } |
|
| 192 | 197 | |
| 193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
| 207 | 212 | 'msg' => $this->_content, |
| 208 | 213 | ) |
| 209 | 214 | ); |
| 210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + } |
|
| 212 | 218 | |
| 213 | 219 | $smcFunc['db_free_result']($request); |
| 214 | - if (empty($this->_idTopic)) |
|
| 215 | - return $this->_error = 'cannot_'; |
|
| 220 | + if (empty($this->_idTopic)) { |
|
| 221 | + return $this->_error = 'cannot_'; |
|
| 222 | + } |
|
| 216 | 223 | |
| 217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
| 218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
| 221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
| 222 | 229 | |
| 223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 224 | - } |
|
| 225 | - |
|
| 226 | - else |
|
| 231 | + } else |
|
| 227 | 232 | { |
| 228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | if ($result !== false) |
| 242 | 247 | { |
| 243 | 248 | // Match the type with what we already have. |
| 244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 245 | - return $this->_error = 'not_valid_like_type'; |
|
| 249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 250 | + return $this->_error = 'not_valid_like_type'; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | 253 | // Fill out the rest. |
| 248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
| 253 | 259 | } |
| 254 | 260 | } |
| 255 | 261 | |
| 256 | - if (!$found) |
|
| 257 | - return $this->_error = 'cannot_'; |
|
| 262 | + if (!$found) { |
|
| 263 | + return $this->_error = 'cannot_'; |
|
| 264 | + } |
|
| 258 | 265 | } |
| 259 | 266 | |
| 260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 262 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 269 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 270 | + } |
|
| 263 | 271 | } |
| 264 | 272 | |
| 265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
| 284 | 292 | ); |
| 285 | 293 | |
| 286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 287 | - if ($this->_sa == __FUNCTION__) |
|
| 288 | - $this->_data = __FUNCTION__; |
|
| 295 | + if ($this->_sa == __FUNCTION__) { |
|
| 296 | + $this->_data = __FUNCTION__; |
|
| 297 | + } |
|
| 289 | 298 | } |
| 290 | 299 | |
| 291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
| 315 | 324 | |
| 316 | 325 | // Add a background task to process sending alerts. |
| 317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 318 | - if ($this->_type == 'msg') |
|
| 319 | - $smcFunc['db_insert']('insert', |
|
| 327 | + if ($this->_type == 'msg') { |
|
| 328 | + $smcFunc['db_insert']('insert', |
|
| 320 | 329 | '{db_prefix}background_tasks', |
| 321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
| 328 | 337 | )), 0), |
| 329 | 338 | array('id_task') |
| 330 | 339 | ); |
| 340 | + } |
|
| 331 | 341 | |
| 332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 333 | - if ($this->_sa == __FUNCTION__) |
|
| 334 | - $this->_data = __FUNCTION__; |
|
| 343 | + if ($this->_sa == __FUNCTION__) { |
|
| 344 | + $this->_data = __FUNCTION__; |
|
| 345 | + } |
|
| 335 | 346 | } |
| 336 | 347 | |
| 337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
| 357 | 368 | $smcFunc['db_free_result']($request); |
| 358 | 369 | |
| 359 | 370 | // If you want to call this directly, fill out _data property too. |
| 360 | - if ($this->_sa == __FUNCTION__) |
|
| 361 | - $this->_data = $this->_numLikes; |
|
| 371 | + if ($this->_sa == __FUNCTION__) { |
|
| 372 | + $this->_data = $this->_numLikes; |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | |
| 364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
| 371 | 383 | global $smcFunc; |
| 372 | 384 | |
| 373 | 385 | // Safety first! |
| 374 | - if (empty($this->_type) || empty($this->_content)) |
|
| 375 | - return $this->_error = 'cannot_'; |
|
| 386 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 387 | + return $this->_error = 'cannot_'; |
|
| 388 | + } |
|
| 376 | 389 | |
| 377 | 390 | // Do we already like this? |
| 378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
| 390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 391 | 404 | $smcFunc['db_free_result']($request); |
| 392 | 405 | |
| 393 | - if ($this->_alreadyLiked) |
|
| 394 | - $this->delete(); |
|
| 395 | - |
|
| 396 | - else |
|
| 397 | - $this->insert(); |
|
| 406 | + if ($this->_alreadyLiked) { |
|
| 407 | + $this->delete(); |
|
| 408 | + } else { |
|
| 409 | + $this->insert(); |
|
| 410 | + } |
|
| 398 | 411 | |
| 399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 400 | 413 | $this->_count(); |
| 401 | 414 | |
| 402 | 415 | // Update the likes count for messages. |
| 403 | - if ($this->_type == 'msg') |
|
| 404 | - $this->msgIssueLike(); |
|
| 416 | + if ($this->_type == 'msg') { |
|
| 417 | + $this->msgIssueLike(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Any callbacks? |
| 407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
| 408 | 422 | { |
| 409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
| 410 | 424 | |
| 411 | - if (!empty($call)) |
|
| 412 | - call_user_func_array($call, array($this)); |
|
| 425 | + if (!empty($call)) { |
|
| 426 | + call_user_func_array($call, array($this)); |
|
| 427 | + } |
|
| 413 | 428 | } |
| 414 | 429 | |
| 415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
| 418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
| 421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 438 | + } |
|
| 423 | 439 | |
| 424 | 440 | // All done, start building the data to pass as response. |
| 425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
| 442 | 458 | { |
| 443 | 459 | global $smcFunc; |
| 444 | 460 | |
| 445 | - if ($this->_type !== 'msg') |
|
| 446 | - return; |
|
| 461 | + if ($this->_type !== 'msg') { |
|
| 462 | + return; |
|
| 463 | + } |
|
| 447 | 464 | |
| 448 | 465 | $smcFunc['db_query']('', ' |
| 449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
| 484 | 501 | 'like_type' => $this->_type, |
| 485 | 502 | ) |
| 486 | 503 | ); |
| 487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 506 | + } |
|
| 489 | 507 | |
| 490 | 508 | // Now to get member data, including avatars and so on. |
| 491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
| 493 | 511 | if (count($loaded) != count($members)) |
| 494 | 512 | { |
| 495 | 513 | $members = array_diff($members, $loaded); |
| 496 | - foreach ($members as $not_loaded) |
|
| 497 | - unset ($context['likers'][$not_loaded]); |
|
| 514 | + foreach ($members as $not_loaded) { |
|
| 515 | + unset ($context['likers'][$not_loaded]); |
|
| 516 | + } |
|
| 498 | 517 | } |
| 499 | 518 | |
| 500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
| 536 | 555 | global $context, $txt; |
| 537 | 556 | |
| 538 | 557 | // Don't do anything if someone else has already take care of the response. |
| 539 | - if (!$this->_setResponse) |
|
| 540 | - return; |
|
| 558 | + if (!$this->_setResponse) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 541 | 561 | |
| 542 | 562 | // Want a json response huh? |
| 543 | - if ($this->_validLikes['json']) |
|
| 544 | - return $this->jsonResponse(); |
|
| 563 | + if ($this->_validLikes['json']) { |
|
| 564 | + return $this->jsonResponse(); |
|
| 565 | + } |
|
| 545 | 566 | |
| 546 | 567 | // Set everything up for display. |
| 547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
| 551 | 572 | if ($this->_error) |
| 552 | 573 | { |
| 553 | 574 | // If this is a generic error, set it up good. |
| 554 | - if ($this->_error == 'cannot_') |
|
| 555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 575 | + if ($this->_error == 'cannot_') { |
|
| 576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 577 | + } |
|
| 556 | 578 | |
| 557 | 579 | // Is this request coming from an ajax call? |
| 558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
| 562 | 584 | } |
| 563 | 585 | |
| 564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
| 565 | - else |
|
| 566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 587 | + else { |
|
| 588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 589 | + } |
|
| 567 | 590 | |
| 568 | 591 | return; |
| 569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
| 572 | 595 | else |
| 573 | 596 | { |
| 574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
| 575 | - if (!$this->_js) |
|
| 576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 598 | + if (!$this->_js) { |
|
| 599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 600 | + } |
|
| 577 | 601 | |
| 578 | 602 | // These fine gentlemen all share the same template. |
| 579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
| 606 | 630 | // If there is an error, send it. |
| 607 | 631 | if ($this->_error) |
| 608 | 632 | { |
| 609 | - if ($this->_error == 'cannot_') |
|
| 610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 633 | + if ($this->_error == 'cannot_') { |
|
| 634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 635 | + } |
|
| 611 | 636 | |
| 612 | 637 | $print['error'] = $this->_error; |
| 613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
| 643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 645 | 670 | |
| 646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 647 | - $_GET['verse'] = '4:16'; |
|
| 671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 672 | + $_GET['verse'] = '4:16'; |
|
| 673 | + } |
|
| 648 | 674 | |
| 649 | - if ($_GET['verse'] == '2:18') |
|
| 650 | - echo ' |
|
| 675 | + if ($_GET['verse'] == '2:18') { |
|
| 676 | + echo ' |
|
| 651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 652 | - elseif ($_GET['verse'] == '4:16') |
|
| 653 | - echo ' |
|
| 678 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 679 | + echo ' |
|
| 654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 655 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 656 | - echo ' |
|
| 681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 682 | + echo ' |
|
| 657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 685 | + } |
|
| 659 | 686 | |
| 660 | 687 | echo ' |
| 661 | 688 | </div> |
| 662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 663 | 690 | |
| 664 | - if ($_GET['verse'] == '2:18') |
|
| 665 | - echo ' |
|
| 691 | + if ($_GET['verse'] == '2:18') { |
|
| 692 | + echo ' |
|
| 666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 667 | - elseif ($_GET['verse'] == '4:16') |
|
| 668 | - echo ' |
|
| 694 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 695 | + echo ' |
|
| 669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 670 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 671 | - echo ' |
|
| 697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 698 | + echo ' |
|
| 672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 700 | + } |
|
| 673 | 701 | |
| 674 | 702 | echo ' |
| 675 | 703 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Main dispatcher, the maintenance access point. |
@@ -96,14 +97,16 @@ discard block |
||
| 96 | 97 | call_integration_hook('integrate_manage_maintenance', array(&$subActions)); |
| 97 | 98 | |
| 98 | 99 | // Yep, sub-action time! |
| 99 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 100 | - $subAction = $_REQUEST['sa']; |
|
| 101 | - else |
|
| 102 | - $subAction = 'routine'; |
|
| 100 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 101 | + $subAction = $_REQUEST['sa']; |
|
| 102 | + } else { |
|
| 103 | + $subAction = 'routine'; |
|
| 104 | + } |
|
| 103 | 105 | |
| 104 | 106 | // Doing something special? |
| 105 | - if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) |
|
| 106 | - $activity = $_REQUEST['activity']; |
|
| 107 | + if (isset($_REQUEST['activity']) && isset($subActions[$subAction]['activities'][$_REQUEST['activity']])) { |
|
| 108 | + $activity = $_REQUEST['activity']; |
|
| 109 | + } |
|
| 107 | 110 | |
| 108 | 111 | // Set a few things. |
| 109 | 112 | $context['page_title'] = $txt['maintain_title']; |
@@ -114,12 +117,14 @@ discard block |
||
| 114 | 117 | call_helper($subActions[$subAction]['function']); |
| 115 | 118 | |
| 116 | 119 | // Any special activity? |
| 117 | - if (isset($activity)) |
|
| 118 | - call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 120 | + if (isset($activity)) { |
|
| 121 | + call_helper($subActions[$subAction]['activities'][$activity]); |
|
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | //converted to UTF-8? show a small maintenance info |
| 121 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 122 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 125 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 126 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 127 | + } |
|
| 123 | 128 | |
| 124 | 129 | // Create a maintenance token. Kinda hard to do it any other way. |
| 125 | 130 | createToken('admin-maint'); |
@@ -141,19 +146,22 @@ discard block |
||
| 141 | 146 | db_extend('packages'); |
| 142 | 147 | |
| 143 | 148 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 144 | - foreach ($colData as $column) |
|
| 145 | - if ($column['name'] == 'body') |
|
| 149 | + foreach ($colData as $column) { |
|
| 150 | + if ($column['name'] == 'body') |
|
| 146 | 151 | $body_type = $column['type']; |
| 152 | + } |
|
| 147 | 153 | |
| 148 | 154 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 149 | 155 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 150 | 156 | } |
| 151 | 157 | |
| 152 | - if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') |
|
| 153 | - $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 154 | - if (isset($_GET['done']) && $_GET['done'] == 'convertentities') |
|
| 155 | - $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 156 | -} |
|
| 158 | + if (isset($_GET['done']) && $_GET['done'] == 'convertutf8') { |
|
| 159 | + $context['maintenance_finished'] = $txt['utf8_title']; |
|
| 160 | + } |
|
| 161 | + if (isset($_GET['done']) && $_GET['done'] == 'convertentities') { |
|
| 162 | + $context['maintenance_finished'] = $txt['entity_convert_title']; |
|
| 163 | + } |
|
| 164 | + } |
|
| 157 | 165 | |
| 158 | 166 | /** |
| 159 | 167 | * Supporting function for the routine maintenance area. |
@@ -162,9 +170,10 @@ discard block |
||
| 162 | 170 | { |
| 163 | 171 | global $context, $txt; |
| 164 | 172 | |
| 165 | - if (isset($_GET['done']) && $_GET['done'] == 'recount') |
|
| 166 | - $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 167 | -} |
|
| 173 | + if (isset($_GET['done']) && $_GET['done'] == 'recount') { |
|
| 174 | + $context['maintenance_finished'] = $txt['maintain_recount']; |
|
| 175 | + } |
|
| 176 | + } |
|
| 168 | 177 | |
| 169 | 178 | /** |
| 170 | 179 | * Supporting function for the members maintenance area. |
@@ -195,8 +204,9 @@ discard block |
||
| 195 | 204 | } |
| 196 | 205 | $smcFunc['db_free_result']($result); |
| 197 | 206 | |
| 198 | - if (isset($_GET['done']) && $_GET['done'] == 'recountposts') |
|
| 199 | - $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 207 | + if (isset($_GET['done']) && $_GET['done'] == 'recountposts') { |
|
| 208 | + $context['maintenance_finished'] = $txt['maintain_recountposts']; |
|
| 209 | + } |
|
| 200 | 210 | |
| 201 | 211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 202 | 212 | } |
@@ -222,11 +232,12 @@ discard block |
||
| 222 | 232 | $context['categories'] = array(); |
| 223 | 233 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 224 | 234 | { |
| 225 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 226 | - $context['categories'][$row['id_cat']] = array( |
|
| 235 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 236 | + $context['categories'][$row['id_cat']] = array( |
|
| 227 | 237 | 'name' => $row['cat_name'], |
| 228 | 238 | 'boards' => array() |
| 229 | 239 | ); |
| 240 | + } |
|
| 230 | 241 | |
| 231 | 242 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
| 232 | 243 | 'id' => $row['id_board'], |
@@ -239,11 +250,12 @@ discard block |
||
| 239 | 250 | require_once($sourcedir . '/Subs-Boards.php'); |
| 240 | 251 | sortCategories($context['categories']); |
| 241 | 252 | |
| 242 | - if (isset($_GET['done']) && $_GET['done'] == 'purgeold') |
|
| 243 | - $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 244 | - elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') |
|
| 245 | - $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 246 | -} |
|
| 253 | + if (isset($_GET['done']) && $_GET['done'] == 'purgeold') { |
|
| 254 | + $context['maintenance_finished'] = $txt['maintain_old']; |
|
| 255 | + } elseif (isset($_GET['done']) && $_GET['done'] == 'massmove') { |
|
| 256 | + $context['maintenance_finished'] = $txt['move_topics_maintenance']; |
|
| 257 | + } |
|
| 258 | + } |
|
| 247 | 259 | |
| 248 | 260 | /** |
| 249 | 261 | * Find and fix all errors on the forum. |
@@ -351,15 +363,17 @@ discard block |
||
| 351 | 363 | // Show me your badge! |
| 352 | 364 | isAllowedTo('admin_forum'); |
| 353 | 365 | |
| 354 | - if ($db_type != 'mysql') |
|
| 355 | - return; |
|
| 366 | + if ($db_type != 'mysql') { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 356 | 369 | |
| 357 | 370 | db_extend('packages'); |
| 358 | 371 | |
| 359 | 372 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 360 | - foreach ($colData as $column) |
|
| 361 | - if ($column['name'] == 'body') |
|
| 373 | + foreach ($colData as $column) { |
|
| 374 | + if ($column['name'] == 'body') |
|
| 362 | 375 | $body_type = $column['type']; |
| 376 | + } |
|
| 363 | 377 | |
| 364 | 378 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 365 | 379 | |
@@ -369,33 +383,36 @@ discard block |
||
| 369 | 383 | validateToken('admin-maint'); |
| 370 | 384 | |
| 371 | 385 | // Make it longer so we can do their limit. |
| 372 | - if ($body_type == 'text') |
|
| 373 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 386 | + if ($body_type == 'text') { |
|
| 387 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'mediumtext')); |
|
| 388 | + } |
|
| 374 | 389 | // Shorten the column so we can have a bit (literally per record) less space occupied |
| 375 | - else |
|
| 376 | - $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 390 | + else { |
|
| 391 | + $smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text')); |
|
| 392 | + } |
|
| 377 | 393 | |
| 378 | 394 | // 3rd party integrations may be interested in knowning about this. |
| 379 | 395 | call_integration_hook('integrate_convert_msgbody', array($body_type)); |
| 380 | 396 | |
| 381 | 397 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
| 382 | - foreach ($colData as $column) |
|
| 383 | - if ($column['name'] == 'body') |
|
| 398 | + foreach ($colData as $column) { |
|
| 399 | + if ($column['name'] == 'body') |
|
| 384 | 400 | $body_type = $column['type']; |
| 401 | + } |
|
| 385 | 402 | |
| 386 | 403 | $context['maintenance_finished'] = $txt[$context['convert_to'] . '_title']; |
| 387 | 404 | $context['convert_to'] = $body_type == 'text' ? 'mediumtext' : 'text'; |
| 388 | 405 | $context['convert_to_suggest'] = ($body_type != 'text' && !empty($modSettings['max_messageLength']) && $modSettings['max_messageLength'] < 65536); |
| 389 | 406 | |
| 390 | 407 | return; |
| 391 | - } |
|
| 392 | - elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 408 | + } elseif ($body_type != 'text' && (!isset($_POST['do_conversion']) || isset($_POST['cont']))) |
|
| 393 | 409 | { |
| 394 | 410 | checkSession(); |
| 395 | - if (empty($_REQUEST['start'])) |
|
| 396 | - validateToken('admin-maint'); |
|
| 397 | - else |
|
| 398 | - validateToken('admin-convertMsg'); |
|
| 411 | + if (empty($_REQUEST['start'])) { |
|
| 412 | + validateToken('admin-maint'); |
|
| 413 | + } else { |
|
| 414 | + validateToken('admin-convertMsg'); |
|
| 415 | + } |
|
| 399 | 416 | |
| 400 | 417 | $context['page_title'] = $txt['not_done_title']; |
| 401 | 418 | $context['continue_post_data'] = ''; |
@@ -427,8 +444,9 @@ discard block |
||
| 427 | 444 | 'increment' => $increment - 1, |
| 428 | 445 | ) |
| 429 | 446 | ); |
| 430 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 431 | - $id_msg_exceeding[] = $row['id_msg']; |
|
| 447 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 448 | + $id_msg_exceeding[] = $row['id_msg']; |
|
| 449 | + } |
|
| 432 | 450 | $smcFunc['db_free_result']($request); |
| 433 | 451 | |
| 434 | 452 | $_REQUEST['start'] += $increment; |
@@ -457,9 +475,9 @@ discard block |
||
| 457 | 475 | { |
| 458 | 476 | $query_msg = array_slice($id_msg_exceeding, 0, 100); |
| 459 | 477 | $context['exceeding_messages_morethan'] = sprintf($txt['exceeding_messages_morethan'], count($id_msg_exceeding)); |
| 478 | + } else { |
|
| 479 | + $query_msg = $id_msg_exceeding; |
|
| 460 | 480 | } |
| 461 | - else |
|
| 462 | - $query_msg = $id_msg_exceeding; |
|
| 463 | 481 | |
| 464 | 482 | $context['exceeding_messages'] = array(); |
| 465 | 483 | $request = $smcFunc['db_query']('', ' |
@@ -470,8 +488,9 @@ discard block |
||
| 470 | 488 | 'messages' => $query_msg, |
| 471 | 489 | ) |
| 472 | 490 | ); |
| 473 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 474 | - $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 491 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 492 | + $context['exceeding_messages'][] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 493 | + } |
|
| 475 | 494 | $smcFunc['db_free_result']($request); |
| 476 | 495 | } |
| 477 | 496 | } |
@@ -495,8 +514,9 @@ discard block |
||
| 495 | 514 | isAllowedTo('admin_forum'); |
| 496 | 515 | |
| 497 | 516 | // Check to see if UTF-8 is currently the default character set. |
| 498 | - if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') |
|
| 499 | - fatal_lang_error('entity_convert_only_utf8'); |
|
| 517 | + if ($modSettings['global_character_set'] !== 'UTF-8' || !isset($db_character_set) || $db_character_set !== 'utf8') { |
|
| 518 | + fatal_lang_error('entity_convert_only_utf8'); |
|
| 519 | + } |
|
| 500 | 520 | |
| 501 | 521 | // Some starting values. |
| 502 | 522 | $context['table'] = empty($_REQUEST['table']) ? 0 : (int) $_REQUEST['table']; |
@@ -558,8 +578,9 @@ discard block |
||
| 558 | 578 | // Make sure we keep stuff unique! |
| 559 | 579 | $primary_keys = array(); |
| 560 | 580 | |
| 561 | - if (function_exists('apache_reset_timeout')) |
|
| 562 | - @apache_reset_timeout(); |
|
| 581 | + if (function_exists('apache_reset_timeout')) { |
|
| 582 | + @apache_reset_timeout(); |
|
| 583 | + } |
|
| 563 | 584 | |
| 564 | 585 | // Get a list of text columns. |
| 565 | 586 | $columns = array(); |
@@ -570,9 +591,10 @@ discard block |
||
| 570 | 591 | 'cur_table' => $cur_table, |
| 571 | 592 | ) |
| 572 | 593 | ); |
| 573 | - while ($column_info = $smcFunc['db_fetch_assoc']($request)) |
|
| 574 | - if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 594 | + while ($column_info = $smcFunc['db_fetch_assoc']($request)) { |
|
| 595 | + if (strpos($column_info['Type'], 'text') !== false || strpos($column_info['Type'], 'char') !== false) |
|
| 575 | 596 | $columns[] = strtolower($column_info['Field']); |
| 597 | + } |
|
| 576 | 598 | |
| 577 | 599 | // Get the column with the (first) primary key. |
| 578 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -586,8 +608,9 @@ discard block |
||
| 586 | 608 | { |
| 587 | 609 | if ($row['Key_name'] === 'PRIMARY') |
| 588 | 610 | { |
| 589 | - if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) |
|
| 590 | - $primary_key = $row['Column_name']; |
|
| 611 | + if (empty($primary_key) || ($row['Seq_in_index'] == 1 && !in_array(strtolower($row['Column_name']), $columns))) { |
|
| 612 | + $primary_key = $row['Column_name']; |
|
| 613 | + } |
|
| 591 | 614 | |
| 592 | 615 | $primary_keys[] = $row['Column_name']; |
| 593 | 616 | } |
@@ -596,8 +619,9 @@ discard block |
||
| 596 | 619 | |
| 597 | 620 | // No primary key, no glory. |
| 598 | 621 | // Same for columns. Just to be sure we've work to do! |
| 599 | - if (empty($primary_key) || empty($columns)) |
|
| 600 | - continue; |
|
| 622 | + if (empty($primary_key) || empty($columns)) { |
|
| 623 | + continue; |
|
| 624 | + } |
|
| 601 | 625 | |
| 602 | 626 | // Get the maximum value for the primary key. |
| 603 | 627 | $request = $smcFunc['db_query']('', ' |
@@ -611,8 +635,9 @@ discard block |
||
| 611 | 635 | list($max_value) = $smcFunc['db_fetch_row']($request); |
| 612 | 636 | $smcFunc['db_free_result']($request); |
| 613 | 637 | |
| 614 | - if (empty($max_value)) |
|
| 615 | - continue; |
|
| 638 | + if (empty($max_value)) { |
|
| 639 | + continue; |
|
| 640 | + } |
|
| 616 | 641 | |
| 617 | 642 | while ($context['start'] <= $max_value) |
| 618 | 643 | { |
@@ -636,10 +661,11 @@ discard block |
||
| 636 | 661 | { |
| 637 | 662 | $insertion_variables = array(); |
| 638 | 663 | $changes = array(); |
| 639 | - foreach ($row as $column_name => $column_value) |
|
| 640 | - if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 664 | + foreach ($row as $column_name => $column_value) { |
|
| 665 | + if ($column_name !== $primary_key && strpos($column_value, '&#') !== false) |
|
| 641 | 666 | { |
| 642 | 667 | $changes[] = $column_name . ' = {string:changes_' . $column_name . '}'; |
| 668 | + } |
|
| 643 | 669 | $insertion_variables['changes_' . $column_name] = preg_replace_callback('~&#(\d{1,7}|x[0-9a-fA-F]{1,6});~', 'fixchar__callback', $column_value); |
| 644 | 670 | } |
| 645 | 671 | |
@@ -651,8 +677,8 @@ discard block |
||
| 651 | 677 | } |
| 652 | 678 | |
| 653 | 679 | // Update the row. |
| 654 | - if (!empty($changes)) |
|
| 655 | - $smcFunc['db_query']('', ' |
|
| 680 | + if (!empty($changes)) { |
|
| 681 | + $smcFunc['db_query']('', ' |
|
| 656 | 682 | UPDATE {db_prefix}' . $cur_table . ' |
| 657 | 683 | SET |
| 658 | 684 | ' . implode(', |
@@ -660,6 +686,7 @@ discard block |
||
| 660 | 686 | WHERE ' . implode(' AND ', $where), |
| 661 | 687 | $insertion_variables |
| 662 | 688 | ); |
| 689 | + } |
|
| 663 | 690 | } |
| 664 | 691 | $smcFunc['db_free_result']($request); |
| 665 | 692 | $context['start'] += 500; |
@@ -700,10 +727,11 @@ discard block |
||
| 700 | 727 | |
| 701 | 728 | checkSession('request'); |
| 702 | 729 | |
| 703 | - if (!isset($_SESSION['optimized_tables'])) |
|
| 704 | - validateToken('admin-maint'); |
|
| 705 | - else |
|
| 706 | - validateToken('admin-optimize', 'post', false); |
|
| 730 | + if (!isset($_SESSION['optimized_tables'])) { |
|
| 731 | + validateToken('admin-maint'); |
|
| 732 | + } else { |
|
| 733 | + validateToken('admin-optimize', 'post', false); |
|
| 734 | + } |
|
| 707 | 735 | |
| 708 | 736 | ignore_user_abort(true); |
| 709 | 737 | db_extend(); |
@@ -719,13 +747,15 @@ discard block |
||
| 719 | 747 | // Get a list of tables, as well as how many there are. |
| 720 | 748 | $temp_tables = $smcFunc['db_list_tables'](false, $real_prefix . '%'); |
| 721 | 749 | $tables = array(); |
| 722 | - foreach ($temp_tables as $table) |
|
| 723 | - $tables[] = array('table_name' => $table); |
|
| 750 | + foreach ($temp_tables as $table) { |
|
| 751 | + $tables[] = array('table_name' => $table); |
|
| 752 | + } |
|
| 724 | 753 | |
| 725 | 754 | // If there aren't any tables then I believe that would mean the world has exploded... |
| 726 | 755 | $context['num_tables'] = count($tables); |
| 727 | - if ($context['num_tables'] == 0) |
|
| 728 | - fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 756 | + if ($context['num_tables'] == 0) { |
|
| 757 | + fatal_error('You appear to be running SMF in a flat file mode... fantastic!', false); |
|
| 758 | + } |
|
| 729 | 759 | |
| 730 | 760 | $_REQUEST['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 731 | 761 | |
@@ -736,8 +766,9 @@ discard block |
||
| 736 | 766 | $_SESSION['optimized_tables'] = !empty($_SESSION['optimized_tables']) ? $_SESSION['optimized_tables'] : array(); |
| 737 | 767 | for ($key = $_REQUEST['start']; $context['num_tables'] - 1; $key++) |
| 738 | 768 | { |
| 739 | - if (empty($tables[$key])) |
|
| 740 | - break; |
|
| 769 | + if (empty($tables[$key])) { |
|
| 770 | + break; |
|
| 771 | + } |
|
| 741 | 772 | |
| 742 | 773 | // Continue? |
| 743 | 774 | if (microtime(true) - $time_start > 10) |
@@ -751,8 +782,9 @@ discard block |
||
| 751 | 782 | createToken('admin-optimize'); |
| 752 | 783 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-optimize_token_var'] . '" value="' . $context['admin-optimize_token'] . '">'; |
| 753 | 784 | |
| 754 | - if (function_exists('apache_reset_timeout')) |
|
| 755 | - apache_reset_timeout(); |
|
| 785 | + if (function_exists('apache_reset_timeout')) { |
|
| 786 | + apache_reset_timeout(); |
|
| 787 | + } |
|
| 756 | 788 | |
| 757 | 789 | return; |
| 758 | 790 | } |
@@ -760,11 +792,12 @@ discard block |
||
| 760 | 792 | // Optimize the table! We use backticks here because it might be a custom table. |
| 761 | 793 | $data_freed = $smcFunc['db_optimize_table']($tables[$key]['table_name']); |
| 762 | 794 | |
| 763 | - if ($data_freed > 0) |
|
| 764 | - $_SESSION['optimized_tables'][] = array( |
|
| 795 | + if ($data_freed > 0) { |
|
| 796 | + $_SESSION['optimized_tables'][] = array( |
|
| 765 | 797 | 'name' => $tables[$key]['table_name'], |
| 766 | 798 | 'data_freed' => $data_freed, |
| 767 | 799 | ); |
| 800 | + } |
|
| 768 | 801 | } |
| 769 | 802 | |
| 770 | 803 | // Number of tables, etc... |
@@ -799,10 +832,11 @@ discard block |
||
| 799 | 832 | checkSession('request'); |
| 800 | 833 | |
| 801 | 834 | // validate the request or the loop |
| 802 | - if (!isset($_REQUEST['step'])) |
|
| 803 | - validateToken('admin-maint'); |
|
| 804 | - else |
|
| 805 | - validateToken('admin-boardrecount'); |
|
| 835 | + if (!isset($_REQUEST['step'])) { |
|
| 836 | + validateToken('admin-maint'); |
|
| 837 | + } else { |
|
| 838 | + validateToken('admin-boardrecount'); |
|
| 839 | + } |
|
| 806 | 840 | |
| 807 | 841 | $context['page_title'] = $txt['not_done_title']; |
| 808 | 842 | $context['continue_post_data'] = ''; |
@@ -823,8 +857,9 @@ discard block |
||
| 823 | 857 | $smcFunc['db_free_result']($request); |
| 824 | 858 | |
| 825 | 859 | $increment = min(max(50, ceil($max_topics / 4)), 2000); |
| 826 | - if (empty($_REQUEST['start'])) |
|
| 827 | - $_REQUEST['start'] = 0; |
|
| 860 | + if (empty($_REQUEST['start'])) { |
|
| 861 | + $_REQUEST['start'] = 0; |
|
| 862 | + } |
|
| 828 | 863 | |
| 829 | 864 | $total_steps = 8; |
| 830 | 865 | |
@@ -851,8 +886,8 @@ discard block |
||
| 851 | 886 | 'max_id' => $_REQUEST['start'] + $increment, |
| 852 | 887 | ) |
| 853 | 888 | ); |
| 854 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 855 | - $smcFunc['db_query']('', ' |
|
| 889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 890 | + $smcFunc['db_query']('', ' |
|
| 856 | 891 | UPDATE {db_prefix}topics |
| 857 | 892 | SET num_replies = {int:num_replies} |
| 858 | 893 | WHERE id_topic = {int:id_topic}', |
@@ -861,6 +896,7 @@ discard block |
||
| 861 | 896 | 'id_topic' => $row['id_topic'], |
| 862 | 897 | ) |
| 863 | 898 | ); |
| 899 | + } |
|
| 864 | 900 | $smcFunc['db_free_result']($request); |
| 865 | 901 | |
| 866 | 902 | // Recount unapproved messages |
@@ -879,8 +915,8 @@ discard block |
||
| 879 | 915 | 'max_id' => $_REQUEST['start'] + $increment, |
| 880 | 916 | ) |
| 881 | 917 | ); |
| 882 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 883 | - $smcFunc['db_query']('', ' |
|
| 918 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 919 | + $smcFunc['db_query']('', ' |
|
| 884 | 920 | UPDATE {db_prefix}topics |
| 885 | 921 | SET unapproved_posts = {int:unapproved_posts} |
| 886 | 922 | WHERE id_topic = {int:id_topic}', |
@@ -889,6 +925,7 @@ discard block |
||
| 889 | 925 | 'id_topic' => $row['id_topic'], |
| 890 | 926 | ) |
| 891 | 927 | ); |
| 928 | + } |
|
| 892 | 929 | $smcFunc['db_free_result']($request); |
| 893 | 930 | |
| 894 | 931 | $_REQUEST['start'] += $increment; |
@@ -911,8 +948,8 @@ discard block |
||
| 911 | 948 | // Update the post count of each board. |
| 912 | 949 | if ($_REQUEST['step'] <= 1) |
| 913 | 950 | { |
| 914 | - if (empty($_REQUEST['start'])) |
|
| 915 | - $smcFunc['db_query']('', ' |
|
| 951 | + if (empty($_REQUEST['start'])) { |
|
| 952 | + $smcFunc['db_query']('', ' |
|
| 916 | 953 | UPDATE {db_prefix}boards |
| 917 | 954 | SET num_posts = {int:num_posts} |
| 918 | 955 | WHERE redirect = {string:redirect}', |
@@ -921,6 +958,7 @@ discard block |
||
| 921 | 958 | 'redirect' => '', |
| 922 | 959 | ) |
| 923 | 960 | ); |
| 961 | + } |
|
| 924 | 962 | |
| 925 | 963 | while ($_REQUEST['start'] < $max_topics) |
| 926 | 964 | { |
@@ -937,8 +975,8 @@ discard block |
||
| 937 | 975 | 'is_approved' => 1, |
| 938 | 976 | ) |
| 939 | 977 | ); |
| 940 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 941 | - $smcFunc['db_query']('', ' |
|
| 978 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 979 | + $smcFunc['db_query']('', ' |
|
| 942 | 980 | UPDATE {db_prefix}boards |
| 943 | 981 | SET num_posts = num_posts + {int:real_num_posts} |
| 944 | 982 | WHERE id_board = {int:id_board}', |
@@ -947,6 +985,7 @@ discard block |
||
| 947 | 985 | 'real_num_posts' => $row['real_num_posts'], |
| 948 | 986 | ) |
| 949 | 987 | ); |
| 988 | + } |
|
| 950 | 989 | $smcFunc['db_free_result']($request); |
| 951 | 990 | |
| 952 | 991 | $_REQUEST['start'] += $increment; |
@@ -969,14 +1008,15 @@ discard block |
||
| 969 | 1008 | // Update the topic count of each board. |
| 970 | 1009 | if ($_REQUEST['step'] <= 2) |
| 971 | 1010 | { |
| 972 | - if (empty($_REQUEST['start'])) |
|
| 973 | - $smcFunc['db_query']('', ' |
|
| 1011 | + if (empty($_REQUEST['start'])) { |
|
| 1012 | + $smcFunc['db_query']('', ' |
|
| 974 | 1013 | UPDATE {db_prefix}boards |
| 975 | 1014 | SET num_topics = {int:num_topics}', |
| 976 | 1015 | array( |
| 977 | 1016 | 'num_topics' => 0, |
| 978 | 1017 | ) |
| 979 | 1018 | ); |
| 1019 | + } |
|
| 980 | 1020 | |
| 981 | 1021 | while ($_REQUEST['start'] < $max_topics) |
| 982 | 1022 | { |
@@ -993,8 +1033,8 @@ discard block |
||
| 993 | 1033 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 994 | 1034 | ) |
| 995 | 1035 | ); |
| 996 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 997 | - $smcFunc['db_query']('', ' |
|
| 1036 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1037 | + $smcFunc['db_query']('', ' |
|
| 998 | 1038 | UPDATE {db_prefix}boards |
| 999 | 1039 | SET num_topics = num_topics + {int:real_num_topics} |
| 1000 | 1040 | WHERE id_board = {int:id_board}', |
@@ -1003,6 +1043,7 @@ discard block |
||
| 1003 | 1043 | 'real_num_topics' => $row['real_num_topics'], |
| 1004 | 1044 | ) |
| 1005 | 1045 | ); |
| 1046 | + } |
|
| 1006 | 1047 | $smcFunc['db_free_result']($request); |
| 1007 | 1048 | |
| 1008 | 1049 | $_REQUEST['start'] += $increment; |
@@ -1025,14 +1066,15 @@ discard block |
||
| 1025 | 1066 | // Update the unapproved post count of each board. |
| 1026 | 1067 | if ($_REQUEST['step'] <= 3) |
| 1027 | 1068 | { |
| 1028 | - if (empty($_REQUEST['start'])) |
|
| 1029 | - $smcFunc['db_query']('', ' |
|
| 1069 | + if (empty($_REQUEST['start'])) { |
|
| 1070 | + $smcFunc['db_query']('', ' |
|
| 1030 | 1071 | UPDATE {db_prefix}boards |
| 1031 | 1072 | SET unapproved_posts = {int:unapproved_posts}', |
| 1032 | 1073 | array( |
| 1033 | 1074 | 'unapproved_posts' => 0, |
| 1034 | 1075 | ) |
| 1035 | 1076 | ); |
| 1077 | + } |
|
| 1036 | 1078 | |
| 1037 | 1079 | while ($_REQUEST['start'] < $max_topics) |
| 1038 | 1080 | { |
@@ -1049,8 +1091,8 @@ discard block |
||
| 1049 | 1091 | 'is_approved' => 0, |
| 1050 | 1092 | ) |
| 1051 | 1093 | ); |
| 1052 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1053 | - $smcFunc['db_query']('', ' |
|
| 1094 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1095 | + $smcFunc['db_query']('', ' |
|
| 1054 | 1096 | UPDATE {db_prefix}boards |
| 1055 | 1097 | SET unapproved_posts = unapproved_posts + {int:unapproved_posts} |
| 1056 | 1098 | WHERE id_board = {int:id_board}', |
@@ -1059,6 +1101,7 @@ discard block |
||
| 1059 | 1101 | 'unapproved_posts' => $row['real_unapproved_posts'], |
| 1060 | 1102 | ) |
| 1061 | 1103 | ); |
| 1104 | + } |
|
| 1062 | 1105 | $smcFunc['db_free_result']($request); |
| 1063 | 1106 | |
| 1064 | 1107 | $_REQUEST['start'] += $increment; |
@@ -1081,14 +1124,15 @@ discard block |
||
| 1081 | 1124 | // Update the unapproved topic count of each board. |
| 1082 | 1125 | if ($_REQUEST['step'] <= 4) |
| 1083 | 1126 | { |
| 1084 | - if (empty($_REQUEST['start'])) |
|
| 1085 | - $smcFunc['db_query']('', ' |
|
| 1127 | + if (empty($_REQUEST['start'])) { |
|
| 1128 | + $smcFunc['db_query']('', ' |
|
| 1086 | 1129 | UPDATE {db_prefix}boards |
| 1087 | 1130 | SET unapproved_topics = {int:unapproved_topics}', |
| 1088 | 1131 | array( |
| 1089 | 1132 | 'unapproved_topics' => 0, |
| 1090 | 1133 | ) |
| 1091 | 1134 | ); |
| 1135 | + } |
|
| 1092 | 1136 | |
| 1093 | 1137 | while ($_REQUEST['start'] < $max_topics) |
| 1094 | 1138 | { |
@@ -1105,8 +1149,8 @@ discard block |
||
| 1105 | 1149 | 'id_topic_max' => $_REQUEST['start'] + $increment, |
| 1106 | 1150 | ) |
| 1107 | 1151 | ); |
| 1108 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1109 | - $smcFunc['db_query']('', ' |
|
| 1152 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1153 | + $smcFunc['db_query']('', ' |
|
| 1110 | 1154 | UPDATE {db_prefix}boards |
| 1111 | 1155 | SET unapproved_topics = unapproved_topics + {int:real_unapproved_topics} |
| 1112 | 1156 | WHERE id_board = {int:id_board}', |
@@ -1115,6 +1159,7 @@ discard block |
||
| 1115 | 1159 | 'real_unapproved_topics' => $row['real_unapproved_topics'], |
| 1116 | 1160 | ) |
| 1117 | 1161 | ); |
| 1162 | + } |
|
| 1118 | 1163 | $smcFunc['db_free_result']($request); |
| 1119 | 1164 | |
| 1120 | 1165 | $_REQUEST['start'] += $increment; |
@@ -1148,8 +1193,9 @@ discard block |
||
| 1148 | 1193 | 'is_not_deleted' => 0, |
| 1149 | 1194 | ) |
| 1150 | 1195 | ); |
| 1151 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1152 | - updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1197 | + updateMemberData($row['id_member'], array('instant_messages' => $row['real_num'])); |
|
| 1198 | + } |
|
| 1153 | 1199 | $smcFunc['db_free_result']($request); |
| 1154 | 1200 | |
| 1155 | 1201 | $request = $smcFunc['db_query']('', ' |
@@ -1164,8 +1210,9 @@ discard block |
||
| 1164 | 1210 | 'is_not_read' => 0, |
| 1165 | 1211 | ) |
| 1166 | 1212 | ); |
| 1167 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1168 | - updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1213 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1214 | + updateMemberData($row['id_member'], array('unread_messages' => $row['real_num'])); |
|
| 1215 | + } |
|
| 1169 | 1216 | $smcFunc['db_free_result']($request); |
| 1170 | 1217 | |
| 1171 | 1218 | if (microtime(true) - $time_start > 3) |
@@ -1197,12 +1244,13 @@ discard block |
||
| 1197 | 1244 | ) |
| 1198 | 1245 | ); |
| 1199 | 1246 | $boards = array(); |
| 1200 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1201 | - $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1247 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1248 | + $boards[$row['id_board']][] = $row['id_msg']; |
|
| 1249 | + } |
|
| 1202 | 1250 | $smcFunc['db_free_result']($request); |
| 1203 | 1251 | |
| 1204 | - foreach ($boards as $board_id => $messages) |
|
| 1205 | - $smcFunc['db_query']('', ' |
|
| 1252 | + foreach ($boards as $board_id => $messages) { |
|
| 1253 | + $smcFunc['db_query']('', ' |
|
| 1206 | 1254 | UPDATE {db_prefix}messages |
| 1207 | 1255 | SET id_board = {int:id_board} |
| 1208 | 1256 | WHERE id_msg IN ({array_int:id_msg_array})', |
@@ -1211,6 +1259,7 @@ discard block |
||
| 1211 | 1259 | 'id_board' => $board_id, |
| 1212 | 1260 | ) |
| 1213 | 1261 | ); |
| 1262 | + } |
|
| 1214 | 1263 | |
| 1215 | 1264 | $_REQUEST['start'] += $increment; |
| 1216 | 1265 | |
@@ -1240,8 +1289,9 @@ discard block |
||
| 1240 | 1289 | ) |
| 1241 | 1290 | ); |
| 1242 | 1291 | $realBoardCounts = array(); |
| 1243 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1244 | - $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1292 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1293 | + $realBoardCounts[$row['id_board']] = $row['local_last_msg']; |
|
| 1294 | + } |
|
| 1245 | 1295 | $smcFunc['db_free_result']($request); |
| 1246 | 1296 | |
| 1247 | 1297 | $request = $smcFunc['db_query']('', ' |
@@ -1261,18 +1311,20 @@ discard block |
||
| 1261 | 1311 | krsort($resort_me); |
| 1262 | 1312 | |
| 1263 | 1313 | $lastModifiedMsg = array(); |
| 1264 | - foreach ($resort_me as $rows) |
|
| 1265 | - foreach ($rows as $row) |
|
| 1314 | + foreach ($resort_me as $rows) { |
|
| 1315 | + foreach ($rows as $row) |
|
| 1266 | 1316 | { |
| 1267 | 1317 | // The latest message is the latest of the current board and its children. |
| 1268 | 1318 | if (isset($lastModifiedMsg[$row['id_board']])) |
| 1269 | 1319 | $curLastModifiedMsg = max($row['local_last_msg'], $lastModifiedMsg[$row['id_board']]); |
| 1270 | - else |
|
| 1271 | - $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1320 | + } |
|
| 1321 | + else { |
|
| 1322 | + $curLastModifiedMsg = $row['local_last_msg']; |
|
| 1323 | + } |
|
| 1272 | 1324 | |
| 1273 | 1325 | // If what is and what should be the latest message differ, an update is necessary. |
| 1274 | - if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) |
|
| 1275 | - $smcFunc['db_query']('', ' |
|
| 1326 | + if ($row['local_last_msg'] != $row['id_last_msg'] || $curLastModifiedMsg != $row['id_msg_updated']) { |
|
| 1327 | + $smcFunc['db_query']('', ' |
|
| 1276 | 1328 | UPDATE {db_prefix}boards |
| 1277 | 1329 | SET id_last_msg = {int:id_last_msg}, id_msg_updated = {int:id_msg_updated} |
| 1278 | 1330 | WHERE id_board = {int:id_board}', |
@@ -1282,12 +1334,14 @@ discard block |
||
| 1282 | 1334 | 'id_board' => $row['id_board'], |
| 1283 | 1335 | ) |
| 1284 | 1336 | ); |
| 1337 | + } |
|
| 1285 | 1338 | |
| 1286 | 1339 | // Parent boards inherit the latest modified message of their children. |
| 1287 | - if (isset($lastModifiedMsg[$row['id_parent']])) |
|
| 1288 | - $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1289 | - else |
|
| 1290 | - $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1340 | + if (isset($lastModifiedMsg[$row['id_parent']])) { |
|
| 1341 | + $lastModifiedMsg[$row['id_parent']] = max($row['local_last_msg'], $lastModifiedMsg[$row['id_parent']]); |
|
| 1342 | + } else { |
|
| 1343 | + $lastModifiedMsg[$row['id_parent']] = $row['local_last_msg']; |
|
| 1344 | + } |
|
| 1291 | 1345 | } |
| 1292 | 1346 | |
| 1293 | 1347 | // Update all the basic statistics. |
@@ -1359,8 +1413,9 @@ discard block |
||
| 1359 | 1413 | require_once($sourcedir . '/Subs-Auth.php'); |
| 1360 | 1414 | $members = findMembers($_POST['to']); |
| 1361 | 1415 | |
| 1362 | - if (empty($members)) |
|
| 1363 | - fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1416 | + if (empty($members)) { |
|
| 1417 | + fatal_lang_error('reattribute_cannot_find_member'); |
|
| 1418 | + } |
|
| 1364 | 1419 | |
| 1365 | 1420 | $memID = array_shift($members); |
| 1366 | 1421 | $memID = $memID['id']; |
@@ -1390,8 +1445,9 @@ discard block |
||
| 1390 | 1445 | validateToken('admin-maint'); |
| 1391 | 1446 | |
| 1392 | 1447 | $groups = array(); |
| 1393 | - foreach ($_POST['groups'] as $id => $dummy) |
|
| 1394 | - $groups[] = (int) $id; |
|
| 1448 | + foreach ($_POST['groups'] as $id => $dummy) { |
|
| 1449 | + $groups[] = (int) $id; |
|
| 1450 | + } |
|
| 1395 | 1451 | $time_limit = (time() - ($_POST['maxdays'] * 24 * 3600)); |
| 1396 | 1452 | $where_vars = array( |
| 1397 | 1453 | 'time_limit' => $time_limit, |
@@ -1400,9 +1456,9 @@ discard block |
||
| 1400 | 1456 | { |
| 1401 | 1457 | $where = 'mem.date_registered < {int:time_limit} AND mem.is_activated = {int:is_activated}'; |
| 1402 | 1458 | $where_vars['is_activated'] = 0; |
| 1459 | + } else { |
|
| 1460 | + $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1403 | 1461 | } |
| 1404 | - else |
|
| 1405 | - $where = 'mem.last_login < {int:time_limit} AND (mem.last_login != 0 OR mem.date_registered < {int:time_limit})'; |
|
| 1406 | 1462 | |
| 1407 | 1463 | // Need to get *all* groups then work out which (if any) we avoid. |
| 1408 | 1464 | $request = $smcFunc['db_query']('', ' |
@@ -1421,8 +1477,7 @@ discard block |
||
| 1421 | 1477 | { |
| 1422 | 1478 | $where .= ' AND mem.id_post_group != {int:id_post_group_' . $row['id_group'] . '}'; |
| 1423 | 1479 | $where_vars['id_post_group_' . $row['id_group']] = $row['id_group']; |
| 1424 | - } |
|
| 1425 | - else |
|
| 1480 | + } else |
|
| 1426 | 1481 | { |
| 1427 | 1482 | $where .= ' AND mem.id_group != {int:id_group_' . $row['id_group'] . '} AND FIND_IN_SET({int:id_group_' . $row['id_group'] . '}, mem.additional_groups) = 0'; |
| 1428 | 1483 | $where_vars['id_group_' . $row['id_group']] = $row['id_group']; |
@@ -1449,8 +1504,9 @@ discard block |
||
| 1449 | 1504 | $members = array(); |
| 1450 | 1505 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1451 | 1506 | { |
| 1452 | - if (!$row['is_mod'] || !in_array(3, $groups)) |
|
| 1453 | - $members[] = $row['id_member']; |
|
| 1507 | + if (!$row['is_mod'] || !in_array(3, $groups)) { |
|
| 1508 | + $members[] = $row['id_member']; |
|
| 1509 | + } |
|
| 1454 | 1510 | } |
| 1455 | 1511 | $smcFunc['db_free_result']($request); |
| 1456 | 1512 | |
@@ -1497,8 +1553,9 @@ discard block |
||
| 1497 | 1553 | ) |
| 1498 | 1554 | ); |
| 1499 | 1555 | |
| 1500 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1501 | - $drafts[] = (int) $row[0]; |
|
| 1556 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1557 | + $drafts[] = (int) $row[0]; |
|
| 1558 | + } |
|
| 1502 | 1559 | $smcFunc['db_free_result']($request); |
| 1503 | 1560 | |
| 1504 | 1561 | // If we have old drafts, remove them |
@@ -1541,8 +1598,9 @@ discard block |
||
| 1541 | 1598 | $sticky = isset($_POST['move_type_sticky']) || isset($_GET['sticky']); |
| 1542 | 1599 | |
| 1543 | 1600 | // No boards then this is your stop. |
| 1544 | - if (empty($id_board_from) || empty($id_board_to)) |
|
| 1545 | - return; |
|
| 1601 | + if (empty($id_board_from) || empty($id_board_to)) { |
|
| 1602 | + return; |
|
| 1603 | + } |
|
| 1546 | 1604 | |
| 1547 | 1605 | // The big WHERE clause |
| 1548 | 1606 | $conditions = 'WHERE t.id_board = {int:id_board_from} |
@@ -1590,18 +1648,20 @@ discard block |
||
| 1590 | 1648 | ); |
| 1591 | 1649 | list ($total_topics) = $smcFunc['db_fetch_row']($request); |
| 1592 | 1650 | $smcFunc['db_free_result']($request); |
| 1651 | + } else { |
|
| 1652 | + $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1593 | 1653 | } |
| 1594 | - else |
|
| 1595 | - $total_topics = (int) $_REQUEST['totaltopics']; |
|
| 1596 | 1654 | |
| 1597 | 1655 | // Seems like we need this here. |
| 1598 | 1656 | $context['continue_get_data'] = '?action=admin;area=maintain;sa=topics;activity=massmove;id_board_from=' . $id_board_from . ';id_board_to=' . $id_board_to . ';totaltopics=' . $total_topics . ';max_days=' . $max_days; |
| 1599 | 1657 | |
| 1600 | - if ($locked) |
|
| 1601 | - $context['continue_get_data'] .= ';locked'; |
|
| 1658 | + if ($locked) { |
|
| 1659 | + $context['continue_get_data'] .= ';locked'; |
|
| 1660 | + } |
|
| 1602 | 1661 | |
| 1603 | - if ($sticky) |
|
| 1604 | - $context['continue_get_data'] .= ';sticky'; |
|
| 1662 | + if ($sticky) { |
|
| 1663 | + $context['continue_get_data'] .= ';sticky'; |
|
| 1664 | + } |
|
| 1605 | 1665 | |
| 1606 | 1666 | $context['continue_get_data'] .= ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 1607 | 1667 | |
@@ -1622,8 +1682,9 @@ discard block |
||
| 1622 | 1682 | |
| 1623 | 1683 | // Get the ids. |
| 1624 | 1684 | $topics = array(); |
| 1625 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1626 | - $topics[] = $row['id_topic']; |
|
| 1685 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1686 | + $topics[] = $row['id_topic']; |
|
| 1687 | + } |
|
| 1627 | 1688 | |
| 1628 | 1689 | // Just return if we don't have any topics left to move. |
| 1629 | 1690 | if (empty($topics)) |
@@ -1714,9 +1775,9 @@ discard block |
||
| 1714 | 1775 | // save it so we don't do this again for this task |
| 1715 | 1776 | list ($_SESSION['total_members']) = $smcFunc['db_fetch_row']($request); |
| 1716 | 1777 | $smcFunc['db_free_result']($request); |
| 1778 | + } else { |
|
| 1779 | + validateToken('admin-recountposts'); |
|
| 1717 | 1780 | } |
| 1718 | - else |
|
| 1719 | - validateToken('admin-recountposts'); |
|
| 1720 | 1781 | |
| 1721 | 1782 | // Lets get a group of members and determine their post count (from the boards that have post count enabled of course). |
| 1722 | 1783 | $request = $smcFunc['db_query']('', ' |
@@ -1762,8 +1823,9 @@ discard block |
||
| 1762 | 1823 | createToken('admin-recountposts'); |
| 1763 | 1824 | $context['continue_post_data'] = '<input type="hidden" name="' . $context['admin-recountposts_token_var'] . '" value="' . $context['admin-recountposts_token'] . '">'; |
| 1764 | 1825 | |
| 1765 | - if (function_exists('apache_reset_timeout')) |
|
| 1766 | - apache_reset_timeout(); |
|
| 1826 | + if (function_exists('apache_reset_timeout')) { |
|
| 1827 | + apache_reset_timeout(); |
|
| 1828 | + } |
|
| 1767 | 1829 | return; |
| 1768 | 1830 | } |
| 1769 | 1831 | |
@@ -1849,10 +1911,9 @@ discard block |
||
| 1849 | 1911 | checkSession('request'); |
| 1850 | 1912 | validateToken('admin-hook', 'request'); |
| 1851 | 1913 | |
| 1852 | - if ($_REQUEST['do'] == 'remove') |
|
| 1853 | - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1854 | - |
|
| 1855 | - else |
|
| 1914 | + if ($_REQUEST['do'] == 'remove') { |
|
| 1915 | + remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); |
|
| 1916 | + } else |
|
| 1856 | 1917 | { |
| 1857 | 1918 | $function_remove = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '' : '!'); |
| 1858 | 1919 | $function_add = urldecode($_REQUEST['function']) . (($_REQUEST['do'] == 'disable') ? '!' : ''); |
@@ -1902,11 +1963,11 @@ discard block |
||
| 1902 | 1963 | // Show a nice icon to indicate this is an instance. |
| 1903 | 1964 | $instance = (!empty($data['instance']) ? '<span class="generic_icons news" title="' . $txt['hooks_field_function_method'] . '"></span> ' : ''); |
| 1904 | 1965 | |
| 1905 | - if (!empty($data['included_file'])) |
|
| 1906 | - return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1907 | - |
|
| 1908 | - else |
|
| 1909 | - return $instance . $data['real_function']; |
|
| 1966 | + if (!empty($data['included_file'])) { |
|
| 1967 | + return $instance . $txt['hooks_field_function'] . ': ' . $data['real_function'] . '<br>' . $txt['hooks_field_included_file'] . ': ' . $data['included_file']; |
|
| 1968 | + } else { |
|
| 1969 | + return $instance . $data['real_function']; |
|
| 1970 | + } |
|
| 1910 | 1971 | }, |
| 1911 | 1972 | ), |
| 1912 | 1973 | 'sort' => array( |
@@ -1971,11 +2032,12 @@ discard block |
||
| 1971 | 2032 | 'data' => array( |
| 1972 | 2033 | 'function' => function($data) use ($txt, $scripturl, $context) |
| 1973 | 2034 | { |
| 1974 | - if (!$data['hook_exists']) |
|
| 1975 | - return ' |
|
| 2035 | + if (!$data['hook_exists']) { |
|
| 2036 | + return ' |
|
| 1976 | 2037 | <a href="' . $scripturl . '?action=admin;area=maintain;sa=hooks;do=remove;hook=' . $data['hook_name'] . ';function=' . urlencode($data['function_name']) . $context['filter_url'] . ';' . $context['admin-hook_token_var'] . '=' . $context['admin-hook_token'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['quickmod_confirm'] . '" class="you_sure"> |
| 1977 | 2038 | <span class="generic_icons delete" title="' . $txt['hooks_button_remove'] . '"></span> |
| 1978 | 2039 | </a>'; |
| 2040 | + } |
|
| 1979 | 2041 | }, |
| 1980 | 2042 | 'class' => 'centertext', |
| 1981 | 2043 | ), |
@@ -2010,10 +2072,11 @@ discard block |
||
| 2010 | 2072 | { |
| 2011 | 2073 | if ($file != '.' && $file != '..') |
| 2012 | 2074 | { |
| 2013 | - if (is_dir($dir_path . '/' . $file)) |
|
| 2014 | - $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2015 | - else |
|
| 2016 | - $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2075 | + if (is_dir($dir_path . '/' . $file)) { |
|
| 2076 | + $files = array_merge($files, get_files_recursive($dir_path . '/' . $file)); |
|
| 2077 | + } else { |
|
| 2078 | + $files[] = array('dir' => $dir_path, 'name' => $file); |
|
| 2079 | + } |
|
| 2017 | 2080 | } |
| 2018 | 2081 | } |
| 2019 | 2082 | } |
@@ -2062,16 +2125,16 @@ discard block |
||
| 2062 | 2125 | // I need to know if there is at least one function called in this file. |
| 2063 | 2126 | $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
| 2064 | 2127 | unset($temp_hooks[$hook][$rawFunc]); |
| 2065 | - } |
|
| 2066 | - elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2128 | + } elseif (strpos(str_replace(' (', '(', $fc), 'function ' . trim($hookParsedData['pureFunc']) . '(') !== false) |
|
| 2067 | 2129 | { |
| 2068 | 2130 | $hook_status[$hook][$hookParsedData['pureFunc']] = $hookParsedData; |
| 2069 | 2131 | $hook_status[$hook][$hookParsedData['pureFunc']]['exists'] = true; |
| 2070 | 2132 | $hook_status[$hook][$hookParsedData['pureFunc']]['in_file'] = (!empty($file['name']) ? $file['name'] : (!empty($hookParsedData['hookFile']) ? $hookParsedData['hookFile'] : '')); |
| 2071 | 2133 | |
| 2072 | 2134 | // Does the hook has its own file? |
| 2073 | - if (!empty($hookParsedData['hookFile'])) |
|
| 2074 | - $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2135 | + if (!empty($hookParsedData['hookFile'])) { |
|
| 2136 | + $temp_data['include'][$hookParsedData['pureFunc']] = array('hook' => $hook, 'function' => $hookParsedData['pureFunc']); |
|
| 2137 | + } |
|
| 2075 | 2138 | |
| 2076 | 2139 | // I want to remember all the functions called within this file (to check later if they are enabled or disabled and decide if the integrare_*_include of that file can be disabled too) |
| 2077 | 2140 | $temp_data['function'][$file['name']][$hookParsedData['pureFunc']] = $hookParsedData['enabled']; |
@@ -2098,15 +2161,17 @@ discard block |
||
| 2098 | 2161 | $sort = array(); |
| 2099 | 2162 | $hooks_filters = array(); |
| 2100 | 2163 | |
| 2101 | - foreach ($hooks as $hook => $functions) |
|
| 2102 | - $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2164 | + foreach ($hooks as $hook => $functions) { |
|
| 2165 | + $hooks_filters[] = '<option' . ($context['current_filter'] == $hook ? ' selected ' : '') . ' value="' . $hook . '">' . $hook . '</option>'; |
|
| 2166 | + } |
|
| 2103 | 2167 | |
| 2104 | - if (!empty($hooks_filters)) |
|
| 2105 | - $context['insert_after_template'] .= ' |
|
| 2168 | + if (!empty($hooks_filters)) { |
|
| 2169 | + $context['insert_after_template'] .= ' |
|
| 2106 | 2170 | <script> |
| 2107 | 2171 | var hook_name_header = document.getElementById(\'header_list_integration_hooks_hook_name\'); |
| 2108 | 2172 | hook_name_header.innerHTML += ' . JavaScriptEscape('<select style="margin-left:15px;" onchange="window.location=(\'' . $scripturl . '?action=admin;area=maintain;sa=hooks\' + (this.value ? \';filter=\' + this.value : \'\'));"><option value="">' . $txt['hooks_reset_filter'] . '</option>' . implode('', $hooks_filters) . '</select>') . '; |
| 2109 | 2173 | </script>'; |
| 2174 | + } |
|
| 2110 | 2175 | |
| 2111 | 2176 | $temp_data = array(); |
| 2112 | 2177 | $id = 0; |
@@ -2148,10 +2213,11 @@ discard block |
||
| 2148 | 2213 | |
| 2149 | 2214 | foreach ($temp_data as $data) |
| 2150 | 2215 | { |
| 2151 | - if (++$counter < $start) |
|
| 2152 | - continue; |
|
| 2153 | - elseif ($counter == $start + $per_page) |
|
| 2154 | - break; |
|
| 2216 | + if (++$counter < $start) { |
|
| 2217 | + continue; |
|
| 2218 | + } elseif ($counter == $start + $per_page) { |
|
| 2219 | + break; |
|
| 2220 | + } |
|
| 2155 | 2221 | |
| 2156 | 2222 | $hooks_data[] = $data; |
| 2157 | 2223 | } |
@@ -2173,13 +2239,15 @@ discard block |
||
| 2173 | 2239 | $hooks_count = 0; |
| 2174 | 2240 | |
| 2175 | 2241 | $context['filter'] = false; |
| 2176 | - if (isset($_GET['filter'])) |
|
| 2177 | - $context['filter'] = $_GET['filter']; |
|
| 2242 | + if (isset($_GET['filter'])) { |
|
| 2243 | + $context['filter'] = $_GET['filter']; |
|
| 2244 | + } |
|
| 2178 | 2245 | |
| 2179 | 2246 | foreach ($hooks as $hook => $functions) |
| 2180 | 2247 | { |
| 2181 | - if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) |
|
| 2182 | - $hooks_count += count($functions); |
|
| 2248 | + if (empty($context['filter']) || (!empty($context['filter']) && $context['filter'] == $hook)) { |
|
| 2249 | + $hooks_count += count($functions); |
|
| 2250 | + } |
|
| 2183 | 2251 | } |
| 2184 | 2252 | |
| 2185 | 2253 | return $hooks_count; |
@@ -2200,8 +2268,9 @@ discard block |
||
| 2200 | 2268 | $integration_hooks = array(); |
| 2201 | 2269 | foreach ($modSettings as $key => $value) |
| 2202 | 2270 | { |
| 2203 | - if (!empty($value) && substr($key, 0, 10) === 'integrate_') |
|
| 2204 | - $integration_hooks[$key] = explode(',', $value); |
|
| 2271 | + if (!empty($value) && substr($key, 0, 10) === 'integrate_') { |
|
| 2272 | + $integration_hooks[$key] = explode(',', $value); |
|
| 2273 | + } |
|
| 2205 | 2274 | } |
| 2206 | 2275 | } |
| 2207 | 2276 | |
@@ -2232,8 +2301,9 @@ discard block |
||
| 2232 | 2301 | ); |
| 2233 | 2302 | |
| 2234 | 2303 | // Meh... |
| 2235 | - if (empty($rawData)) |
|
| 2236 | - return $hookData; |
|
| 2304 | + if (empty($rawData)) { |
|
| 2305 | + return $hookData; |
|
| 2306 | + } |
|
| 2237 | 2307 | |
| 2238 | 2308 | // For convenience purposes only! |
| 2239 | 2309 | $modFunc = $rawData; |
@@ -2244,11 +2314,11 @@ discard block |
||
| 2244 | 2314 | list ($hookData['hookFile'], $modFunc) = explode('|', $modFunc); |
| 2245 | 2315 | |
| 2246 | 2316 | // Does the file exists? who knows! |
| 2247 | - if (empty($settings['theme_dir'])) |
|
| 2248 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2249 | - |
|
| 2250 | - else |
|
| 2251 | - $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2317 | + if (empty($settings['theme_dir'])) { |
|
| 2318 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
| 2319 | + } else { |
|
| 2320 | + $hookData['absPath'] = strtr(trim($hookData['hookFile']), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
| 2321 | + } |
|
| 2252 | 2322 | |
| 2253 | 2323 | $hookData['fileExists'] = file_exists($hookData['absPath']); |
| 2254 | 2324 | $hookData['hookFile'] = basename($hookData['hookFile']); |
@@ -2273,11 +2343,10 @@ discard block |
||
| 2273 | 2343 | { |
| 2274 | 2344 | list ($hookData['class'], $hookData['method']) = explode('::', $modFunc); |
| 2275 | 2345 | $hookData['pureFunc'] = $hookData['method']; |
| 2346 | + } else { |
|
| 2347 | + $hookData['pureFunc'] = $modFunc; |
|
| 2276 | 2348 | } |
| 2277 | 2349 | |
| 2278 | - else |
|
| 2279 | - $hookData['pureFunc'] = $modFunc; |
|
| 2280 | - |
|
| 2281 | 2350 | return $hookData; |
| 2282 | 2351 | } |
| 2283 | 2352 | |
@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | // ><html dir="ltr"><head><title>Error!</title></head><body>Sorry, this installer requires PHP!<div style="display: none;"> |
| 21 | 21 | |
| 22 | 22 | // Let's pull in useful classes |
| 23 | -if (!defined('SMF')) |
|
| 23 | +if (!defined('SMF')) { |
|
| 24 | 24 | define('SMF', 1); |
| 25 | +} |
|
| 25 | 26 | |
| 26 | 27 | require_once('Sources/Class-Package.php'); |
| 27 | 28 | |
@@ -63,10 +64,11 @@ discard block |
||
| 63 | 64 | |
| 64 | 65 | list ($charcode) = pg_fetch_row($request); |
| 65 | 66 | |
| 66 | - if ($charcode == 'UTF8') |
|
| 67 | - return true; |
|
| 68 | - else |
|
| 69 | - return false; |
|
| 67 | + if ($charcode == 'UTF8') { |
|
| 68 | + return true; |
|
| 69 | + } else { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 70 | 72 | }, |
| 71 | 73 | 'utf8_version' => '8.0', |
| 72 | 74 | 'utf8_version_check' => '$request = pg_query(\'SELECT version()\'); list ($version) = pg_fetch_row($request); list($pgl, $version) = explode(" ", $version); return $version;', |
@@ -76,12 +78,14 @@ discard block |
||
| 76 | 78 | $value = preg_replace('~[^A-Za-z0-9_\$]~', '', $value); |
| 77 | 79 | |
| 78 | 80 | // Is it reserved? |
| 79 | - if ($value == 'pg_') |
|
| 80 | - return $txt['error_db_prefix_reserved']; |
|
| 81 | + if ($value == 'pg_') { |
|
| 82 | + return $txt['error_db_prefix_reserved']; |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Is the prefix numeric? |
| 83 | - if (preg_match('~^\d~', $value)) |
|
| 84 | - return $txt['error_db_prefix_numeric']; |
|
| 86 | + if (preg_match('~^\d~', $value)) { |
|
| 87 | + return $txt['error_db_prefix_numeric']; |
|
| 88 | + } |
|
| 85 | 89 | |
| 86 | 90 | return true; |
| 87 | 91 | }, |
@@ -128,10 +132,11 @@ discard block |
||
| 128 | 132 | $incontext['skip'] = false; |
| 129 | 133 | |
| 130 | 134 | // Call the step and if it returns false that means pause! |
| 131 | - if (function_exists($step[2]) && $step[2]() === false) |
|
| 132 | - break; |
|
| 133 | - elseif (function_exists($step[2])) |
|
| 134 | - $incontext['current_step']++; |
|
| 135 | + if (function_exists($step[2]) && $step[2]() === false) { |
|
| 136 | + break; |
|
| 137 | + } elseif (function_exists($step[2])) { |
|
| 138 | + $incontext['current_step']++; |
|
| 139 | + } |
|
| 135 | 140 | |
| 136 | 141 | // No warnings pass on. |
| 137 | 142 | $incontext['warning'] = ''; |
@@ -147,8 +152,9 @@ discard block |
||
| 147 | 152 | global $databases; |
| 148 | 153 | |
| 149 | 154 | // Just so people using older versions of PHP aren't left in the cold. |
| 150 | - if (!isset($_SERVER['PHP_SELF'])) |
|
| 151 | - $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 155 | + if (!isset($_SERVER['PHP_SELF'])) { |
|
| 156 | + $_SERVER['PHP_SELF'] = isset($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']) ? $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] : 'install.php'; |
|
| 157 | + } |
|
| 152 | 158 | |
| 153 | 159 | // Enable error reporting for fatal errors. |
| 154 | 160 | error_reporting(E_ERROR | E_PARSE); |
@@ -164,21 +170,23 @@ discard block |
||
| 164 | 170 | { |
| 165 | 171 | ob_start(); |
| 166 | 172 | |
| 167 | - if (ini_get('session.save_handler') == 'user') |
|
| 168 | - @ini_set('session.save_handler', 'files'); |
|
| 169 | - if (function_exists('session_start')) |
|
| 170 | - @session_start(); |
|
| 171 | - } |
|
| 172 | - else |
|
| 173 | + if (ini_get('session.save_handler') == 'user') { |
|
| 174 | + @ini_set('session.save_handler', 'files'); |
|
| 175 | + } |
|
| 176 | + if (function_exists('session_start')) { |
|
| 177 | + @session_start(); |
|
| 178 | + } |
|
| 179 | + } else |
|
| 173 | 180 | { |
| 174 | 181 | ob_start('ob_gzhandler'); |
| 175 | 182 | |
| 176 | - if (ini_get('session.save_handler') == 'user') |
|
| 177 | - @ini_set('session.save_handler', 'files'); |
|
| 183 | + if (ini_get('session.save_handler') == 'user') { |
|
| 184 | + @ini_set('session.save_handler', 'files'); |
|
| 185 | + } |
|
| 178 | 186 | session_start(); |
| 179 | 187 | |
| 180 | - if (!headers_sent()) |
|
| 181 | - echo '<!DOCTYPE html> |
|
| 188 | + if (!headers_sent()) { |
|
| 189 | + echo '<!DOCTYPE html> |
|
| 182 | 190 | <html> |
| 183 | 191 | <head> |
| 184 | 192 | <title>', htmlspecialchars($_GET['pass_string']), '</title> |
@@ -187,14 +195,16 @@ discard block |
||
| 187 | 195 | <strong>', htmlspecialchars($_GET['pass_string']), '</strong> |
| 188 | 196 | </body> |
| 189 | 197 | </html>'; |
| 198 | + } |
|
| 190 | 199 | exit; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | 202 | // Add slashes, as long as they aren't already being added. |
| 194 | - if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) |
|
| 195 | - foreach ($_POST as $k => $v) |
|
| 203 | + if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0) { |
|
| 204 | + foreach ($_POST as $k => $v) |
|
| 196 | 205 | if (strpos($k, 'password') === false && strpos($k, 'db_passwd') === false) |
| 197 | 206 | $_POST[$k] = addslashes($v); |
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | // This is really quite simple; if ?delete is on the URL, delete the installer... |
| 200 | 210 | if (isset($_GET['delete'])) |
@@ -215,8 +225,7 @@ discard block |
||
| 215 | 225 | $ftp->close(); |
| 216 | 226 | |
| 217 | 227 | unset($_SESSION['installer_temp_ftp']); |
| 218 | - } |
|
| 219 | - else |
|
| 228 | + } else |
|
| 220 | 229 | { |
| 221 | 230 | @unlink(__FILE__); |
| 222 | 231 | |
@@ -237,10 +246,11 @@ discard block |
||
| 237 | 246 | { |
| 238 | 247 | // Get PHP's default timezone, if set |
| 239 | 248 | $ini_tz = ini_get('date.timezone'); |
| 240 | - if (!empty($ini_tz)) |
|
| 241 | - $timezone_id = $ini_tz; |
|
| 242 | - else |
|
| 243 | - $timezone_id = ''; |
|
| 249 | + if (!empty($ini_tz)) { |
|
| 250 | + $timezone_id = $ini_tz; |
|
| 251 | + } else { |
|
| 252 | + $timezone_id = ''; |
|
| 253 | + } |
|
| 244 | 254 | |
| 245 | 255 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 246 | 256 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -270,8 +280,9 @@ discard block |
||
| 270 | 280 | $dir = dir(dirname(__FILE__) . '/Themes/default/languages'); |
| 271 | 281 | while ($entry = $dir->read()) |
| 272 | 282 | { |
| 273 | - if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') |
|
| 274 | - $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 283 | + if (substr($entry, 0, 8) == 'Install.' && substr($entry, -4) == '.php') { |
|
| 284 | + $incontext['detected_languages'][$entry] = ucfirst(substr($entry, 8, strlen($entry) - 12)); |
|
| 285 | + } |
|
| 275 | 286 | } |
| 276 | 287 | $dir->close(); |
| 277 | 288 | } |
@@ -306,10 +317,11 @@ discard block |
||
| 306 | 317 | } |
| 307 | 318 | |
| 308 | 319 | // Override the language file? |
| 309 | - if (isset($_GET['lang_file'])) |
|
| 310 | - $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 311 | - elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) |
|
| 312 | - $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 320 | + if (isset($_GET['lang_file'])) { |
|
| 321 | + $_SESSION['installer_temp_lang'] = $_GET['lang_file']; |
|
| 322 | + } elseif (isset($GLOBALS['HTTP_GET_VARS']['lang_file'])) { |
|
| 323 | + $_SESSION['installer_temp_lang'] = $GLOBALS['HTTP_GET_VARS']['lang_file']; |
|
| 324 | + } |
|
| 313 | 325 | |
| 314 | 326 | // Make sure it exists, if it doesn't reset it. |
| 315 | 327 | if (!isset($_SESSION['installer_temp_lang']) || preg_match('~[^\\w_\\-.]~', $_SESSION['installer_temp_lang']) === 1 || !file_exists(dirname(__FILE__) . '/Themes/default/languages/' . $_SESSION['installer_temp_lang'])) |
@@ -318,8 +330,9 @@ discard block |
||
| 318 | 330 | list ($_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
| 319 | 331 | |
| 320 | 332 | // If we have english and some other language, use the other language. We Americans hate english :P. |
| 321 | - if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) |
|
| 322 | - list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 333 | + if ($_SESSION['installer_temp_lang'] == 'Install.english.php' && count($incontext['detected_languages']) > 1) { |
|
| 334 | + list (, $_SESSION['installer_temp_lang']) = array_keys($incontext['detected_languages']); |
|
| 335 | + } |
|
| 323 | 336 | } |
| 324 | 337 | |
| 325 | 338 | // And now include the actual language file itself. |
@@ -332,15 +345,18 @@ discard block |
||
| 332 | 345 | global $db_prefix, $db_connection, $sourcedir, $smcFunc, $modSettings; |
| 333 | 346 | global $db_server, $db_passwd, $db_type, $db_name, $db_user, $db_persist; |
| 334 | 347 | |
| 335 | - if (empty($sourcedir)) |
|
| 336 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 348 | + if (empty($sourcedir)) { |
|
| 349 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 350 | + } |
|
| 337 | 351 | |
| 338 | 352 | // Need this to check whether we need the database password. |
| 339 | 353 | require(dirname(__FILE__) . '/Settings.php'); |
| 340 | - if (!defined('SMF')) |
|
| 341 | - define('SMF', 1); |
|
| 342 | - if (empty($smcFunc)) |
|
| 343 | - $smcFunc = array(); |
|
| 354 | + if (!defined('SMF')) { |
|
| 355 | + define('SMF', 1); |
|
| 356 | + } |
|
| 357 | + if (empty($smcFunc)) { |
|
| 358 | + $smcFunc = array(); |
|
| 359 | + } |
|
| 344 | 360 | |
| 345 | 361 | $modSettings['disableQueryCheck'] = true; |
| 346 | 362 | |
@@ -348,8 +364,9 @@ discard block |
||
| 348 | 364 | if (!$db_connection) |
| 349 | 365 | { |
| 350 | 366 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 351 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 352 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 367 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 368 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 369 | + } |
|
| 353 | 370 | |
| 354 | 371 | $db_options = array('persist' => $db_persist); |
| 355 | 372 | $port = ''; |
@@ -360,19 +377,20 @@ discard block |
||
| 360 | 377 | if ($db_type == 'mysql') |
| 361 | 378 | { |
| 362 | 379 | $port = ((int) $_POST['db_port'] == ini_get($db_type . 'default_port')) ? '' : (int) $_POST['db_port']; |
| 363 | - } |
|
| 364 | - elseif ($db_type == 'postgresql') |
|
| 380 | + } elseif ($db_type == 'postgresql') |
|
| 365 | 381 | { |
| 366 | 382 | // PostgreSQL doesn't have a default port setting in php.ini, so just check against the default |
| 367 | 383 | $port = ((int) $_POST['db_port'] == 5432) ? '' : (int) $_POST['db_port']; |
| 368 | 384 | } |
| 369 | 385 | } |
| 370 | 386 | |
| 371 | - if (!empty($port)) |
|
| 372 | - $db_options['port'] = $port; |
|
| 387 | + if (!empty($port)) { |
|
| 388 | + $db_options['port'] = $port; |
|
| 389 | + } |
|
| 373 | 390 | |
| 374 | - if (!$db_connection) |
|
| 375 | - $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 391 | + if (!$db_connection) { |
|
| 392 | + $db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options); |
|
| 393 | + } |
|
| 376 | 394 | } |
| 377 | 395 | } |
| 378 | 396 | |
@@ -400,8 +418,9 @@ discard block |
||
| 400 | 418 | // @todo REMOVE THIS!! |
| 401 | 419 | else |
| 402 | 420 | { |
| 403 | - if (function_exists('doStep' . $_GET['step'])) |
|
| 404 | - call_user_func('doStep' . $_GET['step']); |
|
| 421 | + if (function_exists('doStep' . $_GET['step'])) { |
|
| 422 | + call_user_func('doStep' . $_GET['step']); |
|
| 423 | + } |
|
| 405 | 424 | } |
| 406 | 425 | // Show the footer. |
| 407 | 426 | template_install_below(); |
@@ -419,8 +438,9 @@ discard block |
||
| 419 | 438 | $incontext['sub_template'] = 'welcome_message'; |
| 420 | 439 | |
| 421 | 440 | // Done the submission? |
| 422 | - if (isset($_POST['contbutt'])) |
|
| 423 | - return true; |
|
| 441 | + if (isset($_POST['contbutt'])) { |
|
| 442 | + return true; |
|
| 443 | + } |
|
| 424 | 444 | |
| 425 | 445 | // See if we think they have already installed it? |
| 426 | 446 | if (is_readable(dirname(__FILE__) . '/Settings.php')) |
@@ -428,14 +448,17 @@ discard block |
||
| 428 | 448 | $probably_installed = 0; |
| 429 | 449 | foreach (file(dirname(__FILE__) . '/Settings.php') as $line) |
| 430 | 450 | { |
| 431 | - if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) |
|
| 432 | - $probably_installed++; |
|
| 433 | - if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) |
|
| 434 | - $probably_installed++; |
|
| 451 | + if (preg_match('~^\$db_passwd\s=\s\'([^\']+)\';$~', $line)) { |
|
| 452 | + $probably_installed++; |
|
| 453 | + } |
|
| 454 | + if (preg_match('~^\$boardurl\s=\s\'([^\']+)\';~', $line) && !preg_match('~^\$boardurl\s=\s\'http://127\.0\.0\.1/smf\';~', $line)) { |
|
| 455 | + $probably_installed++; |
|
| 456 | + } |
|
| 435 | 457 | } |
| 436 | 458 | |
| 437 | - if ($probably_installed == 2) |
|
| 438 | - $incontext['warning'] = $txt['error_already_installed']; |
|
| 459 | + if ($probably_installed == 2) { |
|
| 460 | + $incontext['warning'] = $txt['error_already_installed']; |
|
| 461 | + } |
|
| 439 | 462 | } |
| 440 | 463 | |
| 441 | 464 | // Is some database support even compiled in? |
@@ -450,45 +473,54 @@ discard block |
||
| 450 | 473 | $databases[$key]['supported'] = false; |
| 451 | 474 | $notFoundSQLFile = true; |
| 452 | 475 | $txt['error_db_script_missing'] = sprintf($txt['error_db_script_missing'], 'install_' . $GLOBALS['db_script_version'] . '_' . $type . '.sql'); |
| 476 | + } else { |
|
| 477 | + $incontext['supported_databases'][] = $db; |
|
| 453 | 478 | } |
| 454 | - else |
|
| 455 | - $incontext['supported_databases'][] = $db; |
|
| 456 | 479 | } |
| 457 | 480 | } |
| 458 | 481 | |
| 459 | 482 | // Check the PHP version. |
| 460 | - if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) |
|
| 461 | - $error = 'error_php_too_low'; |
|
| 483 | + if ((!function_exists('version_compare') || version_compare($GLOBALS['required_php_version'], PHP_VERSION, '>='))) { |
|
| 484 | + $error = 'error_php_too_low'; |
|
| 485 | + } |
|
| 462 | 486 | // Make sure we have a supported database |
| 463 | - elseif (empty($incontext['supported_databases'])) |
|
| 464 | - $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 487 | + elseif (empty($incontext['supported_databases'])) { |
|
| 488 | + $error = empty($notFoundSQLFile) ? 'error_db_missing' : 'error_db_script_missing'; |
|
| 489 | + } |
|
| 465 | 490 | // How about session support? Some crazy sysadmin remove it? |
| 466 | - elseif (!function_exists('session_start')) |
|
| 467 | - $error = 'error_session_missing'; |
|
| 491 | + elseif (!function_exists('session_start')) { |
|
| 492 | + $error = 'error_session_missing'; |
|
| 493 | + } |
|
| 468 | 494 | // Make sure they uploaded all the files. |
| 469 | - elseif (!file_exists(dirname(__FILE__) . '/index.php')) |
|
| 470 | - $error = 'error_missing_files'; |
|
| 495 | + elseif (!file_exists(dirname(__FILE__) . '/index.php')) { |
|
| 496 | + $error = 'error_missing_files'; |
|
| 497 | + } |
|
| 471 | 498 | // Very simple check on the session.save_path for Windows. |
| 472 | 499 | // @todo Move this down later if they don't use database-driven sessions? |
| 473 | - elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') |
|
| 474 | - $error = 'error_session_save_path'; |
|
| 500 | + elseif (@ini_get('session.save_path') == '/tmp' && substr(__FILE__, 1, 2) == ':\\') { |
|
| 501 | + $error = 'error_session_save_path'; |
|
| 502 | + } |
|
| 475 | 503 | |
| 476 | 504 | // Since each of the three messages would look the same, anyway... |
| 477 | - if (isset($error)) |
|
| 478 | - $incontext['error'] = $txt[$error]; |
|
| 505 | + if (isset($error)) { |
|
| 506 | + $incontext['error'] = $txt[$error]; |
|
| 507 | + } |
|
| 479 | 508 | |
| 480 | 509 | // Mod_security blocks everything that smells funny. Let SMF handle security. |
| 481 | - if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) |
|
| 482 | - $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 510 | + if (!fixModSecurity() && !isset($_GET['overmodsecurity'])) { |
|
| 511 | + $incontext['error'] = $txt['error_mod_security'] . '<br><br><a href="' . $installurl . '?overmodsecurity=true">' . $txt['error_message_click'] . '</a> ' . $txt['error_message_bad_try_again']; |
|
| 512 | + } |
|
| 483 | 513 | |
| 484 | 514 | // Confirm mbstring is loaded... |
| 485 | - if (!extension_loaded('mbstring')) |
|
| 486 | - $incontext['error'] = $txt['install_no_mbstring']; |
|
| 515 | + if (!extension_loaded('mbstring')) { |
|
| 516 | + $incontext['error'] = $txt['install_no_mbstring']; |
|
| 517 | + } |
|
| 487 | 518 | |
| 488 | 519 | // Check for https stream support. |
| 489 | 520 | $supported_streams = stream_get_wrappers(); |
| 490 | - if (!in_array('https', $supported_streams)) |
|
| 491 | - $incontext['warning'] = $txt['install_no_https']; |
|
| 521 | + if (!in_array('https', $supported_streams)) { |
|
| 522 | + $incontext['warning'] = $txt['install_no_https']; |
|
| 523 | + } |
|
| 492 | 524 | |
| 493 | 525 | return false; |
| 494 | 526 | } |
@@ -514,12 +546,14 @@ discard block |
||
| 514 | 546 | 'db_last_error.php', |
| 515 | 547 | ); |
| 516 | 548 | |
| 517 | - foreach ($incontext['detected_languages'] as $lang => $temp) |
|
| 518 | - $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 549 | + foreach ($incontext['detected_languages'] as $lang => $temp) { |
|
| 550 | + $extra_files[] = 'Themes/default/languages/' . $lang; |
|
| 551 | + } |
|
| 519 | 552 | |
| 520 | 553 | // With mod_security installed, we could attempt to fix it with .htaccess. |
| 521 | - if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) |
|
| 522 | - $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 554 | + if (function_exists('apache_get_modules') && in_array('mod_security', apache_get_modules())) { |
|
| 555 | + $writable_files[] = file_exists(dirname(__FILE__) . '/.htaccess') ? '.htaccess' : '.'; |
|
| 556 | + } |
|
| 523 | 557 | |
| 524 | 558 | $failed_files = array(); |
| 525 | 559 | |
@@ -531,20 +565,23 @@ discard block |
||
| 531 | 565 | foreach ($writable_files as $file) |
| 532 | 566 | { |
| 533 | 567 | // Some files won't exist, try to address up front |
| 534 | - if (!file_exists(dirname(__FILE__) . '/' . $file)) |
|
| 535 | - @touch(dirname(__FILE__) . '/' . $file); |
|
| 568 | + if (!file_exists(dirname(__FILE__) . '/' . $file)) { |
|
| 569 | + @touch(dirname(__FILE__) . '/' . $file); |
|
| 570 | + } |
|
| 536 | 571 | // NOW do the writable check... |
| 537 | 572 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 538 | 573 | { |
| 539 | 574 | @chmod(dirname(__FILE__) . '/' . $file, 0755); |
| 540 | 575 | |
| 541 | 576 | // Well, 755 hopefully worked... if not, try 777. |
| 542 | - if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) |
|
| 543 | - $failed_files[] = $file; |
|
| 577 | + if (!is_writable(dirname(__FILE__) . '/' . $file) && !@chmod(dirname(__FILE__) . '/' . $file, 0777)) { |
|
| 578 | + $failed_files[] = $file; |
|
| 579 | + } |
|
| 544 | 580 | } |
| 545 | 581 | } |
| 546 | - foreach ($extra_files as $file) |
|
| 547 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 582 | + foreach ($extra_files as $file) { |
|
| 583 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 584 | + } |
|
| 548 | 585 | } |
| 549 | 586 | // Windows is trickier. Let's try opening for r+... |
| 550 | 587 | else |
@@ -554,30 +591,35 @@ discard block |
||
| 554 | 591 | foreach ($writable_files as $file) |
| 555 | 592 | { |
| 556 | 593 | // Folders can't be opened for write... but the index.php in them can ;) |
| 557 | - if (is_dir(dirname(__FILE__) . '/' . $file)) |
|
| 558 | - $file .= '/index.php'; |
|
| 594 | + if (is_dir(dirname(__FILE__) . '/' . $file)) { |
|
| 595 | + $file .= '/index.php'; |
|
| 596 | + } |
|
| 559 | 597 | |
| 560 | 598 | // Funny enough, chmod actually does do something on windows - it removes the read only attribute. |
| 561 | 599 | @chmod(dirname(__FILE__) . '/' . $file, 0777); |
| 562 | 600 | $fp = @fopen(dirname(__FILE__) . '/' . $file, 'r+'); |
| 563 | 601 | |
| 564 | 602 | // Hmm, okay, try just for write in that case... |
| 565 | - if (!is_resource($fp)) |
|
| 566 | - $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 603 | + if (!is_resource($fp)) { |
|
| 604 | + $fp = @fopen(dirname(__FILE__) . '/' . $file, 'w'); |
|
| 605 | + } |
|
| 567 | 606 | |
| 568 | - if (!is_resource($fp)) |
|
| 569 | - $failed_files[] = $file; |
|
| 607 | + if (!is_resource($fp)) { |
|
| 608 | + $failed_files[] = $file; |
|
| 609 | + } |
|
| 570 | 610 | |
| 571 | 611 | @fclose($fp); |
| 572 | 612 | } |
| 573 | - foreach ($extra_files as $file) |
|
| 574 | - @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 613 | + foreach ($extra_files as $file) { |
|
| 614 | + @chmod(dirname(__FILE__) . (empty($file) ? '' : '/' . $file), 0777); |
|
| 615 | + } |
|
| 575 | 616 | } |
| 576 | 617 | |
| 577 | 618 | $failure = count($failed_files) >= 1; |
| 578 | 619 | |
| 579 | - if (!isset($_SERVER)) |
|
| 580 | - return !$failure; |
|
| 620 | + if (!isset($_SERVER)) { |
|
| 621 | + return !$failure; |
|
| 622 | + } |
|
| 581 | 623 | |
| 582 | 624 | // Put the list into context. |
| 583 | 625 | $incontext['failed_files'] = $failed_files; |
@@ -625,19 +667,23 @@ discard block |
||
| 625 | 667 | |
| 626 | 668 | if (!isset($ftp) || $ftp->error !== false) |
| 627 | 669 | { |
| 628 | - if (!isset($ftp)) |
|
| 629 | - $ftp = new ftp_connection(null); |
|
| 670 | + if (!isset($ftp)) { |
|
| 671 | + $ftp = new ftp_connection(null); |
|
| 672 | + } |
|
| 630 | 673 | // Save the error so we can mess with listing... |
| 631 | - elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) |
|
| 632 | - $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 674 | + elseif ($ftp->error !== false && empty($incontext['ftp_errors']) && !empty($ftp->last_message)) { |
|
| 675 | + $incontext['ftp_errors'][] = $ftp->last_message; |
|
| 676 | + } |
|
| 633 | 677 | |
| 634 | 678 | list ($username, $detect_path, $found_path) = $ftp->detect_path(dirname(__FILE__)); |
| 635 | 679 | |
| 636 | - if (empty($_POST['ftp_path']) && $found_path) |
|
| 637 | - $_POST['ftp_path'] = $detect_path; |
|
| 680 | + if (empty($_POST['ftp_path']) && $found_path) { |
|
| 681 | + $_POST['ftp_path'] = $detect_path; |
|
| 682 | + } |
|
| 638 | 683 | |
| 639 | - if (!isset($_POST['ftp_username'])) |
|
| 640 | - $_POST['ftp_username'] = $username; |
|
| 684 | + if (!isset($_POST['ftp_username'])) { |
|
| 685 | + $_POST['ftp_username'] = $username; |
|
| 686 | + } |
|
| 641 | 687 | |
| 642 | 688 | // Set the username etc, into context. |
| 643 | 689 | $incontext['ftp'] = array( |
@@ -649,8 +695,7 @@ discard block |
||
| 649 | 695 | ); |
| 650 | 696 | |
| 651 | 697 | return false; |
| 652 | - } |
|
| 653 | - else |
|
| 698 | + } else |
|
| 654 | 699 | { |
| 655 | 700 | $_SESSION['installer_temp_ftp'] = array( |
| 656 | 701 | 'server' => $_POST['ftp_server'], |
@@ -664,10 +709,12 @@ discard block |
||
| 664 | 709 | |
| 665 | 710 | foreach ($failed_files as $file) |
| 666 | 711 | { |
| 667 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 668 | - $ftp->chmod($file, 0755); |
|
| 669 | - if (!is_writable(dirname(__FILE__) . '/' . $file)) |
|
| 670 | - $ftp->chmod($file, 0777); |
|
| 712 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 713 | + $ftp->chmod($file, 0755); |
|
| 714 | + } |
|
| 715 | + if (!is_writable(dirname(__FILE__) . '/' . $file)) { |
|
| 716 | + $ftp->chmod($file, 0777); |
|
| 717 | + } |
|
| 671 | 718 | if (!is_writable(dirname(__FILE__) . '/' . $file)) |
| 672 | 719 | { |
| 673 | 720 | $failed_files_updated[] = $file; |
@@ -723,15 +770,17 @@ discard block |
||
| 723 | 770 | |
| 724 | 771 | if (!$foundOne) |
| 725 | 772 | { |
| 726 | - if (isset($db['default_host'])) |
|
| 727 | - $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 773 | + if (isset($db['default_host'])) { |
|
| 774 | + $incontext['db']['server'] = ini_get($db['default_host']) or $incontext['db']['server'] = 'localhost'; |
|
| 775 | + } |
|
| 728 | 776 | if (isset($db['default_user'])) |
| 729 | 777 | { |
| 730 | 778 | $incontext['db']['user'] = ini_get($db['default_user']); |
| 731 | 779 | $incontext['db']['name'] = ini_get($db['default_user']); |
| 732 | 780 | } |
| 733 | - if (isset($db['default_password'])) |
|
| 734 | - $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 781 | + if (isset($db['default_password'])) { |
|
| 782 | + $incontext['db']['pass'] = ini_get($db['default_password']); |
|
| 783 | + } |
|
| 735 | 784 | |
| 736 | 785 | // For simplicity and less confusion, leave the port blank by default |
| 737 | 786 | $incontext['db']['port'] = ''; |
@@ -750,10 +799,10 @@ discard block |
||
| 750 | 799 | $incontext['db']['server'] = $_POST['db_server']; |
| 751 | 800 | $incontext['db']['prefix'] = $_POST['db_prefix']; |
| 752 | 801 | |
| 753 | - if (!empty($_POST['db_port'])) |
|
| 754 | - $incontext['db']['port'] = $_POST['db_port']; |
|
| 755 | - } |
|
| 756 | - else |
|
| 802 | + if (!empty($_POST['db_port'])) { |
|
| 803 | + $incontext['db']['port'] = $_POST['db_port']; |
|
| 804 | + } |
|
| 805 | + } else |
|
| 757 | 806 | { |
| 758 | 807 | $incontext['db']['prefix'] = 'smf_'; |
| 759 | 808 | } |
@@ -789,10 +838,11 @@ discard block |
||
| 789 | 838 | if (!empty($_POST['db_port'])) |
| 790 | 839 | { |
| 791 | 840 | // For MySQL, we can get the "default port" from PHP. PostgreSQL has no such option though. |
| 792 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) |
|
| 793 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 794 | - elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) |
|
| 795 | - $vars['db_port'] = (int) $_POST['db_port']; |
|
| 841 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && $_POST['db_port'] != ini_get($db_type . '.default_port')) { |
|
| 842 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 843 | + } elseif ($db_type == 'postgresql' && $_POST['db_port'] != 5432) { |
|
| 844 | + $vars['db_port'] = (int) $_POST['db_port']; |
|
| 845 | + } |
|
| 796 | 846 | } |
| 797 | 847 | |
| 798 | 848 | // God I hope it saved! |
@@ -805,8 +855,9 @@ discard block |
||
| 805 | 855 | // Make sure it works. |
| 806 | 856 | require(dirname(__FILE__) . '/Settings.php'); |
| 807 | 857 | |
| 808 | - if (empty($sourcedir)) |
|
| 809 | - $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 858 | + if (empty($sourcedir)) { |
|
| 859 | + $sourcedir = dirname(__FILE__) . '/Sources'; |
|
| 860 | + } |
|
| 810 | 861 | |
| 811 | 862 | // Better find the database file! |
| 812 | 863 | if (!file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
@@ -816,18 +867,21 @@ discard block |
||
| 816 | 867 | } |
| 817 | 868 | |
| 818 | 869 | // Now include it for database functions! |
| 819 | - if (!defined('SMF')) |
|
| 820 | - define('SMF', 1); |
|
| 870 | + if (!defined('SMF')) { |
|
| 871 | + define('SMF', 1); |
|
| 872 | + } |
|
| 821 | 873 | |
| 822 | 874 | $modSettings['disableQueryCheck'] = true; |
| 823 | - if (empty($smcFunc)) |
|
| 824 | - $smcFunc = array(); |
|
| 875 | + if (empty($smcFunc)) { |
|
| 876 | + $smcFunc = array(); |
|
| 877 | + } |
|
| 825 | 878 | |
| 826 | 879 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
| 827 | 880 | |
| 828 | 881 | // What - running PHP4? The shame! |
| 829 | - if (version_compare(PHP_VERSION, '5', '<')) |
|
| 830 | - require_once($sourcedir . '/Subs-Compat.php'); |
|
| 882 | + if (version_compare(PHP_VERSION, '5', '<')) { |
|
| 883 | + require_once($sourcedir . '/Subs-Compat.php'); |
|
| 884 | + } |
|
| 831 | 885 | |
| 832 | 886 | // Attempt a connection. |
| 833 | 887 | $needsDB = !empty($databases[$db_type]['always_has_db']); |
@@ -915,12 +969,14 @@ discard block |
||
| 915 | 969 | $incontext['page_title'] = $txt['install_settings']; |
| 916 | 970 | |
| 917 | 971 | // Let's see if we got the database type correct. |
| 918 | - if (isset($_POST['db_type'], $databases[$_POST['db_type']])) |
|
| 919 | - $db_type = $_POST['db_type']; |
|
| 972 | + if (isset($_POST['db_type'], $databases[$_POST['db_type']])) { |
|
| 973 | + $db_type = $_POST['db_type']; |
|
| 974 | + } |
|
| 920 | 975 | |
| 921 | 976 | // Else we'd better be able to get the connection. |
| 922 | - else |
|
| 923 | - load_database(); |
|
| 977 | + else { |
|
| 978 | + load_database(); |
|
| 979 | + } |
|
| 924 | 980 | |
| 925 | 981 | $db_type = isset($_POST['db_type']) ? $_POST['db_type'] : $db_type; |
| 926 | 982 | |
@@ -957,18 +1013,21 @@ discard block |
||
| 957 | 1013 | // Submitting? |
| 958 | 1014 | if (isset($_POST['boardurl'])) |
| 959 | 1015 | { |
| 960 | - if (substr($_POST['boardurl'], -10) == '/index.php') |
|
| 961 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 962 | - elseif (substr($_POST['boardurl'], -1) == '/') |
|
| 963 | - $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 964 | - if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') |
|
| 965 | - $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1016 | + if (substr($_POST['boardurl'], -10) == '/index.php') { |
|
| 1017 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -10); |
|
| 1018 | + } elseif (substr($_POST['boardurl'], -1) == '/') { |
|
| 1019 | + $_POST['boardurl'] = substr($_POST['boardurl'], 0, -1); |
|
| 1020 | + } |
|
| 1021 | + if (substr($_POST['boardurl'], 0, 7) != 'http://' && substr($_POST['boardurl'], 0, 7) != 'file://' && substr($_POST['boardurl'], 0, 8) != 'https://') { |
|
| 1022 | + $_POST['boardurl'] = 'http://' . $_POST['boardurl']; |
|
| 1023 | + } |
|
| 966 | 1024 | |
| 967 | 1025 | //Make sure boardurl is aligned with ssl setting |
| 968 | - if (empty($_POST['force_ssl'])) |
|
| 969 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 970 | - else |
|
| 971 | - $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1026 | + if (empty($_POST['force_ssl'])) { |
|
| 1027 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('https://' => 'http://')); |
|
| 1028 | + } else { |
|
| 1029 | + $_POST['boardurl'] = strtr($_POST['boardurl'], array('http://' => 'https://')); |
|
| 1030 | + } |
|
| 972 | 1031 | |
| 973 | 1032 | // Save these variables. |
| 974 | 1033 | $vars = array( |
@@ -1007,10 +1066,10 @@ discard block |
||
| 1007 | 1066 | { |
| 1008 | 1067 | $incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']); |
| 1009 | 1068 | return false; |
| 1010 | - } |
|
| 1011 | - else |
|
| 1012 | - // Set the character set here. |
|
| 1069 | + } else { |
|
| 1070 | + // Set the character set here. |
|
| 1013 | 1071 | updateSettingsFile(array('db_character_set' => 'utf8')); |
| 1072 | + } |
|
| 1014 | 1073 | } |
| 1015 | 1074 | |
| 1016 | 1075 | // Good, skip on. |
@@ -1030,8 +1089,9 @@ discard block |
||
| 1030 | 1089 | $incontext['continue'] = 1; |
| 1031 | 1090 | |
| 1032 | 1091 | // Already done? |
| 1033 | - if (isset($_POST['pop_done'])) |
|
| 1034 | - return true; |
|
| 1092 | + if (isset($_POST['pop_done'])) { |
|
| 1093 | + return true; |
|
| 1094 | + } |
|
| 1035 | 1095 | |
| 1036 | 1096 | // Reload settings. |
| 1037 | 1097 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1049,8 +1109,9 @@ discard block |
||
| 1049 | 1109 | $modSettings = array(); |
| 1050 | 1110 | if ($result !== false) |
| 1051 | 1111 | { |
| 1052 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 1053 | - $modSettings[$row['variable']] = $row['value']; |
|
| 1112 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 1113 | + $modSettings[$row['variable']] = $row['value']; |
|
| 1114 | + } |
|
| 1054 | 1115 | $smcFunc['db_free_result']($result); |
| 1055 | 1116 | |
| 1056 | 1117 | // Do they match? If so, this is just a refresh so charge on! |
@@ -1063,20 +1124,22 @@ discard block |
||
| 1063 | 1124 | $modSettings['disableQueryCheck'] = true; |
| 1064 | 1125 | |
| 1065 | 1126 | // If doing UTF8, select it. PostgreSQL requires passing it as a string... |
| 1066 | - if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) |
|
| 1067 | - $smcFunc['db_query']('', ' |
|
| 1127 | + if (!empty($db_character_set) && $db_character_set == 'utf8' && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1128 | + $smcFunc['db_query']('', ' |
|
| 1068 | 1129 | SET NAMES {string:utf8}', |
| 1069 | 1130 | array( |
| 1070 | 1131 | 'db_error_skip' => true, |
| 1071 | 1132 | 'utf8' => 'utf8', |
| 1072 | 1133 | ) |
| 1073 | 1134 | ); |
| 1135 | + } |
|
| 1074 | 1136 | |
| 1075 | 1137 | // Windows likes to leave the trailing slash, which yields to C:\path\to\SMF\/attachments... |
| 1076 | - if (substr(__DIR__, -1) == '\\') |
|
| 1077 | - $attachdir = __DIR__ . 'attachments'; |
|
| 1078 | - else |
|
| 1079 | - $attachdir = __DIR__ . '/attachments'; |
|
| 1138 | + if (substr(__DIR__, -1) == '\\') { |
|
| 1139 | + $attachdir = __DIR__ . 'attachments'; |
|
| 1140 | + } else { |
|
| 1141 | + $attachdir = __DIR__ . '/attachments'; |
|
| 1142 | + } |
|
| 1080 | 1143 | |
| 1081 | 1144 | $replaces = array( |
| 1082 | 1145 | '{$db_prefix}' => $db_prefix, |
@@ -1093,8 +1156,9 @@ discard block |
||
| 1093 | 1156 | |
| 1094 | 1157 | foreach ($txt as $key => $value) |
| 1095 | 1158 | { |
| 1096 | - if (substr($key, 0, 8) == 'default_') |
|
| 1097 | - $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1159 | + if (substr($key, 0, 8) == 'default_') { |
|
| 1160 | + $replaces['{$' . $key . '}'] = $smcFunc['db_escape_string']($value); |
|
| 1161 | + } |
|
| 1098 | 1162 | } |
| 1099 | 1163 | $replaces['{$default_reserved_names}'] = strtr($replaces['{$default_reserved_names}'], array('\\\\n' => '\\n')); |
| 1100 | 1164 | |
@@ -1109,8 +1173,9 @@ discard block |
||
| 1109 | 1173 | |
| 1110 | 1174 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
| 1111 | 1175 | { |
| 1112 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
| 1113 | - $engines[] = $row['Engine']; |
|
| 1176 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
| 1177 | + $engines[] = $row['Engine']; |
|
| 1178 | + } |
|
| 1114 | 1179 | } |
| 1115 | 1180 | |
| 1116 | 1181 | // Done with this now |
@@ -1134,8 +1199,7 @@ discard block |
||
| 1134 | 1199 | $replaces['START TRANSACTION;'] = ''; |
| 1135 | 1200 | $replaces['COMMIT;'] = ''; |
| 1136 | 1201 | } |
| 1137 | - } |
|
| 1138 | - else |
|
| 1202 | + } else |
|
| 1139 | 1203 | { |
| 1140 | 1204 | $has_innodb = false; |
| 1141 | 1205 | } |
@@ -1157,21 +1221,24 @@ discard block |
||
| 1157 | 1221 | foreach ($sql_lines as $count => $line) |
| 1158 | 1222 | { |
| 1159 | 1223 | // No comments allowed! |
| 1160 | - if (substr(trim($line), 0, 1) != '#') |
|
| 1161 | - $current_statement .= "\n" . rtrim($line); |
|
| 1224 | + if (substr(trim($line), 0, 1) != '#') { |
|
| 1225 | + $current_statement .= "\n" . rtrim($line); |
|
| 1226 | + } |
|
| 1162 | 1227 | |
| 1163 | 1228 | // Is this the end of the query string? |
| 1164 | - if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) |
|
| 1165 | - continue; |
|
| 1229 | + if (empty($current_statement) || (preg_match('~;[\s]*$~s', $line) == 0 && $count != count($sql_lines))) { |
|
| 1230 | + continue; |
|
| 1231 | + } |
|
| 1166 | 1232 | |
| 1167 | 1233 | // Does this table already exist? If so, don't insert more data into it! |
| 1168 | 1234 | if (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) != 0 && in_array($match[1], $exists)) |
| 1169 | 1235 | { |
| 1170 | 1236 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1171 | - if (!empty($matches[0])) |
|
| 1172 | - $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1173 | - else |
|
| 1174 | - $incontext['sql_results']['insert_dups']++; |
|
| 1237 | + if (!empty($matches[0])) { |
|
| 1238 | + $incontext['sql_results']['insert_dups'] += count($matches[0]); |
|
| 1239 | + } else { |
|
| 1240 | + $incontext['sql_results']['insert_dups']++; |
|
| 1241 | + } |
|
| 1175 | 1242 | |
| 1176 | 1243 | $current_statement = ''; |
| 1177 | 1244 | continue; |
@@ -1180,8 +1247,9 @@ discard block |
||
| 1180 | 1247 | if ($smcFunc['db_query']('', $current_statement, array('security_override' => true, 'db_error_skip' => true), $db_connection) === false) |
| 1181 | 1248 | { |
| 1182 | 1249 | // Use the appropriate function based on the DB type |
| 1183 | - if ($db_type == 'mysql' || $db_type == 'mysqli') |
|
| 1184 | - $db_errorno = $db_type . '_errno'; |
|
| 1250 | + if ($db_type == 'mysql' || $db_type == 'mysqli') { |
|
| 1251 | + $db_errorno = $db_type . '_errno'; |
|
| 1252 | + } |
|
| 1185 | 1253 | |
| 1186 | 1254 | // Error 1050: Table already exists! |
| 1187 | 1255 | // @todo Needs to be made better! |
@@ -1196,18 +1264,18 @@ discard block |
||
| 1196 | 1264 | // MySQLi requires a connection object. It's optional with MySQL and Postgres |
| 1197 | 1265 | $incontext['failures'][$count] = $smcFunc['db_error']($db_connection); |
| 1198 | 1266 | } |
| 1199 | - } |
|
| 1200 | - else |
|
| 1267 | + } else |
|
| 1201 | 1268 | { |
| 1202 | - if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1203 | - $incontext['sql_results']['tables']++; |
|
| 1204 | - elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1269 | + if (preg_match('~^\s*CREATE TABLE ([^\s\n\r]+?)~', $current_statement, $match) == 1) { |
|
| 1270 | + $incontext['sql_results']['tables']++; |
|
| 1271 | + } elseif (preg_match('~^\s*INSERT INTO ([^\s\n\r]+?)~', $current_statement, $match) == 1) |
|
| 1205 | 1272 | { |
| 1206 | 1273 | preg_match_all('~\)[,;]~', $current_statement, $matches); |
| 1207 | - if (!empty($matches[0])) |
|
| 1208 | - $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1209 | - else |
|
| 1210 | - $incontext['sql_results']['inserts']++; |
|
| 1274 | + if (!empty($matches[0])) { |
|
| 1275 | + $incontext['sql_results']['inserts'] += count($matches[0]); |
|
| 1276 | + } else { |
|
| 1277 | + $incontext['sql_results']['inserts']++; |
|
| 1278 | + } |
|
| 1211 | 1279 | } |
| 1212 | 1280 | } |
| 1213 | 1281 | |
@@ -1220,15 +1288,17 @@ discard block |
||
| 1220 | 1288 | // Sort out the context for the SQL. |
| 1221 | 1289 | foreach ($incontext['sql_results'] as $key => $number) |
| 1222 | 1290 | { |
| 1223 | - if ($number == 0) |
|
| 1224 | - unset($incontext['sql_results'][$key]); |
|
| 1225 | - else |
|
| 1226 | - $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1291 | + if ($number == 0) { |
|
| 1292 | + unset($incontext['sql_results'][$key]); |
|
| 1293 | + } else { |
|
| 1294 | + $incontext['sql_results'][$key] = sprintf($txt['db_populate_' . $key], $number); |
|
| 1295 | + } |
|
| 1227 | 1296 | } |
| 1228 | 1297 | |
| 1229 | 1298 | // Make sure UTF will be used globally. |
| 1230 | - if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) |
|
| 1231 | - $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1299 | + if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8']))) { |
|
| 1300 | + $newSettings[] = array('global_character_set', 'UTF-8'); |
|
| 1301 | + } |
|
| 1232 | 1302 | |
| 1233 | 1303 | // Auto-detect local & global cookie settings |
| 1234 | 1304 | $url_parts = parse_url($boardurl); |
@@ -1257,15 +1327,19 @@ discard block |
||
| 1257 | 1327 | |
| 1258 | 1328 | // Look for subfolder, if found, set localCookie |
| 1259 | 1329 | // Checking for len > 1 ensures you don't have just a slash... |
| 1260 | - if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) |
|
| 1261 | - $localCookies = '1'; |
|
| 1330 | + if (!empty($url_parts['path']) && strlen($url_parts['path']) > 1) { |
|
| 1331 | + $localCookies = '1'; |
|
| 1332 | + } |
|
| 1262 | 1333 | |
| 1263 | - if (isset($globalCookies)) |
|
| 1264 | - $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1265 | - if (isset($globalCookiesDomain)) |
|
| 1266 | - $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1267 | - if (isset($localCookies)) |
|
| 1268 | - $newSettings[] = array('localCookies', $localCookies); |
|
| 1334 | + if (isset($globalCookies)) { |
|
| 1335 | + $newSettings[] = array('globalCookies', $globalCookies); |
|
| 1336 | + } |
|
| 1337 | + if (isset($globalCookiesDomain)) { |
|
| 1338 | + $newSettings[] = array('globalCookiesDomain', $globalCookiesDomain); |
|
| 1339 | + } |
|
| 1340 | + if (isset($localCookies)) { |
|
| 1341 | + $newSettings[] = array('localCookies', $localCookies); |
|
| 1342 | + } |
|
| 1269 | 1343 | } |
| 1270 | 1344 | |
| 1271 | 1345 | // Are we allowing stat collection? |
@@ -1283,16 +1357,17 @@ discard block |
||
| 1283 | 1357 | fwrite($fp, $out); |
| 1284 | 1358 | |
| 1285 | 1359 | $return_data = ''; |
| 1286 | - while (!feof($fp)) |
|
| 1287 | - $return_data .= fgets($fp, 128); |
|
| 1360 | + while (!feof($fp)) { |
|
| 1361 | + $return_data .= fgets($fp, 128); |
|
| 1362 | + } |
|
| 1288 | 1363 | |
| 1289 | 1364 | fclose($fp); |
| 1290 | 1365 | |
| 1291 | 1366 | // Get the unique site ID. |
| 1292 | 1367 | preg_match('~SITE-ID:\s(\w{10})~', $return_data, $ID); |
| 1293 | 1368 | |
| 1294 | - if (!empty($ID[1])) |
|
| 1295 | - $smcFunc['db_insert']('replace', |
|
| 1369 | + if (!empty($ID[1])) { |
|
| 1370 | + $smcFunc['db_insert']('replace', |
|
| 1296 | 1371 | $db_prefix . 'settings', |
| 1297 | 1372 | array('variable' => 'string', 'value' => 'string'), |
| 1298 | 1373 | array( |
@@ -1301,11 +1376,12 @@ discard block |
||
| 1301 | 1376 | ), |
| 1302 | 1377 | array('variable') |
| 1303 | 1378 | ); |
| 1379 | + } |
|
| 1304 | 1380 | } |
| 1305 | 1381 | } |
| 1306 | 1382 | // Don't remove stat collection unless we unchecked the box for real, not from the loop. |
| 1307 | - elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) |
|
| 1308 | - $smcFunc['db_query']('', ' |
|
| 1383 | + elseif (empty($_POST['stats']) && empty($upcontext['allow_sm_stats'])) { |
|
| 1384 | + $smcFunc['db_query']('', ' |
|
| 1309 | 1385 | DELETE FROM {db_prefix}settings |
| 1310 | 1386 | WHERE variable = {string:enable_sm_stats}', |
| 1311 | 1387 | array( |
@@ -1313,20 +1389,23 @@ discard block |
||
| 1313 | 1389 | 'db_error_skip' => true, |
| 1314 | 1390 | ) |
| 1315 | 1391 | ); |
| 1392 | + } |
|
| 1316 | 1393 | |
| 1317 | 1394 | // Are we enabling SSL? |
| 1318 | - if (!empty($_POST['force_ssl'])) |
|
| 1319 | - $newSettings[] = array('force_ssl', 2); |
|
| 1395 | + if (!empty($_POST['force_ssl'])) { |
|
| 1396 | + $newSettings[] = array('force_ssl', 2); |
|
| 1397 | + } |
|
| 1320 | 1398 | |
| 1321 | 1399 | // Setting a timezone is required. |
| 1322 | 1400 | if (!isset($modSettings['default_timezone']) && function_exists('date_default_timezone_set')) |
| 1323 | 1401 | { |
| 1324 | 1402 | // Get PHP's default timezone, if set |
| 1325 | 1403 | $ini_tz = ini_get('date.timezone'); |
| 1326 | - if (!empty($ini_tz)) |
|
| 1327 | - $timezone_id = $ini_tz; |
|
| 1328 | - else |
|
| 1329 | - $timezone_id = ''; |
|
| 1404 | + if (!empty($ini_tz)) { |
|
| 1405 | + $timezone_id = $ini_tz; |
|
| 1406 | + } else { |
|
| 1407 | + $timezone_id = ''; |
|
| 1408 | + } |
|
| 1330 | 1409 | |
| 1331 | 1410 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
| 1332 | 1411 | if (!in_array($timezone_id, timezone_identifiers_list())) |
@@ -1335,8 +1414,9 @@ discard block |
||
| 1335 | 1414 | $timezone_id = timezone_name_from_abbr('', $server_offset, 0); |
| 1336 | 1415 | } |
| 1337 | 1416 | |
| 1338 | - if (date_default_timezone_set($timezone_id)) |
|
| 1339 | - $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1417 | + if (date_default_timezone_set($timezone_id)) { |
|
| 1418 | + $newSettings[] = array('default_timezone', $timezone_id); |
|
| 1419 | + } |
|
| 1340 | 1420 | } |
| 1341 | 1421 | |
| 1342 | 1422 | if (!empty($newSettings)) |
@@ -1367,16 +1447,18 @@ discard block |
||
| 1367 | 1447 | } |
| 1368 | 1448 | |
| 1369 | 1449 | // MySQL specific stuff |
| 1370 | - if (substr($db_type, 0, 5) != 'mysql') |
|
| 1371 | - return false; |
|
| 1450 | + if (substr($db_type, 0, 5) != 'mysql') { |
|
| 1451 | + return false; |
|
| 1452 | + } |
|
| 1372 | 1453 | |
| 1373 | 1454 | // Find database user privileges. |
| 1374 | 1455 | $privs = array(); |
| 1375 | 1456 | $get_privs = $smcFunc['db_query']('', 'SHOW PRIVILEGES', array()); |
| 1376 | 1457 | while ($row = $smcFunc['db_fetch_assoc']($get_privs)) |
| 1377 | 1458 | { |
| 1378 | - if ($row['Privilege'] == 'Alter') |
|
| 1379 | - $privs[] = $row['Privilege']; |
|
| 1459 | + if ($row['Privilege'] == 'Alter') { |
|
| 1460 | + $privs[] = $row['Privilege']; |
|
| 1461 | + } |
|
| 1380 | 1462 | } |
| 1381 | 1463 | $smcFunc['db_free_result']($get_privs); |
| 1382 | 1464 | |
@@ -1406,8 +1488,9 @@ discard block |
||
| 1406 | 1488 | $incontext['continue'] = 1; |
| 1407 | 1489 | |
| 1408 | 1490 | // Skipping? |
| 1409 | - if (!empty($_POST['skip'])) |
|
| 1410 | - return true; |
|
| 1491 | + if (!empty($_POST['skip'])) { |
|
| 1492 | + return true; |
|
| 1493 | + } |
|
| 1411 | 1494 | |
| 1412 | 1495 | // Need this to check whether we need the database password. |
| 1413 | 1496 | require(dirname(__FILE__) . '/Settings.php'); |
@@ -1424,18 +1507,22 @@ discard block |
||
| 1424 | 1507 | // We need this to properly hash the password for Admin |
| 1425 | 1508 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : function($string) { |
| 1426 | 1509 | global $sourcedir; |
| 1427 | - if (function_exists('mb_strtolower')) |
|
| 1428 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1510 | + if (function_exists('mb_strtolower')) { |
|
| 1511 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1512 | + } |
|
| 1429 | 1513 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1430 | 1514 | return utf8_strtolower($string); |
| 1431 | 1515 | }; |
| 1432 | 1516 | |
| 1433 | - if (!isset($_POST['username'])) |
|
| 1434 | - $_POST['username'] = ''; |
|
| 1435 | - if (!isset($_POST['email'])) |
|
| 1436 | - $_POST['email'] = ''; |
|
| 1437 | - if (!isset($_POST['server_email'])) |
|
| 1438 | - $_POST['server_email'] = ''; |
|
| 1517 | + if (!isset($_POST['username'])) { |
|
| 1518 | + $_POST['username'] = ''; |
|
| 1519 | + } |
|
| 1520 | + if (!isset($_POST['email'])) { |
|
| 1521 | + $_POST['email'] = ''; |
|
| 1522 | + } |
|
| 1523 | + if (!isset($_POST['server_email'])) { |
|
| 1524 | + $_POST['server_email'] = ''; |
|
| 1525 | + } |
|
| 1439 | 1526 | |
| 1440 | 1527 | $incontext['username'] = htmlspecialchars(stripslashes($_POST['username'])); |
| 1441 | 1528 | $incontext['email'] = htmlspecialchars(stripslashes($_POST['email'])); |
@@ -1454,8 +1541,9 @@ discard block |
||
| 1454 | 1541 | 'admin_group' => 1, |
| 1455 | 1542 | ) |
| 1456 | 1543 | ); |
| 1457 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 1458 | - $incontext['skip'] = 1; |
|
| 1544 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 1545 | + $incontext['skip'] = 1; |
|
| 1546 | + } |
|
| 1459 | 1547 | $smcFunc['db_free_result']($request); |
| 1460 | 1548 | |
| 1461 | 1549 | // Trying to create an account? |
@@ -1486,8 +1574,9 @@ discard block |
||
| 1486 | 1574 | } |
| 1487 | 1575 | |
| 1488 | 1576 | // Update the webmaster's email? |
| 1489 | - if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) |
|
| 1490 | - updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1577 | + if (!empty($_POST['server_email']) && (empty($webmaster_email) || $webmaster_email == '[email protected]')) { |
|
| 1578 | + updateSettingsFile(array('webmaster_email' => $_POST['server_email'])); |
|
| 1579 | + } |
|
| 1491 | 1580 | |
| 1492 | 1581 | // Work out whether we're going to have dodgy characters and remove them. |
| 1493 | 1582 | $invalid_characters = preg_match('~[<>&"\'=\\\]~', $_POST['username']) != 0; |
@@ -1510,32 +1599,27 @@ discard block |
||
| 1510 | 1599 | $smcFunc['db_free_result']($result); |
| 1511 | 1600 | |
| 1512 | 1601 | $incontext['account_existed'] = $txt['error_user_settings_taken']; |
| 1513 | - } |
|
| 1514 | - elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1602 | + } elseif ($_POST['username'] == '' || strlen($_POST['username']) > 25) |
|
| 1515 | 1603 | { |
| 1516 | 1604 | // Try the previous step again. |
| 1517 | 1605 | $incontext['error'] = $_POST['username'] == '' ? $txt['error_username_left_empty'] : $txt['error_username_too_long']; |
| 1518 | 1606 | return false; |
| 1519 | - } |
|
| 1520 | - elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1607 | + } elseif ($invalid_characters || $_POST['username'] == '_' || $_POST['username'] == '|' || strpos($_POST['username'], '[code') !== false || strpos($_POST['username'], '[/code') !== false) |
|
| 1521 | 1608 | { |
| 1522 | 1609 | // Try the previous step again. |
| 1523 | 1610 | $incontext['error'] = $txt['error_invalid_characters_username']; |
| 1524 | 1611 | return false; |
| 1525 | - } |
|
| 1526 | - elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1612 | + } elseif (empty($_POST['email']) || !filter_var(stripslashes($_POST['email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['email'])) > 255) |
|
| 1527 | 1613 | { |
| 1528 | 1614 | // One step back, this time fill out a proper admin email address. |
| 1529 | 1615 | $incontext['error'] = sprintf($txt['error_valid_admin_email_needed'], $_POST['username']); |
| 1530 | 1616 | return false; |
| 1531 | - } |
|
| 1532 | - elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1617 | + } elseif (empty($_POST['server_email']) || !filter_var(stripslashes($_POST['server_email']), FILTER_VALIDATE_EMAIL) || strlen(stripslashes($_POST['server_email'])) > 255) |
|
| 1533 | 1618 | { |
| 1534 | 1619 | // One step back, this time fill out a proper admin email address. |
| 1535 | 1620 | $incontext['error'] = $txt['error_valid_server_email_needed']; |
| 1536 | 1621 | return false; |
| 1537 | - } |
|
| 1538 | - elseif ($_POST['username'] != '') |
|
| 1622 | + } elseif ($_POST['username'] != '') |
|
| 1539 | 1623 | { |
| 1540 | 1624 | $incontext['member_salt'] = substr(md5(mt_rand()), 0, 4); |
| 1541 | 1625 | |
@@ -1603,17 +1687,19 @@ discard block |
||
| 1603 | 1687 | reloadSettings(); |
| 1604 | 1688 | |
| 1605 | 1689 | // Bring a warning over. |
| 1606 | - if (!empty($incontext['account_existed'])) |
|
| 1607 | - $incontext['warning'] = $incontext['account_existed']; |
|
| 1690 | + if (!empty($incontext['account_existed'])) { |
|
| 1691 | + $incontext['warning'] = $incontext['account_existed']; |
|
| 1692 | + } |
|
| 1608 | 1693 | |
| 1609 | - if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) |
|
| 1610 | - $smcFunc['db_query']('', ' |
|
| 1694 | + if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) { |
|
| 1695 | + $smcFunc['db_query']('', ' |
|
| 1611 | 1696 | SET NAMES {string:db_character_set}', |
| 1612 | 1697 | array( |
| 1613 | 1698 | 'db_character_set' => $db_character_set, |
| 1614 | 1699 | 'db_error_skip' => true, |
| 1615 | 1700 | ) |
| 1616 | 1701 | ); |
| 1702 | + } |
|
| 1617 | 1703 | |
| 1618 | 1704 | // As track stats is by default enabled let's add some activity. |
| 1619 | 1705 | $smcFunc['db_insert']('ignore', |
@@ -1634,14 +1720,16 @@ discard block |
||
| 1634 | 1720 | // Only proceed if we can load the data. |
| 1635 | 1721 | if ($request) |
| 1636 | 1722 | { |
| 1637 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 1638 | - $modSettings[$row[0]] = $row[1]; |
|
| 1723 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 1724 | + $modSettings[$row[0]] = $row[1]; |
|
| 1725 | + } |
|
| 1639 | 1726 | $smcFunc['db_free_result']($request); |
| 1640 | 1727 | } |
| 1641 | 1728 | |
| 1642 | 1729 | // Automatically log them in ;) |
| 1643 | - if (isset($incontext['member_id']) && isset($incontext['member_salt'])) |
|
| 1644 | - setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1730 | + if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { |
|
| 1731 | + setLoginCookie(3153600 * 60, $incontext['member_id'], hash_salt($_POST['password1'], $incontext['member_salt'])); |
|
| 1732 | + } |
|
| 1645 | 1733 | |
| 1646 | 1734 | $result = $smcFunc['db_query']('', ' |
| 1647 | 1735 | SELECT value |
@@ -1652,13 +1740,14 @@ discard block |
||
| 1652 | 1740 | 'db_error_skip' => true, |
| 1653 | 1741 | ) |
| 1654 | 1742 | ); |
| 1655 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
| 1656 | - list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1743 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
| 1744 | + list ($db_sessions) = $smcFunc['db_fetch_row']($result); |
|
| 1745 | + } |
|
| 1657 | 1746 | $smcFunc['db_free_result']($result); |
| 1658 | 1747 | |
| 1659 | - if (empty($db_sessions)) |
|
| 1660 | - $_SESSION['admin_time'] = time(); |
|
| 1661 | - else |
|
| 1748 | + if (empty($db_sessions)) { |
|
| 1749 | + $_SESSION['admin_time'] = time(); |
|
| 1750 | + } else |
|
| 1662 | 1751 | { |
| 1663 | 1752 | $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); |
| 1664 | 1753 | |
@@ -1682,8 +1771,9 @@ discard block |
||
| 1682 | 1771 | $smcFunc['strtolower'] = $db_character_set != 'utf8' && $txt['lang_character_set'] != 'UTF-8' ? 'strtolower' : |
| 1683 | 1772 | function($string){ |
| 1684 | 1773 | global $sourcedir; |
| 1685 | - if (function_exists('mb_strtolower')) |
|
| 1686 | - return mb_strtolower($string, 'UTF-8'); |
|
| 1774 | + if (function_exists('mb_strtolower')) { |
|
| 1775 | + return mb_strtolower($string, 'UTF-8'); |
|
| 1776 | + } |
|
| 1687 | 1777 | require_once($sourcedir . '/Subs-Charset.php'); |
| 1688 | 1778 | return utf8_strtolower($string); |
| 1689 | 1779 | }; |
@@ -1699,8 +1789,9 @@ discard block |
||
| 1699 | 1789 | ) |
| 1700 | 1790 | ); |
| 1701 | 1791 | $context['utf8'] = $db_character_set === 'utf8' || $txt['lang_character_set'] === 'UTF-8'; |
| 1702 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
| 1703 | - updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1792 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
| 1793 | + updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); |
|
| 1794 | + } |
|
| 1704 | 1795 | $smcFunc['db_free_result']($request); |
| 1705 | 1796 | |
| 1706 | 1797 | // Now is the perfect time to fetch the SM files. |
@@ -1719,8 +1810,9 @@ discard block |
||
| 1719 | 1810 | |
| 1720 | 1811 | // Check if we need some stupid MySQL fix. |
| 1721 | 1812 | $server_version = $smcFunc['db_server_info'](); |
| 1722 | - if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) |
|
| 1723 | - updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1813 | + if (($db_type == 'mysql' || $db_type == 'mysqli') && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { |
|
| 1814 | + updateSettings(array('db_mysql_group_by_fix' => '1')); |
|
| 1815 | + } |
|
| 1724 | 1816 | |
| 1725 | 1817 | // Some final context for the template. |
| 1726 | 1818 | $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; |
@@ -1740,8 +1832,9 @@ discard block |
||
| 1740 | 1832 | $settingsArray = file(dirname(__FILE__) . '/Settings.php'); |
| 1741 | 1833 | |
| 1742 | 1834 | // @todo Do we just want to read the file in clean, and split it this way always? |
| 1743 | - if (count($settingsArray) == 1) |
|
| 1744 | - $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1835 | + if (count($settingsArray) == 1) { |
|
| 1836 | + $settingsArray = preg_split('~[\r\n]~', $settingsArray[0]); |
|
| 1837 | + } |
|
| 1745 | 1838 | |
| 1746 | 1839 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
| 1747 | 1840 | { |
@@ -1756,19 +1849,22 @@ discard block |
||
| 1756 | 1849 | continue; |
| 1757 | 1850 | } |
| 1758 | 1851 | |
| 1759 | - if (trim($settingsArray[$i]) == '?' . '>') |
|
| 1760 | - $settingsArray[$i] = ''; |
|
| 1852 | + if (trim($settingsArray[$i]) == '?' . '>') { |
|
| 1853 | + $settingsArray[$i] = ''; |
|
| 1854 | + } |
|
| 1761 | 1855 | |
| 1762 | 1856 | // Don't trim or bother with it if it's not a variable. |
| 1763 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
| 1764 | - continue; |
|
| 1857 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
| 1858 | + continue; |
|
| 1859 | + } |
|
| 1765 | 1860 | |
| 1766 | 1861 | $settingsArray[$i] = rtrim($settingsArray[$i]) . "\n"; |
| 1767 | 1862 | |
| 1768 | - foreach ($vars as $var => $val) |
|
| 1769 | - if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1863 | + foreach ($vars as $var => $val) { |
|
| 1864 | + if (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
| 1770 | 1865 | { |
| 1771 | 1866 | $comment = strstr($settingsArray[$i], '#'); |
| 1867 | + } |
|
| 1772 | 1868 | $settingsArray[$i] = '$' . $var . ' = \'' . $val . '\';' . ($comment != '' ? "\t\t" . $comment : "\n"); |
| 1773 | 1869 | unset($vars[$var]); |
| 1774 | 1870 | } |
@@ -1778,36 +1874,41 @@ discard block |
||
| 1778 | 1874 | if (!empty($vars)) |
| 1779 | 1875 | { |
| 1780 | 1876 | $settingsArray[$i++] = ''; |
| 1781 | - foreach ($vars as $var => $val) |
|
| 1782 | - $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1877 | + foreach ($vars as $var => $val) { |
|
| 1878 | + $settingsArray[$i++] = '$' . $var . ' = \'' . $val . '\';' . "\n"; |
|
| 1879 | + } |
|
| 1783 | 1880 | } |
| 1784 | 1881 | |
| 1785 | 1882 | // Blank out the file - done to fix a oddity with some servers. |
| 1786 | 1883 | $fp = @fopen(dirname(__FILE__) . '/Settings.php', 'w'); |
| 1787 | - if (!$fp) |
|
| 1788 | - return false; |
|
| 1884 | + if (!$fp) { |
|
| 1885 | + return false; |
|
| 1886 | + } |
|
| 1789 | 1887 | fclose($fp); |
| 1790 | 1888 | |
| 1791 | 1889 | $fp = fopen(dirname(__FILE__) . '/Settings.php', 'r+'); |
| 1792 | 1890 | |
| 1793 | 1891 | // Gotta have one of these ;) |
| 1794 | - if (trim($settingsArray[0]) != '<?php') |
|
| 1795 | - fwrite($fp, "<?php\n"); |
|
| 1892 | + if (trim($settingsArray[0]) != '<?php') { |
|
| 1893 | + fwrite($fp, "<?php\n"); |
|
| 1894 | + } |
|
| 1796 | 1895 | |
| 1797 | 1896 | $lines = count($settingsArray); |
| 1798 | 1897 | for ($i = 0; $i < $lines - 1; $i++) |
| 1799 | 1898 | { |
| 1800 | 1899 | // Don't just write a bunch of blank lines. |
| 1801 | - if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') |
|
| 1802 | - fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1900 | + if ($settingsArray[$i] != '' || @$settingsArray[$i - 1] != '') { |
|
| 1901 | + fwrite($fp, strtr($settingsArray[$i], "\r", '')); |
|
| 1902 | + } |
|
| 1803 | 1903 | } |
| 1804 | 1904 | fwrite($fp, $settingsArray[$i] . '?' . '>'); |
| 1805 | 1905 | fclose($fp); |
| 1806 | 1906 | |
| 1807 | 1907 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
| 1808 | 1908 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
| 1809 | - if (function_exists('opcache_invalidate')) |
|
| 1810 | - opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1909 | + if (function_exists('opcache_invalidate')) { |
|
| 1910 | + opcache_invalidate(dirname(__FILE__) . '/Settings.php', true); |
|
| 1911 | + } |
|
| 1811 | 1912 | |
| 1812 | 1913 | return true; |
| 1813 | 1914 | } |
@@ -1832,9 +1933,9 @@ discard block |
||
| 1832 | 1933 | SecFilterScanPOST Off |
| 1833 | 1934 | </IfModule>'; |
| 1834 | 1935 | |
| 1835 | - if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) |
|
| 1836 | - return true; |
|
| 1837 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1936 | + if (!function_exists('apache_get_modules') || !in_array('mod_security', apache_get_modules())) { |
|
| 1937 | + return true; |
|
| 1938 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess') && is_writable(dirname(__FILE__) . '/.htaccess')) |
|
| 1838 | 1939 | { |
| 1839 | 1940 | $current_htaccess = implode('', file(dirname(__FILE__) . '/.htaccess')); |
| 1840 | 1941 | |
@@ -1846,29 +1947,28 @@ discard block |
||
| 1846 | 1947 | fwrite($ht_handle, $htaccess_addition); |
| 1847 | 1948 | fclose($ht_handle); |
| 1848 | 1949 | return true; |
| 1950 | + } else { |
|
| 1951 | + return false; |
|
| 1849 | 1952 | } |
| 1850 | - else |
|
| 1851 | - return false; |
|
| 1953 | + } else { |
|
| 1954 | + return true; |
|
| 1852 | 1955 | } |
| 1853 | - else |
|
| 1854 | - return true; |
|
| 1855 | - } |
|
| 1856 | - elseif (file_exists(dirname(__FILE__) . '/.htaccess')) |
|
| 1857 | - return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1858 | - elseif (is_writable(dirname(__FILE__))) |
|
| 1956 | + } elseif (file_exists(dirname(__FILE__) . '/.htaccess')) { |
|
| 1957 | + return strpos(implode('', file(dirname(__FILE__) . '/.htaccess')), '<IfModule mod_security.c>') !== false; |
|
| 1958 | + } elseif (is_writable(dirname(__FILE__))) |
|
| 1859 | 1959 | { |
| 1860 | 1960 | if ($ht_handle = fopen(dirname(__FILE__) . '/.htaccess', 'w')) |
| 1861 | 1961 | { |
| 1862 | 1962 | fwrite($ht_handle, $htaccess_addition); |
| 1863 | 1963 | fclose($ht_handle); |
| 1864 | 1964 | return true; |
| 1965 | + } else { |
|
| 1966 | + return false; |
|
| 1865 | 1967 | } |
| 1866 | - else |
|
| 1968 | + } else { |
|
| 1867 | 1969 | return false; |
| 1868 | 1970 | } |
| 1869 | - else |
|
| 1870 | - return false; |
|
| 1871 | -} |
|
| 1971 | + } |
|
| 1872 | 1972 | |
| 1873 | 1973 | function template_install_above() |
| 1874 | 1974 | { |
@@ -1906,9 +2006,10 @@ discard block |
||
| 1906 | 2006 | <label for="installer_language">', $txt['installer_language'], ':</label> |
| 1907 | 2007 | <select id="installer_language" name="lang_file" onchange="location.href = \'', $installurl, '?lang_file=\' + this.options[this.selectedIndex].value;">'; |
| 1908 | 2008 | |
| 1909 | - foreach ($incontext['detected_languages'] as $lang => $name) |
|
| 1910 | - echo ' |
|
| 2009 | + foreach ($incontext['detected_languages'] as $lang => $name) { |
|
| 2010 | + echo ' |
|
| 1911 | 2011 | <option', isset($_SESSION['installer_temp_lang']) && $_SESSION['installer_temp_lang'] == $lang ? ' selected' : '', ' value="', $lang, '">', $name, '</option>'; |
| 2012 | + } |
|
| 1912 | 2013 | |
| 1913 | 2014 | echo ' |
| 1914 | 2015 | </select> |
@@ -1928,9 +2029,10 @@ discard block |
||
| 1928 | 2029 | <h2>', $txt['upgrade_progress'], '</h2> |
| 1929 | 2030 | <ul>'; |
| 1930 | 2031 | |
| 1931 | - foreach ($incontext['steps'] as $num => $step) |
|
| 1932 | - echo ' |
|
| 2032 | + foreach ($incontext['steps'] as $num => $step) { |
|
| 2033 | + echo ' |
|
| 1933 | 2034 | <li class="', $num < $incontext['current_step'] ? 'stepdone' : ($num == $incontext['current_step'] ? 'stepcurrent' : 'stepwaiting'), '">', $txt['upgrade_step'], ' ', $step[0], ': ', $step[1], '</li>'; |
| 2035 | + } |
|
| 1934 | 2036 | |
| 1935 | 2037 | echo ' |
| 1936 | 2038 | </ul> |
@@ -1955,20 +2057,23 @@ discard block |
||
| 1955 | 2057 | echo ' |
| 1956 | 2058 | <div class="floatright">'; |
| 1957 | 2059 | |
| 1958 | - if (!empty($incontext['continue'])) |
|
| 1959 | - echo ' |
|
| 2060 | + if (!empty($incontext['continue'])) { |
|
| 2061 | + echo ' |
|
| 1960 | 2062 | <input type="submit" id="contbutt" name="contbutt" value="', $txt['upgrade_continue'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 1961 | - if (!empty($incontext['skip'])) |
|
| 1962 | - echo ' |
|
| 2063 | + } |
|
| 2064 | + if (!empty($incontext['skip'])) { |
|
| 2065 | + echo ' |
|
| 1963 | 2066 | <input type="submit" id="skip" name="skip" value="', $txt['upgrade_skip'], '" onclick="return submitThisOnce(this);" class="button" />'; |
| 2067 | + } |
|
| 1964 | 2068 | echo ' |
| 1965 | 2069 | </div>'; |
| 1966 | 2070 | } |
| 1967 | 2071 | |
| 1968 | 2072 | // Show the closing form tag and other data only if not in the last step |
| 1969 | - if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) |
|
| 1970 | - echo ' |
|
| 2073 | + if (count($incontext['steps']) - 1 !== (int) $incontext['current_step']) { |
|
| 2074 | + echo ' |
|
| 1971 | 2075 | </form>'; |
| 2076 | + } |
|
| 1972 | 2077 | |
| 1973 | 2078 | echo ' |
| 1974 | 2079 | </div> |
@@ -2003,13 +2108,15 @@ discard block |
||
| 2003 | 2108 | </div>'; |
| 2004 | 2109 | |
| 2005 | 2110 | // Show the warnings, or not. |
| 2006 | - if (template_warning_divs()) |
|
| 2007 | - echo ' |
|
| 2111 | + if (template_warning_divs()) { |
|
| 2112 | + echo ' |
|
| 2008 | 2113 | <h3>', $txt['install_all_lovely'], '</h3>'; |
| 2114 | + } |
|
| 2009 | 2115 | |
| 2010 | 2116 | // Say we want the continue button! |
| 2011 | - if (empty($incontext['error'])) |
|
| 2012 | - $incontext['continue'] = 1; |
|
| 2117 | + if (empty($incontext['error'])) { |
|
| 2118 | + $incontext['continue'] = 1; |
|
| 2119 | + } |
|
| 2013 | 2120 | |
| 2014 | 2121 | // For the latest version stuff. |
| 2015 | 2122 | echo ' |
@@ -2043,8 +2150,8 @@ discard block |
||
| 2043 | 2150 | global $txt, $incontext; |
| 2044 | 2151 | |
| 2045 | 2152 | // Errors are very serious.. |
| 2046 | - if (!empty($incontext['error'])) |
|
| 2047 | - echo ' |
|
| 2153 | + if (!empty($incontext['error'])) { |
|
| 2154 | + echo ' |
|
| 2048 | 2155 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2049 | 2156 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2050 | 2157 | <strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br> |
@@ -2052,9 +2159,10 @@ discard block |
||
| 2052 | 2159 | ', $incontext['error'], ' |
| 2053 | 2160 | </div> |
| 2054 | 2161 | </div>'; |
| 2162 | + } |
|
| 2055 | 2163 | // A warning message? |
| 2056 | - elseif (!empty($incontext['warning'])) |
|
| 2057 | - echo ' |
|
| 2164 | + elseif (!empty($incontext['warning'])) { |
|
| 2165 | + echo ' |
|
| 2058 | 2166 | <div style="margin: 2ex; padding: 2ex; border: 2px dashed #cc3344; color: black; background-color: #ffe4e9;"> |
| 2059 | 2167 | <div style="float: left; width: 2ex; font-size: 2em; color: red;">!!</div> |
| 2060 | 2168 | <strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br> |
@@ -2062,6 +2170,7 @@ discard block |
||
| 2062 | 2170 | ', $incontext['warning'], ' |
| 2063 | 2171 | </div> |
| 2064 | 2172 | </div>'; |
| 2173 | + } |
|
| 2065 | 2174 | |
| 2066 | 2175 | return empty($incontext['error']) && empty($incontext['warning']); |
| 2067 | 2176 | } |
@@ -2077,27 +2186,30 @@ discard block |
||
| 2077 | 2186 | <li>', $incontext['failed_files']), '</li> |
| 2078 | 2187 | </ul>'; |
| 2079 | 2188 | |
| 2080 | - if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') |
|
| 2081 | - echo ' |
|
| 2189 | + if (isset($incontext['systemos'], $incontext['detected_path']) && $incontext['systemos'] == 'linux') { |
|
| 2190 | + echo ' |
|
| 2082 | 2191 | <hr> |
| 2083 | 2192 | <p>', $txt['chmod_linux_info'], '</p> |
| 2084 | 2193 | <tt># chmod a+w ', implode(' ' . $incontext['detected_path'] . '/', $incontext['failed_files']), '</tt>'; |
| 2194 | + } |
|
| 2085 | 2195 | |
| 2086 | 2196 | // This is serious! |
| 2087 | - if (!template_warning_divs()) |
|
| 2088 | - return; |
|
| 2197 | + if (!template_warning_divs()) { |
|
| 2198 | + return; |
|
| 2199 | + } |
|
| 2089 | 2200 | |
| 2090 | 2201 | echo ' |
| 2091 | 2202 | <hr> |
| 2092 | 2203 | <p>', $txt['ftp_setup_info'], '</p>'; |
| 2093 | 2204 | |
| 2094 | - if (!empty($incontext['ftp_errors'])) |
|
| 2095 | - echo ' |
|
| 2205 | + if (!empty($incontext['ftp_errors'])) { |
|
| 2206 | + echo ' |
|
| 2096 | 2207 | <div class="error_message"> |
| 2097 | 2208 | ', $txt['error_ftp_no_connect'], '<br><br> |
| 2098 | 2209 | <code>', implode('<br>', $incontext['ftp_errors']), '</code> |
| 2099 | 2210 | </div> |
| 2100 | 2211 | <br>'; |
| 2212 | + } |
|
| 2101 | 2213 | |
| 2102 | 2214 | echo ' |
| 2103 | 2215 | <form action="', $incontext['form_url'], '" method="post"> |
@@ -2157,17 +2269,17 @@ discard block |
||
| 2157 | 2269 | <td> |
| 2158 | 2270 | <select name="db_type" id="db_type_input" onchange="toggleDBInput();">'; |
| 2159 | 2271 | |
| 2160 | - foreach ($incontext['supported_databases'] as $key => $db) |
|
| 2161 | - echo ' |
|
| 2272 | + foreach ($incontext['supported_databases'] as $key => $db) { |
|
| 2273 | + echo ' |
|
| 2162 | 2274 | <option value="', $key, '"', isset($_POST['db_type']) && $_POST['db_type'] == $key ? ' selected' : '', '>', $db['name'], '</option>'; |
| 2275 | + } |
|
| 2163 | 2276 | |
| 2164 | 2277 | echo ' |
| 2165 | 2278 | </select> |
| 2166 | 2279 | <div class="smalltext block">', $txt['db_settings_type_info'], '</div> |
| 2167 | 2280 | </td> |
| 2168 | 2281 | </tr>'; |
| 2169 | - } |
|
| 2170 | - else |
|
| 2282 | + } else |
|
| 2171 | 2283 | { |
| 2172 | 2284 | echo ' |
| 2173 | 2285 | <tr style="display: none;"> |
@@ -2360,9 +2472,10 @@ discard block |
||
| 2360 | 2472 | <div style="color: red;">', $txt['error_db_queries'], '</div> |
| 2361 | 2473 | <ul>'; |
| 2362 | 2474 | |
| 2363 | - foreach ($incontext['failures'] as $line => $fail) |
|
| 2364 | - echo ' |
|
| 2475 | + foreach ($incontext['failures'] as $line => $fail) { |
|
| 2476 | + echo ' |
|
| 2365 | 2477 | <li><strong>', $txt['error_db_queries_line'], $line + 1, ':</strong> ', nl2br(htmlspecialchars($fail)), '</li>'; |
| 2478 | + } |
|
| 2366 | 2479 | |
| 2367 | 2480 | echo ' |
| 2368 | 2481 | </ul>'; |
@@ -2423,15 +2536,16 @@ discard block |
||
| 2423 | 2536 | </tr> |
| 2424 | 2537 | </table>'; |
| 2425 | 2538 | |
| 2426 | - if ($incontext['require_db_confirm']) |
|
| 2427 | - echo ' |
|
| 2539 | + if ($incontext['require_db_confirm']) { |
|
| 2540 | + echo ' |
|
| 2428 | 2541 | <h2>', $txt['user_settings_database'], '</h2> |
| 2429 | 2542 | <p>', $txt['user_settings_database_info'], '</p> |
| 2430 | 2543 | |
| 2431 | 2544 | <div style="margin-bottom: 2ex; padding-', $txt['lang_rtl'] == false ? 'left' : 'right', ': 50px;"> |
| 2432 | 2545 | <input type="password" name="password3" size="30" /> |
| 2433 | 2546 | </div>'; |
| 2434 | -} |
|
| 2547 | + } |
|
| 2548 | + } |
|
| 2435 | 2549 | |
| 2436 | 2550 | // Tell them it's done, and to delete. |
| 2437 | 2551 | function template_delete_install() |
@@ -2444,14 +2558,15 @@ discard block |
||
| 2444 | 2558 | template_warning_divs(); |
| 2445 | 2559 | |
| 2446 | 2560 | // Install directory still writable? |
| 2447 | - if ($incontext['dir_still_writable']) |
|
| 2448 | - echo ' |
|
| 2561 | + if ($incontext['dir_still_writable']) { |
|
| 2562 | + echo ' |
|
| 2449 | 2563 | <em>', $txt['still_writable'], '</em><br> |
| 2450 | 2564 | <br>'; |
| 2565 | + } |
|
| 2451 | 2566 | |
| 2452 | 2567 | // Don't show the box if it's like 99% sure it won't work :P. |
| 2453 | - if ($incontext['probably_delete_install']) |
|
| 2454 | - echo ' |
|
| 2568 | + if ($incontext['probably_delete_install']) { |
|
| 2569 | + echo ' |
|
| 2455 | 2570 | <div style="margin: 1ex; font-weight: bold;"> |
| 2456 | 2571 | <label for="delete_self"><input type="checkbox" id="delete_self" onclick="doTheDelete();" /> ', $txt['delete_installer'], !isset($_SESSION['installer_temp_ftp']) ? ' ' . $txt['delete_installer_maybe'] : '', '</label> |
| 2457 | 2572 | </div> |
@@ -2467,6 +2582,7 @@ discard block |
||
| 2467 | 2582 | } |
| 2468 | 2583 | </script> |
| 2469 | 2584 | <br>'; |
| 2585 | + } |
|
| 2470 | 2586 | |
| 2471 | 2587 | echo ' |
| 2472 | 2588 | ', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br> |
@@ -18,23 +18,25 @@ discard block |
||
| 18 | 18 | global $context; |
| 19 | 19 | |
| 20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
| 21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
| 22 | - echo ' |
|
| 21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
| 22 | + echo ' |
|
| 23 | 23 | <script> |
| 24 | 24 | disableAutoComplete(); |
| 25 | 25 | </script>'; |
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
| 28 | 29 | echo ' |
| 29 | 30 | ', template_error_message(); |
| 30 | 31 | |
| 31 | 32 | // If the profile was update successfully, let the user know this. |
| 32 | - if (!empty($context['profile_updated'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['profile_updated'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <div class="infobox"> |
| 35 | 36 | ', $context['profile_updated'], ' |
| 36 | 37 | </div>'; |
| 37 | -} |
|
| 38 | + } |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | /** |
| 40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -102,8 +104,7 @@ discard block |
||
| 102 | 104 | if (empty($context['unread_alerts'])) |
| 103 | 105 | { |
| 104 | 106 | template_alerts_all_read(); |
| 105 | - } |
|
| 106 | - else |
|
| 107 | + } else |
|
| 107 | 108 | { |
| 108 | 109 | foreach ($context['unread_alerts'] as $id_alert => $details) |
| 109 | 110 | { |
@@ -164,10 +165,11 @@ discard block |
||
| 164 | 165 | <div class="custom_fields_above_name"> |
| 165 | 166 | <ul >'; |
| 166 | 167 | |
| 167 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
| 168 | - if (!empty($field['output_html'])) |
|
| 168 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
| 169 | + if (!empty($field['output_html'])) |
|
| 169 | 170 | echo ' |
| 170 | 171 | <li>', $field['output_html'], '</li>'; |
| 172 | + } |
|
| 171 | 173 | |
| 172 | 174 | echo ' |
| 173 | 175 | </ul> |
@@ -188,10 +190,11 @@ discard block |
||
| 188 | 190 | <div class="custom_fields_below_avatar"> |
| 189 | 191 | <ul >'; |
| 190 | 192 | |
| 191 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
| 192 | - if (!empty($field['output_html'])) |
|
| 193 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
| 194 | + if (!empty($field['output_html'])) |
|
| 193 | 195 | echo ' |
| 194 | 196 | <li>', $field['output_html'], '</li>'; |
| 197 | + } |
|
| 195 | 198 | |
| 196 | 199 | echo ' |
| 197 | 200 | </ul> |
@@ -202,22 +205,25 @@ discard block |
||
| 202 | 205 | echo ' |
| 203 | 206 | <ul class="clear">'; |
| 204 | 207 | // Email is only visible if it's your profile or you have the moderate_forum permission |
| 205 | - if ($context['member']['show_email']) |
|
| 206 | - echo ' |
|
| 208 | + if ($context['member']['show_email']) { |
|
| 209 | + echo ' |
|
| 207 | 210 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
| 211 | + } |
|
| 208 | 212 | |
| 209 | 213 | // Don't show an icon if they haven't specified a website. |
| 210 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
| 211 | - echo ' |
|
| 214 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
| 215 | + echo ' |
|
| 212 | 216 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
| 217 | + } |
|
| 213 | 218 | |
| 214 | 219 | // Are there any custom profile fields as icons? |
| 215 | 220 | if (!empty($context['print_custom_fields']['icons'])) |
| 216 | 221 | { |
| 217 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
| 218 | - if (!empty($field['output_html'])) |
|
| 222 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
| 223 | + if (!empty($field['output_html'])) |
|
| 219 | 224 | echo ' |
| 220 | 225 | <li class="custom_field">', $field['output_html'], '</li>'; |
| 226 | + } |
|
| 221 | 227 | } |
| 222 | 228 | |
| 223 | 229 | echo ' |
@@ -225,23 +231,26 @@ discard block |
||
| 225 | 231 | <span id="userstatus">', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
| 226 | 232 | |
| 227 | 233 | // Can they add this member as a buddy? |
| 228 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
| 229 | - echo ' |
|
| 234 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
| 235 | + echo ' |
|
| 230 | 236 | <br><a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
| 237 | + } |
|
| 231 | 238 | |
| 232 | 239 | echo ' |
| 233 | 240 | </span>'; |
| 234 | 241 | |
| 235 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
| 236 | - echo ' |
|
| 242 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
| 243 | + echo ' |
|
| 237 | 244 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
| 245 | + } |
|
| 238 | 246 | |
| 239 | 247 | echo ' |
| 240 | 248 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
| 241 | 249 | |
| 242 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
| 243 | - echo ' |
|
| 250 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
| 251 | + echo ' |
|
| 244 | 252 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
| 253 | + } |
|
| 245 | 254 | |
| 246 | 255 | echo ' |
| 247 | 256 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -253,10 +262,11 @@ discard block |
||
| 253 | 262 | <div class="custom_fields_bottom"> |
| 254 | 263 | <ul class="nolist">'; |
| 255 | 264 | |
| 256 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
| 257 | - if (!empty($field['output_html'])) |
|
| 265 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
| 266 | + if (!empty($field['output_html'])) |
|
| 258 | 267 | echo ' |
| 259 | 268 | <li>', $field['output_html'], '</li>'; |
| 269 | + } |
|
| 260 | 270 | |
| 261 | 271 | echo ' |
| 262 | 272 | </ul> |
@@ -270,15 +280,17 @@ discard block |
||
| 270 | 280 | <div id="detailedinfo"> |
| 271 | 281 | <dl class="settings">'; |
| 272 | 282 | |
| 273 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
| 274 | - echo ' |
|
| 283 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
| 284 | + echo ' |
|
| 275 | 285 | <dt>', $txt['username'], ': </dt> |
| 276 | 286 | <dd>', $context['member']['username'], '</dd>'; |
| 287 | + } |
|
| 277 | 288 | |
| 278 | - if (!isset($context['disabled_fields']['posts'])) |
|
| 279 | - echo ' |
|
| 289 | + if (!isset($context['disabled_fields']['posts'])) { |
|
| 290 | + echo ' |
|
| 280 | 291 | <dt>', $txt['profile_posts'], ': </dt> |
| 281 | 292 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
| 293 | + } |
|
| 282 | 294 | |
| 283 | 295 | if ($context['member']['show_email']) |
| 284 | 296 | { |
@@ -287,15 +299,17 @@ discard block |
||
| 287 | 299 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
| 288 | 300 | } |
| 289 | 301 | |
| 290 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
| 291 | - echo ' |
|
| 302 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
| 303 | + echo ' |
|
| 292 | 304 | <dt>', $txt['custom_title'], ': </dt> |
| 293 | 305 | <dd>', $context['member']['title'], '</dd>'; |
| 306 | + } |
|
| 294 | 307 | |
| 295 | - if (!empty($context['member']['blurb'])) |
|
| 296 | - echo ' |
|
| 308 | + if (!empty($context['member']['blurb'])) { |
|
| 309 | + echo ' |
|
| 297 | 310 | <dt>', $txt['personal_text'], ': </dt> |
| 298 | 311 | <dd>', $context['member']['blurb'], '</dd>'; |
| 312 | + } |
|
| 299 | 313 | |
| 300 | 314 | echo ' |
| 301 | 315 | <dt>', $txt['age'], ':</dt> |
@@ -309,19 +323,21 @@ discard block |
||
| 309 | 323 | { |
| 310 | 324 | $fields = array(); |
| 311 | 325 | |
| 312 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
| 313 | - if (!empty($field['output_html'])) |
|
| 326 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
| 327 | + if (!empty($field['output_html'])) |
|
| 314 | 328 | $fields[] = $field; |
| 329 | + } |
|
| 315 | 330 | |
| 316 | 331 | if (count($fields) > 0) |
| 317 | 332 | { |
| 318 | 333 | echo ' |
| 319 | 334 | <dl class="settings">'; |
| 320 | 335 | |
| 321 | - foreach ($fields as $field) |
|
| 322 | - echo ' |
|
| 336 | + foreach ($fields as $field) { |
|
| 337 | + echo ' |
|
| 323 | 338 | <dt>', $field['name'], ':</dt> |
| 324 | 339 | <dd>', $field['output_html'], '</dd>'; |
| 340 | + } |
|
| 325 | 341 | |
| 326 | 342 | echo ' |
| 327 | 343 | </dl>'; |
@@ -341,9 +357,10 @@ discard block |
||
| 341 | 357 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
| 342 | 358 | |
| 343 | 359 | // Can we provide information on what this means? |
| 344 | - if (!empty($context['warning_status'])) |
|
| 345 | - echo ' |
|
| 360 | + if (!empty($context['warning_status'])) { |
|
| 361 | + echo ' |
|
| 346 | 362 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
| 363 | + } |
|
| 347 | 364 | |
| 348 | 365 | echo ' |
| 349 | 366 | </dd>'; |
@@ -354,9 +371,10 @@ discard block |
||
| 354 | 371 | { |
| 355 | 372 | |
| 356 | 373 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
| 357 | - if (!empty($context['activate_message'])) |
|
| 358 | - echo ' |
|
| 374 | + if (!empty($context['activate_message'])) { |
|
| 375 | + echo ' |
|
| 359 | 376 | <dt class="clear"><span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>)</dt>'; |
| 377 | + } |
|
| 360 | 378 | |
| 361 | 379 | // If the current member is banned, show a message and possibly a link to the ban. |
| 362 | 380 | if (!empty($context['member']['bans'])) |
@@ -366,9 +384,10 @@ discard block |
||
| 366 | 384 | <dt class="clear" id="ban_info" style="display: none;"> |
| 367 | 385 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
| 368 | 386 | |
| 369 | - foreach ($context['member']['bans'] as $ban) |
|
| 370 | - echo ' |
|
| 387 | + foreach ($context['member']['bans'] as $ban) { |
|
| 388 | + echo ' |
|
| 371 | 389 | <br><span class="smalltext">', $ban['explanation'], '</span>'; |
| 390 | + } |
|
| 372 | 391 | |
| 373 | 392 | echo ' |
| 374 | 393 | </dt>'; |
@@ -382,30 +401,34 @@ discard block |
||
| 382 | 401 | // If the person looking is allowed, they can check the members IP address and hostname. |
| 383 | 402 | if ($context['can_see_ip']) |
| 384 | 403 | { |
| 385 | - if (!empty($context['member']['ip'])) |
|
| 386 | - echo ' |
|
| 404 | + if (!empty($context['member']['ip'])) { |
|
| 405 | + echo ' |
|
| 387 | 406 | <dt>', $txt['ip'], ': </dt> |
| 388 | 407 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
| 408 | + } |
|
| 389 | 409 | |
| 390 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
| 391 | - echo ' |
|
| 410 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
| 411 | + echo ' |
|
| 392 | 412 | <dt>', $txt['hostname'], ': </dt> |
| 393 | 413 | <dd>', $context['member']['hostname'], '</dd>'; |
| 414 | + } |
|
| 394 | 415 | } |
| 395 | 416 | |
| 396 | 417 | echo ' |
| 397 | 418 | <dt>', $txt['local_time'], ':</dt> |
| 398 | 419 | <dd>', $context['member']['local_time'], '</dd>'; |
| 399 | 420 | |
| 400 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
| 401 | - echo ' |
|
| 421 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
| 422 | + echo ' |
|
| 402 | 423 | <dt>', $txt['language'], ':</dt> |
| 403 | 424 | <dd>', $context['member']['language'], '</dd>'; |
| 425 | + } |
|
| 404 | 426 | |
| 405 | - if ($context['member']['show_last_login']) |
|
| 406 | - echo ' |
|
| 427 | + if ($context['member']['show_last_login']) { |
|
| 428 | + echo ' |
|
| 407 | 429 | <dt>', $txt['lastLoggedIn'], ': </dt> |
| 408 | 430 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
| 431 | + } |
|
| 409 | 432 | |
| 410 | 433 | echo ' |
| 411 | 434 | </dl>'; |
@@ -417,10 +440,11 @@ discard block |
||
| 417 | 440 | <div class="custom_fields_above_signature"> |
| 418 | 441 | <ul class="nolist">'; |
| 419 | 442 | |
| 420 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
| 421 | - if (!empty($field['output_html'])) |
|
| 443 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
| 444 | + if (!empty($field['output_html'])) |
|
| 422 | 445 | echo ' |
| 423 | 446 | <li>', $field['output_html'], '</li>'; |
| 447 | + } |
|
| 424 | 448 | |
| 425 | 449 | echo ' |
| 426 | 450 | </ul> |
@@ -428,12 +452,13 @@ discard block |
||
| 428 | 452 | } |
| 429 | 453 | |
| 430 | 454 | // Show the users signature. |
| 431 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
| 432 | - echo ' |
|
| 455 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
| 456 | + echo ' |
|
| 433 | 457 | <div class="signature"> |
| 434 | 458 | <h5>', $txt['signature'], ':</h5> |
| 435 | 459 | ', $context['member']['signature'], ' |
| 436 | 460 | </div>'; |
| 461 | + } |
|
| 437 | 462 | |
| 438 | 463 | // Are there any custom profile fields for below the signature? |
| 439 | 464 | if (!empty($context['print_custom_fields']['below_signature'])) |
@@ -442,10 +467,11 @@ discard block |
||
| 442 | 467 | <div class="custom_fields_below_signature"> |
| 443 | 468 | <ul class="nolist">'; |
| 444 | 469 | |
| 445 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
| 446 | - if (!empty($field['output_html'])) |
|
| 470 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
| 471 | + if (!empty($field['output_html'])) |
|
| 447 | 472 | echo ' |
| 448 | 473 | <li>', $field['output_html'], '</li>'; |
| 474 | + } |
|
| 449 | 475 | |
| 450 | 476 | echo ' |
| 451 | 477 | </ul> |
@@ -490,62 +516,70 @@ discard block |
||
| 490 | 516 | </div> |
| 491 | 517 | <div class="list_posts">'; |
| 492 | 518 | |
| 493 | - if (!$post['approved']) |
|
| 494 | - echo ' |
|
| 519 | + if (!$post['approved']) { |
|
| 520 | + echo ' |
|
| 495 | 521 | <div class="approve_post"> |
| 496 | 522 | <em>', $txt['post_awaiting_approval'], '</em> |
| 497 | 523 | </div>'; |
| 524 | + } |
|
| 498 | 525 | |
| 499 | 526 | echo ' |
| 500 | 527 | ', $post['body'], ' |
| 501 | 528 | </div>'; |
| 502 | 529 | |
| 503 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 504 | - echo ' |
|
| 530 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 531 | + echo ' |
|
| 505 | 532 | <div class="floatright"> |
| 506 | 533 | <ul class="quickbuttons">'; |
| 534 | + } |
|
| 507 | 535 | |
| 508 | 536 | // If they *can* reply? |
| 509 | - if ($post['can_reply']) |
|
| 510 | - echo ' |
|
| 537 | + if ($post['can_reply']) { |
|
| 538 | + echo ' |
|
| 511 | 539 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 540 | + } |
|
| 512 | 541 | |
| 513 | 542 | // If they *can* quote? |
| 514 | - if ($post['can_quote']) |
|
| 515 | - echo ' |
|
| 543 | + if ($post['can_quote']) { |
|
| 544 | + echo ' |
|
| 516 | 545 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 546 | + } |
|
| 517 | 547 | |
| 518 | 548 | // How about... even... remove it entirely?! |
| 519 | - if ($post['can_delete']) |
|
| 520 | - echo ' |
|
| 549 | + if ($post['can_delete']) { |
|
| 550 | + echo ' |
|
| 521 | 551 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
| 552 | + } |
|
| 522 | 553 | |
| 523 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
| 524 | - echo ' |
|
| 554 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
| 555 | + echo ' |
|
| 525 | 556 | </ul> |
| 526 | 557 | </div>'; |
| 558 | + } |
|
| 527 | 559 | |
| 528 | 560 | echo ' |
| 529 | 561 | </div>'; |
| 530 | 562 | } |
| 563 | + } else { |
|
| 564 | + template_show_list('attachments'); |
|
| 531 | 565 | } |
| 532 | - else |
|
| 533 | - template_show_list('attachments'); |
|
| 534 | 566 | |
| 535 | 567 | // No posts? Just end with a informative message. |
| 536 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
| 537 | - echo ' |
|
| 568 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
| 569 | + echo ' |
|
| 538 | 570 | <div class="windowbg2"> |
| 539 | 571 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
| 540 | 572 | </div>'; |
| 573 | + } |
|
| 541 | 574 | |
| 542 | 575 | // Show more page numbers. |
| 543 | - if (!empty($context['page_index'])) |
|
| 544 | - echo ' |
|
| 576 | + if (!empty($context['page_index'])) { |
|
| 577 | + echo ' |
|
| 545 | 578 | <div class="pagesection"> |
| 546 | 579 | <div class="pagelinks">', $context['page_index'], '</div> |
| 547 | 580 | </div>'; |
| 548 | -} |
|
| 581 | + } |
|
| 582 | + } |
|
| 549 | 583 | |
| 550 | 584 | /** |
| 551 | 585 | * Template for showing alerts within the alerts popup |
@@ -555,11 +589,12 @@ discard block |
||
| 555 | 589 | global $context, $txt, $scripturl; |
| 556 | 590 | |
| 557 | 591 | // Do we have an update message? |
| 558 | - if (!empty($context['update_message'])) |
|
| 559 | - echo ' |
|
| 592 | + if (!empty($context['update_message'])) { |
|
| 593 | + echo ' |
|
| 560 | 594 | <div class="infobox"> |
| 561 | 595 | ', $context['update_message'], '. |
| 562 | 596 | </div>'; |
| 597 | + } |
|
| 563 | 598 | |
| 564 | 599 | echo ' |
| 565 | 600 | <div class="cat_bar"> |
@@ -568,13 +603,12 @@ discard block |
||
| 568 | 603 | </h3> |
| 569 | 604 | </div>'; |
| 570 | 605 | |
| 571 | - if (empty($context['alerts'])) |
|
| 572 | - echo ' |
|
| 606 | + if (empty($context['alerts'])) { |
|
| 607 | + echo ' |
|
| 573 | 608 | <div class="information"> |
| 574 | 609 | ', $txt['alerts_none'], ' |
| 575 | 610 | </div>'; |
| 576 | - |
|
| 577 | - else |
|
| 611 | + } else |
|
| 578 | 612 | { |
| 579 | 613 | // Start the form. |
| 580 | 614 | echo ' |
@@ -636,12 +670,12 @@ discard block |
||
| 636 | 670 | </div>' : ''; |
| 637 | 671 | |
| 638 | 672 | // No drafts? Just show an informative message. |
| 639 | - if (empty($context['drafts'])) |
|
| 640 | - echo ' |
|
| 673 | + if (empty($context['drafts'])) { |
|
| 674 | + echo ' |
|
| 641 | 675 | <div class="windowbg2 centertext"> |
| 642 | 676 | ', $txt['draft_none'], ' |
| 643 | 677 | </div>'; |
| 644 | - else |
|
| 678 | + } else |
|
| 645 | 679 | { |
| 646 | 680 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
| 647 | 681 | foreach ($context['drafts'] as $draft) |
@@ -652,11 +686,13 @@ discard block |
||
| 652 | 686 | <div class="topic_details"> |
| 653 | 687 | <h5><strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
| 654 | 688 | |
| 655 | - if (!empty($draft['sticky'])) |
|
| 656 | - echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 689 | + if (!empty($draft['sticky'])) { |
|
| 690 | + echo '<span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
|
| 691 | + } |
|
| 657 | 692 | |
| 658 | - if (!empty($draft['locked'])) |
|
| 659 | - echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 693 | + if (!empty($draft['locked'])) { |
|
| 694 | + echo '<span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
|
| 695 | + } |
|
| 660 | 696 | |
| 661 | 697 | echo ' |
| 662 | 698 | </h5> |
@@ -689,12 +725,13 @@ discard block |
||
| 689 | 725 | { |
| 690 | 726 | global $context, $scripturl, $txt; |
| 691 | 727 | |
| 692 | - if (!empty($context['saved_successful'])) |
|
| 693 | - echo ' |
|
| 728 | + if (!empty($context['saved_successful'])) { |
|
| 729 | + echo ' |
|
| 694 | 730 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 695 | - elseif (!empty($context['saved_failed'])) |
|
| 696 | - echo ' |
|
| 731 | + } elseif (!empty($context['saved_failed'])) { |
|
| 732 | + echo ' |
|
| 697 | 733 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 734 | + } |
|
| 698 | 735 | |
| 699 | 736 | echo ' |
| 700 | 737 | <div id="edit_buddies"> |
@@ -708,24 +745,27 @@ discard block |
||
| 708 | 745 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 709 | 746 | <th scope="col">', $txt['status'], '</th>'; |
| 710 | 747 | |
| 711 | - if (allowedTo('moderate_forum')) |
|
| 712 | - echo ' |
|
| 748 | + if (allowedTo('moderate_forum')) { |
|
| 749 | + echo ' |
|
| 713 | 750 | <th scope="col">', $txt['email'], '</th>'; |
| 751 | + } |
|
| 714 | 752 | |
| 715 | - if (!empty($context['custom_pf'])) |
|
| 716 | - foreach ($context['custom_pf'] as $column) |
|
| 753 | + if (!empty($context['custom_pf'])) { |
|
| 754 | + foreach ($context['custom_pf'] as $column) |
|
| 717 | 755 | echo '<th scope="col">', $column['label'], '</th>'; |
| 756 | + } |
|
| 718 | 757 | |
| 719 | 758 | echo ' |
| 720 | 759 | <th scope="col">', $txt['remove'], '</th> |
| 721 | 760 | </tr>'; |
| 722 | 761 | |
| 723 | 762 | // If they don't have any buddies don't list them! |
| 724 | - if (empty($context['buddies'])) |
|
| 725 | - echo ' |
|
| 763 | + if (empty($context['buddies'])) { |
|
| 764 | + echo ' |
|
| 726 | 765 | <tr class="windowbg"> |
| 727 | 766 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"><strong>', $txt['no_buddies'], '</strong></td> |
| 728 | 767 | </tr>'; |
| 768 | + } |
|
| 729 | 769 | |
| 730 | 770 | // Now loop through each buddy showing info on each. |
| 731 | 771 | else |
@@ -737,15 +777,17 @@ discard block |
||
| 737 | 777 | <td>', $buddy['link'], '</td> |
| 738 | 778 | <td><a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a></td>'; |
| 739 | 779 | |
| 740 | - if ($buddy['show_email']) |
|
| 741 | - echo ' |
|
| 780 | + if ($buddy['show_email']) { |
|
| 781 | + echo ' |
|
| 742 | 782 | <td><a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a></td>'; |
| 783 | + } |
|
| 743 | 784 | |
| 744 | 785 | // Show the custom profile fields for this user. |
| 745 | - if (!empty($context['custom_pf'])) |
|
| 746 | - foreach ($context['custom_pf'] as $key => $column) |
|
| 786 | + if (!empty($context['custom_pf'])) { |
|
| 787 | + foreach ($context['custom_pf'] as $key => $column) |
|
| 747 | 788 | echo ' |
| 748 | 789 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
| 790 | + } |
|
| 749 | 791 | |
| 750 | 792 | echo ' |
| 751 | 793 | <td><a href="', $scripturl, '?action=profile;area=lists;sa=buddies;u=', $context['id_member'], ';remove=', $buddy['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['buddy_remove'], '"></span></a></td> |
@@ -775,9 +817,10 @@ discard block |
||
| 775 | 817 | </dl> |
| 776 | 818 | </div>'; |
| 777 | 819 | |
| 778 | - if (!empty($context['token_check'])) |
|
| 779 | - echo ' |
|
| 820 | + if (!empty($context['token_check'])) { |
|
| 821 | + echo ' |
|
| 780 | 822 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 823 | + } |
|
| 781 | 824 | |
| 782 | 825 | echo ' |
| 783 | 826 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -803,12 +846,13 @@ discard block |
||
| 803 | 846 | { |
| 804 | 847 | global $context, $scripturl, $txt; |
| 805 | 848 | |
| 806 | - if (!empty($context['saved_successful'])) |
|
| 807 | - echo ' |
|
| 849 | + if (!empty($context['saved_successful'])) { |
|
| 850 | + echo ' |
|
| 808 | 851 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
| 809 | - elseif (!empty($context['saved_failed'])) |
|
| 810 | - echo ' |
|
| 852 | + } elseif (!empty($context['saved_failed'])) { |
|
| 853 | + echo ' |
|
| 811 | 854 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
| 855 | + } |
|
| 812 | 856 | |
| 813 | 857 | echo ' |
| 814 | 858 | <div id="edit_buddies"> |
@@ -822,20 +866,22 @@ discard block |
||
| 822 | 866 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
| 823 | 867 | <th scope="col">', $txt['status'], '</th>'; |
| 824 | 868 | |
| 825 | - if (allowedTo('moderate_forum')) |
|
| 826 | - echo ' |
|
| 869 | + if (allowedTo('moderate_forum')) { |
|
| 870 | + echo ' |
|
| 827 | 871 | <th scope="col">', $txt['email'], '</th>'; |
| 872 | + } |
|
| 828 | 873 | |
| 829 | 874 | echo ' |
| 830 | 875 | <th scope="col">', $txt['ignore_remove'], '</th> |
| 831 | 876 | </tr>'; |
| 832 | 877 | |
| 833 | 878 | // If they don't have anyone on their ignore list, don't list it! |
| 834 | - if (empty($context['ignore_list'])) |
|
| 835 | - echo ' |
|
| 879 | + if (empty($context['ignore_list'])) { |
|
| 880 | + echo ' |
|
| 836 | 881 | <tr class="windowbg"> |
| 837 | 882 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"><strong>', $txt['no_ignore'], '</strong></td> |
| 838 | 883 | </tr>'; |
| 884 | + } |
|
| 839 | 885 | |
| 840 | 886 | // Now loop through each buddy showing info on each. |
| 841 | 887 | foreach ($context['ignore_list'] as $member) |
@@ -845,9 +891,10 @@ discard block |
||
| 845 | 891 | <td>', $member['link'], '</td> |
| 846 | 892 | <td><a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a></td>'; |
| 847 | 893 | |
| 848 | - if ($member['show_email']) |
|
| 849 | - echo ' |
|
| 894 | + if ($member['show_email']) { |
|
| 895 | + echo ' |
|
| 850 | 896 | <td><a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a></td>'; |
| 897 | + } |
|
| 851 | 898 | echo ' |
| 852 | 899 | <td><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a></td> |
| 853 | 900 | </tr>'; |
@@ -874,9 +921,10 @@ discard block |
||
| 874 | 921 | </dl> |
| 875 | 922 | </div>'; |
| 876 | 923 | |
| 877 | - if (!empty($context['token_check'])) |
|
| 878 | - echo ' |
|
| 924 | + if (!empty($context['token_check'])) { |
|
| 925 | + echo ' |
|
| 879 | 926 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 927 | + } |
|
| 880 | 928 | |
| 881 | 929 | echo ' |
| 882 | 930 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -921,9 +969,10 @@ discard block |
||
| 921 | 969 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
| 922 | 970 | |
| 923 | 971 | // Second address detected? |
| 924 | - if (!empty($context['last_ip2'])) |
|
| 925 | - echo ' |
|
| 972 | + if (!empty($context['last_ip2'])) { |
|
| 973 | + echo ' |
|
| 926 | 974 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
| 975 | + } |
|
| 927 | 976 | |
| 928 | 977 | echo ' |
| 929 | 978 | </dd>'; |
@@ -988,9 +1037,10 @@ discard block |
||
| 988 | 1037 | <h3 class="catbg">', $txt['whois_title'], ' ', $context['ip'], '</h3> |
| 989 | 1038 | </div> |
| 990 | 1039 | <div class="windowbg2 noup">'; |
| 991 | - foreach ($context['whois_servers'] as $server) |
|
| 992 | - echo ' |
|
| 1040 | + foreach ($context['whois_servers'] as $server) { |
|
| 1041 | + echo ' |
|
| 993 | 1042 | <a href="', $server['url'], '" target="_blank"', isset($context['auto_whois_server']) && $context['auto_whois_server']['name'] == $server['name'] ? ' style="font-weight: bold;"' : '', '>', $server['name'], '</a><br>'; |
| 1043 | + } |
|
| 994 | 1044 | echo ' |
| 995 | 1045 | </div> |
| 996 | 1046 | <br>'; |
@@ -1001,10 +1051,10 @@ discard block |
||
| 1001 | 1051 | <div class="cat_bar"> |
| 1002 | 1052 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
| 1003 | 1053 | </div>'; |
| 1004 | - if (empty($context['ips'])) |
|
| 1005 | - echo ' |
|
| 1054 | + if (empty($context['ips'])) { |
|
| 1055 | + echo ' |
|
| 1006 | 1056 | <p class="windowbg2 description"><em>', $txt['no_members_from_ip'], '</em></p>'; |
| 1007 | - else |
|
| 1057 | + } else |
|
| 1008 | 1058 | { |
| 1009 | 1059 | echo ' |
| 1010 | 1060 | <table class="table_grid"> |
@@ -1017,12 +1067,13 @@ discard block |
||
| 1017 | 1067 | <tbody>'; |
| 1018 | 1068 | |
| 1019 | 1069 | // Loop through each of the members and display them. |
| 1020 | - foreach ($context['ips'] as $ip => $memberlist) |
|
| 1021 | - echo ' |
|
| 1070 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
| 1071 | + echo ' |
|
| 1022 | 1072 | <tr class="windowbg"> |
| 1023 | 1073 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
| 1024 | 1074 | <td>', implode(', ', $memberlist), '</td> |
| 1025 | 1075 | </tr>'; |
| 1076 | + } |
|
| 1026 | 1077 | |
| 1027 | 1078 | echo ' |
| 1028 | 1079 | </tbody> |
@@ -1068,8 +1119,7 @@ discard block |
||
| 1068 | 1119 | { |
| 1069 | 1120 | echo ' |
| 1070 | 1121 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
| 1071 | - } |
|
| 1072 | - else |
|
| 1122 | + } else |
|
| 1073 | 1123 | { |
| 1074 | 1124 | echo ' |
| 1075 | 1125 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1083,9 +1133,10 @@ discard block |
||
| 1083 | 1133 | </div> |
| 1084 | 1134 | <div class="windowbg smalltext"> |
| 1085 | 1135 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
| 1086 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
| 1087 | - echo ' |
|
| 1136 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
| 1137 | + echo ' |
|
| 1088 | 1138 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
| 1139 | + } |
|
| 1089 | 1140 | echo ' |
| 1090 | 1141 | </div>'; |
| 1091 | 1142 | } |
@@ -1117,12 +1168,13 @@ discard block |
||
| 1117 | 1168 | </td> |
| 1118 | 1169 | <td class="smalltext">'; |
| 1119 | 1170 | |
| 1120 | - if ($permission['is_denied']) |
|
| 1121 | - echo ' |
|
| 1171 | + if ($permission['is_denied']) { |
|
| 1172 | + echo ' |
|
| 1122 | 1173 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1123 | - else |
|
| 1124 | - echo ' |
|
| 1174 | + } else { |
|
| 1175 | + echo ' |
|
| 1125 | 1176 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
| 1177 | + } |
|
| 1126 | 1178 | |
| 1127 | 1179 | echo ' |
| 1128 | 1180 | </td> |
@@ -1132,10 +1184,10 @@ discard block |
||
| 1132 | 1184 | </tbody> |
| 1133 | 1185 | </table> |
| 1134 | 1186 | </div><br>'; |
| 1135 | - } |
|
| 1136 | - else |
|
| 1137 | - echo ' |
|
| 1187 | + } else { |
|
| 1188 | + echo ' |
|
| 1138 | 1189 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
| 1190 | + } |
|
| 1139 | 1191 | |
| 1140 | 1192 | // Board permission section. |
| 1141 | 1193 | echo ' |
@@ -1145,14 +1197,16 @@ discard block |
||
| 1145 | 1197 | <a id="board_permissions"></a>', $txt['showPermissions_select'], ': |
| 1146 | 1198 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
| 1147 | 1199 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], ' </option>'; |
| 1148 | - if (!empty($context['boards'])) |
|
| 1149 | - echo ' |
|
| 1200 | + if (!empty($context['boards'])) { |
|
| 1201 | + echo ' |
|
| 1150 | 1202 | <option value="" disabled>---------------------------</option>'; |
| 1203 | + } |
|
| 1151 | 1204 | |
| 1152 | 1205 | // Fill the box with any local permission boards. |
| 1153 | - foreach ($context['boards'] as $board) |
|
| 1154 | - echo ' |
|
| 1206 | + foreach ($context['boards'] as $board) { |
|
| 1207 | + echo ' |
|
| 1155 | 1208 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
| 1209 | + } |
|
| 1156 | 1210 | |
| 1157 | 1211 | echo ' |
| 1158 | 1212 | </select> |
@@ -1183,8 +1237,7 @@ discard block |
||
| 1183 | 1237 | { |
| 1184 | 1238 | echo ' |
| 1185 | 1239 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
| 1186 | - } |
|
| 1187 | - else |
|
| 1240 | + } else |
|
| 1188 | 1241 | { |
| 1189 | 1242 | echo ' |
| 1190 | 1243 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
@@ -1196,10 +1249,10 @@ discard block |
||
| 1196 | 1249 | echo ' |
| 1197 | 1250 | </tbody> |
| 1198 | 1251 | </table>'; |
| 1199 | - } |
|
| 1200 | - else |
|
| 1201 | - echo ' |
|
| 1252 | + } else { |
|
| 1253 | + echo ' |
|
| 1202 | 1254 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
| 1255 | + } |
|
| 1203 | 1256 | echo ' |
| 1204 | 1257 | </div> |
| 1205 | 1258 | </div>'; |
@@ -1241,9 +1294,10 @@ discard block |
||
| 1241 | 1294 | </div>'; |
| 1242 | 1295 | |
| 1243 | 1296 | // If they haven't post at all, don't draw the graph. |
| 1244 | - if (empty($context['posts_by_time'])) |
|
| 1245 | - echo ' |
|
| 1297 | + if (empty($context['posts_by_time'])) { |
|
| 1298 | + echo ' |
|
| 1246 | 1299 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1300 | + } |
|
| 1247 | 1301 | // Otherwise do! |
| 1248 | 1302 | else |
| 1249 | 1303 | { |
@@ -1282,11 +1336,10 @@ discard block |
||
| 1282 | 1336 | </h3> |
| 1283 | 1337 | </div>'; |
| 1284 | 1338 | |
| 1285 | - if (empty($context['popular_boards'])) |
|
| 1286 | - echo ' |
|
| 1339 | + if (empty($context['popular_boards'])) { |
|
| 1340 | + echo ' |
|
| 1287 | 1341 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1288 | - |
|
| 1289 | - else |
|
| 1342 | + } else |
|
| 1290 | 1343 | { |
| 1291 | 1344 | echo ' |
| 1292 | 1345 | <dl class="stats">'; |
@@ -1317,10 +1370,10 @@ discard block |
||
| 1317 | 1370 | </h3> |
| 1318 | 1371 | </div>'; |
| 1319 | 1372 | |
| 1320 | - if (empty($context['board_activity'])) |
|
| 1321 | - echo ' |
|
| 1373 | + if (empty($context['board_activity'])) { |
|
| 1374 | + echo ' |
|
| 1322 | 1375 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
| 1323 | - else |
|
| 1376 | + } else |
|
| 1324 | 1377 | { |
| 1325 | 1378 | echo ' |
| 1326 | 1379 | <dl class="stats">'; |
@@ -1368,41 +1421,46 @@ discard block |
||
| 1368 | 1421 | <h3 class="catbg profile_hd">'; |
| 1369 | 1422 | |
| 1370 | 1423 | // Don't say "Profile" if this isn't the profile... |
| 1371 | - if (!empty($context['profile_header_text'])) |
|
| 1372 | - echo ' |
|
| 1424 | + if (!empty($context['profile_header_text'])) { |
|
| 1425 | + echo ' |
|
| 1373 | 1426 | ', $context['profile_header_text']; |
| 1374 | - else |
|
| 1375 | - echo ' |
|
| 1427 | + } else { |
|
| 1428 | + echo ' |
|
| 1376 | 1429 | ', $txt['profile']; |
| 1430 | + } |
|
| 1377 | 1431 | |
| 1378 | 1432 | echo ' |
| 1379 | 1433 | </h3> |
| 1380 | 1434 | </div>'; |
| 1381 | 1435 | |
| 1382 | 1436 | // Have we some description? |
| 1383 | - if ($context['page_desc']) |
|
| 1384 | - echo ' |
|
| 1437 | + if ($context['page_desc']) { |
|
| 1438 | + echo ' |
|
| 1385 | 1439 | <p class="information">', $context['page_desc'], '</p>'; |
| 1440 | + } |
|
| 1386 | 1441 | |
| 1387 | 1442 | echo ' |
| 1388 | 1443 | <div class="roundframe">'; |
| 1389 | 1444 | |
| 1390 | 1445 | // Any bits at the start? |
| 1391 | - if (!empty($context['profile_prehtml'])) |
|
| 1392 | - echo ' |
|
| 1446 | + if (!empty($context['profile_prehtml'])) { |
|
| 1447 | + echo ' |
|
| 1393 | 1448 | <div>', $context['profile_prehtml'], '</div>'; |
| 1449 | + } |
|
| 1394 | 1450 | |
| 1395 | - if (!empty($context['profile_fields'])) |
|
| 1396 | - echo ' |
|
| 1451 | + if (!empty($context['profile_fields'])) { |
|
| 1452 | + echo ' |
|
| 1397 | 1453 | <dl class="settings">'; |
| 1454 | + } |
|
| 1398 | 1455 | |
| 1399 | 1456 | // Start the big old loop 'of love. |
| 1400 | 1457 | $lastItem = 'hr'; |
| 1401 | 1458 | foreach ($context['profile_fields'] as $key => $field) |
| 1402 | 1459 | { |
| 1403 | 1460 | // We add a little hack to be sure we never get more than one hr in a row! |
| 1404 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
| 1405 | - continue; |
|
| 1461 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
| 1462 | + continue; |
|
| 1463 | + } |
|
| 1406 | 1464 | |
| 1407 | 1465 | $lastItem = $field['type']; |
| 1408 | 1466 | if ($field['type'] == 'hr') |
@@ -1411,48 +1469,50 @@ discard block |
||
| 1411 | 1469 | </dl> |
| 1412 | 1470 | <hr> |
| 1413 | 1471 | <dl class="settings">'; |
| 1414 | - } |
|
| 1415 | - elseif ($field['type'] == 'callback') |
|
| 1472 | + } elseif ($field['type'] == 'callback') |
|
| 1416 | 1473 | { |
| 1417 | 1474 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
| 1418 | 1475 | { |
| 1419 | 1476 | $callback_func = 'template_profile_' . $field['callback_func']; |
| 1420 | 1477 | $callback_func(); |
| 1421 | 1478 | } |
| 1422 | - } |
|
| 1423 | - else |
|
| 1479 | + } else |
|
| 1424 | 1480 | { |
| 1425 | 1481 | echo ' |
| 1426 | 1482 | <dt> |
| 1427 | 1483 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
| 1428 | 1484 | |
| 1429 | 1485 | // Does it have any subtext to show? |
| 1430 | - if (!empty($field['subtext'])) |
|
| 1431 | - echo ' |
|
| 1486 | + if (!empty($field['subtext'])) { |
|
| 1487 | + echo ' |
|
| 1432 | 1488 | <br> |
| 1433 | 1489 | <span class="smalltext">', $field['subtext'], '</span>'; |
| 1490 | + } |
|
| 1434 | 1491 | |
| 1435 | 1492 | echo ' |
| 1436 | 1493 | </dt> |
| 1437 | 1494 | <dd>'; |
| 1438 | 1495 | |
| 1439 | 1496 | // Want to put something infront of the box? |
| 1440 | - if (!empty($field['preinput'])) |
|
| 1441 | - echo ' |
|
| 1497 | + if (!empty($field['preinput'])) { |
|
| 1498 | + echo ' |
|
| 1442 | 1499 | ', $field['preinput']; |
| 1500 | + } |
|
| 1443 | 1501 | |
| 1444 | 1502 | // What type of data are we showing? |
| 1445 | - if ($field['type'] == 'label') |
|
| 1446 | - echo ' |
|
| 1503 | + if ($field['type'] == 'label') { |
|
| 1504 | + echo ' |
|
| 1447 | 1505 | ', $field['value']; |
| 1506 | + } |
|
| 1448 | 1507 | |
| 1449 | 1508 | // Maybe it's a text box - very likely! |
| 1450 | 1509 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
| 1451 | 1510 | { |
| 1452 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
| 1453 | - $type = 'number'; |
|
| 1454 | - else |
|
| 1455 | - $type = $field['type']; |
|
| 1511 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
| 1512 | + $type = 'number'; |
|
| 1513 | + } else { |
|
| 1514 | + $type = $field['type']; |
|
| 1515 | + } |
|
| 1456 | 1516 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
| 1457 | 1517 | |
| 1458 | 1518 | |
@@ -1460,9 +1520,10 @@ discard block |
||
| 1460 | 1520 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
| 1461 | 1521 | } |
| 1462 | 1522 | // You "checking" me out? ;) |
| 1463 | - elseif ($field['type'] == 'check') |
|
| 1464 | - echo ' |
|
| 1523 | + elseif ($field['type'] == 'check') { |
|
| 1524 | + echo ' |
|
| 1465 | 1525 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
| 1526 | + } |
|
| 1466 | 1527 | |
| 1467 | 1528 | // Always fun - select boxes! |
| 1468 | 1529 | elseif ($field['type'] == 'select') |
@@ -1473,13 +1534,15 @@ discard block |
||
| 1473 | 1534 | if (isset($field['options'])) |
| 1474 | 1535 | { |
| 1475 | 1536 | // Is this some code to generate the options? |
| 1476 | - if (!is_array($field['options'])) |
|
| 1477 | - $field['options'] = $field['options'](); |
|
| 1537 | + if (!is_array($field['options'])) { |
|
| 1538 | + $field['options'] = $field['options'](); |
|
| 1539 | + } |
|
| 1478 | 1540 | // Assuming we now have some! |
| 1479 | - if (is_array($field['options'])) |
|
| 1480 | - foreach ($field['options'] as $value => $name) |
|
| 1541 | + if (is_array($field['options'])) { |
|
| 1542 | + foreach ($field['options'] as $value => $name) |
|
| 1481 | 1543 | echo ' |
| 1482 | 1544 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
| 1545 | + } |
|
| 1483 | 1546 | } |
| 1484 | 1547 | |
| 1485 | 1548 | echo ' |
@@ -1487,25 +1550,28 @@ discard block |
||
| 1487 | 1550 | } |
| 1488 | 1551 | |
| 1489 | 1552 | // Something to end with? |
| 1490 | - if (!empty($field['postinput'])) |
|
| 1491 | - echo ' |
|
| 1553 | + if (!empty($field['postinput'])) { |
|
| 1554 | + echo ' |
|
| 1492 | 1555 | ', $field['postinput']; |
| 1556 | + } |
|
| 1493 | 1557 | |
| 1494 | 1558 | echo ' |
| 1495 | 1559 | </dd>'; |
| 1496 | 1560 | } |
| 1497 | 1561 | } |
| 1498 | 1562 | |
| 1499 | - if (!empty($context['profile_fields'])) |
|
| 1500 | - echo ' |
|
| 1563 | + if (!empty($context['profile_fields'])) { |
|
| 1564 | + echo ' |
|
| 1501 | 1565 | </dl>'; |
| 1566 | + } |
|
| 1502 | 1567 | |
| 1503 | 1568 | // Are there any custom profile fields - if so print them! |
| 1504 | 1569 | if (!empty($context['custom_fields'])) |
| 1505 | 1570 | { |
| 1506 | - if ($lastItem != 'hr') |
|
| 1507 | - echo ' |
|
| 1571 | + if ($lastItem != 'hr') { |
|
| 1572 | + echo ' |
|
| 1508 | 1573 | <hr>'; |
| 1574 | + } |
|
| 1509 | 1575 | |
| 1510 | 1576 | echo ' |
| 1511 | 1577 | <dl class="settings">'; |
@@ -1528,13 +1594,14 @@ discard block |
||
| 1528 | 1594 | } |
| 1529 | 1595 | |
| 1530 | 1596 | // Any closing HTML? |
| 1531 | - if (!empty($context['profile_posthtml'])) |
|
| 1532 | - echo ' |
|
| 1597 | + if (!empty($context['profile_posthtml'])) { |
|
| 1598 | + echo ' |
|
| 1533 | 1599 | <div>', $context['profile_posthtml'], '</div>'; |
| 1600 | + } |
|
| 1534 | 1601 | |
| 1535 | 1602 | // Only show the password box if it's actually needed. |
| 1536 | - if ($context['require_password']) |
|
| 1537 | - echo ' |
|
| 1603 | + if ($context['require_password']) { |
|
| 1604 | + echo ' |
|
| 1538 | 1605 | <dl class="settings"> |
| 1539 | 1606 | <dt> |
| 1540 | 1607 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1544,18 +1611,21 @@ discard block |
||
| 1544 | 1611 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
| 1545 | 1612 | </dd> |
| 1546 | 1613 | </dl>'; |
| 1614 | + } |
|
| 1547 | 1615 | |
| 1548 | 1616 | // The button shouldn't say "Change profile" unless we're changing the profile... |
| 1549 | - if (!empty($context['submit_button_text'])) |
|
| 1550 | - echo ' |
|
| 1617 | + if (!empty($context['submit_button_text'])) { |
|
| 1618 | + echo ' |
|
| 1551 | 1619 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button">'; |
| 1552 | - else |
|
| 1553 | - echo ' |
|
| 1620 | + } else { |
|
| 1621 | + echo ' |
|
| 1554 | 1622 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button">'; |
| 1623 | + } |
|
| 1555 | 1624 | |
| 1556 | - if (!empty($context['token_check'])) |
|
| 1557 | - echo ' |
|
| 1625 | + if (!empty($context['token_check'])) { |
|
| 1626 | + echo ' |
|
| 1558 | 1627 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 1628 | + } |
|
| 1559 | 1629 | |
| 1560 | 1630 | echo ' |
| 1561 | 1631 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1565,10 +1635,11 @@ discard block |
||
| 1565 | 1635 | </form>'; |
| 1566 | 1636 | |
| 1567 | 1637 | // Any final spellchecking stuff? |
| 1568 | - if (!empty($context['show_spellchecking'])) |
|
| 1569 | - echo ' |
|
| 1638 | + if (!empty($context['show_spellchecking'])) { |
|
| 1639 | + echo ' |
|
| 1570 | 1640 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
| 1571 | -} |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1572 | 1643 | |
| 1573 | 1644 | /** |
| 1574 | 1645 | * Personal Message settings. |
@@ -1605,10 +1676,11 @@ discard block |
||
| 1605 | 1676 | <select name="pm_receive_from" id="pm_receive_from"> |
| 1606 | 1677 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
| 1607 | 1678 | |
| 1608 | - if (!empty($modSettings['enable_buddylist'])) |
|
| 1609 | - echo ' |
|
| 1679 | + if (!empty($modSettings['enable_buddylist'])) { |
|
| 1680 | + echo ' |
|
| 1610 | 1681 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
| 1611 | 1682 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
| 1683 | + } |
|
| 1612 | 1684 | |
| 1613 | 1685 | echo ' |
| 1614 | 1686 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1651,11 +1723,12 @@ discard block |
||
| 1651 | 1723 | if (empty($setting) || !is_array($setting)) |
| 1652 | 1724 | { |
| 1653 | 1725 | // Insert a separator (unless this is the first item in the list) |
| 1654 | - if ($i !== $first_option_key) |
|
| 1655 | - echo ' |
|
| 1726 | + if ($i !== $first_option_key) { |
|
| 1727 | + echo ' |
|
| 1656 | 1728 | </dl> |
| 1657 | 1729 | <hr> |
| 1658 | 1730 | <dl class="settings">'; |
| 1731 | + } |
|
| 1659 | 1732 | |
| 1660 | 1733 | // Should we give a name to this section? |
| 1661 | 1734 | if (is_string($setting) && !empty($setting)) |
@@ -1663,51 +1736,56 @@ discard block |
||
| 1663 | 1736 | $titled_section = true; |
| 1664 | 1737 | echo ' |
| 1665 | 1738 | <dt><strong>' . $setting . '</strong></dt><dd></dd>'; |
| 1739 | + } else { |
|
| 1740 | + $titled_section = false; |
|
| 1666 | 1741 | } |
| 1667 | - else |
|
| 1668 | - $titled_section = false; |
|
| 1669 | 1742 | |
| 1670 | 1743 | continue; |
| 1671 | 1744 | } |
| 1672 | 1745 | |
| 1673 | 1746 | // Is this disabled? |
| 1674 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
| 1675 | - continue; |
|
| 1676 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
| 1677 | - continue; |
|
| 1678 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
| 1679 | - continue; |
|
| 1680 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
| 1681 | - continue; |
|
| 1682 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
| 1683 | - continue; |
|
| 1684 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1685 | - continue; |
|
| 1686 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
| 1687 | - continue; |
|
| 1747 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
| 1748 | + continue; |
|
| 1749 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
| 1750 | + continue; |
|
| 1751 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
| 1752 | + continue; |
|
| 1753 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
| 1754 | + continue; |
|
| 1755 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
| 1756 | + continue; |
|
| 1757 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1758 | + continue; |
|
| 1759 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
| 1760 | + continue; |
|
| 1761 | + } |
|
| 1688 | 1762 | |
| 1689 | 1763 | // Some of these may not be set... Set to defaults here |
| 1690 | 1764 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
| 1691 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
| 1692 | - $context['member']['options'][$setting['id']] = 0; |
|
| 1765 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
| 1766 | + $context['member']['options'][$setting['id']] = 0; |
|
| 1767 | + } |
|
| 1693 | 1768 | |
| 1694 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
| 1695 | - $setting['type'] = 'checkbox'; |
|
| 1696 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
| 1697 | - $setting['type'] = 'number'; |
|
| 1698 | - elseif ($setting['type'] == 'string') |
|
| 1699 | - $setting['type'] = 'text'; |
|
| 1769 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
| 1770 | + $setting['type'] = 'checkbox'; |
|
| 1771 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
| 1772 | + $setting['type'] = 'number'; |
|
| 1773 | + } elseif ($setting['type'] == 'string') { |
|
| 1774 | + $setting['type'] = 'text'; |
|
| 1775 | + } |
|
| 1700 | 1776 | |
| 1701 | - if (isset($setting['options'])) |
|
| 1702 | - $setting['type'] = 'list'; |
|
| 1777 | + if (isset($setting['options'])) { |
|
| 1778 | + $setting['type'] = 'list'; |
|
| 1779 | + } |
|
| 1703 | 1780 | |
| 1704 | 1781 | echo ' |
| 1705 | 1782 | <dt> |
| 1706 | 1783 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
| 1707 | 1784 | |
| 1708 | - if (isset($setting['description'])) |
|
| 1709 | - echo ' |
|
| 1785 | + if (isset($setting['description'])) { |
|
| 1786 | + echo ' |
|
| 1710 | 1787 | <br><span class="smalltext">', $setting['description'], '</span>'; |
| 1788 | + } |
|
| 1711 | 1789 | echo ' |
| 1712 | 1790 | </dt> |
| 1713 | 1791 | <dd>'; |
@@ -1745,13 +1823,11 @@ discard block |
||
| 1745 | 1823 | |
| 1746 | 1824 | echo ' |
| 1747 | 1825 | <input type="number"', $min . $max . $step; |
| 1748 | - } |
|
| 1749 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1826 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
| 1750 | 1827 | { |
| 1751 | 1828 | echo' |
| 1752 | 1829 | <input type="url"'; |
| 1753 | - } |
|
| 1754 | - else |
|
| 1830 | + } else |
|
| 1755 | 1831 | { |
| 1756 | 1832 | echo ' |
| 1757 | 1833 | <input type="text"'; |
@@ -1790,8 +1866,8 @@ discard block |
||
| 1790 | 1866 | <dl class="settings">'; |
| 1791 | 1867 | |
| 1792 | 1868 | // Allow notification on announcements to be disabled? |
| 1793 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
| 1794 | - echo ' |
|
| 1869 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
| 1870 | + echo ' |
|
| 1795 | 1871 | <dt> |
| 1796 | 1872 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
| 1797 | 1873 | </dt> |
@@ -1799,9 +1875,10 @@ discard block |
||
| 1799 | 1875 | <input type="hidden" name="notify_announcements" value="0"> |
| 1800 | 1876 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
| 1801 | 1877 | </dd>'; |
| 1878 | + } |
|
| 1802 | 1879 | |
| 1803 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
| 1804 | - echo ' |
|
| 1880 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
| 1881 | + echo ' |
|
| 1805 | 1882 | <dt> |
| 1806 | 1883 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
| 1807 | 1884 | </dt> |
@@ -1809,6 +1886,7 @@ discard block |
||
| 1809 | 1886 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
| 1810 | 1887 | </dd> |
| 1811 | 1888 | '; |
| 1889 | + } |
|
| 1812 | 1890 | |
| 1813 | 1891 | echo ' |
| 1814 | 1892 | </dl> |
@@ -1838,9 +1916,10 @@ discard block |
||
| 1838 | 1916 | <td colspan="3">'; |
| 1839 | 1917 | $label = $txt['alert_opt_' . $opts[1]]; |
| 1840 | 1918 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
| 1841 | - if ($label_pos == 'before') |
|
| 1842 | - echo ' |
|
| 1919 | + if ($label_pos == 'before') { |
|
| 1920 | + echo ' |
|
| 1843 | 1921 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1922 | + } |
|
| 1844 | 1923 | |
| 1845 | 1924 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
| 1846 | 1925 | switch ($opts[0]) |
@@ -1852,17 +1931,19 @@ discard block |
||
| 1852 | 1931 | case 'select': |
| 1853 | 1932 | echo ' |
| 1854 | 1933 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
| 1855 | - foreach ($opts['opts'] as $k => $v) |
|
| 1856 | - echo ' |
|
| 1934 | + foreach ($opts['opts'] as $k => $v) { |
|
| 1935 | + echo ' |
|
| 1857 | 1936 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
| 1937 | + } |
|
| 1858 | 1938 | echo ' |
| 1859 | 1939 | </select>'; |
| 1860 | 1940 | break; |
| 1861 | 1941 | } |
| 1862 | 1942 | |
| 1863 | - if ($label_pos == 'after') |
|
| 1864 | - echo ' |
|
| 1943 | + if ($label_pos == 'after') { |
|
| 1944 | + echo ' |
|
| 1865 | 1945 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
| 1946 | + } |
|
| 1866 | 1947 | |
| 1867 | 1948 | echo ' |
| 1868 | 1949 | </td> |
@@ -1976,11 +2057,12 @@ discard block |
||
| 1976 | 2057 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
| 1977 | 2058 | |
| 1978 | 2059 | // Do we have an update message? |
| 1979 | - if (!empty($context['update_message'])) |
|
| 1980 | - echo ' |
|
| 2060 | + if (!empty($context['update_message'])) { |
|
| 2061 | + echo ' |
|
| 1981 | 2062 | <div class="infobox"> |
| 1982 | 2063 | ', $context['update_message'], '. |
| 1983 | 2064 | </div>'; |
| 2065 | + } |
|
| 1984 | 2066 | |
| 1985 | 2067 | echo ' |
| 1986 | 2068 | <div id="groups">'; |
@@ -2002,8 +2084,7 @@ discard block |
||
| 2002 | 2084 | </div> |
| 2003 | 2085 | </div> |
| 2004 | 2086 | </div>'; |
| 2005 | - } |
|
| 2006 | - else |
|
| 2087 | + } else |
|
| 2007 | 2088 | { |
| 2008 | 2089 | echo ' |
| 2009 | 2090 | <div class="title_bar"> |
@@ -2015,27 +2096,30 @@ discard block |
||
| 2015 | 2096 | echo ' |
| 2016 | 2097 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
| 2017 | 2098 | |
| 2018 | - if ($context['can_edit_primary']) |
|
| 2019 | - echo ' |
|
| 2099 | + if ($context['can_edit_primary']) { |
|
| 2100 | + echo ' |
|
| 2020 | 2101 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
| 2102 | + } |
|
| 2021 | 2103 | |
| 2022 | 2104 | echo ' |
| 2023 | 2105 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
| 2024 | 2106 | |
| 2025 | 2107 | // Can they leave their group? |
| 2026 | - if ($group['can_leave']) |
|
| 2027 | - echo ' |
|
| 2108 | + if ($group['can_leave']) { |
|
| 2109 | + echo ' |
|
| 2028 | 2110 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
| 2111 | + } |
|
| 2029 | 2112 | |
| 2030 | 2113 | echo ' |
| 2031 | 2114 | </div>'; |
| 2032 | 2115 | } |
| 2033 | 2116 | |
| 2034 | - if ($context['can_edit_primary']) |
|
| 2035 | - echo ' |
|
| 2117 | + if ($context['can_edit_primary']) { |
|
| 2118 | + echo ' |
|
| 2036 | 2119 | <div class="padding righttext"> |
| 2037 | 2120 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
| 2038 | 2121 | </div>'; |
| 2122 | + } |
|
| 2039 | 2123 | |
| 2040 | 2124 | // Any groups they can join? |
| 2041 | 2125 | if (!empty($context['groups']['available'])) |
@@ -2051,15 +2135,16 @@ discard block |
||
| 2051 | 2135 | <div class="windowbg"> |
| 2052 | 2136 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
| 2053 | 2137 | |
| 2054 | - if ($group['type'] == 3) |
|
| 2055 | - echo ' |
|
| 2138 | + if ($group['type'] == 3) { |
|
| 2139 | + echo ' |
|
| 2056 | 2140 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
| 2057 | - elseif ($group['type'] == 2 && $group['pending']) |
|
| 2058 | - echo ' |
|
| 2141 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
| 2142 | + echo ' |
|
| 2059 | 2143 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
| 2060 | - elseif ($group['type'] == 2) |
|
| 2061 | - echo ' |
|
| 2144 | + } elseif ($group['type'] == 2) { |
|
| 2145 | + echo ' |
|
| 2062 | 2146 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
| 2147 | + } |
|
| 2063 | 2148 | |
| 2064 | 2149 | echo ' |
| 2065 | 2150 | </div>'; |
@@ -2082,9 +2167,10 @@ discard block |
||
| 2082 | 2167 | |
| 2083 | 2168 | prevDiv.className = "windowbg"; |
| 2084 | 2169 | }'; |
| 2085 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
| 2086 | - echo ' |
|
| 2170 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
| 2171 | + echo ' |
|
| 2087 | 2172 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
| 2173 | + } |
|
| 2088 | 2174 | echo ' |
| 2089 | 2175 | </script>'; |
| 2090 | 2176 | } |
@@ -2092,9 +2178,10 @@ discard block |
||
| 2092 | 2178 | echo ' |
| 2093 | 2179 | </div>'; |
| 2094 | 2180 | |
| 2095 | - if (!empty($context['token_check'])) |
|
| 2096 | - echo ' |
|
| 2181 | + if (!empty($context['token_check'])) { |
|
| 2182 | + echo ' |
|
| 2097 | 2183 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2184 | + } |
|
| 2098 | 2185 | |
| 2099 | 2186 | echo ' |
| 2100 | 2187 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2141,14 +2228,15 @@ discard block |
||
| 2141 | 2228 | |
| 2142 | 2229 | foreach ($category['boards'] as $board) |
| 2143 | 2230 | { |
| 2144 | - if ($i == $limit) |
|
| 2145 | - echo ' |
|
| 2231 | + if ($i == $limit) { |
|
| 2232 | + echo ' |
|
| 2146 | 2233 | </ul> |
| 2147 | 2234 | </li> |
| 2148 | 2235 | </ul> |
| 2149 | 2236 | <ul class="ignoreboards floatright"> |
| 2150 | 2237 | <li class="category"> |
| 2151 | 2238 | <ul>'; |
| 2239 | + } |
|
| 2152 | 2240 | |
| 2153 | 2241 | echo ' |
| 2154 | 2242 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2194,10 +2282,11 @@ discard block |
||
| 2194 | 2282 | |
| 2195 | 2283 | // Work out the starting color. |
| 2196 | 2284 | $context['current_color'] = $context['colors'][0]; |
| 2197 | - foreach ($context['colors'] as $limit => $color) |
|
| 2198 | - if ($context['member']['warning'] >= $limit) |
|
| 2285 | + foreach ($context['colors'] as $limit => $color) { |
|
| 2286 | + if ($context['member']['warning'] >= $limit) |
|
| 2199 | 2287 | $context['current_color'] = $color; |
| 2200 | -} |
|
| 2288 | + } |
|
| 2289 | + } |
|
| 2201 | 2290 | |
| 2202 | 2291 | // Show all warnings of a user? |
| 2203 | 2292 | function template_viewWarning() |
@@ -2236,14 +2325,15 @@ discard block |
||
| 2236 | 2325 | </dd>'; |
| 2237 | 2326 | |
| 2238 | 2327 | // There's some impact of this? |
| 2239 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
| 2240 | - echo ' |
|
| 2328 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
| 2329 | + echo ' |
|
| 2241 | 2330 | <dt> |
| 2242 | 2331 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
| 2243 | 2332 | </dt> |
| 2244 | 2333 | <dd> |
| 2245 | 2334 | ', $context['level_effects'][$context['current_level']], ' |
| 2246 | 2335 | </dd>'; |
| 2336 | + } |
|
| 2247 | 2337 | |
| 2248 | 2338 | echo ' |
| 2249 | 2339 | </dl> |
@@ -2281,10 +2371,11 @@ discard block |
||
| 2281 | 2371 | |
| 2282 | 2372 | // Otherwise see what we can do...'; |
| 2283 | 2373 | |
| 2284 | - foreach ($context['notification_templates'] as $k => $type) |
|
| 2285 | - echo ' |
|
| 2374 | + foreach ($context['notification_templates'] as $k => $type) { |
|
| 2375 | + echo ' |
|
| 2286 | 2376 | if (index == ', $k, ') |
| 2287 | 2377 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
| 2378 | + } |
|
| 2288 | 2379 | |
| 2289 | 2380 | echo ' |
| 2290 | 2381 | } |
@@ -2294,10 +2385,11 @@ discard block |
||
| 2294 | 2385 | // Also set the right effect. |
| 2295 | 2386 | effectText = "";'; |
| 2296 | 2387 | |
| 2297 | - foreach ($context['level_effects'] as $limit => $text) |
|
| 2298 | - echo ' |
|
| 2388 | + foreach ($context['level_effects'] as $limit => $text) { |
|
| 2389 | + echo ' |
|
| 2299 | 2390 | if (slideAmount >= ', $limit, ') |
| 2300 | 2391 | effectText = "', $text, '";'; |
| 2392 | + } |
|
| 2301 | 2393 | |
| 2302 | 2394 | echo ' |
| 2303 | 2395 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2312,31 +2404,34 @@ discard block |
||
| 2312 | 2404 | </h3> |
| 2313 | 2405 | </div>'; |
| 2314 | 2406 | |
| 2315 | - if (!$context['user']['is_owner']) |
|
| 2316 | - echo ' |
|
| 2407 | + if (!$context['user']['is_owner']) { |
|
| 2408 | + echo ' |
|
| 2317 | 2409 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
| 2410 | + } |
|
| 2318 | 2411 | |
| 2319 | 2412 | echo ' |
| 2320 | 2413 | <div class="windowbg"> |
| 2321 | 2414 | <dl class="settings">'; |
| 2322 | 2415 | |
| 2323 | - if (!$context['user']['is_owner']) |
|
| 2324 | - echo ' |
|
| 2416 | + if (!$context['user']['is_owner']) { |
|
| 2417 | + echo ' |
|
| 2325 | 2418 | <dt> |
| 2326 | 2419 | <strong>', $txt['profile_warning_name'], ':</strong> |
| 2327 | 2420 | </dt> |
| 2328 | 2421 | <dd> |
| 2329 | 2422 | <strong>', $context['member']['name'], '</strong> |
| 2330 | 2423 | </dd>'; |
| 2424 | + } |
|
| 2331 | 2425 | |
| 2332 | 2426 | echo ' |
| 2333 | 2427 | <dt> |
| 2334 | 2428 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
| 2335 | 2429 | |
| 2336 | 2430 | // Is there only so much they can apply? |
| 2337 | - if ($context['warning_limit']) |
|
| 2338 | - echo ' |
|
| 2431 | + if ($context['warning_limit']) { |
|
| 2432 | + echo ' |
|
| 2339 | 2433 | <br><span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
| 2434 | + } |
|
| 2340 | 2435 | |
| 2341 | 2436 | echo ' |
| 2342 | 2437 | </dt> |
@@ -2389,9 +2484,10 @@ discard block |
||
| 2389 | 2484 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
| 2390 | 2485 | <option value="-1" disabled>------------------------------</option>'; |
| 2391 | 2486 | |
| 2392 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
| 2393 | - echo ' |
|
| 2487 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
| 2488 | + echo ' |
|
| 2394 | 2489 | <option value="', $id_template, '">', $template['title'], '</option>'; |
| 2490 | + } |
|
| 2395 | 2491 | |
| 2396 | 2492 | echo ' |
| 2397 | 2493 | </select> |
@@ -2404,9 +2500,10 @@ discard block |
||
| 2404 | 2500 | </dl> |
| 2405 | 2501 | <div class="righttext">'; |
| 2406 | 2502 | |
| 2407 | - if (!empty($context['token_check'])) |
|
| 2408 | - echo ' |
|
| 2503 | + if (!empty($context['token_check'])) { |
|
| 2504 | + echo ' |
|
| 2409 | 2505 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2506 | + } |
|
| 2410 | 2507 | |
| 2411 | 2508 | echo ' |
| 2412 | 2509 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2422,8 +2519,8 @@ discard block |
||
| 2422 | 2519 | echo ' |
| 2423 | 2520 | <script>'; |
| 2424 | 2521 | |
| 2425 | - if (!$context['user']['is_owner']) |
|
| 2426 | - echo ' |
|
| 2522 | + if (!$context['user']['is_owner']) { |
|
| 2523 | + echo ' |
|
| 2427 | 2524 | modifyWarnNotify(); |
| 2428 | 2525 | $(document).ready(function() { |
| 2429 | 2526 | $("#preview_button").click(function() { |
@@ -2462,6 +2559,7 @@ discard block |
||
| 2462 | 2559 | }); |
| 2463 | 2560 | return false; |
| 2464 | 2561 | }'; |
| 2562 | + } |
|
| 2465 | 2563 | |
| 2466 | 2564 | echo ' |
| 2467 | 2565 | </script>'; |
@@ -2484,16 +2582,18 @@ discard block |
||
| 2484 | 2582 | </div>'; |
| 2485 | 2583 | |
| 2486 | 2584 | // If deleting another account give them a lovely info box. |
| 2487 | - if (!$context['user']['is_owner']) |
|
| 2488 | - echo ' |
|
| 2585 | + if (!$context['user']['is_owner']) { |
|
| 2586 | + echo ' |
|
| 2489 | 2587 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
| 2588 | + } |
|
| 2490 | 2589 | echo ' |
| 2491 | 2590 | <div class="windowbg2">'; |
| 2492 | 2591 | |
| 2493 | 2592 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
| 2494 | - if ($context['needs_approval']) |
|
| 2495 | - echo ' |
|
| 2593 | + if ($context['needs_approval']) { |
|
| 2594 | + echo ' |
|
| 2496 | 2595 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
| 2596 | + } |
|
| 2497 | 2597 | |
| 2498 | 2598 | // If the user is deleting their own account warn them first - and require a password! |
| 2499 | 2599 | if ($context['user']['is_owner']) |
@@ -2505,9 +2605,10 @@ discard block |
||
| 2505 | 2605 | <input type="password" name="oldpasswrd" size="20"> |
| 2506 | 2606 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
| 2507 | 2607 | |
| 2508 | - if (!empty($context['token_check'])) |
|
| 2509 | - echo ' |
|
| 2608 | + if (!empty($context['token_check'])) { |
|
| 2609 | + echo ' |
|
| 2510 | 2610 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2611 | + } |
|
| 2511 | 2612 | |
| 2512 | 2613 | echo ' |
| 2513 | 2614 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2533,9 +2634,10 @@ discard block |
||
| 2533 | 2634 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
| 2534 | 2635 | </select>'; |
| 2535 | 2636 | |
| 2536 | - if ($context['show_perma_delete']) |
|
| 2537 | - echo ' |
|
| 2637 | + if ($context['show_perma_delete']) { |
|
| 2638 | + echo ' |
|
| 2538 | 2639 | <br><label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
| 2640 | + } |
|
| 2539 | 2641 | |
| 2540 | 2642 | echo ' |
| 2541 | 2643 | </div>'; |
@@ -2548,9 +2650,10 @@ discard block |
||
| 2548 | 2650 | <div> |
| 2549 | 2651 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
| 2550 | 2652 | |
| 2551 | - if (!empty($context['token_check'])) |
|
| 2552 | - echo ' |
|
| 2653 | + if (!empty($context['token_check'])) { |
|
| 2654 | + echo ' |
|
| 2553 | 2655 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2656 | + } |
|
| 2554 | 2657 | |
| 2555 | 2658 | echo ' |
| 2556 | 2659 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2576,8 +2679,8 @@ discard block |
||
| 2576 | 2679 | <hr>'; |
| 2577 | 2680 | |
| 2578 | 2681 | // Only show the password box if it's actually needed. |
| 2579 | - if ($context['require_password']) |
|
| 2580 | - echo ' |
|
| 2682 | + if ($context['require_password']) { |
|
| 2683 | + echo ' |
|
| 2581 | 2684 | <dl class="settings"> |
| 2582 | 2685 | <dt> |
| 2583 | 2686 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2587,13 +2690,15 @@ discard block |
||
| 2587 | 2690 | <input type="password" name="oldpasswrd" size="20"> |
| 2588 | 2691 | </dd> |
| 2589 | 2692 | </dl>'; |
| 2693 | + } |
|
| 2590 | 2694 | |
| 2591 | 2695 | echo ' |
| 2592 | 2696 | <div class="righttext">'; |
| 2593 | 2697 | |
| 2594 | - if (!empty($context['token_check'])) |
|
| 2595 | - echo ' |
|
| 2698 | + if (!empty($context['token_check'])) { |
|
| 2699 | + echo ' |
|
| 2596 | 2700 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
| 2701 | + } |
|
| 2597 | 2702 | |
| 2598 | 2703 | echo ' |
| 2599 | 2704 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2620,9 +2725,10 @@ discard block |
||
| 2620 | 2725 | <ul id="list_errors">'; |
| 2621 | 2726 | |
| 2622 | 2727 | // Cycle through each error and display an error message. |
| 2623 | - foreach ($context['post_errors'] as $error) |
|
| 2624 | - echo ' |
|
| 2728 | + foreach ($context['post_errors'] as $error) { |
|
| 2729 | + echo ' |
|
| 2625 | 2730 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
| 2731 | + } |
|
| 2626 | 2732 | |
| 2627 | 2733 | echo ' |
| 2628 | 2734 | </ul>'; |
@@ -2648,12 +2754,13 @@ discard block |
||
| 2648 | 2754 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
| 2649 | 2755 | |
| 2650 | 2756 | // Fill the select box with all primary member groups that can be assigned to a member. |
| 2651 | - foreach ($context['member_groups'] as $member_group) |
|
| 2652 | - if (!empty($member_group['can_be_primary'])) |
|
| 2757 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2758 | + if (!empty($member_group['can_be_primary'])) |
|
| 2653 | 2759 | echo ' |
| 2654 | 2760 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
| 2655 | 2761 | ', $member_group['name'], ' |
| 2656 | 2762 | </option>'; |
| 2763 | + } |
|
| 2657 | 2764 | echo ' |
| 2658 | 2765 | </select> |
| 2659 | 2766 | </dd> |
@@ -2665,10 +2772,11 @@ discard block |
||
| 2665 | 2772 | <input type="hidden" name="additional_groups[]" value="0">'; |
| 2666 | 2773 | |
| 2667 | 2774 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
| 2668 | - foreach ($context['member_groups'] as $member_group) |
|
| 2669 | - if ($member_group['can_be_additional']) |
|
| 2775 | + foreach ($context['member_groups'] as $member_group) { |
|
| 2776 | + if ($member_group['can_be_additional']) |
|
| 2670 | 2777 | echo ' |
| 2671 | 2778 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
| 2779 | + } |
|
| 2672 | 2780 | echo ' |
| 2673 | 2781 | </span> |
| 2674 | 2782 | <a href="javascript:void(0);" onclick="document.getElementById(\'additional_groupsList\').style.display = \'block\'; document.getElementById(\'additional_groupsLink\').style.display = \'none\'; return false;" id="additional_groupsLink" style="display: none;" class="toggle_down">', $txt['additional_membergroups_show'], '</a> |
@@ -2728,9 +2836,10 @@ discard block |
||
| 2728 | 2836 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
| 2729 | 2837 | <br>'; |
| 2730 | 2838 | |
| 2731 | - if ($context['show_spellchecking']) |
|
| 2732 | - echo ' |
|
| 2839 | + if ($context['show_spellchecking']) { |
|
| 2840 | + echo ' |
|
| 2733 | 2841 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
| 2842 | + } |
|
| 2734 | 2843 | |
| 2735 | 2844 | echo ' |
| 2736 | 2845 | </dt> |
@@ -2738,17 +2847,20 @@ discard block |
||
| 2738 | 2847 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
| 2739 | 2848 | |
| 2740 | 2849 | // If there is a limit at all! |
| 2741 | - if (!empty($context['signature_limits']['max_length'])) |
|
| 2742 | - echo ' |
|
| 2850 | + if (!empty($context['signature_limits']['max_length'])) { |
|
| 2851 | + echo ' |
|
| 2743 | 2852 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
| 2853 | + } |
|
| 2744 | 2854 | |
| 2745 | - if (!empty($context['show_preview_button'])) |
|
| 2746 | - echo ' |
|
| 2855 | + if (!empty($context['show_preview_button'])) { |
|
| 2856 | + echo ' |
|
| 2747 | 2857 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button">'; |
| 2858 | + } |
|
| 2748 | 2859 | |
| 2749 | - if ($context['signature_warning']) |
|
| 2750 | - echo ' |
|
| 2860 | + if ($context['signature_warning']) { |
|
| 2861 | + echo ' |
|
| 2751 | 2862 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
| 2863 | + } |
|
| 2752 | 2864 | |
| 2753 | 2865 | // Some javascript used to count how many characters have been used so far in the signature. |
| 2754 | 2866 | echo ' |
@@ -2792,9 +2904,10 @@ discard block |
||
| 2792 | 2904 | <div> |
| 2793 | 2905 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
| 2794 | 2906 | // This lists all the file categories. |
| 2795 | - foreach ($context['avatars'] as $avatar) |
|
| 2796 | - echo ' |
|
| 2907 | + foreach ($context['avatars'] as $avatar) { |
|
| 2908 | + echo ' |
|
| 2797 | 2909 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
| 2910 | + } |
|
| 2798 | 2911 | echo ' |
| 2799 | 2912 | </select> |
| 2800 | 2913 | </div> |
@@ -2849,16 +2962,17 @@ discard block |
||
| 2849 | 2962 | <div id="avatar_gravatar"> |
| 2850 | 2963 | <img src="' . $context['member']['avatar']['href'] . '" alt="" />'; |
| 2851 | 2964 | |
| 2852 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
| 2853 | - echo ' |
|
| 2965 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
| 2966 | + echo ' |
|
| 2854 | 2967 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
| 2855 | - else |
|
| 2968 | + } else |
|
| 2856 | 2969 | { |
| 2857 | 2970 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
| 2858 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
| 2859 | - $textbox_value = ''; |
|
| 2860 | - else |
|
| 2861 | - $textbox_value = $context['member']['avatar']['external']; |
|
| 2971 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
| 2972 | + $textbox_value = ''; |
|
| 2973 | + } else { |
|
| 2974 | + $textbox_value = $context['member']['avatar']['external']; |
|
| 2975 | + } |
|
| 2862 | 2976 | |
| 2863 | 2977 | echo ' |
| 2864 | 2978 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -2930,8 +3044,9 @@ discard block |
||
| 2930 | 3044 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
| 2931 | 3045 | |
| 2932 | 3046 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
| 2933 | - if (empty($suffix)) |
|
| 2934 | - return; |
|
| 3047 | + if (empty($suffix)) { |
|
| 3048 | + return; |
|
| 3049 | + } |
|
| 2935 | 3050 | |
| 2936 | 3051 | echo ' |
| 2937 | 3052 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -2953,9 +3068,10 @@ discard block |
||
| 2953 | 3068 | <dd> |
| 2954 | 3069 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
| 2955 | 3070 | // Help the user by showing a list of common time formats. |
| 2956 | - foreach ($context['easy_timeformats'] as $time_format) |
|
| 2957 | - echo ' |
|
| 3071 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
| 3072 | + echo ' |
|
| 2958 | 3073 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
| 3074 | + } |
|
| 2959 | 3075 | echo ' |
| 2960 | 3076 | </select><br> |
| 2961 | 3077 | <input type="text" name="time_format" id="time_format" value="', $context['member']['time_format'], '" size="30"> |
@@ -2991,9 +3107,10 @@ discard block |
||
| 2991 | 3107 | </dt> |
| 2992 | 3108 | <dd> |
| 2993 | 3109 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.gif\';">'; |
| 2994 | - foreach ($context['smiley_sets'] as $set) |
|
| 2995 | - echo ' |
|
| 3110 | + foreach ($context['smiley_sets'] as $set) { |
|
| 3111 | + echo ' |
|
| 2996 | 3112 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
| 3113 | + } |
|
| 2997 | 3114 | echo ' |
| 2998 | 3115 | </select> |
| 2999 | 3116 | <img id="smileypr" class="centericon" src="', $context['member']['smiley_set']['id'] != 'none' ? $modSettings['smileys_url'] . '/' . ($context['member']['smiley_set']['id'] != '' ? $context['member']['smiley_set']['id'] : (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'])) . '/smiley.gif' : $settings['images_url'] . '/blank.png', '" alt=":)"> |
@@ -3044,10 +3161,11 @@ discard block |
||
| 3044 | 3161 | <img src="', $context['tfa_qr_url'], '" alt=""> |
| 3045 | 3162 | </div>'; |
| 3046 | 3163 | |
| 3047 | - if (!empty($context['from_ajax'])) |
|
| 3048 | - echo ' |
|
| 3164 | + if (!empty($context['from_ajax'])) { |
|
| 3165 | + echo ' |
|
| 3049 | 3166 | <br> |
| 3050 | 3167 | <a href="javascript:self.close();"></a>'; |
| 3168 | + } |
|
| 3051 | 3169 | |
| 3052 | 3170 | echo ' |
| 3053 | 3171 | </div> |
@@ -3086,15 +3204,16 @@ discard block |
||
| 3086 | 3204 | <br><div class="smalltext">', $txt['tfa_profile_desc'], '</div> |
| 3087 | 3205 | </dt> |
| 3088 | 3206 | <dd>'; |
| 3089 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
| 3090 | - echo ' |
|
| 3207 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
| 3208 | + echo ' |
|
| 3091 | 3209 | <a href="', !empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
| 3092 | - elseif (!$context['tfa_enabled']) |
|
| 3093 | - echo ' |
|
| 3210 | + } elseif (!$context['tfa_enabled']) { |
|
| 3211 | + echo ' |
|
| 3094 | 3212 | ', $txt['tfa_profile_disabled']; |
| 3095 | - else |
|
| 3096 | - echo ' |
|
| 3213 | + } else { |
|
| 3214 | + echo ' |
|
| 3097 | 3215 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
| 3216 | + } |
|
| 3098 | 3217 | echo ' |
| 3099 | 3218 | </dd>'; |
| 3100 | 3219 | } |
@@ -25,13 +25,15 @@ discard block |
||
| 25 | 25 | </h3> |
| 26 | 26 | </div>'; |
| 27 | 27 | |
| 28 | - if (!empty($context['search_errors'])) |
|
| 29 | - echo ' |
|
| 28 | + if (!empty($context['search_errors'])) { |
|
| 29 | + echo ' |
|
| 30 | 30 | <div class="errorbox">', implode('<br>', $context['search_errors']['messages']), '</div>'; |
| 31 | + } |
|
| 31 | 32 | |
| 32 | - if (!empty($context['search_ignored'])) |
|
| 33 | - echo ' |
|
| 33 | + if (!empty($context['search_ignored'])) { |
|
| 34 | + echo ' |
|
| 34 | 35 | <p class="noticebox">', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p>'; |
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | echo ' |
| 37 | 39 | <div id="advanced_search" class="roundframe"> |
@@ -42,9 +44,10 @@ discard block |
||
| 42 | 44 | <dd> |
| 43 | 45 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
| 44 | 46 | |
| 45 | - if (empty($modSettings['search_simple_fulltext'])) |
|
| 46 | - echo ' |
|
| 47 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
| 48 | + echo ' |
|
| 47 | 49 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
| 50 | + } |
|
| 48 | 51 | |
| 49 | 52 | echo ' |
| 50 | 53 | </dd> |
@@ -115,11 +118,12 @@ discard block |
||
| 115 | 118 | } |
| 116 | 119 | |
| 117 | 120 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
| 118 | - if (!empty($context['search_params']['topic'])) |
|
| 119 | - echo ' |
|
| 121 | + if (!empty($context['search_params']['topic'])) { |
|
| 122 | + echo ' |
|
| 120 | 123 | <p>', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '".</p> |
| 121 | 124 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
| 122 | 125 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
| 126 | + } |
|
| 123 | 127 | |
| 124 | 128 | echo ' |
| 125 | 129 | </div>'; |
@@ -149,14 +153,15 @@ discard block |
||
| 149 | 153 | |
| 150 | 154 | foreach ($category['boards'] as $board) |
| 151 | 155 | { |
| 152 | - if ($i == $limit) |
|
| 153 | - echo ' |
|
| 156 | + if ($i == $limit) { |
|
| 157 | + echo ' |
|
| 154 | 158 | </ul> |
| 155 | 159 | </li> |
| 156 | 160 | </ul> |
| 157 | 161 | <ul class="ignoreboards floatright"> |
| 158 | 162 | <li class="category"> |
| 159 | 163 | <ul>'; |
| 164 | + } |
|
| 160 | 165 | |
| 161 | 166 | echo ' |
| 162 | 167 | <li class="board"> |
@@ -244,13 +249,15 @@ discard block |
||
| 244 | 249 | <div class="roundframe">'; |
| 245 | 250 | |
| 246 | 251 | // Did they make any typos or mistakes, perhaps? |
| 247 | - if (isset($context['did_you_mean'])) |
|
| 248 | - echo ' |
|
| 252 | + if (isset($context['did_you_mean'])) { |
|
| 253 | + echo ' |
|
| 249 | 254 | <p>', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.</p>'; |
| 255 | + } |
|
| 250 | 256 | |
| 251 | - if (!empty($context['search_ignored'])) |
|
| 252 | - echo ' |
|
| 257 | + if (!empty($context['search_ignored'])) { |
|
| 258 | + echo ' |
|
| 253 | 259 | <p>', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p>'; |
| 260 | + } |
|
| 254 | 261 | |
| 255 | 262 | echo ' |
| 256 | 263 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -272,10 +279,11 @@ discard block |
||
| 272 | 279 | <input type="hidden" name="maxage" value="', !empty($context['search_params']['maxage']) ? $context['search_params']['maxage'] : '9999', '"> |
| 273 | 280 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
| 274 | 281 | </div>'; |
| 275 | - if (!empty($context['search_params']['brd'])) |
|
| 276 | - foreach ($context['search_params']['brd'] as $board_id) |
|
| 282 | + if (!empty($context['search_params']['brd'])) { |
|
| 283 | + foreach ($context['search_params']['brd'] as $board_id) |
|
| 277 | 284 | echo ' |
| 278 | 285 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
| 286 | + } |
|
| 279 | 287 | |
| 280 | 288 | echo ' |
| 281 | 289 | </form> |
@@ -286,17 +294,19 @@ discard block |
||
| 286 | 294 | if ($context['compact']) |
| 287 | 295 | { |
| 288 | 296 | // Quick moderation set to checkboxes? Oh, how fun :/. |
| 289 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 290 | - echo ' |
|
| 297 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 298 | + echo ' |
|
| 291 | 299 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
| 300 | + } |
|
| 292 | 301 | |
| 293 | 302 | echo ' |
| 294 | 303 | <div class="cat_bar"> |
| 295 | 304 | <h3 class="catbg"> |
| 296 | 305 | <span class="floatright">'; |
| 297 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 298 | - echo ' |
|
| 306 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 307 | + echo ' |
|
| 299 | 308 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
| 309 | + } |
|
| 300 | 310 | echo ' |
| 301 | 311 | </span> |
| 302 | 312 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -304,14 +314,15 @@ discard block |
||
| 304 | 314 | </div>'; |
| 305 | 315 | |
| 306 | 316 | // was anything even found? |
| 307 | - if (!empty($context['topics'])) |
|
| 308 | - echo' |
|
| 317 | + if (!empty($context['topics'])) { |
|
| 318 | + echo' |
|
| 309 | 319 | <div class="pagesection"> |
| 310 | 320 | <span>', $context['page_index'], '</span> |
| 311 | 321 | </div>'; |
| 312 | - else |
|
| 313 | - echo ' |
|
| 322 | + } else { |
|
| 323 | + echo ' |
|
| 314 | 324 | <div class="roundframe">', $txt['find_no_results'], '</div>'; |
| 325 | + } |
|
| 315 | 326 | |
| 316 | 327 | // while we have results to show ... |
| 317 | 328 | while ($topic = $context['get_topics']()) |
@@ -339,38 +350,43 @@ discard block |
||
| 339 | 350 | { |
| 340 | 351 | echo ' |
| 341 | 352 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
| 342 | - } |
|
| 343 | - else |
|
| 353 | + } else |
|
| 344 | 354 | { |
| 345 | - if ($topic['quick_mod']['remove']) |
|
| 346 | - echo ' |
|
| 355 | + if ($topic['quick_mod']['remove']) { |
|
| 356 | + echo ' |
|
| 347 | 357 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
| 358 | + } |
|
| 348 | 359 | |
| 349 | - if ($topic['quick_mod']['lock']) |
|
| 350 | - echo ' |
|
| 360 | + if ($topic['quick_mod']['lock']) { |
|
| 361 | + echo ' |
|
| 351 | 362 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
| 363 | + } |
|
| 352 | 364 | |
| 353 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 354 | - echo ' |
|
| 365 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 366 | + echo ' |
|
| 355 | 367 | <br>'; |
| 368 | + } |
|
| 356 | 369 | |
| 357 | - if ($topic['quick_mod']['sticky']) |
|
| 358 | - echo ' |
|
| 370 | + if ($topic['quick_mod']['sticky']) { |
|
| 371 | + echo ' |
|
| 359 | 372 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
| 373 | + } |
|
| 360 | 374 | |
| 361 | - if ($topic['quick_mod']['move']) |
|
| 362 | - echo ' |
|
| 375 | + if ($topic['quick_mod']['move']) { |
|
| 376 | + echo ' |
|
| 363 | 377 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
| 378 | + } |
|
| 364 | 379 | } |
| 365 | 380 | |
| 366 | 381 | echo ' |
| 367 | 382 | </div>'; |
| 368 | 383 | } |
| 369 | 384 | |
| 370 | - if ($message['body_highlighted'] != '') |
|
| 371 | - echo ' |
|
| 385 | + if ($message['body_highlighted'] != '') { |
|
| 386 | + echo ' |
|
| 372 | 387 | <br class="clear"> |
| 373 | 388 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
| 389 | + } |
|
| 374 | 390 | } |
| 375 | 391 | |
| 376 | 392 | echo ' |
@@ -378,11 +394,12 @@ discard block |
||
| 378 | 394 | </div>'; |
| 379 | 395 | |
| 380 | 396 | } |
| 381 | - if (!empty($context['topics'])) |
|
| 382 | - echo ' |
|
| 397 | + if (!empty($context['topics'])) { |
|
| 398 | + echo ' |
|
| 383 | 399 | <div class="pagesection"> |
| 384 | 400 | <span>', $context['page_index'], '</span> |
| 385 | 401 | </div>'; |
| 402 | + } |
|
| 386 | 403 | |
| 387 | 404 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
| 388 | 405 | { |
@@ -392,17 +409,19 @@ discard block |
||
| 392 | 409 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 393 | 410 | <option value="">--------</option>'; |
| 394 | 411 | |
| 395 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 396 | - if ($context['can_' . $qmod_action]) |
|
| 412 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 413 | + if ($context['can_' . $qmod_action]) |
|
| 397 | 414 | echo ' |
| 398 | 415 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 416 | + } |
|
| 399 | 417 | |
| 400 | 418 | echo ' |
| 401 | 419 | </select>'; |
| 402 | 420 | |
| 403 | - if ($context['can_move']) |
|
| 404 | - echo ' |
|
| 421 | + if ($context['can_move']) { |
|
| 422 | + echo ' |
|
| 405 | 423 | <span id="quick_mod_jump_to"> </span>'; |
| 424 | + } |
|
| 406 | 425 | |
| 407 | 426 | echo ' |
| 408 | 427 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -412,13 +431,13 @@ discard block |
||
| 412 | 431 | } |
| 413 | 432 | |
| 414 | 433 | |
| 415 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
| 416 | - echo ' |
|
| 434 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
| 435 | + echo ' |
|
| 417 | 436 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 418 | 437 | </form>'; |
| 438 | + } |
|
| 419 | 439 | |
| 420 | - } |
|
| 421 | - else |
|
| 440 | + } else |
|
| 422 | 441 | { |
| 423 | 442 | echo ' |
| 424 | 443 | <div class="cat_bar"> |
@@ -430,9 +449,10 @@ discard block |
||
| 430 | 449 | <span>', $context['page_index'], '</span> |
| 431 | 450 | </div>'; |
| 432 | 451 | |
| 433 | - if (empty($context['topics'])) |
|
| 434 | - echo ' |
|
| 452 | + if (empty($context['topics'])) { |
|
| 453 | + echo ' |
|
| 435 | 454 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
| 455 | + } |
|
| 436 | 456 | |
| 437 | 457 | while ($topic = $context['get_topics']()) |
| 438 | 458 | { |
@@ -447,23 +467,27 @@ discard block |
||
| 447 | 467 | </div> |
| 448 | 468 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
| 449 | 469 | |
| 450 | - if ($topic['can_reply']) |
|
| 451 | - echo ' |
|
| 470 | + if ($topic['can_reply']) { |
|
| 471 | + echo ' |
|
| 452 | 472 | <ul class="quickbuttons">'; |
| 473 | + } |
|
| 453 | 474 | |
| 454 | 475 | // If they *can* reply? |
| 455 | - if ($topic['can_reply']) |
|
| 456 | - echo ' |
|
| 476 | + if ($topic['can_reply']) { |
|
| 477 | + echo ' |
|
| 457 | 478 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
| 479 | + } |
|
| 458 | 480 | |
| 459 | 481 | // If they *can* quote? |
| 460 | - if ($topic['can_quote']) |
|
| 461 | - echo ' |
|
| 482 | + if ($topic['can_quote']) { |
|
| 483 | + echo ' |
|
| 462 | 484 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
| 485 | + } |
|
| 463 | 486 | |
| 464 | - if ($topic['can_reply']) |
|
| 465 | - echo ' |
|
| 487 | + if ($topic['can_reply']) { |
|
| 488 | + echo ' |
|
| 466 | 489 | </ul>'; |
| 490 | + } |
|
| 467 | 491 | echo ' |
| 468 | 492 | <br class="clear"> |
| 469 | 493 | </div>'; |
@@ -482,8 +506,8 @@ discard block |
||
| 482 | 506 | <div class="smalltext righttext" id="search_jump_to"> </div> |
| 483 | 507 | <script>'; |
| 484 | 508 | |
| 485 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 486 | - echo ' |
|
| 509 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 510 | + echo ' |
|
| 487 | 511 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 488 | 512 | aJumpTo[aJumpTo.length] = new JumpTo({ |
| 489 | 513 | sContainerId: "quick_mod_jump_to", |
@@ -498,6 +522,7 @@ discard block |
||
| 498 | 522 | bDisabled: true, |
| 499 | 523 | sCustomName: "move_to" |
| 500 | 524 | });'; |
| 525 | + } |
|
| 501 | 526 | |
| 502 | 527 | echo ' |
| 503 | 528 | if (typeof(window.XMLHttpRequest) != "undefined") |