@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
| 54 | 55 | return; |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | - if (empty($modSettings['search_custom_index_config'])) |
|
| 58 | - return; |
|
| 58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 59 | 61 | |
| 60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 61 | 63 | |
@@ -117,21 +119,23 @@ discard block |
||
| 117 | 119 | |
| 118 | 120 | $subwords = text2words($word, $this->min_word_length, true); |
| 119 | 121 | |
| 120 | - if (empty($modSettings['search_force_index'])) |
|
| 121 | - $wordsSearch['words'][] = $word; |
|
| 122 | + if (empty($modSettings['search_force_index'])) { |
|
| 123 | + $wordsSearch['words'][] = $word; |
|
| 124 | + } |
|
| 122 | 125 | |
| 123 | 126 | // Excluded phrases don't benefit from being split into subwords. |
| 124 | - if (count($subwords) > 1 && $isExcluded) |
|
| 125 | - return; |
|
| 126 | - else |
|
| 127 | + if (count($subwords) > 1 && $isExcluded) { |
|
| 128 | + return; |
|
| 129 | + } else |
|
| 127 | 130 | { |
| 128 | 131 | foreach ($subwords as $subword) |
| 129 | 132 | { |
| 130 | 133 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
| 131 | 134 | { |
| 132 | 135 | $wordsSearch['indexed_words'][] = $subword; |
| 133 | - if ($isExcluded) |
|
| 134 | - $wordsExclude[] = $subword; |
|
| 136 | + if ($isExcluded) { |
|
| 137 | + $wordsExclude[] = $subword; |
|
| 138 | + } |
|
| 135 | 139 | } |
| 136 | 140 | } |
| 137 | 141 | } |
@@ -152,8 +156,9 @@ discard block |
||
| 152 | 156 | $query_where = array(); |
| 153 | 157 | $query_params = $search_data['params']; |
| 154 | 158 | |
| 155 | - if ($query_params['id_search']) |
|
| 156 | - $query_select['id_search'] = '{int:id_search}'; |
|
| 159 | + if ($query_params['id_search']) { |
|
| 160 | + $query_select['id_search'] = '{int:id_search}'; |
|
| 161 | + } |
|
| 157 | 162 | |
| 158 | 163 | $count = 0; |
| 159 | 164 | foreach ($words['words'] as $regularWord) |
@@ -162,30 +167,37 @@ discard block |
||
| 162 | 167 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | - if ($query_params['user_query']) |
|
| 166 | - $query_where[] = '{raw:user_query}'; |
|
| 167 | - if ($query_params['board_query']) |
|
| 168 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 170 | + if ($query_params['user_query']) { |
|
| 171 | + $query_where[] = '{raw:user_query}'; |
|
| 172 | + } |
|
| 173 | + if ($query_params['board_query']) { |
|
| 174 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
| 175 | + } |
|
| 169 | 176 | |
| 170 | - if ($query_params['topic']) |
|
| 171 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 172 | - if ($query_params['min_msg_id']) |
|
| 173 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 174 | - if ($query_params['max_msg_id']) |
|
| 175 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 177 | + if ($query_params['topic']) { |
|
| 178 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
| 179 | + } |
|
| 180 | + if ($query_params['min_msg_id']) { |
|
| 181 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
| 182 | + } |
|
| 183 | + if ($query_params['max_msg_id']) { |
|
| 184 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
| 185 | + } |
|
| 176 | 186 | |
| 177 | 187 | $count = 0; |
| 178 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
| 179 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 188 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
| 189 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
| 180 | 190 | { |
| 181 | 191 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
| 192 | + } |
|
| 182 | 193 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
| 183 | 194 | } |
| 184 | 195 | $count = 0; |
| 185 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
| 186 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 196 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
| 197 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
| 187 | 198 | { |
| 188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
| 200 | + } |
|
| 189 | 201 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
| 190 | 202 | } |
| 191 | 203 | |
@@ -198,8 +210,7 @@ discard block |
||
| 198 | 210 | { |
| 199 | 211 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
| 200 | 212 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
| 201 | - } |
|
| 202 | - else |
|
| 213 | + } else |
|
| 203 | 214 | { |
| 204 | 215 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
| 205 | 216 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -235,16 +246,18 @@ discard block |
||
| 235 | 246 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
| 236 | 247 | |
| 237 | 248 | $inserts = array(); |
| 238 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
| 239 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 249 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
| 250 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 251 | + } |
|
| 240 | 252 | |
| 241 | - if (!empty($inserts)) |
|
| 242 | - $smcFunc['db_insert']('ignore', |
|
| 253 | + if (!empty($inserts)) { |
|
| 254 | + $smcFunc['db_insert']('ignore', |
|
| 243 | 255 | '{db_prefix}log_search_words', |
| 244 | 256 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 245 | 257 | $inserts, |
| 246 | 258 | array('id_word', 'id_msg') |
| 247 | 259 | ); |
| 260 | + } |
|
| 248 | 261 | } |
| 249 | 262 | |
| 250 | 263 | /** |
@@ -287,8 +300,9 @@ discard block |
||
| 287 | 300 | if (!empty($inserted_words)) |
| 288 | 301 | { |
| 289 | 302 | $inserts = array(); |
| 290 | - foreach ($inserted_words as $word) |
|
| 291 | - $inserts[] = array($word, $msgOptions['id']); |
|
| 303 | + foreach ($inserted_words as $word) { |
|
| 304 | + $inserts[] = array($word, $msgOptions['id']); |
|
| 305 | + } |
|
| 292 | 306 | $smcFunc['db_insert']('insert', |
| 293 | 307 | '{db_prefix}log_search_words', |
| 294 | 308 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -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 | /** |
@@ -44,8 +45,9 @@ discard block |
||
| 44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
| 45 | 46 | |
| 46 | 47 | // Is it elsewhere? |
| 47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
| 48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
| 49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | // Do the permission check, you might not be allowed her. |
| 51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
| 104 | 106 | 'function' => function($rowData) use ($scripturl) |
| 105 | 107 | { |
| 106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
| 107 | - if ($rowData['id_group'] == 3) |
|
| 108 | - $group_name = $rowData['group_name']; |
|
| 109 | - else |
|
| 109 | + if ($rowData['id_group'] == 3) { |
|
| 110 | + $group_name = $rowData['group_name']; |
|
| 111 | + } else |
|
| 110 | 112 | { |
| 111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | // Add a help option for moderator and administrator. |
| 116 | - if ($rowData['id_group'] == 1) |
|
| 117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | - elseif ($rowData['id_group'] == 3) |
|
| 119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 118 | + if ($rowData['id_group'] == 1) { |
|
| 119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 120 | + } elseif ($rowData['id_group'] == 3) { |
|
| 121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | return $group_name; |
| 122 | 125 | }, |
@@ -329,12 +332,14 @@ discard block |
||
| 329 | 332 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
| 330 | 333 | |
| 331 | 334 | // Update the post groups now, if this is a post group! |
| 332 | - if (isset($_POST['min_posts'])) |
|
| 333 | - updateStats('postgroups'); |
|
| 335 | + if (isset($_POST['min_posts'])) { |
|
| 336 | + updateStats('postgroups'); |
|
| 337 | + } |
|
| 334 | 338 | |
| 335 | 339 | // You cannot set permissions for post groups if they are disabled. |
| 336 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
| 337 | - $_POST['perm_type'] = ''; |
|
| 340 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
| 341 | + $_POST['perm_type'] = ''; |
|
| 342 | + } |
|
| 338 | 343 | |
| 339 | 344 | if ($_POST['perm_type'] == 'predefined') |
| 340 | 345 | { |
@@ -364,8 +369,9 @@ discard block |
||
| 364 | 369 | $smcFunc['db_free_result']($request); |
| 365 | 370 | |
| 366 | 371 | // Protected groups are... well, protected! |
| 367 | - if ($copy_type == 1) |
|
| 368 | - fatal_lang_error('membergroup_does_not_exist'); |
|
| 372 | + if ($copy_type == 1) { |
|
| 373 | + fatal_lang_error('membergroup_does_not_exist'); |
|
| 374 | + } |
|
| 369 | 375 | } |
| 370 | 376 | |
| 371 | 377 | // Don't allow copying of a real priviledged person! |
@@ -383,18 +389,20 @@ discard block |
||
| 383 | 389 | $inserts = array(); |
| 384 | 390 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 385 | 391 | { |
| 386 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
| 387 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 392 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
| 393 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
| 394 | + } |
|
| 388 | 395 | } |
| 389 | 396 | $smcFunc['db_free_result']($request); |
| 390 | 397 | |
| 391 | - if (!empty($inserts)) |
|
| 392 | - $smcFunc['db_insert']('insert', |
|
| 398 | + if (!empty($inserts)) { |
|
| 399 | + $smcFunc['db_insert']('insert', |
|
| 393 | 400 | '{db_prefix}permissions', |
| 394 | 401 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 395 | 402 | $inserts, |
| 396 | 403 | array('id_group', 'permission') |
| 397 | 404 | ); |
| 405 | + } |
|
| 398 | 406 | |
| 399 | 407 | $request = $smcFunc['db_query']('', ' |
| 400 | 408 | SELECT id_profile, permission, add_deny |
@@ -405,17 +413,19 @@ discard block |
||
| 405 | 413 | ) |
| 406 | 414 | ); |
| 407 | 415 | $inserts = array(); |
| 408 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 409 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 416 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 417 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
| 418 | + } |
|
| 410 | 419 | $smcFunc['db_free_result']($request); |
| 411 | 420 | |
| 412 | - if (!empty($inserts)) |
|
| 413 | - $smcFunc['db_insert']('insert', |
|
| 421 | + if (!empty($inserts)) { |
|
| 422 | + $smcFunc['db_insert']('insert', |
|
| 414 | 423 | '{db_prefix}board_permissions', |
| 415 | 424 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
| 416 | 425 | $inserts, |
| 417 | 426 | array('id_group', 'id_profile', 'permission') |
| 418 | 427 | ); |
| 428 | + } |
|
| 419 | 429 | |
| 420 | 430 | // Also get some membergroup information if we're copying and not copying from guests... |
| 421 | 431 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -468,14 +478,15 @@ discard block |
||
| 468 | 478 | $changed_boards['allow'] = array(); |
| 469 | 479 | $changed_boards['deny'] = array(); |
| 470 | 480 | $changed_boards['ignore'] = array(); |
| 471 | - foreach ($accesses as $group_id => $action) |
|
| 472 | - $changed_boards[$action][] = (int) $group_id; |
|
| 481 | + foreach ($accesses as $group_id => $action) { |
|
| 482 | + $changed_boards[$action][] = (int) $group_id; |
|
| 483 | + } |
|
| 473 | 484 | |
| 474 | 485 | foreach (array('allow', 'deny') as $board_action) |
| 475 | 486 | { |
| 476 | 487 | // Only do this if they have special access requirements. |
| 477 | - if (!empty($changed_boards[$board_action])) |
|
| 478 | - $smcFunc['db_query']('', ' |
|
| 488 | + if (!empty($changed_boards[$board_action])) { |
|
| 489 | + $smcFunc['db_query']('', ' |
|
| 479 | 490 | UPDATE {db_prefix}boards |
| 480 | 491 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 481 | 492 | WHERE id_board IN ({array_int:board_list})', |
@@ -487,11 +498,13 @@ discard block |
||
| 487 | 498 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 488 | 499 | ) |
| 489 | 500 | ); |
| 501 | + } |
|
| 490 | 502 | } |
| 491 | 503 | |
| 492 | 504 | // If this is joinable then set it to show group membership in people's profiles. |
| 493 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
| 494 | - updateSettings(array('show_group_membership' => 1)); |
|
| 505 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
| 506 | + updateSettings(array('show_group_membership' => 1)); |
|
| 507 | + } |
|
| 495 | 508 | |
| 496 | 509 | // Rebuild the group cache. |
| 497 | 510 | updateSettings(array( |
@@ -512,8 +525,9 @@ discard block |
||
| 512 | 525 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
| 513 | 526 | $context['allow_protected'] = allowedTo('admin_forum'); |
| 514 | 527 | |
| 515 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 516 | - loadLanguage('ManagePermissions'); |
|
| 528 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 529 | + loadLanguage('ManagePermissions'); |
|
| 530 | + } |
|
| 517 | 531 | |
| 518 | 532 | $result = $smcFunc['db_query']('', ' |
| 519 | 533 | SELECT id_group, group_name |
@@ -530,11 +544,12 @@ discard block |
||
| 530 | 544 | ) |
| 531 | 545 | ); |
| 532 | 546 | $context['groups'] = array(); |
| 533 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 534 | - $context['groups'][] = array( |
|
| 547 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 548 | + $context['groups'][] = array( |
|
| 535 | 549 | 'id' => $row['id_group'], |
| 536 | 550 | 'name' => $row['group_name'] |
| 537 | 551 | ); |
| 552 | + } |
|
| 538 | 553 | $smcFunc['db_free_result']($result); |
| 539 | 554 | |
| 540 | 555 | $request = $smcFunc['db_query']('', ' |
@@ -551,12 +566,13 @@ discard block |
||
| 551 | 566 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 552 | 567 | { |
| 553 | 568 | // This category hasn't been set up yet.. |
| 554 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 555 | - $context['categories'][$row['id_cat']] = array( |
|
| 569 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 570 | + $context['categories'][$row['id_cat']] = array( |
|
| 556 | 571 | 'id' => $row['id_cat'], |
| 557 | 572 | 'name' => $row['cat_name'], |
| 558 | 573 | 'boards' => array() |
| 559 | 574 | ); |
| 575 | + } |
|
| 560 | 576 | |
| 561 | 577 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 562 | 578 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -604,8 +620,9 @@ discard block |
||
| 604 | 620 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 605 | 621 | $result = deleteMembergroups((int) $_REQUEST['group']); |
| 606 | 622 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 607 | - if ($result === 'group_cannot_delete_sub') |
|
| 608 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 623 | + if ($result === 'group_cannot_delete_sub') { |
|
| 624 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 625 | + } |
|
| 609 | 626 | |
| 610 | 627 | // Go back to the membergroup index. |
| 611 | 628 | redirectexit('action=admin;area=membergroups;'); |
@@ -627,8 +644,9 @@ discard block |
||
| 627 | 644 | |
| 628 | 645 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
| 629 | 646 | |
| 630 | - if (!empty($modSettings['deny_boards_access'])) |
|
| 631 | - loadLanguage('ManagePermissions'); |
|
| 647 | + if (!empty($modSettings['deny_boards_access'])) { |
|
| 648 | + loadLanguage('ManagePermissions'); |
|
| 649 | + } |
|
| 632 | 650 | |
| 633 | 651 | // Make sure this group is editable. |
| 634 | 652 | if (!empty($_REQUEST['group'])) |
@@ -650,8 +668,9 @@ discard block |
||
| 650 | 668 | } |
| 651 | 669 | |
| 652 | 670 | // Now, do we have a valid id? |
| 653 | - if (empty($_REQUEST['group'])) |
|
| 654 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 671 | + if (empty($_REQUEST['group'])) { |
|
| 672 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 673 | + } |
|
| 655 | 674 | |
| 656 | 675 | // People who can manage boards are a bit special. |
| 657 | 676 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -682,8 +701,9 @@ discard block |
||
| 682 | 701 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 683 | 702 | $result = deleteMembergroups($_REQUEST['group']); |
| 684 | 703 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
| 685 | - if ($result === 'group_cannot_delete_sub') |
|
| 686 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 704 | + if ($result === 'group_cannot_delete_sub') { |
|
| 705 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
| 706 | + } |
|
| 687 | 707 | |
| 688 | 708 | redirectexit('action=admin;area=membergroups;'); |
| 689 | 709 | } |
@@ -760,16 +780,18 @@ discard block |
||
| 760 | 780 | $request = $smcFunc['db_query']('', ' |
| 761 | 781 | SELECT id_board |
| 762 | 782 | FROM {db_prefix}boards'); |
| 763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 764 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
| 783 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 784 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
| 785 | + } |
|
| 765 | 786 | $smcFunc['db_free_result']($request); |
| 766 | 787 | } |
| 767 | 788 | |
| 768 | 789 | $changed_boards['allow'] = array(); |
| 769 | 790 | $changed_boards['deny'] = array(); |
| 770 | 791 | $changed_boards['ignore'] = array(); |
| 771 | - foreach ($accesses as $group_id => $action) |
|
| 772 | - $changed_boards[$action][] = (int) $group_id; |
|
| 792 | + foreach ($accesses as $group_id => $action) { |
|
| 793 | + $changed_boards[$action][] = (int) $group_id; |
|
| 794 | + } |
|
| 773 | 795 | |
| 774 | 796 | foreach (array('allow', 'deny') as $board_action) |
| 775 | 797 | { |
@@ -785,8 +807,8 @@ discard block |
||
| 785 | 807 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 786 | 808 | ) |
| 787 | 809 | ); |
| 788 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 789 | - $smcFunc['db_query']('', ' |
|
| 810 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 811 | + $smcFunc['db_query']('', ' |
|
| 790 | 812 | UPDATE {db_prefix}boards |
| 791 | 813 | SET {raw:column} = {string:member_group_access} |
| 792 | 814 | WHERE id_board = {int:current_board}', |
@@ -796,11 +818,12 @@ discard block |
||
| 796 | 818 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 797 | 819 | ) |
| 798 | 820 | ); |
| 821 | + } |
|
| 799 | 822 | $smcFunc['db_free_result']($request); |
| 800 | 823 | |
| 801 | 824 | // Add the membergroup to all boards that hadn't been set yet. |
| 802 | - if (!empty($changed_boards[$board_action])) |
|
| 803 | - $smcFunc['db_query']('', ' |
|
| 825 | + if (!empty($changed_boards[$board_action])) { |
|
| 826 | + $smcFunc['db_query']('', ' |
|
| 804 | 827 | UPDATE {db_prefix}boards |
| 805 | 828 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
| 806 | 829 | WHERE id_board IN ({array_int:board_list}) |
@@ -814,6 +837,7 @@ discard block |
||
| 814 | 837 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
| 815 | 838 | ) |
| 816 | 839 | ); |
| 840 | + } |
|
| 817 | 841 | } |
| 818 | 842 | } |
| 819 | 843 | |
@@ -839,12 +863,14 @@ discard block |
||
| 839 | 863 | ) |
| 840 | 864 | ); |
| 841 | 865 | $updates = array(); |
| 842 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 843 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 866 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 867 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 868 | + } |
|
| 844 | 869 | $smcFunc['db_free_result']($request); |
| 845 | 870 | |
| 846 | - foreach ($updates as $additional_groups => $memberArray) |
|
| 847 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 871 | + foreach ($updates as $additional_groups => $memberArray) { |
|
| 872 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
| 873 | + } |
|
| 848 | 874 | |
| 849 | 875 | // Sorry, but post groups can't moderate boards |
| 850 | 876 | $smcFunc['db_query']('', ' |
@@ -854,8 +880,7 @@ discard block |
||
| 854 | 880 | 'current_group' => (int) $_REQUEST['group'], |
| 855 | 881 | ) |
| 856 | 882 | ); |
| 857 | - } |
|
| 858 | - elseif ($_REQUEST['group'] != 3) |
|
| 883 | + } elseif ($_REQUEST['group'] != 3) |
|
| 859 | 884 | { |
| 860 | 885 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
| 861 | 886 | if ($_POST['group_hidden'] == 2) |
@@ -870,8 +895,9 @@ discard block |
||
| 870 | 895 | ) |
| 871 | 896 | ); |
| 872 | 897 | $updates = array(); |
| 873 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 874 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 898 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 899 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
| 900 | + } |
|
| 875 | 901 | $smcFunc['db_free_result']($request); |
| 876 | 902 | |
| 877 | 903 | foreach ($updates as $additional_groups => $memberArray) |
@@ -913,8 +939,9 @@ discard block |
||
| 913 | 939 | $smcFunc['db_free_result']($request); |
| 914 | 940 | |
| 915 | 941 | // Do we need to update the setting? |
| 916 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
| 917 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 942 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
| 943 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
| 944 | + } |
|
| 918 | 945 | } |
| 919 | 946 | |
| 920 | 947 | // Do we need to set inherited permissions? |
@@ -947,8 +974,9 @@ discard block |
||
| 947 | 974 | { |
| 948 | 975 | $moderators[$k] = trim($moderators[$k]); |
| 949 | 976 | |
| 950 | - if (strlen($moderators[$k]) == 0) |
|
| 951 | - unset($moderators[$k]); |
|
| 977 | + if (strlen($moderators[$k]) == 0) { |
|
| 978 | + unset($moderators[$k]); |
|
| 979 | + } |
|
| 952 | 980 | } |
| 953 | 981 | |
| 954 | 982 | // Find all the id_member's for the member_name's in the list. |
@@ -964,8 +992,9 @@ discard block |
||
| 964 | 992 | 'count' => count($moderators), |
| 965 | 993 | ) |
| 966 | 994 | ); |
| 967 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 968 | - $group_moderators[] = $row['id_member']; |
|
| 995 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 996 | + $group_moderators[] = $row['id_member']; |
|
| 997 | + } |
|
| 969 | 998 | $smcFunc['db_free_result']($request); |
| 970 | 999 | } |
| 971 | 1000 | } |
@@ -973,8 +1002,9 @@ discard block |
||
| 973 | 1002 | if (!empty($_POST['moderator_list'])) |
| 974 | 1003 | { |
| 975 | 1004 | $moderators = array(); |
| 976 | - foreach ($_POST['moderator_list'] as $moderator) |
|
| 977 | - $moderators[] = (int) $moderator; |
|
| 1005 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
| 1006 | + $moderators[] = (int) $moderator; |
|
| 1007 | + } |
|
| 978 | 1008 | |
| 979 | 1009 | if (!empty($moderators)) |
| 980 | 1010 | { |
@@ -988,8 +1018,9 @@ discard block |
||
| 988 | 1018 | 'num_moderators' => count($moderators), |
| 989 | 1019 | ) |
| 990 | 1020 | ); |
| 991 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 992 | - $group_moderators[] = $row['id_member']; |
|
| 1021 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1022 | + $group_moderators[] = $row['id_member']; |
|
| 1023 | + } |
|
| 993 | 1024 | $smcFunc['db_free_result']($request); |
| 994 | 1025 | } |
| 995 | 1026 | } |
@@ -1001,8 +1032,9 @@ discard block |
||
| 1001 | 1032 | if (!empty($group_moderators)) |
| 1002 | 1033 | { |
| 1003 | 1034 | $mod_insert = array(); |
| 1004 | - foreach ($group_moderators as $moderator) |
|
| 1005 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1035 | + foreach ($group_moderators as $moderator) { |
|
| 1036 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
| 1037 | + } |
|
| 1006 | 1038 | |
| 1007 | 1039 | $smcFunc['db_insert']('insert', |
| 1008 | 1040 | '{db_prefix}group_moderators', |
@@ -1036,8 +1068,9 @@ discard block |
||
| 1036 | 1068 | 'current_group' => (int) $_REQUEST['group'], |
| 1037 | 1069 | ) |
| 1038 | 1070 | ); |
| 1039 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1040 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1071 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1072 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 1073 | + } |
|
| 1041 | 1074 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1042 | 1075 | $smcFunc['db_free_result']($request); |
| 1043 | 1076 | |
@@ -1074,14 +1107,16 @@ discard block |
||
| 1074 | 1107 | ) |
| 1075 | 1108 | ); |
| 1076 | 1109 | $context['group']['moderators'] = array(); |
| 1077 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1078 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1110 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1111 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
| 1112 | + } |
|
| 1079 | 1113 | $smcFunc['db_free_result']($request); |
| 1080 | 1114 | |
| 1081 | 1115 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
| 1082 | 1116 | |
| 1083 | - if (!empty($context['group']['moderators'])) |
|
| 1084 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1117 | + if (!empty($context['group']['moderators'])) { |
|
| 1118 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
| 1119 | + } |
|
| 1085 | 1120 | |
| 1086 | 1121 | // Get a list of boards this membergroup is allowed to see. |
| 1087 | 1122 | $context['boards'] = array(); |
@@ -1101,12 +1136,13 @@ discard block |
||
| 1101 | 1136 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1102 | 1137 | { |
| 1103 | 1138 | // This category hasn't been set up yet.. |
| 1104 | - if (!isset($context['categories'][$row['id_cat']])) |
|
| 1105 | - $context['categories'][$row['id_cat']] = array( |
|
| 1139 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
| 1140 | + $context['categories'][$row['id_cat']] = array( |
|
| 1106 | 1141 | 'id' => $row['id_cat'], |
| 1107 | 1142 | 'name' => $row['cat_name'], |
| 1108 | 1143 | 'boards' => array() |
| 1109 | 1144 | ); |
| 1145 | + } |
|
| 1110 | 1146 | |
| 1111 | 1147 | // Set this board up, and let the template know when it's a child. (indent them..) |
| 1112 | 1148 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1154,19 +1190,22 @@ discard block |
||
| 1154 | 1190 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
| 1155 | 1191 | |
| 1156 | 1192 | // If this is bigger than 128 in width or 32 in height, skip this one. |
| 1157 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
| 1158 | - continue; |
|
| 1193 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
| 1194 | + continue; |
|
| 1195 | + } |
|
| 1159 | 1196 | |
| 1160 | 1197 | // Else it's valid. Add it in. |
| 1161 | - else |
|
| 1162 | - $context['possible_icons'][] = $value; |
|
| 1198 | + else { |
|
| 1199 | + $context['possible_icons'][] = $value; |
|
| 1200 | + } |
|
| 1163 | 1201 | } |
| 1164 | 1202 | } |
| 1165 | 1203 | } |
| 1166 | 1204 | |
| 1167 | 1205 | // Insert our JS, if we have possible icons. |
| 1168 | - if (!empty($context['possible_icons'])) |
|
| 1169 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1206 | + if (!empty($context['possible_icons'])) { |
|
| 1207 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
| 1208 | + } |
|
| 1170 | 1209 | |
| 1171 | 1210 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
| 1172 | 1211 | |
@@ -1188,8 +1227,9 @@ discard block |
||
| 1188 | 1227 | ) |
| 1189 | 1228 | ); |
| 1190 | 1229 | $context['inheritable_groups'] = array(); |
| 1191 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1192 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1230 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1231 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
| 1232 | + } |
|
| 1193 | 1233 | $smcFunc['db_free_result']($request); |
| 1194 | 1234 | |
| 1195 | 1235 | call_integration_hook('integrate_view_membergroup'); |
@@ -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 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | global $board_info, $smcFunc, $modSettings; |
| 33 | 34 | |
| 34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
| 35 | - if (empty($topic)) |
|
| 36 | - redirectexit(); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + redirectexit(); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
| 39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | ) |
| 60 | 62 | ); |
| 61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
| 62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 63 | - redirectexit(); |
|
| 64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 65 | + redirectexit(); |
|
| 66 | + } |
|
| 64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
| 65 | 68 | $smcFunc['db_free_result']($request); |
| 66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
| 134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
| 135 | 138 | { |
| 136 | 139 | $guestvoted = explode(',', $guestvoted); |
| 137 | - if ($guestvoted[0] == $row['id_poll']) |
|
| 138 | - break; |
|
| 140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
| 141 | + break; |
|
| 142 | + } |
|
| 139 | 143 | } |
| 140 | 144 | // Has the poll been reset since guest voted? |
| 141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 142 | 146 | { |
| 143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
| 144 | 148 | unset($guestinfo[$i]); |
| 145 | - if (!empty($guestinfo)) |
|
| 146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 147 | - else |
|
| 148 | - unset($_COOKIE['guest_poll_vote']); |
|
| 149 | - } |
|
| 150 | - else |
|
| 149 | + if (!empty($guestinfo)) { |
|
| 150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 151 | + } else { |
|
| 152 | + unset($_COOKIE['guest_poll_vote']); |
|
| 153 | + } |
|
| 154 | + } else |
|
| 151 | 155 | { |
| 152 | 156 | // What did they vote for? |
| 153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
| 233 | 237 | $context['poster_name'] = $row['poster_name']; |
| 234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
| 235 | 239 | $context['parent_boards'] = array(); |
| 236 | - foreach ($board_info['parent_boards'] as $parent) |
|
| 237 | - $context['parent_boards'][] = $parent['name']; |
|
| 240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
| 241 | + $context['parent_boards'][] = $parent['name']; |
|
| 242 | + } |
|
| 238 | 243 | |
| 239 | 244 | // Split the topics up so we can print them. |
| 240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
| 266 | 271 | 'id_msg' => $row['id_msg'], |
| 267 | 272 | ); |
| 268 | 273 | |
| 269 | - if (!isset($context['topic_subject'])) |
|
| 270 | - $context['topic_subject'] = $row['subject']; |
|
| 274 | + if (!isset($context['topic_subject'])) { |
|
| 275 | + $context['topic_subject'] = $row['subject']; |
|
| 276 | + } |
|
| 271 | 277 | } |
| 272 | 278 | $smcFunc['db_free_result']($request); |
| 273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
| 275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
| 276 | 282 | { |
| 277 | 283 | $messages = array(); |
| 278 | - foreach ($context['posts'] as $temp) |
|
| 279 | - $messages[] = $temp['id_msg']; |
|
| 284 | + foreach ($context['posts'] as $temp) { |
|
| 285 | + $messages[] = $temp['id_msg']; |
|
| 286 | + } |
|
| 280 | 287 | |
| 281 | 288 | // build the request |
| 282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
| 295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 296 | 303 | { |
| 297 | 304 | $temp[$row['id_attach']] = $row; |
| 298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
| 299 | - $context['printattach'][$row['id_msg']] = array(); |
|
| 305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
| 306 | + $context['printattach'][$row['id_msg']] = array(); |
|
| 307 | + } |
|
| 300 | 308 | } |
| 301 | 309 | $smcFunc['db_free_result']($request); |
| 302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
| 313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
| 314 | 322 | $row['width'] = $modSettings['max_image_width']; |
| 315 | 323 | } |
| 316 | - } |
|
| 317 | - elseif (!empty($modSettings['max_image_width'])) |
|
| 324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
| 318 | 325 | { |
| 319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
| 320 | 327 | { |
@@ -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 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | is_not_guest(); |
| 35 | 36 | |
| 36 | 37 | // You have to specify a board to turn notifications on! |
| 37 | - if (empty($board)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($board)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // No subaction: find out what to do. |
| 41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
| 48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
| 49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
| 50 | 52 | |
| 51 | - if ($mode > 1) |
|
| 52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | + if ($mode > 1) { |
|
| 54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
| 53 | 55 | $smcFunc['db_insert']('ignore', |
| 54 | 56 | '{db_prefix}log_notify', |
| 55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
| 56 | 58 | array($user_info['id'], $board), |
| 57 | 59 | array('id_member', 'id_board') |
| 58 | 60 | ); |
| 59 | - else |
|
| 60 | - $smcFunc['db_query']('', ' |
|
| 61 | + } else { |
|
| 62 | + $smcFunc['db_query']('', ' |
|
| 61 | 63 | DELETE FROM {db_prefix}log_notify |
| 62 | 64 | WHERE id_member = {int:current_member} |
| 63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
| 66 | 68 | 'current_member' => $user_info['id'], |
| 67 | 69 | ) |
| 68 | 70 | ); |
| 71 | + } |
|
| 69 | 72 | |
| 70 | 73 | } |
| 71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
| 81 | 84 | ), |
| 82 | 85 | ); |
| 83 | 86 | $context['sub_template'] = 'generic_xml'; |
| 87 | + } else { |
|
| 88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 89 | + } |
|
| 84 | 90 | } |
| 85 | - else |
|
| 86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
| 87 | -} |
|
| 88 | 91 | |
| 89 | 92 | /** |
| 90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
| 108 | 111 | $mode = (int) $_GET['mode']; |
| 109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
| 110 | 113 | |
| 111 | - if (empty($mode)) |
|
| 112 | - $mode = 1; |
|
| 114 | + if (empty($mode)) { |
|
| 115 | + $mode = 1; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | $request = $smcFunc['db_query']('', ' |
| 115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
| 132 | 136 | 'id_msg' => 0, |
| 133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
| 134 | 138 | ); |
| 135 | - } |
|
| 136 | - else |
|
| 139 | + } else |
|
| 137 | 140 | { |
| 138 | 141 | $insert = false; |
| 139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
| 160 | 163 | array($user_info['id'], $log['id_topic']), |
| 161 | 164 | array('id_member', 'id_board') |
| 162 | 165 | ); |
| 163 | - } |
|
| 164 | - else |
|
| 165 | - $smcFunc['db_query']('', ' |
|
| 166 | + } else { |
|
| 167 | + $smcFunc['db_query']('', ' |
|
| 166 | 168 | DELETE FROM {db_prefix}log_notify |
| 167 | 169 | WHERE id_topic = {int:topic} |
| 168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
| 170 | 172 | 'topic' => $log['id_topic'], |
| 171 | 173 | 'member' => $user_info['id'], |
| 172 | 174 | )); |
| 175 | + } |
|
| 173 | 176 | |
| 174 | 177 | } |
| 175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
| 186 | 189 | ), |
| 187 | 190 | ); |
| 188 | 191 | $context['sub_template'] = 'generic_xml'; |
| 192 | + } else { |
|
| 193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 194 | + } |
|
| 189 | 195 | } |
| 190 | - else |
|
| 191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 192 | -} |
|
| 193 | 196 | |
| 194 | 197 | ?> |
| 195 | 198 | \ No newline at end of file |
@@ -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 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
| 35 | 36 | |
| 36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
| 37 | 38 | { |
| 38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
| 39 | - $modSettings['enableCompressedOutput'] = 0; |
|
| 40 | - |
|
| 41 | - else |
|
| 42 | - ob_start('ob_gzhandler'); |
|
| 39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
| 40 | + $modSettings['enableCompressedOutput'] = 0; |
|
| 41 | + } else { |
|
| 42 | + ob_start('ob_gzhandler'); |
|
| 43 | + } |
|
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
| 71 | 72 | } |
| 72 | 73 | |
| 73 | 74 | // Use cache when possible. |
| 74 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
| 75 | - list($file, $thumbFile) = $cache; |
|
| 75 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
| 76 | + list($file, $thumbFile) = $cache; |
|
| 77 | + } |
|
| 76 | 78 | |
| 77 | 79 | // Get the info from the DB. |
| 78 | 80 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
| 80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 81 | 83 | $attachRequest = null; |
| 82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 84 | - $request = $attachRequest; |
|
| 85 | - |
|
| 86 | - else |
|
| 85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 86 | + $request = $attachRequest; |
|
| 87 | + } else |
|
| 87 | 88 | { |
| 88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
| 89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,15 @@ discard block |
||
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | // Cache it. |
| 179 | - if (!empty($file) || !empty($thumbFile)) |
|
| 180 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 180 | + if (!empty($file) || !empty($thumbFile)) { |
|
| 181 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
| 182 | + } |
|
| 181 | 183 | } |
| 182 | 184 | |
| 183 | 185 | // Replace the normal file with its thumbnail if it has one! |
| 184 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
| 185 | - $file = $thumbFile; |
|
| 186 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
| 187 | + $file = $thumbFile; |
|
| 188 | + } |
|
| 186 | 189 | |
| 187 | 190 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
| 188 | 191 | if (!file_exists($file['filePath'])) |
@@ -232,8 +235,8 @@ discard block |
||
| 232 | 235 | } |
| 233 | 236 | |
| 234 | 237 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
| 235 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
| 236 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 238 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
| 239 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 237 | 240 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 238 | 241 | SET downloads = downloads + 1 |
| 239 | 242 | WHERE id_attach = {int:id_attach}', |
@@ -241,12 +244,14 @@ discard block |
||
| 241 | 244 | 'id_attach' => $attachId, |
| 242 | 245 | ) |
| 243 | 246 | ); |
| 247 | + } |
|
| 244 | 248 | |
| 245 | 249 | // Send the attachment headers. |
| 246 | 250 | header('Pragma: '); |
| 247 | 251 | |
| 248 | - if (!isBrowser('gecko')) |
|
| 249 | - header('Content-Transfer-Encoding: binary'); |
|
| 252 | + if (!isBrowser('gecko')) { |
|
| 253 | + header('Content-Transfer-Encoding: binary'); |
|
| 254 | + } |
|
| 250 | 255 | |
| 251 | 256 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 252 | 257 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -255,18 +260,19 @@ discard block |
||
| 255 | 260 | header('ETag: ' . $eTag); |
| 256 | 261 | |
| 257 | 262 | // Make sure the mime type warrants an inline display. |
| 258 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
| 259 | - unset($_REQUEST['image']); |
|
| 263 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
| 264 | + unset($_REQUEST['image']); |
|
| 265 | + } |
|
| 260 | 266 | |
| 261 | 267 | // Does this have a mime type? |
| 262 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 263 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 264 | - |
|
| 265 | - else |
|
| 268 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 269 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 270 | + } else |
|
| 266 | 271 | { |
| 267 | 272 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 268 | - if (isset($_REQUEST['image'])) |
|
| 269 | - unset($_REQUEST['image']); |
|
| 273 | + if (isset($_REQUEST['image'])) { |
|
| 274 | + unset($_REQUEST['image']); |
|
| 275 | + } |
|
| 270 | 276 | } |
| 271 | 277 | |
| 272 | 278 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -274,24 +280,22 @@ discard block |
||
| 274 | 280 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 275 | 281 | |
| 276 | 282 | // Different browsers like different standards... |
| 277 | - if (isBrowser('firefox')) |
|
| 278 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 279 | - |
|
| 280 | - elseif (isBrowser('opera')) |
|
| 281 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 282 | - |
|
| 283 | - elseif (isBrowser('ie')) |
|
| 284 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 285 | - |
|
| 286 | - else |
|
| 287 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 283 | + if (isBrowser('firefox')) { |
|
| 284 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 285 | + } elseif (isBrowser('opera')) { |
|
| 286 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 287 | + } elseif (isBrowser('ie')) { |
|
| 288 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 289 | + } else { |
|
| 290 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 291 | + } |
|
| 288 | 292 | |
| 289 | 293 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 290 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 291 | - header('Cache-Control: no-cache'); |
|
| 292 | - |
|
| 293 | - else |
|
| 294 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 294 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 295 | + header('Cache-Control: no-cache'); |
|
| 296 | + } else { |
|
| 297 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 298 | + } |
|
| 295 | 299 | |
| 296 | 300 | // Multipart and resuming support |
| 297 | 301 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -299,9 +303,9 @@ discard block |
||
| 299 | 303 | header("HTTP/1.1 206 Partial Content"); |
| 300 | 304 | header("Content-Length: $new_length"); |
| 301 | 305 | header("Content-Range: bytes $range-$range_end/$size"); |
| 306 | + } else { |
|
| 307 | + header("Content-Length: " . $size); |
|
| 302 | 308 | } |
| 303 | - else |
|
| 304 | - header("Content-Length: " . $size); |
|
| 305 | 309 | |
| 306 | 310 | |
| 307 | 311 | // Try to buy some time... |
@@ -310,8 +314,9 @@ discard block |
||
| 310 | 314 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
| 311 | 315 | if (isset($_SERVER['HTTP_RANGE'])) |
| 312 | 316 | { |
| 313 | - while (@ob_get_level() > 0) |
|
| 314 | - @ob_end_clean(); |
|
| 317 | + while (@ob_get_level() > 0) { |
|
| 318 | + @ob_end_clean(); |
|
| 319 | + } |
|
| 315 | 320 | |
| 316 | 321 | // 40 kilobytes is a good-ish amount |
| 317 | 322 | $chunksize = 40 * 1024; |
@@ -335,8 +340,9 @@ discard block |
||
| 335 | 340 | elseif ($size > 4194304) |
| 336 | 341 | { |
| 337 | 342 | // Forcibly end any output buffering going on. |
| 338 | - while (@ob_get_level() > 0) |
|
| 339 | - @ob_end_clean(); |
|
| 343 | + while (@ob_get_level() > 0) { |
|
| 344 | + @ob_end_clean(); |
|
| 345 | + } |
|
| 340 | 346 | |
| 341 | 347 | $fp = fopen($file['filePath'], 'rb'); |
| 342 | 348 | while (!feof($fp)) |
@@ -348,8 +354,9 @@ discard block |
||
| 348 | 354 | } |
| 349 | 355 | |
| 350 | 356 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 351 | - elseif (@readfile($file['filePath']) === null) |
|
| 352 | - echo file_get_contents($file['filePath']); |
|
| 357 | + elseif (@readfile($file['filePath']) === null) { |
|
| 358 | + echo file_get_contents($file['filePath']); |
|
| 359 | + } |
|
| 353 | 360 | |
| 354 | 361 | die(); |
| 355 | 362 | } |
@@ -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 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
| 32 | 33 | { |
| 33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
| 34 | 35 | |
| 35 | - if (empty($topic)) |
|
| 36 | - fatal_lang_error('no_access', false); |
|
| 36 | + if (empty($topic)) { |
|
| 37 | + fatal_lang_error('no_access', false); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | $request = $smcFunc['db_query']('', ' |
| 39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
| 49 | 51 | $smcFunc['db_free_result']($request); |
| 50 | 52 | |
| 51 | 53 | // Can they see it - if not approved? |
| 52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
| 53 | - isAllowedTo('approve_posts'); |
|
| 54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
| 55 | + isAllowedTo('approve_posts'); |
|
| 56 | + } |
|
| 54 | 57 | |
| 55 | 58 | // Permission check! |
| 56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
| 59 | 62 | if ($id_member_started == $user_info['id']) |
| 60 | 63 | { |
| 61 | 64 | isAllowedTo('move_own'); |
| 65 | + } else { |
|
| 66 | + isAllowedTo('move_any'); |
|
| 62 | 67 | } |
| 63 | - else |
|
| 64 | - isAllowedTo('move_any'); |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
| 83 | 86 | 'not_redirection' => true, |
| 84 | 87 | ); |
| 85 | 88 | |
| 86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
| 87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
| 90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | - if (!$context['move_any']) |
|
| 90 | - $options['included_boards'] = $boards; |
|
| 93 | + if (!$context['move_any']) { |
|
| 94 | + $options['included_boards'] = $boards; |
|
| 95 | + } |
|
| 91 | 96 | |
| 92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
| 93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
| 138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
| 139 | 144 | global $board, $language, $user_info, $smcFunc; |
| 140 | 145 | |
| 141 | - if (empty($topic)) |
|
| 142 | - fatal_lang_error('no_access', false); |
|
| 146 | + if (empty($topic)) { |
|
| 147 | + fatal_lang_error('no_access', false); |
|
| 148 | + } |
|
| 143 | 149 | |
| 144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
| 145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
| 146 | - fatal_lang_error('movetopic_no_reason', false); |
|
| 151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
| 152 | + fatal_lang_error('movetopic_no_reason', false); |
|
| 153 | + } |
|
| 147 | 154 | |
| 148 | 155 | moveTopicConcurrence(); |
| 149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
| 163 | 170 | $smcFunc['db_free_result']($request); |
| 164 | 171 | |
| 165 | 172 | // Can they see it? |
| 166 | - if (!$context['is_approved']) |
|
| 167 | - isAllowedTo('approve_posts'); |
|
| 173 | + if (!$context['is_approved']) { |
|
| 174 | + isAllowedTo('approve_posts'); |
|
| 175 | + } |
|
| 168 | 176 | |
| 169 | 177 | // Can they move topics on this board? |
| 170 | 178 | if (!allowedTo('move_any')) |
| 171 | 179 | { |
| 172 | - if ($id_member_started == $user_info['id']) |
|
| 173 | - isAllowedTo('move_own'); |
|
| 174 | - else |
|
| 175 | - isAllowedTo('move_any'); |
|
| 180 | + if ($id_member_started == $user_info['id']) { |
|
| 181 | + isAllowedTo('move_own'); |
|
| 182 | + } else { |
|
| 183 | + isAllowedTo('move_any'); |
|
| 184 | + } |
|
| 176 | 185 | } |
| 177 | 186 | |
| 178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
| 197 | 206 | 'blank_redirect' => '', |
| 198 | 207 | ) |
| 199 | 208 | ); |
| 200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 201 | - fatal_lang_error('no_board'); |
|
| 209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 210 | + fatal_lang_error('no_board'); |
|
| 211 | + } |
|
| 202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
| 203 | 213 | $smcFunc['db_free_result']($request); |
| 204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
| 210 | 220 | { |
| 211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
| 212 | 222 | // Keep checking the length. |
| 213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
| 214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
| 224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
| 225 | + } |
|
| 215 | 226 | |
| 216 | 227 | // If it's still valid move onwards and upwards. |
| 217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
| 221 | 232 | // Get a response prefix, but in the forum's default language. |
| 222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 223 | 234 | { |
| 224 | - if ($language === $user_info['language']) |
|
| 225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 226 | - else |
|
| 235 | + if ($language === $user_info['language']) { |
|
| 236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 237 | + } else |
|
| 227 | 238 | { |
| 228 | 239 | loadLanguage('index', $language, false); |
| 229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
| 263 | 274 | if (isset($_POST['postRedirect'])) |
| 264 | 275 | { |
| 265 | 276 | // Should be in the boardwide language. |
| 266 | - if ($user_info['language'] != $language) |
|
| 267 | - loadLanguage('index', $language); |
|
| 277 | + if ($user_info['language'] != $language) { |
|
| 278 | + loadLanguage('index', $language); |
|
| 279 | + } |
|
| 268 | 280 | |
| 269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
| 270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
| 328 | 340 | $posters = array(); |
| 329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 330 | 342 | { |
| 331 | - if (!isset($posters[$row['id_member']])) |
|
| 332 | - $posters[$row['id_member']] = 0; |
|
| 343 | + if (!isset($posters[$row['id_member']])) { |
|
| 344 | + $posters[$row['id_member']] = 0; |
|
| 345 | + } |
|
| 333 | 346 | |
| 334 | 347 | $posters[$row['id_member']]++; |
| 335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
| 338 | 351 | foreach ($posters as $id_member => $posts) |
| 339 | 352 | { |
| 340 | 353 | // The board we're moving from counted posts, but not to. |
| 341 | - if (empty($pcounter_from)) |
|
| 342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 354 | + if (empty($pcounter_from)) { |
|
| 355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
| 356 | + } |
|
| 343 | 357 | // The reverse: from didn't, to did. |
| 344 | - else |
|
| 345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 358 | + else { |
|
| 359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
| 360 | + } |
|
| 346 | 361 | } |
| 347 | 362 | } |
| 348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
| 350 | 365 | moveTopics($topic, $_POST['toboard']); |
| 351 | 366 | |
| 352 | 367 | // Log that they moved this topic. |
| 353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
| 354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
| 369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
| 370 | + } |
|
| 355 | 371 | // Notify people that this topic has been moved? |
| 356 | 372 | sendNotifications($topic, 'move'); |
| 357 | 373 | |
| 358 | 374 | // Why not go back to the original board in case they want to keep moving? |
| 359 | - if (!isset($_REQUEST['goback'])) |
|
| 360 | - redirectexit('board=' . $board . '.0'); |
|
| 361 | - else |
|
| 362 | - redirectexit('topic=' . $topic . '.0'); |
|
| 363 | -} |
|
| 375 | + if (!isset($_REQUEST['goback'])) { |
|
| 376 | + redirectexit('board=' . $board . '.0'); |
|
| 377 | + } else { |
|
| 378 | + redirectexit('topic=' . $topic . '.0'); |
|
| 379 | + } |
|
| 380 | + } |
|
| 364 | 381 | |
| 365 | 382 | /** |
| 366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
| 376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
| 377 | 394 | |
| 378 | 395 | // Empty array? |
| 379 | - if (empty($topics)) |
|
| 380 | - return; |
|
| 396 | + if (empty($topics)) { |
|
| 397 | + return; |
|
| 398 | + } |
|
| 381 | 399 | |
| 382 | 400 | // Only a single topic. |
| 383 | - if (is_numeric($topics)) |
|
| 384 | - $topics = array($topics); |
|
| 401 | + if (is_numeric($topics)) { |
|
| 402 | + $topics = array($topics); |
|
| 403 | + } |
|
| 385 | 404 | |
| 386 | 405 | $fromBoards = array(); |
| 387 | 406 | |
| 388 | 407 | // Destination board empty or equal to 0? |
| 389 | - if (empty($toBoard)) |
|
| 390 | - return; |
|
| 408 | + if (empty($toBoard)) { |
|
| 409 | + return; |
|
| 410 | + } |
|
| 391 | 411 | |
| 392 | 412 | // Are we moving to the recycle board? |
| 393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
| 395 | 415 | // Callback for search APIs to do their thing |
| 396 | 416 | require_once($sourcedir . '/Search.php'); |
| 397 | 417 | $searchAPI = findSearchAPI(); |
| 398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
| 399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
| 418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
| 419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
| 420 | + } |
|
| 400 | 421 | |
| 401 | 422 | // Determine the source boards... |
| 402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
| 410 | 431 | ) |
| 411 | 432 | ); |
| 412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
| 413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 414 | - return; |
|
| 434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 435 | + return; |
|
| 436 | + } |
|
| 415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 416 | 438 | { |
| 417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
| 429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
| 430 | 452 | |
| 431 | 453 | // Add the topics to the right type. |
| 432 | - if ($row['approved']) |
|
| 433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 434 | - else |
|
| 435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 454 | + if ($row['approved']) { |
|
| 455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
| 456 | + } else { |
|
| 457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
| 458 | + } |
|
| 436 | 459 | } |
| 437 | 460 | $smcFunc['db_free_result']($request); |
| 438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
| 558 | 581 | ) |
| 559 | 582 | ); |
| 560 | 583 | $approval_msgs = array(); |
| 561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 562 | - $approval_msgs[] = $row['id_msg']; |
|
| 584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 585 | + $approval_msgs[] = $row['id_msg']; |
|
| 586 | + } |
|
| 563 | 587 | $smcFunc['db_free_result']($request); |
| 564 | 588 | |
| 565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
| 566 | - if (!empty($approval_msgs)) |
|
| 567 | - $smcFunc['db_query']('', ' |
|
| 590 | + if (!empty($approval_msgs)) { |
|
| 591 | + $smcFunc['db_query']('', ' |
|
| 568 | 592 | DELETE FROM {db_prefix}approval_queue |
| 569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
| 570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
| 573 | 597 | 'id_attach' => 0, |
| 574 | 598 | ) |
| 575 | 599 | ); |
| 600 | + } |
|
| 576 | 601 | |
| 577 | 602 | // Get all the current max and mins. |
| 578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
| 606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 607 | 632 | { |
| 608 | 633 | // If not, update. |
| 609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
| 610 | - $smcFunc['db_query']('', ' |
|
| 634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
| 635 | + $smcFunc['db_query']('', ' |
|
| 611 | 636 | UPDATE {db_prefix}topics |
| 612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
| 613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
| 617 | 642 | 'selected_topic' => $row['id_topic'], |
| 618 | 643 | ) |
| 619 | 644 | ); |
| 645 | + } |
|
| 620 | 646 | } |
| 621 | 647 | $smcFunc['db_free_result']($request); |
| 622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
| 675 | 701 | } |
| 676 | 702 | |
| 677 | 703 | // Update the cache? |
| 678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
| 679 | - foreach ($topics as $topic_id) |
|
| 704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
| 705 | + foreach ($topics as $topic_id) |
|
| 680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
| 707 | + } |
|
| 681 | 708 | |
| 682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
| 683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
| 701 | 728 | { |
| 702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
| 703 | 730 | |
| 704 | - if (isset($_GET['current_board'])) |
|
| 705 | - $move_from = (int) $_GET['current_board']; |
|
| 731 | + if (isset($_GET['current_board'])) { |
|
| 732 | + $move_from = (int) $_GET['current_board']; |
|
| 733 | + } |
|
| 706 | 734 | |
| 707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
| 708 | - return true; |
|
| 735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 709 | 738 | |
| 710 | - if ($move_from == $board) |
|
| 711 | - return true; |
|
| 712 | - else |
|
| 739 | + if ($move_from == $board) { |
|
| 740 | + return true; |
|
| 741 | + } else |
|
| 713 | 742 | { |
| 714 | 743 | $request = $smcFunc['db_query']('', ' |
| 715 | 744 | SELECT m.subject, b.name |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | call_integration_hook('integrate_poll_buttons'); |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - if(!empty($_REQUEST['page_id'])) |
|
| 827 | + if (!empty($_REQUEST['page_id'])) |
|
| 828 | 828 | $start_char = substr($_REQUEST['page_id'], 0, 1); |
| 829 | 829 | else |
| 830 | 830 | $start_char = null; |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | SELECT id_msg, id_member, approved |
| 887 | 887 | FROM {db_prefix}messages |
| 888 | 888 | WHERE id_topic = {int:current_topic} |
| 889 | - AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 889 | + AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : ' |
|
| 890 | 890 | AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . ' |
| 891 | 891 | ORDER BY id_msg ' . ($ascending ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : ' |
| 892 | 892 | LIMIT {int:limit}'), |
@@ -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 central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
| 34 | 35 | global $messages_request, $language, $smcFunc; |
| 35 | 36 | |
| 36 | 37 | // What are you gonna display if these are empty?! |
| 37 | - if (empty($topic)) |
|
| 38 | - fatal_lang_error('no_board', false); |
|
| 38 | + if (empty($topic)) { |
|
| 39 | + fatal_lang_error('no_board', false); |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | // Load the proper template. |
| 41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
| 52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
| 53 | 55 | |
| 54 | 56 | // Let's do some work on what to search index. |
| 55 | - if (count($_GET) > 2) |
|
| 56 | - foreach ($_GET as $k => $v) |
|
| 57 | + if (count($_GET) > 2) { |
|
| 58 | + foreach ($_GET as $k => $v) |
|
| 57 | 59 | { |
| 58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
| 59 | 61 | $context['robot_no_index'] = true; |
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 63 | - $context['robot_no_index'] = true; |
|
| 65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 66 | + $context['robot_no_index'] = true; |
|
| 67 | + } |
|
| 64 | 68 | |
| 65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
| 66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
| 172 | 176 | $topic_parameters |
| 173 | 177 | ); |
| 174 | 178 | |
| 175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 176 | - fatal_lang_error('not_a_topic', false, 404); |
|
| 179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 180 | + fatal_lang_error('not_a_topic', false, 404); |
|
| 181 | + } |
|
| 177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
| 178 | 183 | $smcFunc['db_free_result']($request); |
| 179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
| 210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
| 211 | 216 | |
| 212 | 217 | // Add up unapproved replies to get real number of replies... |
| 213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
| 214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
| 219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
| 220 | + } |
|
| 215 | 221 | |
| 216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
| 217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
| 231 | 237 | $smcFunc['db_free_result']($request); |
| 232 | 238 | |
| 233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
| 240 | + } elseif ($user_info['is_guest']) { |
|
| 241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 242 | + } else { |
|
| 243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 234 | 244 | } |
| 235 | - elseif ($user_info['is_guest']) |
|
| 236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 237 | - else |
|
| 238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
| 239 | 245 | |
| 240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
| 241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
| 248 | 254 | { |
| 249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
| 250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
| 251 | - } |
|
| 252 | - else |
|
| 257 | + } else |
|
| 253 | 258 | { |
| 254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
| 255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
| 277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
| 278 | 283 | { |
| 279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
| 280 | - if ($timestamp === 0) |
|
| 281 | - $_REQUEST['start'] = 0; |
|
| 282 | - else |
|
| 285 | + if ($timestamp === 0) { |
|
| 286 | + $_REQUEST['start'] = 0; |
|
| 287 | + } else |
|
| 283 | 288 | { |
| 284 | 289 | // Find the number of messages posted before said time... |
| 285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
| 307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
| 308 | 313 | { |
| 309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
| 310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
| 311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
| 313 | - $context['start_from'] = 0; |
|
| 314 | - else |
|
| 315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
| 317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
| 318 | + $context['start_from'] = 0; |
|
| 319 | + } else |
|
| 315 | 320 | { |
| 316 | 321 | // Find the start value for that message...... |
| 317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
| 394 | 399 | ); |
| 395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 396 | 401 | { |
| 397 | - if (empty($row['id_member'])) |
|
| 398 | - continue; |
|
| 402 | + if (empty($row['id_member'])) { |
|
| 403 | + continue; |
|
| 404 | + } |
|
| 399 | 405 | |
| 400 | - if (!empty($row['online_color'])) |
|
| 401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 402 | - else |
|
| 403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 406 | + if (!empty($row['online_color'])) { |
|
| 407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 408 | + } else { |
|
| 409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 410 | + } |
|
| 404 | 411 | |
| 405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 406 | - if ($is_buddy) |
|
| 407 | - $link = '<strong>' . $link . '</strong>'; |
|
| 413 | + if ($is_buddy) { |
|
| 414 | + $link = '<strong>' . $link . '</strong>'; |
|
| 415 | + } |
|
| 408 | 416 | |
| 409 | 417 | // Add them both to the list and to the more detailed list. |
| 410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 420 | + } |
|
| 412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 413 | 422 | 'id' => $row['id_member'], |
| 414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
| 420 | 429 | 'hidden' => empty($row['show_online']), |
| 421 | 430 | ); |
| 422 | 431 | |
| 423 | - if (empty($row['show_online'])) |
|
| 424 | - $context['view_num_hidden']++; |
|
| 432 | + if (empty($row['show_online'])) { |
|
| 433 | + $context['view_num_hidden']++; |
|
| 434 | + } |
|
| 425 | 435 | } |
| 426 | 436 | |
| 427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
| 435 | 445 | |
| 436 | 446 | // If all is set, but not allowed... just unset it. |
| 437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
| 438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
| 439 | - unset($_REQUEST['all']); |
|
| 448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
| 449 | + unset($_REQUEST['all']); |
|
| 450 | + } |
|
| 440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
| 441 | - elseif (isset($_REQUEST['all'])) |
|
| 442 | - $_REQUEST['start'] = -1; |
|
| 452 | + elseif (isset($_REQUEST['all'])) { |
|
| 453 | + $_REQUEST['start'] = -1; |
|
| 454 | + } |
|
| 443 | 455 | |
| 444 | 456 | // Construct allowing for the .START method... |
| 445 | 457 | $context['start'] = $_REQUEST['start']; |
@@ -475,14 +487,16 @@ discard block |
||
| 475 | 487 | if (!empty($board_info['moderators'])) |
| 476 | 488 | { |
| 477 | 489 | // Add a link for each moderator... |
| 478 | - foreach ($board_info['moderators'] as $mod) |
|
| 479 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 490 | + foreach ($board_info['moderators'] as $mod) { |
|
| 491 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 492 | + } |
|
| 480 | 493 | } |
| 481 | 494 | if (!empty($board_info['moderator_groups'])) |
| 482 | 495 | { |
| 483 | 496 | // Add a link for each moderator group as well... |
| 484 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 485 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 497 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 498 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 499 | + } |
|
| 486 | 500 | } |
| 487 | 501 | |
| 488 | 502 | if (!empty($context['link_moderators'])) |
@@ -513,9 +527,9 @@ discard block |
||
| 513 | 527 | // For quick reply we need a response prefix in the default forum language. |
| 514 | 528 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
| 515 | 529 | { |
| 516 | - if ($language === $user_info['language']) |
|
| 517 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 518 | - else |
|
| 530 | + if ($language === $user_info['language']) { |
|
| 531 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 532 | + } else |
|
| 519 | 533 | { |
| 520 | 534 | loadLanguage('index', $language, false); |
| 521 | 535 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -547,8 +561,9 @@ discard block |
||
| 547 | 561 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 548 | 562 | |
| 549 | 563 | // Sanity check |
| 550 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 551 | - continue; |
|
| 564 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 565 | + continue; |
|
| 566 | + } |
|
| 552 | 567 | |
| 553 | 568 | $linked_calendar_event = array( |
| 554 | 569 | 'id' => $row['id_event'], |
@@ -597,8 +612,9 @@ discard block |
||
| 597 | 612 | } |
| 598 | 613 | $smcFunc['db_free_result']($request); |
| 599 | 614 | |
| 600 | - if (!empty($context['linked_calendar_events'])) |
|
| 601 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 615 | + if (!empty($context['linked_calendar_events'])) { |
|
| 616 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
| 617 | + } |
|
| 602 | 618 | } |
| 603 | 619 | |
| 604 | 620 | // Create the poll info if it exists. |
@@ -661,8 +677,9 @@ discard block |
||
| 661 | 677 | $smcFunc['db_free_result']($request); |
| 662 | 678 | |
| 663 | 679 | // Got we multi choice? |
| 664 | - if ($pollinfo['max_votes'] > 1) |
|
| 665 | - $realtotal = $pollinfo['total']; |
|
| 680 | + if ($pollinfo['max_votes'] > 1) { |
|
| 681 | + $realtotal = $pollinfo['total']; |
|
| 682 | + } |
|
| 666 | 683 | |
| 667 | 684 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
| 668 | 685 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -675,20 +692,21 @@ discard block |
||
| 675 | 692 | foreach ($guestinfo as $i => $guestvoted) |
| 676 | 693 | { |
| 677 | 694 | $guestvoted = explode(',', $guestvoted); |
| 678 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
| 679 | - break; |
|
| 695 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
| 696 | + break; |
|
| 697 | + } |
|
| 680 | 698 | } |
| 681 | 699 | // Has the poll been reset since guest voted? |
| 682 | 700 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
| 683 | 701 | { |
| 684 | 702 | // Remove the poll info from the cookie to allow guest to vote again |
| 685 | 703 | unset($guestinfo[$i]); |
| 686 | - if (!empty($guestinfo)) |
|
| 687 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 688 | - else |
|
| 689 | - unset($_COOKIE['guest_poll_vote']); |
|
| 690 | - } |
|
| 691 | - else |
|
| 704 | + if (!empty($guestinfo)) { |
|
| 705 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
| 706 | + } else { |
|
| 707 | + unset($_COOKIE['guest_poll_vote']); |
|
| 708 | + } |
|
| 709 | + } else |
|
| 692 | 710 | { |
| 693 | 711 | // What did they vote for? |
| 694 | 712 | unset($guestvoted[0], $guestvoted[1]); |
@@ -802,35 +820,43 @@ discard block |
||
| 802 | 820 | // Build the poll moderation button array. |
| 803 | 821 | $context['poll_buttons'] = array(); |
| 804 | 822 | |
| 805 | - if ($context['allow_return_vote']) |
|
| 806 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 823 | + if ($context['allow_return_vote']) { |
|
| 824 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 825 | + } |
|
| 807 | 826 | |
| 808 | - if ($context['show_view_results_button']) |
|
| 809 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 827 | + if ($context['show_view_results_button']) { |
|
| 828 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
| 829 | + } |
|
| 810 | 830 | |
| 811 | - if ($context['allow_change_vote']) |
|
| 812 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 831 | + if ($context['allow_change_vote']) { |
|
| 832 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 833 | + } |
|
| 813 | 834 | |
| 814 | - if ($context['allow_lock_poll']) |
|
| 815 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 835 | + if ($context['allow_lock_poll']) { |
|
| 836 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 837 | + } |
|
| 816 | 838 | |
| 817 | - if ($context['allow_edit_poll']) |
|
| 818 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 839 | + if ($context['allow_edit_poll']) { |
|
| 840 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 841 | + } |
|
| 819 | 842 | |
| 820 | - if ($context['can_remove_poll']) |
|
| 821 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 843 | + if ($context['can_remove_poll']) { |
|
| 844 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 845 | + } |
|
| 822 | 846 | |
| 823 | 847 | // Allow mods to add additional buttons here |
| 824 | 848 | call_integration_hook('integrate_poll_buttons'); |
| 825 | 849 | } |
| 826 | 850 | |
| 827 | - if(!empty($_REQUEST['page_id'])) |
|
| 828 | - $start_char = substr($_REQUEST['page_id'], 0, 1); |
|
| 829 | - else |
|
| 830 | - $start_char = null; |
|
| 851 | + if(!empty($_REQUEST['page_id'])) { |
|
| 852 | + $start_char = substr($_REQUEST['page_id'], 0, 1); |
|
| 853 | + } else { |
|
| 854 | + $start_char = null; |
|
| 855 | + } |
|
| 831 | 856 | |
| 832 | - if ($start_char === 'M' || $start_char === 'L') |
|
| 833 | - $page_id = substr($_REQUEST['page_id'], 1); |
|
| 857 | + if ($start_char === 'M' || $start_char === 'L') { |
|
| 858 | + $page_id = substr($_REQUEST['page_id'], 1); |
|
| 859 | + } |
|
| 834 | 860 | |
| 835 | 861 | $limit = $context['messages_per_page']; |
| 836 | 862 | |
@@ -866,8 +892,7 @@ discard block |
||
| 866 | 892 | 'max' => $limit, |
| 867 | 893 | ) |
| 868 | 894 | ); |
| 869 | - } |
|
| 870 | - else //next or before page |
|
| 895 | + } else //next or before page |
|
| 871 | 896 | { |
| 872 | 897 | $firstIndex = 0; |
| 873 | 898 | |
@@ -875,8 +900,7 @@ discard block |
||
| 875 | 900 | { |
| 876 | 901 | $ascending = true; |
| 877 | 902 | $page_operator = '>'; |
| 878 | - } |
|
| 879 | - else |
|
| 903 | + } else |
|
| 880 | 904 | { |
| 881 | 905 | $ascending = false; |
| 882 | 906 | $page_operator = '<'; |
@@ -906,14 +930,16 @@ discard block |
||
| 906 | 930 | $all_posters = array(); |
| 907 | 931 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 908 | 932 | { |
| 909 | - if (!empty($row['id_member'])) |
|
| 910 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 933 | + if (!empty($row['id_member'])) { |
|
| 934 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
| 935 | + } |
|
| 911 | 936 | $messages[] = $row['id_msg']; |
| 912 | 937 | } |
| 913 | 938 | |
| 914 | 939 | // Before Page bring in the right order |
| 915 | - if (!empty($start_char) && $start_char === 'L') |
|
| 916 | - krsort($messages); |
|
| 940 | + if (!empty($start_char) && $start_char === 'L') { |
|
| 941 | + krsort($messages); |
|
| 942 | + } |
|
| 917 | 943 | |
| 918 | 944 | // Construct the page index, allowing for the .START method... |
| 919 | 945 | $page_options = array( |
@@ -935,8 +961,9 @@ discard block |
||
| 935 | 961 | $_REQUEST['start'] = 0; |
| 936 | 962 | } |
| 937 | 963 | // They aren't using it, but the *option* is there, at least. |
| 938 | - else |
|
| 939 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 964 | + else { |
|
| 965 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
| 966 | + } |
|
| 940 | 967 | } |
| 941 | 968 | |
| 942 | 969 | $smcFunc['db_free_result']($request); |
@@ -948,8 +975,9 @@ discard block |
||
| 948 | 975 | if (!$user_info['is_guest'] && !empty($messages)) |
| 949 | 976 | { |
| 950 | 977 | $mark_at_msg = max($messages); |
| 951 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
| 952 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
| 978 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
| 979 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
| 980 | + } |
|
| 953 | 981 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
| 954 | 982 | { |
| 955 | 983 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -981,8 +1009,9 @@ discard block |
||
| 981 | 1009 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 982 | 1010 | { |
| 983 | 1011 | // Find if this topic is marked for notification... |
| 984 | - if (!empty($row['id_topic'])) |
|
| 985 | - $context['is_marked_notify'] = true; |
|
| 1012 | + if (!empty($row['id_topic'])) { |
|
| 1013 | + $context['is_marked_notify'] = true; |
|
| 1014 | + } |
|
| 986 | 1015 | |
| 987 | 1016 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
| 988 | 1017 | if (!empty($row['sent']) && $do_once) |
@@ -1004,8 +1033,9 @@ discard block |
||
| 1004 | 1033 | } |
| 1005 | 1034 | |
| 1006 | 1035 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
| 1007 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
| 1008 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1036 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
| 1037 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1038 | + } |
|
| 1009 | 1039 | // Mark board as seen if this is the only new topic. |
| 1010 | 1040 | elseif (isset($_REQUEST['topicseen'])) |
| 1011 | 1041 | { |
@@ -1029,14 +1059,16 @@ discard block |
||
| 1029 | 1059 | $smcFunc['db_free_result']($request); |
| 1030 | 1060 | |
| 1031 | 1061 | // If there're no real new topics in this board, mark the board as seen. |
| 1032 | - if (empty($numNewTopics)) |
|
| 1033 | - $_REQUEST['boardseen'] = true; |
|
| 1034 | - else |
|
| 1035 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1062 | + if (empty($numNewTopics)) { |
|
| 1063 | + $_REQUEST['boardseen'] = true; |
|
| 1064 | + } else { |
|
| 1065 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
| 1066 | + } |
|
| 1036 | 1067 | } |
| 1037 | 1068 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
| 1038 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
| 1039 | - $_SESSION['topicseen_cache'][$board]--; |
|
| 1069 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 1070 | + $_SESSION['topicseen_cache'][$board]--; |
|
| 1071 | + } |
|
| 1040 | 1072 | |
| 1041 | 1073 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
| 1042 | 1074 | if (isset($_REQUEST['boardseen'])) |
@@ -1093,23 +1125,26 @@ discard block |
||
| 1093 | 1125 | $temp = array(); |
| 1094 | 1126 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1095 | 1127 | { |
| 1096 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
| 1097 | - continue; |
|
| 1128 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
| 1129 | + continue; |
|
| 1130 | + } |
|
| 1098 | 1131 | |
| 1099 | 1132 | $temp[$row['id_attach']] = $row; |
| 1100 | 1133 | $temp[$row['id_attach']]['topic'] = $topic; |
| 1101 | 1134 | $temp[$row['id_attach']]['board'] = $board; |
| 1102 | 1135 | |
| 1103 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
| 1104 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1136 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
| 1137 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
| 1138 | + } |
|
| 1105 | 1139 | } |
| 1106 | 1140 | $smcFunc['db_free_result']($request); |
| 1107 | 1141 | |
| 1108 | 1142 | // This is better than sorting it with the query... |
| 1109 | 1143 | ksort($temp); |
| 1110 | 1144 | |
| 1111 | - foreach ($temp as $row) |
|
| 1112 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1145 | + foreach ($temp as $row) { |
|
| 1146 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
| 1147 | + } |
|
| 1113 | 1148 | } |
| 1114 | 1149 | |
| 1115 | 1150 | $msg_parameters = array( |
@@ -1136,21 +1171,23 @@ discard block |
||
| 1136 | 1171 | ); |
| 1137 | 1172 | |
| 1138 | 1173 | // And the likes |
| 1139 | - if (!empty($modSettings['enable_likes'])) |
|
| 1140 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1174 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1175 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
| 1176 | + } |
|
| 1141 | 1177 | |
| 1142 | 1178 | // Go to the last message if the given time is beyond the time of the last message. |
| 1143 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
| 1144 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1179 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
| 1180 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
| 1181 | + } |
|
| 1145 | 1182 | |
| 1146 | 1183 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
| 1147 | 1184 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
| 1148 | - if (empty($options['view_newest_first'])) |
|
| 1149 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1150 | - else |
|
| 1151 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1152 | - } |
|
| 1153 | - else |
|
| 1185 | + if (empty($options['view_newest_first'])) { |
|
| 1186 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
| 1187 | + } else { |
|
| 1188 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
| 1189 | + } |
|
| 1190 | + } else |
|
| 1154 | 1191 | { |
| 1155 | 1192 | $messages_request = false; |
| 1156 | 1193 | $context['first_message'] = 0; |
@@ -1186,8 +1223,9 @@ discard block |
||
| 1186 | 1223 | 'can_see_likes' => 'likes_view', |
| 1187 | 1224 | 'can_like' => 'likes_like', |
| 1188 | 1225 | ); |
| 1189 | - foreach ($common_permissions as $contextual => $perm) |
|
| 1190 | - $context[$contextual] = allowedTo($perm); |
|
| 1226 | + foreach ($common_permissions as $contextual => $perm) { |
|
| 1227 | + $context[$contextual] = allowedTo($perm); |
|
| 1228 | + } |
|
| 1191 | 1229 | |
| 1192 | 1230 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
| 1193 | 1231 | $anyown_permissions = array( |
@@ -1200,8 +1238,9 @@ discard block |
||
| 1200 | 1238 | 'can_reply_unapproved' => 'post_unapproved_replies', |
| 1201 | 1239 | 'can_view_warning' => 'profile_warning', |
| 1202 | 1240 | ); |
| 1203 | - foreach ($anyown_permissions as $contextual => $perm) |
|
| 1204 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1241 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
| 1242 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
| 1243 | + } |
|
| 1205 | 1244 | |
| 1206 | 1245 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
| 1207 | 1246 | { |
@@ -1247,8 +1286,9 @@ discard block |
||
| 1247 | 1286 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
| 1248 | 1287 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
| 1249 | 1288 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
| 1250 | - if (!empty($context['drafts_save'])) |
|
| 1251 | - loadLanguage('Drafts'); |
|
| 1289 | + if (!empty($context['drafts_save'])) { |
|
| 1290 | + loadLanguage('Drafts'); |
|
| 1291 | + } |
|
| 1252 | 1292 | |
| 1253 | 1293 | // When was the last time this topic was replied to? Should we warn them about it? |
| 1254 | 1294 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1309,26 +1349,31 @@ discard block |
||
| 1309 | 1349 | // Message icons - customized icons are off? |
| 1310 | 1350 | $context['icons'] = getMessageIcons($board); |
| 1311 | 1351 | |
| 1312 | - if (!empty($context['icons'])) |
|
| 1313 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1352 | + if (!empty($context['icons'])) { |
|
| 1353 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1354 | + } |
|
| 1314 | 1355 | |
| 1315 | 1356 | // Build the normal button array. |
| 1316 | 1357 | $context['normal_buttons'] = array(); |
| 1317 | 1358 | |
| 1318 | - if ($context['can_reply']) |
|
| 1319 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1359 | + if ($context['can_reply']) { |
|
| 1360 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
| 1361 | + } |
|
| 1320 | 1362 | |
| 1321 | - if ($context['can_add_poll']) |
|
| 1322 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1363 | + if ($context['can_add_poll']) { |
|
| 1364 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
| 1365 | + } |
|
| 1323 | 1366 | |
| 1324 | - if ($context['can_mark_unread']) |
|
| 1325 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1367 | + if ($context['can_mark_unread']) { |
|
| 1368 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1369 | + } |
|
| 1326 | 1370 | |
| 1327 | - if ($context['can_print']) |
|
| 1328 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1371 | + if ($context['can_print']) { |
|
| 1372 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
| 1373 | + } |
|
| 1329 | 1374 | |
| 1330 | - if ($context['can_set_notify']) |
|
| 1331 | - $context['normal_buttons']['notify'] = array( |
|
| 1375 | + if ($context['can_set_notify']) { |
|
| 1376 | + $context['normal_buttons']['notify'] = array( |
|
| 1332 | 1377 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
| 1333 | 1378 | 'sub_buttons' => array( |
| 1334 | 1379 | array( |
@@ -1350,38 +1395,47 @@ discard block |
||
| 1350 | 1395 | ), |
| 1351 | 1396 | ), |
| 1352 | 1397 | ); |
| 1398 | + } |
|
| 1353 | 1399 | |
| 1354 | 1400 | // Build the mod button array |
| 1355 | 1401 | $context['mod_buttons'] = array(); |
| 1356 | 1402 | |
| 1357 | - if ($context['can_move']) |
|
| 1358 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1403 | + if ($context['can_move']) { |
|
| 1404 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1405 | + } |
|
| 1359 | 1406 | |
| 1360 | - if ($context['can_delete']) |
|
| 1361 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1407 | + if ($context['can_delete']) { |
|
| 1408 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1409 | + } |
|
| 1362 | 1410 | |
| 1363 | - if ($context['can_lock']) |
|
| 1364 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1411 | + if ($context['can_lock']) { |
|
| 1412 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1413 | + } |
|
| 1365 | 1414 | |
| 1366 | - if ($context['can_sticky']) |
|
| 1367 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1415 | + if ($context['can_sticky']) { |
|
| 1416 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1417 | + } |
|
| 1368 | 1418 | |
| 1369 | - if ($context['can_merge']) |
|
| 1370 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1419 | + if ($context['can_merge']) { |
|
| 1420 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
| 1421 | + } |
|
| 1371 | 1422 | |
| 1372 | - if ($context['calendar_post']) |
|
| 1373 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1423 | + if ($context['calendar_post']) { |
|
| 1424 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
| 1425 | + } |
|
| 1374 | 1426 | |
| 1375 | 1427 | // Restore topic. eh? No monkey business. |
| 1376 | - if ($context['can_restore_topic']) |
|
| 1377 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1428 | + if ($context['can_restore_topic']) { |
|
| 1429 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1430 | + } |
|
| 1378 | 1431 | |
| 1379 | 1432 | // Show a message in case a recently posted message became unapproved. |
| 1380 | 1433 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 1381 | 1434 | |
| 1382 | 1435 | // Don't want to show this forever... |
| 1383 | - if ($context['becomesUnapproved']) |
|
| 1384 | - unset($_SESSION['becomesUnapproved']); |
|
| 1436 | + if ($context['becomesUnapproved']) { |
|
| 1437 | + unset($_SESSION['becomesUnapproved']); |
|
| 1438 | + } |
|
| 1385 | 1439 | |
| 1386 | 1440 | // Allow adding new mod buttons easily. |
| 1387 | 1441 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1390,12 +1444,14 @@ discard block |
||
| 1390 | 1444 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
| 1391 | 1445 | |
| 1392 | 1446 | // Load the drafts js file |
| 1393 | - if ($context['drafts_autosave']) |
|
| 1394 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1447 | + if ($context['drafts_autosave']) { |
|
| 1448 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
| 1449 | + } |
|
| 1395 | 1450 | |
| 1396 | 1451 | // Spellcheck |
| 1397 | - if ($context['show_spellchecking']) |
|
| 1398 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1452 | + if ($context['show_spellchecking']) { |
|
| 1453 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
| 1454 | + } |
|
| 1399 | 1455 | |
| 1400 | 1456 | // topic.js |
| 1401 | 1457 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1429,16 +1485,19 @@ discard block |
||
| 1429 | 1485 | static $counter = null; |
| 1430 | 1486 | |
| 1431 | 1487 | // If the query returned false, bail. |
| 1432 | - if ($messages_request == false) |
|
| 1433 | - return false; |
|
| 1488 | + if ($messages_request == false) { |
|
| 1489 | + return false; |
|
| 1490 | + } |
|
| 1434 | 1491 | |
| 1435 | 1492 | // Remember which message this is. (ie. reply #83) |
| 1436 | - if ($counter === null || $reset) |
|
| 1437 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1493 | + if ($counter === null || $reset) { |
|
| 1494 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
| 1495 | + } |
|
| 1438 | 1496 | |
| 1439 | 1497 | // Start from the beginning... |
| 1440 | - if ($reset) |
|
| 1441 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1498 | + if ($reset) { |
|
| 1499 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
| 1500 | + } |
|
| 1442 | 1501 | |
| 1443 | 1502 | // Attempt to get the next message. |
| 1444 | 1503 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1452,19 +1511,21 @@ discard block |
||
| 1452 | 1511 | if (empty($context['icon_sources'])) |
| 1453 | 1512 | { |
| 1454 | 1513 | $context['icon_sources'] = array(); |
| 1455 | - foreach ($context['stable_icons'] as $icon) |
|
| 1456 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 1514 | + foreach ($context['stable_icons'] as $icon) { |
|
| 1515 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 1516 | + } |
|
| 1457 | 1517 | } |
| 1458 | 1518 | |
| 1459 | 1519 | // Message Icon Management... check the images exist. |
| 1460 | 1520 | if (empty($modSettings['messageIconChecks_disable'])) |
| 1461 | 1521 | { |
| 1462 | 1522 | // If the current icon isn't known, then we need to do something... |
| 1463 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
| 1464 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1523 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1524 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 1525 | + } |
|
| 1526 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
| 1527 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1465 | 1528 | } |
| 1466 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
| 1467 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
| 1468 | 1529 | |
| 1469 | 1530 | // If you're a lazy bum, you probably didn't give a subject... |
| 1470 | 1531 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1489,8 +1550,7 @@ discard block |
||
| 1489 | 1550 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
| 1490 | 1551 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
| 1491 | 1552 | $memberContext[$message['id_member']]['is_guest'] = true; |
| 1492 | - } |
|
| 1493 | - else |
|
| 1553 | + } else |
|
| 1494 | 1554 | { |
| 1495 | 1555 | // Define this here to make things a bit more readable |
| 1496 | 1556 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1513,8 +1573,9 @@ discard block |
||
| 1513 | 1573 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
| 1514 | 1574 | |
| 1515 | 1575 | // If it's in the recycle bin we need to override whatever icon we did have. |
| 1516 | - if (!empty($board_info['recycle'])) |
|
| 1517 | - $message['icon'] = 'recycled'; |
|
| 1576 | + if (!empty($board_info['recycle'])) { |
|
| 1577 | + $message['icon'] = 'recycled'; |
|
| 1578 | + } |
|
| 1518 | 1579 | |
| 1519 | 1580 | require_once($sourcedir . '/Subs-Attachments.php'); |
| 1520 | 1581 | |
@@ -1558,32 +1619,36 @@ discard block |
||
| 1558 | 1619 | } |
| 1559 | 1620 | |
| 1560 | 1621 | // Are likes enable? |
| 1561 | - if (!empty($modSettings['enable_likes'])) |
|
| 1562 | - $output['likes'] = array( |
|
| 1622 | + if (!empty($modSettings['enable_likes'])) { |
|
| 1623 | + $output['likes'] = array( |
|
| 1563 | 1624 | 'count' => $message['likes'], |
| 1564 | 1625 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
| 1565 | 1626 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
| 1566 | 1627 | ); |
| 1628 | + } |
|
| 1567 | 1629 | |
| 1568 | 1630 | // Is this user the message author? |
| 1569 | 1631 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
| 1570 | - if (!empty($output['modified']['name'])) |
|
| 1571 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1632 | + if (!empty($output['modified']['name'])) { |
|
| 1633 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
| 1634 | + } |
|
| 1572 | 1635 | |
| 1573 | 1636 | // Did they give a reason for editing? |
| 1574 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
| 1575 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1637 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
| 1638 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
| 1639 | + } |
|
| 1576 | 1640 | |
| 1577 | 1641 | // Any custom profile fields? |
| 1578 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
| 1579 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1642 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
| 1643 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
| 1580 | 1644 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 1645 | + } |
|
| 1581 | 1646 | |
| 1582 | - if (empty($options['view_newest_first'])) |
|
| 1583 | - $counter++; |
|
| 1584 | - |
|
| 1585 | - else |
|
| 1586 | - $counter--; |
|
| 1647 | + if (empty($options['view_newest_first'])) { |
|
| 1648 | + $counter++; |
|
| 1649 | + } else { |
|
| 1650 | + $counter--; |
|
| 1651 | + } |
|
| 1587 | 1652 | |
| 1588 | 1653 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
| 1589 | 1654 | |
@@ -1609,21 +1674,23 @@ discard block |
||
| 1609 | 1674 | $context['no_last_modified'] = true; |
| 1610 | 1675 | |
| 1611 | 1676 | // Prevent a preview image from being displayed twice. |
| 1612 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
| 1613 | - return; |
|
| 1677 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
| 1678 | + return; |
|
| 1679 | + } |
|
| 1614 | 1680 | |
| 1615 | 1681 | // Make sure some attachment was requested! |
| 1616 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
| 1617 | - fatal_lang_error('no_access', false); |
|
| 1682 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
| 1683 | + fatal_lang_error('no_access', false); |
|
| 1684 | + } |
|
| 1618 | 1685 | |
| 1619 | 1686 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
| 1620 | 1687 | |
| 1621 | 1688 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
| 1622 | 1689 | $attachRequest = null; |
| 1623 | 1690 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
| 1624 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
| 1625 | - $request = $attachRequest; |
|
| 1626 | - else |
|
| 1691 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
| 1692 | + $request = $attachRequest; |
|
| 1693 | + } else |
|
| 1627 | 1694 | { |
| 1628 | 1695 | // This checks only the current board for $board/$topic's permissions. |
| 1629 | 1696 | isAllowedTo('view_attachments'); |
@@ -1644,19 +1711,21 @@ discard block |
||
| 1644 | 1711 | ); |
| 1645 | 1712 | } |
| 1646 | 1713 | |
| 1647 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1648 | - fatal_lang_error('no_access', false); |
|
| 1714 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1715 | + fatal_lang_error('no_access', false); |
|
| 1716 | + } |
|
| 1649 | 1717 | |
| 1650 | 1718 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
| 1651 | 1719 | $smcFunc['db_free_result']($request); |
| 1652 | 1720 | |
| 1653 | 1721 | // If it isn't yet approved, do they have permission to view it? |
| 1654 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
| 1655 | - isAllowedTo('approve_posts'); |
|
| 1722 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
| 1723 | + isAllowedTo('approve_posts'); |
|
| 1724 | + } |
|
| 1656 | 1725 | |
| 1657 | 1726 | // Update the download counter (unless it's a thumbnail). |
| 1658 | - if ($attachment_type != 3) |
|
| 1659 | - $smcFunc['db_query']('attach_download_increase', ' |
|
| 1727 | + if ($attachment_type != 3) { |
|
| 1728 | + $smcFunc['db_query']('attach_download_increase', ' |
|
| 1660 | 1729 | UPDATE LOW_PRIORITY {db_prefix}attachments |
| 1661 | 1730 | SET downloads = downloads + 1 |
| 1662 | 1731 | WHERE id_attach = {int:id_attach}', |
@@ -1664,15 +1733,15 @@ discard block |
||
| 1664 | 1733 | 'id_attach' => $id_attach, |
| 1665 | 1734 | ) |
| 1666 | 1735 | ); |
| 1736 | + } |
|
| 1667 | 1737 | |
| 1668 | 1738 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
| 1669 | 1739 | |
| 1670 | 1740 | // This is done to clear any output that was made before now. |
| 1671 | 1741 | ob_end_clean(); |
| 1672 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
| 1673 | - @ob_start('ob_gzhandler'); |
|
| 1674 | - |
|
| 1675 | - else |
|
| 1742 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
| 1743 | + @ob_start('ob_gzhandler'); |
|
| 1744 | + } else |
|
| 1676 | 1745 | { |
| 1677 | 1746 | ob_start(); |
| 1678 | 1747 | header('Content-Encoding: none'); |
@@ -1715,8 +1784,9 @@ discard block |
||
| 1715 | 1784 | // Send the attachment headers. |
| 1716 | 1785 | header('Pragma: '); |
| 1717 | 1786 | |
| 1718 | - if (!isBrowser('gecko')) |
|
| 1719 | - header('Content-Transfer-Encoding: binary'); |
|
| 1787 | + if (!isBrowser('gecko')) { |
|
| 1788 | + header('Content-Transfer-Encoding: binary'); |
|
| 1789 | + } |
|
| 1720 | 1790 | |
| 1721 | 1791 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
| 1722 | 1792 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1725,18 +1795,19 @@ discard block |
||
| 1725 | 1795 | header('ETag: ' . $eTag); |
| 1726 | 1796 | |
| 1727 | 1797 | // Make sure the mime type warrants an inline display. |
| 1728 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
| 1729 | - unset($_REQUEST['image']); |
|
| 1798 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
| 1799 | + unset($_REQUEST['image']); |
|
| 1800 | + } |
|
| 1730 | 1801 | |
| 1731 | 1802 | // Does this have a mime type? |
| 1732 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
| 1733 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1734 | - |
|
| 1735 | - else |
|
| 1803 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
| 1804 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
| 1805 | + } else |
|
| 1736 | 1806 | { |
| 1737 | 1807 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
| 1738 | - if (isset($_REQUEST['image'])) |
|
| 1739 | - unset($_REQUEST['image']); |
|
| 1808 | + if (isset($_REQUEST['image'])) { |
|
| 1809 | + unset($_REQUEST['image']); |
|
| 1810 | + } |
|
| 1740 | 1811 | } |
| 1741 | 1812 | |
| 1742 | 1813 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1744,23 +1815,22 @@ discard block |
||
| 1744 | 1815 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
| 1745 | 1816 | |
| 1746 | 1817 | // Different browsers like different standards... |
| 1747 | - if (isBrowser('firefox')) |
|
| 1748 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1749 | - |
|
| 1750 | - elseif (isBrowser('opera')) |
|
| 1751 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1752 | - |
|
| 1753 | - elseif (isBrowser('ie')) |
|
| 1754 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1755 | - |
|
| 1756 | - else |
|
| 1757 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1818 | + if (isBrowser('firefox')) { |
|
| 1819 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
| 1820 | + } elseif (isBrowser('opera')) { |
|
| 1821 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
| 1822 | + } elseif (isBrowser('ie')) { |
|
| 1823 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
| 1824 | + } else { |
|
| 1825 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
| 1826 | + } |
|
| 1758 | 1827 | |
| 1759 | 1828 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
| 1760 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
| 1761 | - header('Cache-Control: no-cache'); |
|
| 1762 | - else |
|
| 1763 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1829 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
| 1830 | + header('Cache-Control: no-cache'); |
|
| 1831 | + } else { |
|
| 1832 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
| 1833 | + } |
|
| 1764 | 1834 | |
| 1765 | 1835 | header('Content-Length: ' . filesize($filename)); |
| 1766 | 1836 | |
@@ -1770,20 +1840,23 @@ discard block |
||
| 1770 | 1840 | // Recode line endings for text files, if enabled. |
| 1771 | 1841 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
| 1772 | 1842 | { |
| 1773 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
| 1774 | - $callback = function($buffer) |
|
| 1843 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
| 1844 | + $callback = function($buffer) |
|
| 1775 | 1845 | { |
| 1776 | 1846 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
| 1847 | + } |
|
| 1777 | 1848 | }; |
| 1778 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
| 1779 | - $callback = function($buffer) |
|
| 1849 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
| 1850 | + $callback = function($buffer) |
|
| 1780 | 1851 | { |
| 1781 | 1852 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
| 1853 | + } |
|
| 1782 | 1854 | }; |
| 1783 | - else |
|
| 1784 | - $callback = function($buffer) |
|
| 1855 | + else { |
|
| 1856 | + $callback = function($buffer) |
|
| 1785 | 1857 | { |
| 1786 | 1858 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
| 1859 | + } |
|
| 1787 | 1860 | }; |
| 1788 | 1861 | } |
| 1789 | 1862 | |
@@ -1791,23 +1864,26 @@ discard block |
||
| 1791 | 1864 | if (filesize($filename) > 4194304) |
| 1792 | 1865 | { |
| 1793 | 1866 | // Forcibly end any output buffering going on. |
| 1794 | - while (@ob_get_level() > 0) |
|
| 1795 | - @ob_end_clean(); |
|
| 1867 | + while (@ob_get_level() > 0) { |
|
| 1868 | + @ob_end_clean(); |
|
| 1869 | + } |
|
| 1796 | 1870 | |
| 1797 | 1871 | $fp = fopen($filename, 'rb'); |
| 1798 | 1872 | while (!feof($fp)) |
| 1799 | 1873 | { |
| 1800 | - if (isset($callback)) |
|
| 1801 | - echo $callback(fread($fp, 8192)); |
|
| 1802 | - else |
|
| 1803 | - echo fread($fp, 8192); |
|
| 1874 | + if (isset($callback)) { |
|
| 1875 | + echo $callback(fread($fp, 8192)); |
|
| 1876 | + } else { |
|
| 1877 | + echo fread($fp, 8192); |
|
| 1878 | + } |
|
| 1804 | 1879 | flush(); |
| 1805 | 1880 | } |
| 1806 | 1881 | fclose($fp); |
| 1807 | 1882 | } |
| 1808 | 1883 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
| 1809 | - elseif (isset($callback) || @readfile($filename) === null) |
|
| 1810 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1884 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
| 1885 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
| 1886 | + } |
|
| 1811 | 1887 | |
| 1812 | 1888 | obExit(false); |
| 1813 | 1889 | } |
@@ -1820,8 +1896,9 @@ discard block |
||
| 1820 | 1896 | */ |
| 1821 | 1897 | function approved_attach_sort($a, $b) |
| 1822 | 1898 | { |
| 1823 | - if ($a['is_approved'] == $b['is_approved']) |
|
| 1824 | - return 0; |
|
| 1899 | + if ($a['is_approved'] == $b['is_approved']) { |
|
| 1900 | + return 0; |
|
| 1901 | + } |
|
| 1825 | 1902 | |
| 1826 | 1903 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
| 1827 | 1904 | } |
@@ -1838,16 +1915,19 @@ discard block |
||
| 1838 | 1915 | |
| 1839 | 1916 | require_once($sourcedir . '/RemoveTopic.php'); |
| 1840 | 1917 | |
| 1841 | - if (empty($_REQUEST['msgs'])) |
|
| 1842 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1918 | + if (empty($_REQUEST['msgs'])) { |
|
| 1919 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
| 1920 | + } |
|
| 1843 | 1921 | |
| 1844 | 1922 | $messages = array(); |
| 1845 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
| 1846 | - $messages[] = (int) $dummy; |
|
| 1923 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
| 1924 | + $messages[] = (int) $dummy; |
|
| 1925 | + } |
|
| 1847 | 1926 | |
| 1848 | 1927 | // We are restoring messages. We handle this in another place. |
| 1849 | - if (isset($_REQUEST['restore_selected'])) |
|
| 1850 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1928 | + if (isset($_REQUEST['restore_selected'])) { |
|
| 1929 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 1930 | + } |
|
| 1851 | 1931 | if (isset($_REQUEST['split_selection'])) |
| 1852 | 1932 | { |
| 1853 | 1933 | $request = $smcFunc['db_query']('', ' |
@@ -1866,8 +1946,9 @@ discard block |
||
| 1866 | 1946 | } |
| 1867 | 1947 | |
| 1868 | 1948 | // Allowed to delete any message? |
| 1869 | - if (allowedTo('delete_any')) |
|
| 1870 | - $allowed_all = true; |
|
| 1949 | + if (allowedTo('delete_any')) { |
|
| 1950 | + $allowed_all = true; |
|
| 1951 | + } |
|
| 1871 | 1952 | // Allowed to delete replies to their messages? |
| 1872 | 1953 | elseif (allowedTo('delete_replies')) |
| 1873 | 1954 | { |
@@ -1884,13 +1965,14 @@ discard block |
||
| 1884 | 1965 | $smcFunc['db_free_result']($request); |
| 1885 | 1966 | |
| 1886 | 1967 | $allowed_all = $starter == $user_info['id']; |
| 1968 | + } else { |
|
| 1969 | + $allowed_all = false; |
|
| 1887 | 1970 | } |
| 1888 | - else |
|
| 1889 | - $allowed_all = false; |
|
| 1890 | 1971 | |
| 1891 | 1972 | // Make sure they're allowed to delete their own messages, if not any. |
| 1892 | - if (!$allowed_all) |
|
| 1893 | - isAllowedTo('delete_own'); |
|
| 1973 | + if (!$allowed_all) { |
|
| 1974 | + isAllowedTo('delete_own'); |
|
| 1975 | + } |
|
| 1894 | 1976 | |
| 1895 | 1977 | // Allowed to remove which messages? |
| 1896 | 1978 | $request = $smcFunc['db_query']('', ' |
@@ -1910,8 +1992,9 @@ discard block |
||
| 1910 | 1992 | $messages = array(); |
| 1911 | 1993 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1912 | 1994 | { |
| 1913 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
| 1914 | - continue; |
|
| 1995 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
| 1996 | + continue; |
|
| 1997 | + } |
|
| 1915 | 1998 | |
| 1916 | 1999 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
| 1917 | 2000 | } |
@@ -1934,17 +2017,20 @@ discard block |
||
| 1934 | 2017 | foreach ($messages as $message => $info) |
| 1935 | 2018 | { |
| 1936 | 2019 | // Just skip the first message - if it's not the last. |
| 1937 | - if ($message == $first_message && $message != $last_message) |
|
| 1938 | - continue; |
|
| 2020 | + if ($message == $first_message && $message != $last_message) { |
|
| 2021 | + continue; |
|
| 2022 | + } |
|
| 1939 | 2023 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
| 1940 | - elseif ($message == $first_message) |
|
| 1941 | - $topicGone = true; |
|
| 2024 | + elseif ($message == $first_message) { |
|
| 2025 | + $topicGone = true; |
|
| 2026 | + } |
|
| 1942 | 2027 | |
| 1943 | 2028 | removeMessage($message); |
| 1944 | 2029 | |
| 1945 | 2030 | // Log this moderation action ;). |
| 1946 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 1947 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 2031 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 2032 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
| 2033 | + } |
|
| 1948 | 2034 | } |
| 1949 | 2035 | |
| 1950 | 2036 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -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 | * Check if the user is who he/she says he is |
@@ -42,12 +43,14 @@ discard block |
||
| 42 | 43 | $refreshTime = isset($_GET['xml']) ? 4200 : 3600; |
| 43 | 44 | |
| 44 | 45 | // Is the security option off? |
| 45 | - if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
|
| 46 | - return; |
|
| 46 | + if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 47 | 49 | |
| 48 | 50 | // Or are they already logged in?, Moderator or admin session is need for this area |
| 49 | - if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
|
| 50 | - return; |
|
| 51 | + if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | require_once($sourcedir . '/Subs-Auth.php'); |
| 53 | 56 | |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | if (isset($_POST[$type . '_pass'])) |
| 56 | 59 | { |
| 57 | 60 | // Check to ensure we're forcing SSL for authentication |
| 58 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 59 | - fatal_lang_error('login_ssl_required'); |
|
| 61 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 62 | + fatal_lang_error('login_ssl_required'); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | checkSession(); |
| 62 | 66 | |
@@ -72,17 +76,19 @@ discard block |
||
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | // Better be sure to remember the real referer |
| 75 | - if (empty($_SESSION['request_referer'])) |
|
| 76 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 77 | - elseif (empty($_POST)) |
|
| 78 | - unset($_SESSION['request_referer']); |
|
| 79 | + if (empty($_SESSION['request_referer'])) { |
|
| 80 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 81 | + } elseif (empty($_POST)) { |
|
| 82 | + unset($_SESSION['request_referer']); |
|
| 83 | + } |
|
| 79 | 84 | |
| 80 | 85 | // Need to type in a password for that, man. |
| 81 | - if (!isset($_GET['xml'])) |
|
| 82 | - adminLogin($type); |
|
| 83 | - else |
|
| 84 | - return 'session_verify_fail'; |
|
| 85 | -} |
|
| 86 | + if (!isset($_GET['xml'])) { |
|
| 87 | + adminLogin($type); |
|
| 88 | + } else { |
|
| 89 | + return 'session_verify_fail'; |
|
| 90 | + } |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | 93 | /** |
| 88 | 94 | * Require a user who is logged in. (not a guest.) |
@@ -96,25 +102,30 @@ discard block |
||
| 96 | 102 | global $user_info, $txt, $context, $scripturl, $modSettings; |
| 97 | 103 | |
| 98 | 104 | // Luckily, this person isn't a guest. |
| 99 | - if (!$user_info['is_guest']) |
|
| 100 | - return; |
|
| 105 | + if (!$user_info['is_guest']) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 101 | 108 | |
| 102 | 109 | // Log what they were trying to do didn't work) |
| 103 | - if (!empty($modSettings['who_enabled'])) |
|
| 104 | - $_GET['error'] = 'guest_login'; |
|
| 110 | + if (!empty($modSettings['who_enabled'])) { |
|
| 111 | + $_GET['error'] = 'guest_login'; |
|
| 112 | + } |
|
| 105 | 113 | writeLog(true); |
| 106 | 114 | |
| 107 | 115 | // Just die. |
| 108 | - if (isset($_REQUEST['xml'])) |
|
| 109 | - obExit(false); |
|
| 116 | + if (isset($_REQUEST['xml'])) { |
|
| 117 | + obExit(false); |
|
| 118 | + } |
|
| 110 | 119 | |
| 111 | 120 | // Attempt to detect if they came from dlattach. |
| 112 | - if (SMF != 'SSI' && empty($context['theme_loaded'])) |
|
| 113 | - loadTheme(); |
|
| 121 | + if (SMF != 'SSI' && empty($context['theme_loaded'])) { |
|
| 122 | + loadTheme(); |
|
| 123 | + } |
|
| 114 | 124 | |
| 115 | 125 | // Never redirect to an attachment |
| 116 | - if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) |
|
| 117 | - $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 126 | + if (strpos($_SERVER['REQUEST_URL'], 'dlattach') === false) { |
|
| 127 | + $_SESSION['login_url'] = $_SERVER['REQUEST_URL']; |
|
| 128 | + } |
|
| 118 | 129 | |
| 119 | 130 | // Load the Login template and language file. |
| 120 | 131 | loadLanguage('Login'); |
@@ -124,8 +135,7 @@ discard block |
||
| 124 | 135 | { |
| 125 | 136 | $_SESSION['login_url'] = $scripturl . '?' . $_SERVER['QUERY_STRING']; |
| 126 | 137 | redirectexit('action=login'); |
| 127 | - } |
|
| 128 | - else |
|
| 138 | + } else |
|
| 129 | 139 | { |
| 130 | 140 | loadTemplate('Login'); |
| 131 | 141 | $context['sub_template'] = 'kick_guest'; |
@@ -155,8 +165,9 @@ discard block |
||
| 155 | 165 | global $sourcedir, $cookiename, $user_settings, $smcFunc; |
| 156 | 166 | |
| 157 | 167 | // You cannot be banned if you are an admin - doesn't help if you log out. |
| 158 | - if ($user_info['is_admin']) |
|
| 159 | - return; |
|
| 168 | + if ($user_info['is_admin']) { |
|
| 169 | + return; |
|
| 170 | + } |
|
| 160 | 171 | |
| 161 | 172 | // Only check the ban every so often. (to reduce load.) |
| 162 | 173 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -177,8 +188,9 @@ discard block |
||
| 177 | 188 | // Check both IP addresses. |
| 178 | 189 | foreach (array('ip', 'ip2') as $ip_number) |
| 179 | 190 | { |
| 180 | - if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
|
| 181 | - continue; |
|
| 191 | + if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 182 | 194 | $ban_query[] = ' {inet:' . $ip_number . '} BETWEEN bi.ip_low and bi.ip_high'; |
| 183 | 195 | $ban_query_vars[$ip_number] = $user_info[$ip_number]; |
| 184 | 196 | // IP was valid, maybe there's also a hostname... |
@@ -228,24 +240,28 @@ discard block |
||
| 228 | 240 | // Store every type of ban that applies to you in your session. |
| 229 | 241 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 230 | 242 | { |
| 231 | - foreach ($restrictions as $restriction) |
|
| 232 | - if (!empty($row[$restriction])) |
|
| 243 | + foreach ($restrictions as $restriction) { |
|
| 244 | + if (!empty($row[$restriction])) |
|
| 233 | 245 | { |
| 234 | 246 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
| 247 | + } |
|
| 235 | 248 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
| 236 | - if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
|
| 237 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 249 | + if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) { |
|
| 250 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
| 251 | + } |
|
| 238 | 252 | |
| 239 | - if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
|
| 240 | - $flag_is_activated = true; |
|
| 253 | + if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) { |
|
| 254 | + $flag_is_activated = true; |
|
| 255 | + } |
|
| 241 | 256 | } |
| 242 | 257 | } |
| 243 | 258 | $smcFunc['db_free_result']($request); |
| 244 | 259 | } |
| 245 | 260 | |
| 246 | 261 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
| 247 | - if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
|
| 248 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 262 | + if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) { |
|
| 263 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
| 264 | + } |
|
| 249 | 265 | |
| 250 | 266 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
| 251 | 267 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -260,8 +276,9 @@ discard block |
||
| 260 | 276 | if (!isset($_SESSION['ban']['cannot_access']) && !empty($_COOKIE[$cookiename . '_'])) |
| 261 | 277 | { |
| 262 | 278 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
| 263 | - foreach ($bans as $key => $value) |
|
| 264 | - $bans[$key] = (int) $value; |
|
| 279 | + foreach ($bans as $key => $value) { |
|
| 280 | + $bans[$key] = (int) $value; |
|
| 281 | + } |
|
| 265 | 282 | $request = $smcFunc['db_query']('', ' |
| 266 | 283 | SELECT bi.id_ban, bg.reason |
| 267 | 284 | FROM {db_prefix}ban_items AS bi |
@@ -297,14 +314,15 @@ discard block |
||
| 297 | 314 | if (isset($_SESSION['ban']['cannot_access'])) |
| 298 | 315 | { |
| 299 | 316 | // We don't wanna see you! |
| 300 | - if (!$user_info['is_guest']) |
|
| 301 | - $smcFunc['db_query']('', ' |
|
| 317 | + if (!$user_info['is_guest']) { |
|
| 318 | + $smcFunc['db_query']('', ' |
|
| 302 | 319 | DELETE FROM {db_prefix}log_online |
| 303 | 320 | WHERE id_member = {int:current_member}', |
| 304 | 321 | array( |
| 305 | 322 | 'current_member' => $user_info['id'], |
| 306 | 323 | ) |
| 307 | 324 | ); |
| 325 | + } |
|
| 308 | 326 | |
| 309 | 327 | // 'Log' the user out. Can't have any funny business... (save the name!) |
| 310 | 328 | $old_name = isset($user_info['name']) && $user_info['name'] != '' ? $user_info['name'] : $txt['guest_title']; |
@@ -390,9 +408,10 @@ discard block |
||
| 390 | 408 | } |
| 391 | 409 | |
| 392 | 410 | // Fix up the banning permissions. |
| 393 | - if (isset($user_info['permissions'])) |
|
| 394 | - banPermissions(); |
|
| 395 | -} |
|
| 411 | + if (isset($user_info['permissions'])) { |
|
| 412 | + banPermissions(); |
|
| 413 | + } |
|
| 414 | + } |
|
| 396 | 415 | |
| 397 | 416 | /** |
| 398 | 417 | * Fix permissions according to ban status. |
@@ -403,8 +422,9 @@ discard block |
||
| 403 | 422 | global $user_info, $sourcedir, $modSettings, $context; |
| 404 | 423 | |
| 405 | 424 | // Somehow they got here, at least take away all permissions... |
| 406 | - if (isset($_SESSION['ban']['cannot_access'])) |
|
| 407 | - $user_info['permissions'] = array(); |
|
| 425 | + if (isset($_SESSION['ban']['cannot_access'])) { |
|
| 426 | + $user_info['permissions'] = array(); |
|
| 427 | + } |
|
| 408 | 428 | // Okay, well, you can watch, but don't touch a thing. |
| 409 | 429 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
| 410 | 430 | { |
@@ -446,19 +466,20 @@ discard block |
||
| 446 | 466 | call_integration_hook('integrate_warn_permissions', array(&$permission_change)); |
| 447 | 467 | foreach ($permission_change as $old => $new) |
| 448 | 468 | { |
| 449 | - if (!in_array($old, $user_info['permissions'])) |
|
| 450 | - unset($permission_change[$old]); |
|
| 451 | - else |
|
| 452 | - $user_info['permissions'][] = $new; |
|
| 469 | + if (!in_array($old, $user_info['permissions'])) { |
|
| 470 | + unset($permission_change[$old]); |
|
| 471 | + } else { |
|
| 472 | + $user_info['permissions'][] = $new; |
|
| 473 | + } |
|
| 453 | 474 | } |
| 454 | 475 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
| 455 | 476 | } |
| 456 | 477 | |
| 457 | 478 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
| 458 | 479 | // Finally, some bits we cache in the session because it saves queries. |
| 459 | - if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
|
| 460 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 461 | - else |
|
| 480 | + if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) { |
|
| 481 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
| 482 | + } else |
|
| 462 | 483 | { |
| 463 | 484 | require_once($sourcedir . '/Subs-Auth.php'); |
| 464 | 485 | rebuildModCache(); |
@@ -469,14 +490,12 @@ discard block |
||
| 469 | 490 | { |
| 470 | 491 | $context['open_mod_reports'] = $_SESSION['rc']['reports']; |
| 471 | 492 | $context['open_member_reports'] = $_SESSION['rc']['member_reports']; |
| 472 | - } |
|
| 473 | - elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 493 | + } elseif ($_SESSION['mc']['bq'] != '0=1') |
|
| 474 | 494 | { |
| 475 | 495 | require_once($sourcedir . '/Subs-ReportedContent.php'); |
| 476 | 496 | $context['open_mod_reports'] = recountOpenReports('posts'); |
| 477 | 497 | $context['open_member_reports'] = recountOpenReports('members'); |
| 478 | - } |
|
| 479 | - else |
|
| 498 | + } else |
|
| 480 | 499 | { |
| 481 | 500 | $context['open_mod_reports'] = 0; |
| 482 | 501 | $context['open_member_reports'] = 0; |
@@ -497,8 +516,9 @@ discard block |
||
| 497 | 516 | global $user_info, $smcFunc; |
| 498 | 517 | |
| 499 | 518 | // Don't log web accelerators, it's very confusing... |
| 500 | - if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
|
| 501 | - return; |
|
| 519 | + if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') { |
|
| 520 | + return; |
|
| 521 | + } |
|
| 502 | 522 | |
| 503 | 523 | $smcFunc['db_insert']('', |
| 504 | 524 | '{db_prefix}log_banned', |
@@ -508,8 +528,8 @@ discard block |
||
| 508 | 528 | ); |
| 509 | 529 | |
| 510 | 530 | // One extra point for these bans. |
| 511 | - if (!empty($ban_ids)) |
|
| 512 | - $smcFunc['db_query']('', ' |
|
| 531 | + if (!empty($ban_ids)) { |
|
| 532 | + $smcFunc['db_query']('', ' |
|
| 513 | 533 | UPDATE {db_prefix}ban_items |
| 514 | 534 | SET hits = hits + 1 |
| 515 | 535 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -517,7 +537,8 @@ discard block |
||
| 517 | 537 | 'ban_ids' => $ban_ids, |
| 518 | 538 | ) |
| 519 | 539 | ); |
| 520 | -} |
|
| 540 | + } |
|
| 541 | + } |
|
| 521 | 542 | |
| 522 | 543 | /** |
| 523 | 544 | * Checks if a given email address might be banned. |
@@ -533,8 +554,9 @@ discard block |
||
| 533 | 554 | global $txt, $smcFunc; |
| 534 | 555 | |
| 535 | 556 | // Can't ban an empty email |
| 536 | - if (empty($email) || trim($email) == '') |
|
| 537 | - return; |
|
| 557 | + if (empty($email) || trim($email) == '') { |
|
| 558 | + return; |
|
| 559 | + } |
|
| 538 | 560 | |
| 539 | 561 | // Let's start with the bans based on your IP/hostname/memberID... |
| 540 | 562 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -607,16 +629,18 @@ discard block |
||
| 607 | 629 | if ($type == 'post') |
| 608 | 630 | { |
| 609 | 631 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
| 610 | - if ($check !== $sc) |
|
| 611 | - $error = 'session_timeout'; |
|
| 632 | + if ($check !== $sc) { |
|
| 633 | + $error = 'session_timeout'; |
|
| 634 | + } |
|
| 612 | 635 | } |
| 613 | 636 | |
| 614 | 637 | // How about $_GET['sesc']? |
| 615 | 638 | elseif ($type == 'get') |
| 616 | 639 | { |
| 617 | 640 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
| 618 | - if ($check !== $sc) |
|
| 619 | - $error = 'session_verify_fail'; |
|
| 641 | + if ($check !== $sc) { |
|
| 642 | + $error = 'session_verify_fail'; |
|
| 643 | + } |
|
| 620 | 644 | } |
| 621 | 645 | |
| 622 | 646 | // Or can it be in either? |
@@ -624,13 +648,15 @@ discard block |
||
| 624 | 648 | { |
| 625 | 649 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
| 626 | 650 | |
| 627 | - if ($check !== $sc) |
|
| 628 | - $error = 'session_verify_fail'; |
|
| 651 | + if ($check !== $sc) { |
|
| 652 | + $error = 'session_verify_fail'; |
|
| 653 | + } |
|
| 629 | 654 | } |
| 630 | 655 | |
| 631 | 656 | // Verify that they aren't changing user agents on us - that could be bad. |
| 632 | - if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) |
|
| 633 | - $error = 'session_verify_fail'; |
|
| 657 | + if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $_SERVER['HTTP_USER_AGENT']) && empty($modSettings['disableCheckUA'])) { |
|
| 658 | + $error = 'session_verify_fail'; |
|
| 659 | + } |
|
| 634 | 660 | |
| 635 | 661 | // Make sure a page with session check requirement is not being prefetched. |
| 636 | 662 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -641,30 +667,35 @@ discard block |
||
| 641 | 667 | } |
| 642 | 668 | |
| 643 | 669 | // Check the referring site - it should be the same server at least! |
| 644 | - if (isset($_SESSION['request_referer'])) |
|
| 645 | - $referrer = $_SESSION['request_referer']; |
|
| 646 | - else |
|
| 647 | - $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 670 | + if (isset($_SESSION['request_referer'])) { |
|
| 671 | + $referrer = $_SESSION['request_referer']; |
|
| 672 | + } else { |
|
| 673 | + $referrer = isset($_SERVER['HTTP_REFERER']) ? @parse_url($_SERVER['HTTP_REFERER']) : array(); |
|
| 674 | + } |
|
| 648 | 675 | if (!empty($referrer['host'])) |
| 649 | 676 | { |
| 650 | - if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
|
| 651 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 652 | - else |
|
| 653 | - $real_host = $_SERVER['HTTP_HOST']; |
|
| 677 | + if (strpos($_SERVER['HTTP_HOST'], ':') !== false) { |
|
| 678 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
| 679 | + } else { |
|
| 680 | + $real_host = $_SERVER['HTTP_HOST']; |
|
| 681 | + } |
|
| 654 | 682 | |
| 655 | 683 | $parsed_url = parse_url($boardurl); |
| 656 | 684 | |
| 657 | 685 | // Are global cookies on? If so, let's check them ;). |
| 658 | 686 | if (!empty($modSettings['globalCookies'])) |
| 659 | 687 | { |
| 660 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 661 | - $parsed_url['host'] = $parts[1]; |
|
| 688 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 689 | + $parsed_url['host'] = $parts[1]; |
|
| 690 | + } |
|
| 662 | 691 | |
| 663 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
|
| 664 | - $referrer['host'] = $parts[1]; |
|
| 692 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) { |
|
| 693 | + $referrer['host'] = $parts[1]; |
|
| 694 | + } |
|
| 665 | 695 | |
| 666 | - if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
|
| 667 | - $real_host = $parts[1]; |
|
| 696 | + if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) { |
|
| 697 | + $real_host = $parts[1]; |
|
| 698 | + } |
|
| 668 | 699 | } |
| 669 | 700 | |
| 670 | 701 | // Okay: referrer must either match parsed_url or real_host. |
@@ -682,12 +713,14 @@ discard block |
||
| 682 | 713 | $log_error = true; |
| 683 | 714 | } |
| 684 | 715 | |
| 685 | - if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') |
|
| 686 | - fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 716 | + if (strtolower($_SERVER['HTTP_USER_AGENT']) == 'hacker') { |
|
| 717 | + fatal_error('Sound the alarm! It\'s a hacker! Close the castle gates!!', false); |
|
| 718 | + } |
|
| 687 | 719 | |
| 688 | 720 | // Everything is ok, return an empty string. |
| 689 | - if (!isset($error)) |
|
| 690 | - return ''; |
|
| 721 | + if (!isset($error)) { |
|
| 722 | + return ''; |
|
| 723 | + } |
|
| 691 | 724 | // A session error occurred, show the error. |
| 692 | 725 | elseif ($is_fatal) |
| 693 | 726 | { |
@@ -696,13 +729,14 @@ discard block |
||
| 696 | 729 | ob_end_clean(); |
| 697 | 730 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
| 698 | 731 | die; |
| 732 | + } else { |
|
| 733 | + fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 699 | 734 | } |
| 700 | - else |
|
| 701 | - fatal_lang_error($error, isset($log_error) ? 'user' : false); |
|
| 702 | 735 | } |
| 703 | 736 | // A session error occurred, return the error to the calling function. |
| 704 | - else |
|
| 705 | - return $error; |
|
| 737 | + else { |
|
| 738 | + return $error; |
|
| 739 | + } |
|
| 706 | 740 | |
| 707 | 741 | // We really should never fall through here, for very important reasons. Let's make sure. |
| 708 | 742 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -718,10 +752,9 @@ discard block |
||
| 718 | 752 | { |
| 719 | 753 | global $modSettings; |
| 720 | 754 | |
| 721 | - if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) |
|
| 722 | - return true; |
|
| 723 | - |
|
| 724 | - else |
|
| 755 | + if (isset($_GET['confirm']) && isset($_SESSION['confirm_' . $action]) && md5($_GET['confirm'] . $_SERVER['HTTP_USER_AGENT']) == $_SESSION['confirm_' . $action]) { |
|
| 756 | + return true; |
|
| 757 | + } else |
|
| 725 | 758 | { |
| 726 | 759 | $token = md5(mt_rand() . session_id() . (string) microtime() . $modSettings['rand_seed']); |
| 727 | 760 | $_SESSION['confirm_' . $action] = md5($token . $_SERVER['HTTP_USER_AGENT']); |
@@ -772,9 +805,9 @@ discard block |
||
| 772 | 805 | $return = $_SESSION['token'][$type . '-' . $action][3]; |
| 773 | 806 | unset($_SESSION['token'][$type . '-' . $action]); |
| 774 | 807 | return $return; |
| 808 | + } else { |
|
| 809 | + return ''; |
|
| 775 | 810 | } |
| 776 | - else |
|
| 777 | - return ''; |
|
| 778 | 811 | } |
| 779 | 812 | |
| 780 | 813 | // This nasty piece of code validates a token. |
@@ -805,12 +838,14 @@ discard block |
||
| 805 | 838 | fatal_lang_error('token_verify_fail', false); |
| 806 | 839 | } |
| 807 | 840 | // Remove this token as its useless |
| 808 | - else |
|
| 809 | - unset($_SESSION['token'][$type . '-' . $action]); |
|
| 841 | + else { |
|
| 842 | + unset($_SESSION['token'][$type . '-' . $action]); |
|
| 843 | + } |
|
| 810 | 844 | |
| 811 | 845 | // Randomly check if we should remove some older tokens. |
| 812 | - if (mt_rand(0, 138) == 23) |
|
| 813 | - cleanTokens(); |
|
| 846 | + if (mt_rand(0, 138) == 23) { |
|
| 847 | + cleanTokens(); |
|
| 848 | + } |
|
| 814 | 849 | |
| 815 | 850 | return false; |
| 816 | 851 | } |
@@ -825,14 +860,16 @@ discard block |
||
| 825 | 860 | function cleanTokens($complete = false) |
| 826 | 861 | { |
| 827 | 862 | // We appreciate cleaning up after yourselves. |
| 828 | - if (!isset($_SESSION['token'])) |
|
| 829 | - return; |
|
| 863 | + if (!isset($_SESSION['token'])) { |
|
| 864 | + return; |
|
| 865 | + } |
|
| 830 | 866 | |
| 831 | 867 | // Clean up tokens, trying to give enough time still. |
| 832 | - foreach ($_SESSION['token'] as $key => $data) |
|
| 833 | - if ($data[2] + 10800 < time() || $complete) |
|
| 868 | + foreach ($_SESSION['token'] as $key => $data) { |
|
| 869 | + if ($data[2] + 10800 < time() || $complete) |
|
| 834 | 870 | unset($_SESSION['token'][$key]); |
| 835 | -} |
|
| 871 | + } |
|
| 872 | + } |
|
| 836 | 873 | |
| 837 | 874 | /** |
| 838 | 875 | * Check whether a form has been submitted twice. |
@@ -850,37 +887,40 @@ discard block |
||
| 850 | 887 | { |
| 851 | 888 | global $context; |
| 852 | 889 | |
| 853 | - if (!isset($_SESSION['forms'])) |
|
| 854 | - $_SESSION['forms'] = array(); |
|
| 890 | + if (!isset($_SESSION['forms'])) { |
|
| 891 | + $_SESSION['forms'] = array(); |
|
| 892 | + } |
|
| 855 | 893 | |
| 856 | 894 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
| 857 | 895 | if ($action == 'register') |
| 858 | 896 | { |
| 859 | 897 | $context['form_sequence_number'] = 0; |
| 860 | - while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
|
| 861 | - $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 898 | + while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) { |
|
| 899 | + $context['form_sequence_number'] = mt_rand(1, 16000000); |
|
| 900 | + } |
|
| 862 | 901 | } |
| 863 | 902 | // Check whether the submitted number can be found in the session. |
| 864 | 903 | elseif ($action == 'check') |
| 865 | 904 | { |
| 866 | - if (!isset($_REQUEST['seqnum'])) |
|
| 867 | - return true; |
|
| 868 | - elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 905 | + if (!isset($_REQUEST['seqnum'])) { |
|
| 906 | + return true; |
|
| 907 | + } elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 869 | 908 | { |
| 870 | 909 | $_SESSION['forms'][] = (int) $_REQUEST['seqnum']; |
| 871 | 910 | return true; |
| 911 | + } elseif ($is_fatal) { |
|
| 912 | + fatal_lang_error('error_form_already_submitted', false); |
|
| 913 | + } else { |
|
| 914 | + return false; |
|
| 872 | 915 | } |
| 873 | - elseif ($is_fatal) |
|
| 874 | - fatal_lang_error('error_form_already_submitted', false); |
|
| 875 | - else |
|
| 876 | - return false; |
|
| 877 | 916 | } |
| 878 | 917 | // Don't check, just free the stack number. |
| 879 | - elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
|
| 880 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 881 | - elseif ($action != 'free') |
|
| 882 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 883 | -} |
|
| 918 | + elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) { |
|
| 919 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
| 920 | + } elseif ($action != 'free') { |
|
| 921 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
| 922 | + } |
|
| 923 | + } |
|
| 884 | 924 | |
| 885 | 925 | /** |
| 886 | 926 | * Check the user's permissions. |
@@ -897,16 +937,19 @@ discard block |
||
| 897 | 937 | global $user_info, $smcFunc; |
| 898 | 938 | |
| 899 | 939 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
| 900 | - if (empty($permission)) |
|
| 901 | - return true; |
|
| 940 | + if (empty($permission)) { |
|
| 941 | + return true; |
|
| 942 | + } |
|
| 902 | 943 | |
| 903 | 944 | // You're never allowed to do something if your data hasn't been loaded yet! |
| 904 | - if (empty($user_info)) |
|
| 905 | - return false; |
|
| 945 | + if (empty($user_info)) { |
|
| 946 | + return false; |
|
| 947 | + } |
|
| 906 | 948 | |
| 907 | 949 | // Administrators are supermen :P. |
| 908 | - if ($user_info['is_admin']) |
|
| 909 | - return true; |
|
| 950 | + if ($user_info['is_admin']) { |
|
| 951 | + return true; |
|
| 952 | + } |
|
| 910 | 953 | |
| 911 | 954 | // Let's ensure this is an array. |
| 912 | 955 | $permission = (array) $permission; |
@@ -914,14 +957,16 @@ discard block |
||
| 914 | 957 | // Are we checking the _current_ board, or some other boards? |
| 915 | 958 | if ($boards === null) |
| 916 | 959 | { |
| 917 | - if (count(array_intersect($permission, $user_info['permissions'])) != 0) |
|
| 918 | - return true; |
|
| 960 | + if (count(array_intersect($permission, $user_info['permissions'])) != 0) { |
|
| 961 | + return true; |
|
| 962 | + } |
|
| 919 | 963 | // You aren't allowed, by default. |
| 920 | - else |
|
| 921 | - return false; |
|
| 964 | + else { |
|
| 965 | + return false; |
|
| 966 | + } |
|
| 967 | + } elseif (!is_array($boards)) { |
|
| 968 | + $boards = array($boards); |
|
| 922 | 969 | } |
| 923 | - elseif (!is_array($boards)) |
|
| 924 | - $boards = array($boards); |
|
| 925 | 970 | |
| 926 | 971 | $request = $smcFunc['db_query']('', ' |
| 927 | 972 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -944,12 +989,14 @@ discard block |
||
| 944 | 989 | ); |
| 945 | 990 | |
| 946 | 991 | // Make sure they can do it on all of the boards. |
| 947 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
| 948 | - return false; |
|
| 992 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
| 993 | + return false; |
|
| 994 | + } |
|
| 949 | 995 | |
| 950 | 996 | $result = true; |
| 951 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 952 | - $result &= !empty($row['add_deny']); |
|
| 997 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 998 | + $result &= !empty($row['add_deny']); |
|
| 999 | + } |
|
| 953 | 1000 | $smcFunc['db_free_result']($request); |
| 954 | 1001 | |
| 955 | 1002 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1014,9 +1061,10 @@ discard block |
||
| 1014 | 1061 | |
| 1015 | 1062 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
| 1016 | 1063 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
| 1017 | - if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
|
| 1018 | - validateSession(); |
|
| 1019 | -} |
|
| 1064 | + if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) { |
|
| 1065 | + validateSession(); |
|
| 1066 | + } |
|
| 1067 | + } |
|
| 1020 | 1068 | |
| 1021 | 1069 | /** |
| 1022 | 1070 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1035,8 +1083,9 @@ discard block |
||
| 1035 | 1083 | global $user_info, $smcFunc; |
| 1036 | 1084 | |
| 1037 | 1085 | // Arrays are nice, most of the time. |
| 1038 | - if (!is_array($permissions)) |
|
| 1039 | - $permissions = array($permissions); |
|
| 1086 | + if (!is_array($permissions)) { |
|
| 1087 | + $permissions = array($permissions); |
|
| 1088 | + } |
|
| 1040 | 1089 | |
| 1041 | 1090 | /* |
| 1042 | 1091 | * Set $simple to true to use this function as it were in SMF 2.0.x. |
@@ -1048,13 +1097,14 @@ discard block |
||
| 1048 | 1097 | // Administrators are all powerful, sorry. |
| 1049 | 1098 | if ($user_info['is_admin']) |
| 1050 | 1099 | { |
| 1051 | - if ($simple) |
|
| 1052 | - return array(0); |
|
| 1053 | - else |
|
| 1100 | + if ($simple) { |
|
| 1101 | + return array(0); |
|
| 1102 | + } else |
|
| 1054 | 1103 | { |
| 1055 | 1104 | $boards = array(); |
| 1056 | - foreach ($permissions as $permission) |
|
| 1057 | - $boards[$permission] = array(0); |
|
| 1105 | + foreach ($permissions as $permission) { |
|
| 1106 | + $boards[$permission] = array(0); |
|
| 1107 | + } |
|
| 1058 | 1108 | |
| 1059 | 1109 | return $boards; |
| 1060 | 1110 | } |
@@ -1086,31 +1136,32 @@ discard block |
||
| 1086 | 1136 | { |
| 1087 | 1137 | if ($simple) |
| 1088 | 1138 | { |
| 1089 | - if (empty($row['add_deny'])) |
|
| 1090 | - $deny_boards[] = $row['id_board']; |
|
| 1091 | - else |
|
| 1092 | - $boards[] = $row['id_board']; |
|
| 1093 | - } |
|
| 1094 | - else |
|
| 1139 | + if (empty($row['add_deny'])) { |
|
| 1140 | + $deny_boards[] = $row['id_board']; |
|
| 1141 | + } else { |
|
| 1142 | + $boards[] = $row['id_board']; |
|
| 1143 | + } |
|
| 1144 | + } else |
|
| 1095 | 1145 | { |
| 1096 | - if (empty($row['add_deny'])) |
|
| 1097 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1098 | - else |
|
| 1099 | - $boards[$row['permission']][] = $row['id_board']; |
|
| 1146 | + if (empty($row['add_deny'])) { |
|
| 1147 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
| 1148 | + } else { |
|
| 1149 | + $boards[$row['permission']][] = $row['id_board']; |
|
| 1150 | + } |
|
| 1100 | 1151 | } |
| 1101 | 1152 | } |
| 1102 | 1153 | $smcFunc['db_free_result']($request); |
| 1103 | 1154 | |
| 1104 | - if ($simple) |
|
| 1105 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1106 | - else |
|
| 1155 | + if ($simple) { |
|
| 1156 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
| 1157 | + } else |
|
| 1107 | 1158 | { |
| 1108 | 1159 | foreach ($permissions as $permission) |
| 1109 | 1160 | { |
| 1110 | 1161 | // never had it to start with |
| 1111 | - if (empty($boards[$permission])) |
|
| 1112 | - $boards[$permission] = array(); |
|
| 1113 | - else |
|
| 1162 | + if (empty($boards[$permission])) { |
|
| 1163 | + $boards[$permission] = array(); |
|
| 1164 | + } else |
|
| 1114 | 1165 | { |
| 1115 | 1166 | // Or it may have been removed |
| 1116 | 1167 | $deny_boards[$permission] = isset($deny_boards[$permission]) ? $deny_boards[$permission] : array(); |
@@ -1146,10 +1197,11 @@ discard block |
||
| 1146 | 1197 | |
| 1147 | 1198 | |
| 1148 | 1199 | // Moderators are free... |
| 1149 | - if (!allowedTo('moderate_board')) |
|
| 1150 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1151 | - else |
|
| 1152 | - $timeLimit = 2; |
|
| 1200 | + if (!allowedTo('moderate_board')) { |
|
| 1201 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
| 1202 | + } else { |
|
| 1203 | + $timeLimit = 2; |
|
| 1204 | + } |
|
| 1153 | 1205 | |
| 1154 | 1206 | call_integration_hook('integrate_spam_protection', array(&$timeOverrides, &$timeLimit)); |
| 1155 | 1207 | |
@@ -1176,8 +1228,9 @@ discard block |
||
| 1176 | 1228 | if ($smcFunc['db_affected_rows']() != 1) |
| 1177 | 1229 | { |
| 1178 | 1230 | // Spammer! You only have to wait a *few* seconds! |
| 1179 | - if (!$only_return_result) |
|
| 1180 | - fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1231 | + if (!$only_return_result) { |
|
| 1232 | + fatal_lang_error($error_type . '_WaitTime_broken', false, array($timeLimit)); |
|
| 1233 | + } |
|
| 1181 | 1234 | |
| 1182 | 1235 | return true; |
| 1183 | 1236 | } |
@@ -1195,11 +1248,13 @@ discard block |
||
| 1195 | 1248 | */ |
| 1196 | 1249 | function secureDirectory($path, $attachments = false) |
| 1197 | 1250 | { |
| 1198 | - if (empty($path)) |
|
| 1199 | - return 'empty_path'; |
|
| 1251 | + if (empty($path)) { |
|
| 1252 | + return 'empty_path'; |
|
| 1253 | + } |
|
| 1200 | 1254 | |
| 1201 | - if (!is_writable($path)) |
|
| 1202 | - return 'path_not_writable'; |
|
| 1255 | + if (!is_writable($path)) { |
|
| 1256 | + return 'path_not_writable'; |
|
| 1257 | + } |
|
| 1203 | 1258 | |
| 1204 | 1259 | $directoryname = basename($path); |
| 1205 | 1260 | |
@@ -1211,9 +1266,9 @@ discard block |
||
| 1211 | 1266 | |
| 1212 | 1267 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
| 1213 | 1268 | |
| 1214 | - if (file_exists($path . '/.htaccess')) |
|
| 1215 | - $errors[] = 'htaccess_exists'; |
|
| 1216 | - else |
|
| 1269 | + if (file_exists($path . '/.htaccess')) { |
|
| 1270 | + $errors[] = 'htaccess_exists'; |
|
| 1271 | + } else |
|
| 1217 | 1272 | { |
| 1218 | 1273 | $fh = @fopen($path . '/.htaccess', 'w'); |
| 1219 | 1274 | if ($fh) { |
@@ -1225,9 +1280,9 @@ discard block |
||
| 1225 | 1280 | $errors[] = 'htaccess_cannot_create_file'; |
| 1226 | 1281 | } |
| 1227 | 1282 | |
| 1228 | - if (file_exists($path . '/index.php')) |
|
| 1229 | - $errors[] = 'index-php_exists'; |
|
| 1230 | - else |
|
| 1283 | + if (file_exists($path . '/index.php')) { |
|
| 1284 | + $errors[] = 'index-php_exists'; |
|
| 1285 | + } else |
|
| 1231 | 1286 | { |
| 1232 | 1287 | $fh = @fopen($path . '/index.php', 'w'); |
| 1233 | 1288 | if ($fh) { |
@@ -1254,11 +1309,12 @@ discard block |
||
| 1254 | 1309 | $errors[] = 'index-php_cannot_create_file'; |
| 1255 | 1310 | } |
| 1256 | 1311 | |
| 1257 | - if (!empty($errors)) |
|
| 1258 | - return $errors; |
|
| 1259 | - else |
|
| 1260 | - return true; |
|
| 1261 | -} |
|
| 1312 | + if (!empty($errors)) { |
|
| 1313 | + return $errors; |
|
| 1314 | + } else { |
|
| 1315 | + return true; |
|
| 1316 | + } |
|
| 1317 | + } |
|
| 1262 | 1318 | |
| 1263 | 1319 | /** |
| 1264 | 1320 | * This sets the X-Frame-Options header. |
@@ -1271,14 +1327,16 @@ discard block |
||
| 1271 | 1327 | global $modSettings; |
| 1272 | 1328 | |
| 1273 | 1329 | $option = 'SAMEORIGIN'; |
| 1274 | - if (is_null($override) && !empty($modSettings['frame_security'])) |
|
| 1275 | - $option = $modSettings['frame_security']; |
|
| 1276 | - elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
|
| 1277 | - $option = $override; |
|
| 1330 | + if (is_null($override) && !empty($modSettings['frame_security'])) { |
|
| 1331 | + $option = $modSettings['frame_security']; |
|
| 1332 | + } elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) { |
|
| 1333 | + $option = $override; |
|
| 1334 | + } |
|
| 1278 | 1335 | |
| 1279 | 1336 | // Don't bother setting the header if we have disabled it. |
| 1280 | - if ($option == 'DISABLE') |
|
| 1281 | - return; |
|
| 1337 | + if ($option == 'DISABLE') { |
|
| 1338 | + return; |
|
| 1339 | + } |
|
| 1282 | 1340 | |
| 1283 | 1341 | // Finally set it. |
| 1284 | 1342 | header('X-Frame-Options: ' . $option); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | 'value' => $txt['date'], |
| 137 | 137 | ), |
| 138 | 138 | 'data' => array( |
| 139 | - 'function' => function ($rowData) use ($txt) |
|
| 139 | + 'function' => function($rowData) use ($txt) |
|
| 140 | 140 | { |
| 141 | 141 | // Recurring every year or just a single year? |
| 142 | 142 | $year = $rowData['year'] == '1004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year']; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | checkSession(); |
| 219 | 219 | |
| 220 | 220 | // Not too long good sir? |
| 221 | - $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 221 | + $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
|
| 222 | 222 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 223 | |
| 224 | 224 | if (isset($_REQUEST['delete'])) |
@@ -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 | * The main controlling function doesn't have much to do... yet. |
@@ -43,8 +44,7 @@ discard block |
||
| 43 | 44 | 'settings' => 'ModifyCalendarSettings' |
| 44 | 45 | ); |
| 45 | 46 | $default = 'holidays'; |
| 46 | - } |
|
| 47 | - else |
|
| 47 | + } else |
|
| 48 | 48 | { |
| 49 | 49 | $subActions = array( |
| 50 | 50 | 'settings' => 'ModifyCalendarSettings' |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | 'help' => 'calendar', |
| 61 | 61 | 'description' => $txt['calendar_settings_desc'], |
| 62 | 62 | ); |
| 63 | - if (!empty($modSettings['cal_enabled'])) |
|
| 64 | - $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 63 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 64 | + $context[$context['admin_menu_name']]['tab_data']['tabs'] = array( |
|
| 65 | 65 | 'holidays' => array( |
| 66 | 66 | 'description' => $txt['manage_holidays_desc'], |
| 67 | 67 | ), |
@@ -69,6 +69,7 @@ discard block |
||
| 69 | 69 | 'description' => $txt['calendar_settings_desc'], |
| 70 | 70 | ), |
| 71 | 71 | ); |
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | call_integration_hook('integrate_manage_calendar', array(&$subActions)); |
| 74 | 75 | |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | checkSession(); |
| 89 | 90 | validateToken('admin-mc'); |
| 90 | 91 | |
| 91 | - foreach ($_REQUEST['holiday'] as $id => $value) |
|
| 92 | - $_REQUEST['holiday'][$id] = (int) $id; |
|
| 92 | + foreach ($_REQUEST['holiday'] as $id => $value) { |
|
| 93 | + $_REQUEST['holiday'][$id] = (int) $id; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | // Now the IDs are "safe" do the delete... |
| 95 | 97 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -209,8 +211,9 @@ discard block |
||
| 209 | 211 | $context['sub_template'] = 'edit_holiday'; |
| 210 | 212 | |
| 211 | 213 | // Cast this for safety... |
| 212 | - if (isset($_REQUEST['holiday'])) |
|
| 213 | - $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 214 | + if (isset($_REQUEST['holiday'])) { |
|
| 215 | + $_REQUEST['holiday'] = (int) $_REQUEST['holiday']; |
|
| 216 | + } |
|
| 214 | 217 | |
| 215 | 218 | // Submitting? |
| 216 | 219 | if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != '')) |
@@ -221,19 +224,19 @@ discard block |
||
| 221 | 224 | $_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60); |
| 222 | 225 | $_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0; |
| 223 | 226 | |
| 224 | - if (isset($_REQUEST['delete'])) |
|
| 225 | - $smcFunc['db_query']('', ' |
|
| 227 | + if (isset($_REQUEST['delete'])) { |
|
| 228 | + $smcFunc['db_query']('', ' |
|
| 226 | 229 | DELETE FROM {db_prefix}calendar_holidays |
| 227 | 230 | WHERE id_holiday = {int:selected_holiday}', |
| 228 | 231 | array( |
| 229 | 232 | 'selected_holiday' => $_REQUEST['holiday'], |
| 230 | 233 | ) |
| 231 | 234 | ); |
| 232 | - else |
|
| 235 | + } else |
|
| 233 | 236 | { |
| 234 | 237 | $date = strftime($_REQUEST['year'] <= 1004 ? '1004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year'])); |
| 235 | - if (isset($_REQUEST['edit'])) |
|
| 236 | - $smcFunc['db_query']('', ' |
|
| 238 | + if (isset($_REQUEST['edit'])) { |
|
| 239 | + $smcFunc['db_query']('', ' |
|
| 237 | 240 | UPDATE {db_prefix}calendar_holidays |
| 238 | 241 | SET event_date = {date:holiday_date}, title = {string:holiday_title} |
| 239 | 242 | WHERE id_holiday = {int:selected_holiday}', |
@@ -243,8 +246,8 @@ discard block |
||
| 243 | 246 | 'holiday_title' => $_REQUEST['title'], |
| 244 | 247 | ) |
| 245 | 248 | ); |
| 246 | - else |
|
| 247 | - $smcFunc['db_insert']('', |
|
| 249 | + } else { |
|
| 250 | + $smcFunc['db_insert']('', |
|
| 248 | 251 | '{db_prefix}calendar_holidays', |
| 249 | 252 | array( |
| 250 | 253 | 'event_date' => 'date', 'title' => 'string-60', |
@@ -254,6 +257,7 @@ discard block |
||
| 254 | 257 | ), |
| 255 | 258 | array('id_holiday') |
| 256 | 259 | ); |
| 260 | + } |
|
| 257 | 261 | } |
| 258 | 262 | |
| 259 | 263 | updateSettings(array( |
@@ -265,14 +269,15 @@ discard block |
||
| 265 | 269 | } |
| 266 | 270 | |
| 267 | 271 | // Default states... |
| 268 | - if ($context['is_new']) |
|
| 269 | - $context['holiday'] = array( |
|
| 272 | + if ($context['is_new']) { |
|
| 273 | + $context['holiday'] = array( |
|
| 270 | 274 | 'id' => 0, |
| 271 | 275 | 'day' => date('d'), |
| 272 | 276 | 'month' => date('m'), |
| 273 | 277 | 'year' => '0000', |
| 274 | 278 | 'title' => '' |
| 275 | 279 | ); |
| 280 | + } |
|
| 276 | 281 | // If it's not new load the data. |
| 277 | 282 | else |
| 278 | 283 | { |
@@ -285,14 +290,15 @@ discard block |
||
| 285 | 290 | 'selected_holiday' => $_REQUEST['holiday'], |
| 286 | 291 | ) |
| 287 | 292 | ); |
| 288 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 289 | - $context['holiday'] = array( |
|
| 293 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 294 | + $context['holiday'] = array( |
|
| 290 | 295 | 'id' => $row['id_holiday'], |
| 291 | 296 | 'day' => $row['day'], |
| 292 | 297 | 'month' => $row['month'], |
| 293 | 298 | 'year' => $row['year'] <= 4 ? 0 : $row['year'], |
| 294 | 299 | 'title' => $row['title'] |
| 295 | 300 | ); |
| 301 | + } |
|
| 296 | 302 | $smcFunc['db_free_result']($request); |
| 297 | 303 | } |
| 298 | 304 | |
@@ -319,16 +325,17 @@ discard block |
||
| 319 | 325 | array( |
| 320 | 326 | ) |
| 321 | 327 | ); |
| 322 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 323 | - $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 329 | + $boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
| 330 | + } |
|
| 324 | 331 | $smcFunc['db_free_result']($request); |
| 325 | 332 | |
| 326 | 333 | require_once($sourcedir . '/Subs-Boards.php'); |
| 327 | 334 | sortBoards($boards); |
| 328 | 335 | |
| 329 | 336 | // Look, all the calendar settings - of which there are many! |
| 330 | - if (!empty($modSettings['cal_enabled'])) |
|
| 331 | - $config_vars = array( |
|
| 337 | + if (!empty($modSettings['cal_enabled'])) { |
|
| 338 | + $config_vars = array( |
|
| 332 | 339 | array('check', 'cal_enabled'), |
| 333 | 340 | '', |
| 334 | 341 | // All the permissions: |
@@ -371,14 +378,16 @@ discard block |
||
| 371 | 378 | array('check', 'cal_short_days'), |
| 372 | 379 | array('check', 'cal_short_months'), |
| 373 | 380 | ); |
| 374 | - else |
|
| 375 | - $config_vars = array( |
|
| 381 | + } else { |
|
| 382 | + $config_vars = array( |
|
| 376 | 383 | array('check', 'cal_enabled'), |
| 377 | 384 | ); |
| 385 | + } |
|
| 378 | 386 | |
| 379 | 387 | call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); |
| 380 | - if ($return_config) |
|
| 381 | - return $config_vars; |
|
| 388 | + if ($return_config) { |
|
| 389 | + return $config_vars; |
|
| 390 | + } |
|
| 382 | 391 | |
| 383 | 392 | // Get the settings template fired up. |
| 384 | 393 | require_once($sourcedir . '/ManageServer.php'); |