@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Entry point function, permission checks, admin bars, etc. |
@@ -99,27 +100,27 @@ discard block |
||
| 99 | 100 | 'function' => function($rowData) use ($scripturl) |
| 100 | 101 | { |
| 101 | 102 | // Since the moderator group has no explicit members, no link is needed. |
| 102 | - if ($rowData['id_group'] == 3) |
|
| 103 | - $group_name = $rowData['group_name']; |
|
| 104 | - else |
|
| 103 | + if ($rowData['id_group'] == 3) { |
|
| 104 | + $group_name = $rowData['group_name']; |
|
| 105 | + } else |
|
| 105 | 106 | { |
| 106 | 107 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
| 107 | 108 | |
| 108 | 109 | if (allowedTo('manage_membergroups')) |
| 109 | 110 | { |
| 110 | 111 | $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']); |
| 111 | - } |
|
| 112 | - else |
|
| 112 | + } else |
|
| 113 | 113 | { |
| 114 | 114 | $group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Add a help option for moderator and administrator. |
| 119 | - if ($rowData['id_group'] == 1) |
|
| 120 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 121 | - elseif ($rowData['id_group'] == 3) |
|
| 122 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 119 | + if ($rowData['id_group'] == 1) { |
|
| 120 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 121 | + } elseif ($rowData['id_group'] == 3) { |
|
| 122 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
| 123 | + } |
|
| 123 | 124 | |
| 124 | 125 | return $group_name; |
| 125 | 126 | }, |
@@ -198,8 +199,9 @@ discard block |
||
| 198 | 199 | $_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0; |
| 199 | 200 | |
| 200 | 201 | // No browsing of guests, membergroup 0 or moderators. |
| 201 | - if (in_array($_REQUEST['group'], array(-1, 0, 3))) |
|
| 202 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 202 | + if (in_array($_REQUEST['group'], array(-1, 0, 3))) { |
|
| 203 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 204 | + } |
|
| 203 | 205 | |
| 204 | 206 | // Load up the group details. |
| 205 | 207 | $request = $smcFunc['db_query']('', ' |
@@ -214,8 +216,9 @@ discard block |
||
| 214 | 216 | ) |
| 215 | 217 | ); |
| 216 | 218 | // Doesn't exist? |
| 217 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 218 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 219 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 220 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 221 | + } |
|
| 219 | 222 | $context['group'] = $smcFunc['db_fetch_assoc']($request); |
| 220 | 223 | $smcFunc['db_free_result']($request); |
| 221 | 224 | |
@@ -248,21 +251,25 @@ discard block |
||
| 248 | 251 | 'name' => $row['real_name'] |
| 249 | 252 | ); |
| 250 | 253 | |
| 251 | - if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) |
|
| 252 | - $context['group']['can_moderate'] = true; |
|
| 254 | + if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) { |
|
| 255 | + $context['group']['can_moderate'] = true; |
|
| 256 | + } |
|
| 253 | 257 | } |
| 254 | 258 | $smcFunc['db_free_result']($request); |
| 255 | 259 | |
| 256 | 260 | // If this group is hidden then it can only "exists" if the user can moderate it! |
| 257 | - if ($context['group']['hidden'] && !$context['group']['can_moderate']) |
|
| 258 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
| 261 | + if ($context['group']['hidden'] && !$context['group']['can_moderate']) { |
|
| 262 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
| 263 | + } |
|
| 259 | 264 | |
| 260 | 265 | // You can only assign membership if you are the moderator and/or can manage groups! |
| 261 | - if (!$context['group']['can_moderate']) |
|
| 262 | - $context['group']['assignable'] = 0; |
|
| 266 | + if (!$context['group']['can_moderate']) { |
|
| 267 | + $context['group']['assignable'] = 0; |
|
| 268 | + } |
|
| 263 | 269 | // Non-admins cannot assign admins. |
| 264 | - elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) |
|
| 265 | - $context['group']['assignable'] = 0; |
|
| 270 | + elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) { |
|
| 271 | + $context['group']['assignable'] = 0; |
|
| 272 | + } |
|
| 266 | 273 | |
| 267 | 274 | // Removing member from group? |
| 268 | 275 | if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) |
@@ -271,8 +278,9 @@ discard block |
||
| 271 | 278 | validateToken('mod-mgm'); |
| 272 | 279 | |
| 273 | 280 | // Make sure we're dealing with integers only. |
| 274 | - foreach ($_REQUEST['rem'] as $key => $group) |
|
| 275 | - $_REQUEST['rem'][$key] = (int) $group; |
|
| 281 | + foreach ($_REQUEST['rem'] as $key => $group) { |
|
| 282 | + $_REQUEST['rem'][$key] = (int) $group; |
|
| 283 | + } |
|
| 276 | 284 | |
| 277 | 285 | require_once($sourcedir . '/Subs-Membergroups.php'); |
| 278 | 286 | removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true); |
@@ -295,16 +303,18 @@ discard block |
||
| 295 | 303 | { |
| 296 | 304 | $member_names[$index] = trim($smcFunc['strtolower']($member_names[$index])); |
| 297 | 305 | |
| 298 | - if (strlen($member_names[$index]) == 0) |
|
| 299 | - unset($member_names[$index]); |
|
| 306 | + if (strlen($member_names[$index]) == 0) { |
|
| 307 | + unset($member_names[$index]); |
|
| 308 | + } |
|
| 300 | 309 | } |
| 301 | 310 | |
| 302 | 311 | // Any passed by ID? |
| 303 | 312 | $member_ids = array(); |
| 304 | - if (!empty($_REQUEST['member_add'])) |
|
| 305 | - foreach ($_REQUEST['member_add'] as $id) |
|
| 313 | + if (!empty($_REQUEST['member_add'])) { |
|
| 314 | + foreach ($_REQUEST['member_add'] as $id) |
|
| 306 | 315 | if ($id > 0) |
| 307 | 316 | $member_ids[] = (int) $id; |
| 317 | + } |
|
| 308 | 318 | |
| 309 | 319 | // Construct the query pelements. |
| 310 | 320 | if (!empty($member_ids)) |
@@ -332,8 +342,9 @@ discard block |
||
| 332 | 342 | 'id_group' => $_REQUEST['group'], |
| 333 | 343 | )) |
| 334 | 344 | ); |
| 335 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 336 | - $members[] = $row['id_member']; |
|
| 345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 346 | + $members[] = $row['id_member']; |
|
| 347 | + } |
|
| 337 | 348 | $smcFunc['db_free_result']($request); |
| 338 | 349 | } |
| 339 | 350 | |
@@ -372,10 +383,11 @@ discard block |
||
| 372 | 383 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
| 373 | 384 | |
| 374 | 385 | // The where on the query is interesting. Non-moderators should only see people who are in this group as primary. |
| 375 | - if ($context['group']['can_moderate']) |
|
| 376 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
| 377 | - else |
|
| 378 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
| 386 | + if ($context['group']['can_moderate']) { |
|
| 387 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
| 388 | + } else { |
|
| 389 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
| 390 | + } |
|
| 379 | 391 | |
| 380 | 392 | // Count members of the group. |
| 381 | 393 | $request = $smcFunc['db_query']('', ' |
@@ -416,8 +428,9 @@ discard block |
||
| 416 | 428 | $last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']); |
| 417 | 429 | |
| 418 | 430 | // Italicize the online note if they aren't activated. |
| 419 | - if ($row['is_activated'] % 10 != 1) |
|
| 420 | - $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
| 431 | + if ($row['is_activated'] % 10 != 1) { |
|
| 432 | + $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
| 433 | + } |
|
| 421 | 434 | |
| 422 | 435 | $context['members'][] = array( |
| 423 | 436 | 'id' => $row['id_member'], |
@@ -437,9 +450,10 @@ discard block |
||
| 437 | 450 | $context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name']; |
| 438 | 451 | createToken('mod-mgm'); |
| 439 | 452 | |
| 440 | - if ($context['group']['assignable']) |
|
| 441 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 442 | -} |
|
| 453 | + if ($context['group']['assignable']) { |
|
| 454 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 455 | + } |
|
| 456 | + } |
|
| 443 | 457 | |
| 444 | 458 | /** |
| 445 | 459 | * Show and manage all group requests. |
@@ -453,16 +467,18 @@ discard block |
||
| 453 | 467 | $context['sub_template'] = 'show_list'; |
| 454 | 468 | |
| 455 | 469 | // Verify we can be here. |
| 456 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
| 457 | - isAllowedTo('manage_membergroups'); |
|
| 470 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
| 471 | + isAllowedTo('manage_membergroups'); |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | // Normally, we act normally... |
| 460 | 475 | $where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']); |
| 461 | 476 | |
| 462 | - if (isset($_GET['closed'])) |
|
| 463 | - $where .= ' AND lgr.status != {int:status_open}'; |
|
| 464 | - else |
|
| 465 | - $where .= ' AND lgr.status = {int:status_open}'; |
|
| 477 | + if (isset($_GET['closed'])) { |
|
| 478 | + $where .= ' AND lgr.status != {int:status_open}'; |
|
| 479 | + } else { |
|
| 480 | + $where .= ' AND lgr.status = {int:status_open}'; |
|
| 481 | + } |
|
| 466 | 482 | |
| 467 | 483 | $where_parameters = array( |
| 468 | 484 | 'status_open' => 0, |
@@ -475,8 +491,9 @@ discard block |
||
| 475 | 491 | validateToken('mod-gr'); |
| 476 | 492 | |
| 477 | 493 | // Clean the values. |
| 478 | - foreach ($_POST['groupr'] as $k => $request) |
|
| 479 | - $_POST['groupr'][$k] = (int) $request; |
|
| 494 | + foreach ($_POST['groupr'] as $k => $request) { |
|
| 495 | + $_POST['groupr'][$k] = (int) $request; |
|
| 496 | + } |
|
| 480 | 497 | |
| 481 | 498 | $log_changes = array(); |
| 482 | 499 | |
@@ -513,8 +530,8 @@ discard block |
||
| 513 | 530 | $request_list = array(); |
| 514 | 531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 515 | 532 | { |
| 516 | - if (!isset($log_changes[$row['id_request']])) |
|
| 517 | - $log_changes[$row['id_request']] = array( |
|
| 533 | + if (!isset($log_changes[$row['id_request']])) { |
|
| 534 | + $log_changes[$row['id_request']] = array( |
|
| 518 | 535 | 'id_request' => $row['id_request'], |
| 519 | 536 | 'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected |
| 520 | 537 | 'id_member_acted' => $user_info['id'], |
@@ -522,6 +539,7 @@ discard block |
||
| 522 | 539 | 'time_acted' => time(), |
| 523 | 540 | 'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '', |
| 524 | 541 | ); |
| 542 | + } |
|
| 525 | 543 | $request_list[] = $row['id_request']; |
| 526 | 544 | } |
| 527 | 545 | $smcFunc['db_free_result']($request); |
@@ -744,21 +762,24 @@ discard block |
||
| 744 | 762 | $group_requests = array(); |
| 745 | 763 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 746 | 764 | { |
| 747 | - if (empty($row['reason'])) |
|
| 748 | - $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
| 749 | - else |
|
| 750 | - $reason = censorText($row['reason']); |
|
| 765 | + if (empty($row['reason'])) { |
|
| 766 | + $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
| 767 | + } else { |
|
| 768 | + $reason = censorText($row['reason']); |
|
| 769 | + } |
|
| 751 | 770 | |
| 752 | 771 | if (isset($_GET['closed'])) |
| 753 | 772 | { |
| 754 | - if ($row['status'] == 1) |
|
| 755 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
| 756 | - elseif ($row['status'] == 2) |
|
| 757 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
| 773 | + if ($row['status'] == 1) { |
|
| 774 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
| 775 | + } elseif ($row['status'] == 2) { |
|
| 776 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
| 777 | + } |
|
| 758 | 778 | |
| 759 | 779 | $reason .= ' (' . timeformat($row['time_acted']) . ')'; |
| 760 | - if (!empty($row['act_reason'])) |
|
| 761 | - $reason .= '<br><br>' . censorText($row['act_reason']); |
|
| 780 | + if (!empty($row['act_reason'])) { |
|
| 781 | + $reason .= '<br><br>' . censorText($row['act_reason']); |
|
| 782 | + } |
|
| 762 | 783 | } |
| 763 | 784 | |
| 764 | 785 | $group_requests[] = array( |
@@ -259,8 +259,8 @@ |
||
| 259 | 259 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
| 260 | 260 | |
| 261 | 261 | $js_time_string = str_replace( |
| 262 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 263 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 262 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
| 263 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
| 264 | 264 | $time_string |
| 265 | 265 | ); |
| 266 | 266 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
| 35 | 36 | global $sourcedir, $smcFunc, $language; |
| 36 | 37 | |
| 37 | 38 | loadLanguage('Post'); |
| 38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
| 39 | - loadLanguage('Drafts'); |
|
| 39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
| 40 | + loadLanguage('Drafts'); |
|
| 41 | + } |
|
| 40 | 42 | |
| 41 | 43 | // You can't reply with a poll... hacker. |
| 42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
| 43 | - unset($_REQUEST['poll']); |
|
| 44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 45 | + unset($_REQUEST['poll']); |
|
| 46 | + } |
|
| 44 | 47 | |
| 45 | 48 | // Posting an event? |
| 46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -55,8 +58,9 @@ discard block |
||
| 55 | 58 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
| 56 | 59 | |
| 57 | 60 | // You must be posting to *some* board. |
| 58 | - if (empty($board) && !$context['make_event']) |
|
| 59 | - fatal_lang_error('no_board', false); |
|
| 61 | + if (empty($board) && !$context['make_event']) { |
|
| 62 | + fatal_lang_error('no_board', false); |
|
| 63 | + } |
|
| 60 | 64 | |
| 61 | 65 | require_once($sourcedir . '/Subs-Post.php'); |
| 62 | 66 | |
@@ -79,10 +83,11 @@ discard block |
||
| 79 | 83 | array( |
| 80 | 84 | 'msg' => (int) $_REQUEST['msg'], |
| 81 | 85 | )); |
| 82 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
| 83 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 84 | - else |
|
| 85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 86 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
| 87 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
| 88 | + } else { |
|
| 89 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
| 90 | + } |
|
| 86 | 91 | $smcFunc['db_free_result']($request); |
| 87 | 92 | } |
| 88 | 93 | |
@@ -109,33 +114,36 @@ discard block |
||
| 109 | 114 | $smcFunc['db_free_result']($request); |
| 110 | 115 | |
| 111 | 116 | // If this topic already has a poll, they sure can't add another. |
| 112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
| 113 | - unset($_REQUEST['poll']); |
|
| 117 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
| 118 | + unset($_REQUEST['poll']); |
|
| 119 | + } |
|
| 114 | 120 | |
| 115 | 121 | if (empty($_REQUEST['msg'])) |
| 116 | 122 | { |
| 117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
| 118 | - is_not_guest(); |
|
| 123 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
| 124 | + is_not_guest(); |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | 127 | // By default the reply will be approved... |
| 121 | 128 | $context['becomes_approved'] = true; |
| 122 | 129 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
| 123 | 130 | { |
| 124 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 125 | - $context['becomes_approved'] = false; |
|
| 126 | - else |
|
| 127 | - isAllowedTo('post_reply_any'); |
|
| 128 | - } |
|
| 129 | - elseif (!allowedTo('post_reply_any')) |
|
| 131 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 132 | + $context['becomes_approved'] = false; |
|
| 133 | + } else { |
|
| 134 | + isAllowedTo('post_reply_any'); |
|
| 135 | + } |
|
| 136 | + } elseif (!allowedTo('post_reply_any')) |
|
| 130 | 137 | { |
| 131 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
| 132 | - $context['becomes_approved'] = false; |
|
| 133 | - else |
|
| 134 | - isAllowedTo('post_reply_own'); |
|
| 138 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
| 139 | + $context['becomes_approved'] = false; |
|
| 140 | + } else { |
|
| 141 | + isAllowedTo('post_reply_own'); |
|
| 142 | + } |
|
| 135 | 143 | } |
| 144 | + } else { |
|
| 145 | + $context['becomes_approved'] = true; |
|
| 136 | 146 | } |
| 137 | - else |
|
| 138 | - $context['becomes_approved'] = true; |
|
| 139 | 147 | |
| 140 | 148 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
| 141 | 149 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +155,19 @@ discard block |
||
| 147 | 155 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
| 148 | 156 | |
| 149 | 157 | // Check whether this is a really old post being bumped... |
| 150 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
| 151 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 152 | - } |
|
| 153 | - else |
|
| 158 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
| 159 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
| 160 | + } |
|
| 161 | + } else |
|
| 154 | 162 | { |
| 155 | 163 | $context['becomes_approved'] = true; |
| 156 | 164 | if ((!$context['make_event'] || !empty($board))) |
| 157 | 165 | { |
| 158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 159 | - $context['becomes_approved'] = false; |
|
| 160 | - else |
|
| 161 | - isAllowedTo('post_new'); |
|
| 166 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 167 | + $context['becomes_approved'] = false; |
|
| 168 | + } else { |
|
| 169 | + isAllowedTo('post_new'); |
|
| 170 | + } |
|
| 162 | 171 | } |
| 163 | 172 | |
| 164 | 173 | $locked = 0; |
@@ -194,20 +203,24 @@ discard block |
||
| 194 | 203 | } |
| 195 | 204 | |
| 196 | 205 | // Don't allow a post if it's locked and you aren't all powerful. |
| 197 | - if ($locked && !allowedTo('moderate_board')) |
|
| 198 | - fatal_lang_error('topic_locked', false); |
|
| 206 | + if ($locked && !allowedTo('moderate_board')) { |
|
| 207 | + fatal_lang_error('topic_locked', false); |
|
| 208 | + } |
|
| 199 | 209 | // Check the users permissions - is the user allowed to add or post a poll? |
| 200 | 210 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 201 | 211 | { |
| 202 | 212 | // New topic, new poll. |
| 203 | - if (empty($topic)) |
|
| 204 | - isAllowedTo('poll_post'); |
|
| 213 | + if (empty($topic)) { |
|
| 214 | + isAllowedTo('poll_post'); |
|
| 215 | + } |
|
| 205 | 216 | // This is an old topic - but it is yours! Can you add to it? |
| 206 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
| 207 | - isAllowedTo('poll_add_own'); |
|
| 217 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
| 218 | + isAllowedTo('poll_add_own'); |
|
| 219 | + } |
|
| 208 | 220 | // If you're not the owner, can you add to any poll? |
| 209 | - else |
|
| 210 | - isAllowedTo('poll_add_any'); |
|
| 221 | + else { |
|
| 222 | + isAllowedTo('poll_add_any'); |
|
| 223 | + } |
|
| 211 | 224 | |
| 212 | 225 | require_once($sourcedir . '/Subs-Members.php'); |
| 213 | 226 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -236,8 +249,9 @@ discard block |
||
| 236 | 249 | if ($context['make_event']) |
| 237 | 250 | { |
| 238 | 251 | // They might want to pick a board. |
| 239 | - if (!isset($context['current_board'])) |
|
| 240 | - $context['current_board'] = 0; |
|
| 252 | + if (!isset($context['current_board'])) { |
|
| 253 | + $context['current_board'] = 0; |
|
| 254 | + } |
|
| 241 | 255 | |
| 242 | 256 | // Start loading up the event info. |
| 243 | 257 | $context['event'] = array(); |
@@ -251,10 +265,11 @@ discard block |
||
| 251 | 265 | isAllowedTo('calendar_post'); |
| 252 | 266 | |
| 253 | 267 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 254 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 255 | - $time_string = '%k:%M'; |
|
| 256 | - else |
|
| 257 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 268 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 269 | + $time_string = '%k:%M'; |
|
| 270 | + } else { |
|
| 271 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 272 | + } |
|
| 258 | 273 | |
| 259 | 274 | $js_time_string = str_replace( |
| 260 | 275 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -276,8 +291,7 @@ discard block |
||
| 276 | 291 | require_once($sourcedir . '/Subs-Calendar.php'); |
| 277 | 292 | $eventProperties = getEventProperties($context['event']['id']); |
| 278 | 293 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 279 | - } |
|
| 280 | - else |
|
| 294 | + } else |
|
| 281 | 295 | { |
| 282 | 296 | // Get the current event information. |
| 283 | 297 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -285,15 +299,18 @@ discard block |
||
| 285 | 299 | $context['event'] = array_merge($context['event'], $eventProperties); |
| 286 | 300 | |
| 287 | 301 | // Make sure the year and month are in the valid range. |
| 288 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
| 289 | - fatal_lang_error('invalid_month', false); |
|
| 290 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
| 291 | - fatal_lang_error('invalid_year', false); |
|
| 302 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
| 303 | + fatal_lang_error('invalid_month', false); |
|
| 304 | + } |
|
| 305 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
| 306 | + fatal_lang_error('invalid_year', false); |
|
| 307 | + } |
|
| 292 | 308 | |
| 293 | 309 | // Get a list of boards they can post in. |
| 294 | 310 | $boards = boardsAllowedTo('post_new'); |
| 295 | - if (empty($boards)) |
|
| 296 | - fatal_lang_error('cannot_post_new', 'user'); |
|
| 311 | + if (empty($boards)) { |
|
| 312 | + fatal_lang_error('cannot_post_new', 'user'); |
|
| 313 | + } |
|
| 297 | 314 | |
| 298 | 315 | // Load a list of boards for this event in the context. |
| 299 | 316 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -412,10 +429,11 @@ discard block |
||
| 412 | 429 | |
| 413 | 430 | if (!empty($context['new_replies'])) |
| 414 | 431 | { |
| 415 | - if ($context['new_replies'] == 1) |
|
| 416 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 417 | - else |
|
| 418 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 432 | + if ($context['new_replies'] == 1) { |
|
| 433 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
| 434 | + } else { |
|
| 435 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
| 436 | + } |
|
| 419 | 437 | |
| 420 | 438 | $post_errors[] = 'new_replies'; |
| 421 | 439 | |
@@ -427,9 +445,9 @@ discard block |
||
| 427 | 445 | // Get a response prefix (like 'Re:') in the default forum language. |
| 428 | 446 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 429 | 447 | { |
| 430 | - if ($language === $user_info['language']) |
|
| 431 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 432 | - else |
|
| 448 | + if ($language === $user_info['language']) { |
|
| 449 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 450 | + } else |
|
| 433 | 451 | { |
| 434 | 452 | loadLanguage('index', $language, false); |
| 435 | 453 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -442,8 +460,9 @@ discard block |
||
| 442 | 460 | // Do we have a body, but an error happened. |
| 443 | 461 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
| 444 | 462 | { |
| 445 | - if (isset($_REQUEST['quickReply'])) |
|
| 446 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 463 | + if (isset($_REQUEST['quickReply'])) { |
|
| 464 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
| 465 | + } |
|
| 447 | 466 | |
| 448 | 467 | // Validate inputs. |
| 449 | 468 | if (empty($context['post_error'])) |
@@ -451,15 +470,17 @@ discard block |
||
| 451 | 470 | // This means they didn't click Post and get an error. |
| 452 | 471 | $really_previewing = true; |
| 453 | 472 | |
| 454 | - } |
|
| 455 | - else |
|
| 473 | + } else |
|
| 456 | 474 | { |
| 457 | - if (!isset($_REQUEST['subject'])) |
|
| 458 | - $_REQUEST['subject'] = ''; |
|
| 459 | - if (!isset($_REQUEST['message'])) |
|
| 460 | - $_REQUEST['message'] = ''; |
|
| 461 | - if (!isset($_REQUEST['icon'])) |
|
| 462 | - $_REQUEST['icon'] = 'xx'; |
|
| 475 | + if (!isset($_REQUEST['subject'])) { |
|
| 476 | + $_REQUEST['subject'] = ''; |
|
| 477 | + } |
|
| 478 | + if (!isset($_REQUEST['message'])) { |
|
| 479 | + $_REQUEST['message'] = ''; |
|
| 480 | + } |
|
| 481 | + if (!isset($_REQUEST['icon'])) { |
|
| 482 | + $_REQUEST['icon'] = 'xx'; |
|
| 483 | + } |
|
| 463 | 484 | |
| 464 | 485 | // They are previewing if they asked to preview (i.e. came from quick reply). |
| 465 | 486 | $really_previewing = !empty($_POST['preview']); |
@@ -475,8 +496,9 @@ discard block |
||
| 475 | 496 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
| 476 | 497 | |
| 477 | 498 | // Make sure the subject isn't too long - taking into account special characters. |
| 478 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
| 479 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 499 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
| 500 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
| 501 | + } |
|
| 480 | 502 | |
| 481 | 503 | if (isset($_REQUEST['poll'])) |
| 482 | 504 | { |
@@ -488,8 +510,9 @@ discard block |
||
| 488 | 510 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
| 489 | 511 | foreach ($_POST['options'] as $option) |
| 490 | 512 | { |
| 491 | - if (trim($option) == '') |
|
| 492 | - continue; |
|
| 513 | + if (trim($option) == '') { |
|
| 514 | + continue; |
|
| 515 | + } |
|
| 493 | 516 | |
| 494 | 517 | $context['choices'][] = array( |
| 495 | 518 | 'id' => $choice_id++, |
@@ -551,13 +574,14 @@ discard block |
||
| 551 | 574 | $context['preview_subject'] = $form_subject; |
| 552 | 575 | |
| 553 | 576 | censorText($context['preview_subject']); |
| 577 | + } else { |
|
| 578 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 554 | 579 | } |
| 555 | - else |
|
| 556 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
| 557 | 580 | |
| 558 | 581 | // Protect any CDATA blocks. |
| 559 | - if (isset($_REQUEST['xml'])) |
|
| 560 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
| 582 | + if (isset($_REQUEST['xml'])) { |
|
| 583 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
| 600 | - fatal_lang_error('no_board', false); |
|
| 623 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 624 | + fatal_lang_error('no_board', false); |
|
| 625 | + } |
|
| 601 | 626 | $row = $smcFunc['db_fetch_assoc']($request); |
| 602 | 627 | |
| 603 | 628 | $attachment_stuff = array($row); |
| 604 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 605 | - $attachment_stuff[] = $row2; |
|
| 629 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 630 | + $attachment_stuff[] = $row2; |
|
| 631 | + } |
|
| 606 | 632 | $smcFunc['db_free_result']($request); |
| 607 | 633 | |
| 608 | 634 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 609 | 635 | { |
| 610 | 636 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 611 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 612 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 613 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 614 | - isAllowedTo('modify_replies'); |
|
| 615 | - else |
|
| 616 | - isAllowedTo('modify_own'); |
|
| 637 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 638 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 639 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 640 | + isAllowedTo('modify_replies'); |
|
| 641 | + } else { |
|
| 642 | + isAllowedTo('modify_own'); |
|
| 643 | + } |
|
| 644 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 645 | + isAllowedTo('modify_replies'); |
|
| 646 | + } else { |
|
| 647 | + isAllowedTo('modify_any'); |
|
| 617 | 648 | } |
| 618 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 619 | - isAllowedTo('modify_replies'); |
|
| 620 | - else |
|
| 621 | - isAllowedTo('modify_any'); |
|
| 622 | 649 | |
| 623 | 650 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 624 | 651 | { |
@@ -642,8 +669,9 @@ discard block |
||
| 642 | 669 | |
| 643 | 670 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 644 | 671 | { |
| 645 | - if ($row['filesize'] <= 0) |
|
| 646 | - continue; |
|
| 672 | + if ($row['filesize'] <= 0) { |
|
| 673 | + continue; |
|
| 674 | + } |
|
| 647 | 675 | $context['current_attachments'][$row['id_attach']] = array( |
| 648 | 676 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
| 649 | 677 | 'size' => $row['filesize'], |
@@ -713,29 +741,32 @@ discard block |
||
| 713 | 741 | ) |
| 714 | 742 | ); |
| 715 | 743 | // The message they were trying to edit was most likely deleted. |
| 716 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 717 | - fatal_lang_error('no_message', false); |
|
| 744 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 745 | + fatal_lang_error('no_message', false); |
|
| 746 | + } |
|
| 718 | 747 | $row = $smcFunc['db_fetch_assoc']($request); |
| 719 | 748 | |
| 720 | 749 | $attachment_stuff = array($row); |
| 721 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
| 722 | - $attachment_stuff[] = $row2; |
|
| 750 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
| 751 | + $attachment_stuff[] = $row2; |
|
| 752 | + } |
|
| 723 | 753 | $smcFunc['db_free_result']($request); |
| 724 | 754 | |
| 725 | 755 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 726 | 756 | { |
| 727 | 757 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
| 728 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 729 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 730 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 731 | - isAllowedTo('modify_replies'); |
|
| 732 | - else |
|
| 733 | - isAllowedTo('modify_own'); |
|
| 758 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 759 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 760 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 761 | + isAllowedTo('modify_replies'); |
|
| 762 | + } else { |
|
| 763 | + isAllowedTo('modify_own'); |
|
| 764 | + } |
|
| 765 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 766 | + isAllowedTo('modify_replies'); |
|
| 767 | + } else { |
|
| 768 | + isAllowedTo('modify_any'); |
|
| 734 | 769 | } |
| 735 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 736 | - isAllowedTo('modify_replies'); |
|
| 737 | - else |
|
| 738 | - isAllowedTo('modify_any'); |
|
| 739 | 770 | |
| 740 | 771 | if ($context['can_announce'] && !empty($row['id_action'])) |
| 741 | 772 | { |
@@ -762,15 +793,17 @@ discard block |
||
| 762 | 793 | $context['icon'] = $row['icon']; |
| 763 | 794 | |
| 764 | 795 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
| 765 | - if (!$row['approved'] && !$context['show_approval']) |
|
| 766 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
| 796 | + if (!$row['approved'] && !$context['show_approval']) { |
|
| 797 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
| 798 | + } |
|
| 767 | 799 | |
| 768 | 800 | // Sort the attachments so they are in the order saved |
| 769 | 801 | $temp = array(); |
| 770 | 802 | foreach ($attachment_stuff as $attachment) |
| 771 | 803 | { |
| 772 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
| 773 | - $temp[$attachment['id_attach']] = $attachment; |
|
| 804 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
| 805 | + $temp[$attachment['id_attach']] = $attachment; |
|
| 806 | + } |
|
| 774 | 807 | |
| 775 | 808 | } |
| 776 | 809 | ksort($temp); |
@@ -832,14 +865,16 @@ discard block |
||
| 832 | 865 | 'is_approved' => 1, |
| 833 | 866 | ) |
| 834 | 867 | ); |
| 835 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 836 | - fatal_lang_error('quoted_post_deleted', false); |
|
| 868 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 869 | + fatal_lang_error('quoted_post_deleted', false); |
|
| 870 | + } |
|
| 837 | 871 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
| 838 | 872 | $smcFunc['db_free_result']($request); |
| 839 | 873 | |
| 840 | 874 | // Add 'Re: ' to the front of the quoted subject. |
| 841 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 842 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 875 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 876 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 877 | + } |
|
| 843 | 878 | |
| 844 | 879 | // Censor the message and subject. |
| 845 | 880 | censorText($form_message); |
@@ -852,10 +887,11 @@ discard block |
||
| 852 | 887 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
| 853 | 888 | { |
| 854 | 889 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
| 855 | - if ($i % 4 == 0) |
|
| 856 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 890 | + if ($i % 4 == 0) { |
|
| 891 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
| 857 | 892 | { |
| 858 | 893 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
| 894 | + } |
|
| 859 | 895 | }, $parts[$i]); |
| 860 | 896 | } |
| 861 | 897 | $form_message = implode('', $parts); |
@@ -864,8 +900,9 @@ discard block |
||
| 864 | 900 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
| 865 | 901 | |
| 866 | 902 | // Remove any nested quotes, if necessary. |
| 867 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 868 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 903 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 904 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
| 905 | + } |
|
| 869 | 906 | |
| 870 | 907 | // Add a quote string on the front and end. |
| 871 | 908 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -877,15 +914,15 @@ discard block |
||
| 877 | 914 | $form_subject = $first_subject; |
| 878 | 915 | |
| 879 | 916 | // Add 'Re: ' to the front of the subject. |
| 880 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
| 881 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
| 917 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
| 918 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
| 919 | + } |
|
| 882 | 920 | |
| 883 | 921 | // Censor the subject. |
| 884 | 922 | censorText($form_subject); |
| 885 | 923 | |
| 886 | 924 | $form_message = ''; |
| 887 | - } |
|
| 888 | - else |
|
| 925 | + } else |
|
| 889 | 926 | { |
| 890 | 927 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
| 891 | 928 | $form_message = ''; |
@@ -903,13 +940,15 @@ discard block |
||
| 903 | 940 | if (isset($_REQUEST['msg'])) |
| 904 | 941 | { |
| 905 | 942 | $context['attachments']['quantity'] = count($context['current_attachments']); |
| 906 | - foreach ($context['current_attachments'] as $attachment) |
|
| 907 | - $context['attachments']['total_size'] += $attachment['size']; |
|
| 943 | + foreach ($context['current_attachments'] as $attachment) { |
|
| 944 | + $context['attachments']['total_size'] += $attachment['size']; |
|
| 945 | + } |
|
| 908 | 946 | } |
| 909 | 947 | |
| 910 | 948 | // A bit of house keeping first. |
| 911 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
| 912 | - unset($_SESSION['temp_attachments']); |
|
| 949 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
| 950 | + unset($_SESSION['temp_attachments']); |
|
| 951 | + } |
|
| 913 | 952 | |
| 914 | 953 | if (!empty($_SESSION['temp_attachments'])) |
| 915 | 954 | { |
@@ -918,9 +957,10 @@ discard block |
||
| 918 | 957 | { |
| 919 | 958 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 920 | 959 | { |
| 921 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 922 | - if (file_exists($attachment['tmp_name'])) |
|
| 960 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
| 961 | + if (file_exists($attachment['tmp_name'])) |
|
| 923 | 962 | unlink($attachment['tmp_name']); |
| 963 | + } |
|
| 924 | 964 | } |
| 925 | 965 | $post_errors[] = 'temp_attachments_gone'; |
| 926 | 966 | $_SESSION['temp_attachments'] = array(); |
@@ -934,8 +974,9 @@ discard block |
||
| 934 | 974 | // See if any files still exist before showing the warning message and the files attached. |
| 935 | 975 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 936 | 976 | { |
| 937 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 938 | - continue; |
|
| 977 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 978 | + continue; |
|
| 979 | + } |
|
| 939 | 980 | |
| 940 | 981 | if (file_exists($attachment['tmp_name'])) |
| 941 | 982 | { |
@@ -945,20 +986,21 @@ discard block |
||
| 945 | 986 | break; |
| 946 | 987 | } |
| 947 | 988 | } |
| 948 | - } |
|
| 949 | - else |
|
| 989 | + } else |
|
| 950 | 990 | { |
| 951 | 991 | // Since, they don't belong here. Let's inform the user that they exist.. |
| 952 | - if (!empty($topic)) |
|
| 953 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 954 | - else |
|
| 955 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 992 | + if (!empty($topic)) { |
|
| 993 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
| 994 | + } else { |
|
| 995 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
| 996 | + } |
|
| 956 | 997 | |
| 957 | 998 | // Compile a list of the files to show the user. |
| 958 | 999 | $file_list = array(); |
| 959 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 960 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1000 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
| 1001 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
| 961 | 1002 | $file_list[] = $attachment['name']; |
| 1003 | + } |
|
| 962 | 1004 | |
| 963 | 1005 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
| 964 | 1006 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -970,8 +1012,7 @@ discard block |
||
| 970 | 1012 | |
| 971 | 1013 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
| 972 | 1014 | $context['ignore_temp_attachments'] = true; |
| 973 | - } |
|
| 974 | - else |
|
| 1015 | + } else |
|
| 975 | 1016 | { |
| 976 | 1017 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
| 977 | 1018 | $context['ignore_temp_attachments'] = true; |
@@ -979,16 +1020,19 @@ discard block |
||
| 979 | 1020 | } |
| 980 | 1021 | } |
| 981 | 1022 | |
| 982 | - if (!empty($context['we_are_history'])) |
|
| 983 | - $post_errors[] = $context['we_are_history']; |
|
| 1023 | + if (!empty($context['we_are_history'])) { |
|
| 1024 | + $post_errors[] = $context['we_are_history']; |
|
| 1025 | + } |
|
| 984 | 1026 | |
| 985 | 1027 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 986 | 1028 | { |
| 987 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
| 988 | - break; |
|
| 1029 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
| 1030 | + break; |
|
| 1031 | + } |
|
| 989 | 1032 | |
| 990 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 991 | - continue; |
|
| 1033 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 1034 | + continue; |
|
| 1035 | + } |
|
| 992 | 1036 | |
| 993 | 1037 | if ($attachID == 'initial_error') |
| 994 | 1038 | { |
@@ -1003,15 +1047,17 @@ discard block |
||
| 1003 | 1047 | { |
| 1004 | 1048 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
| 1005 | 1049 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
| 1006 | - foreach ($attachment['errors'] as $error) |
|
| 1007 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1050 | + foreach ($attachment['errors'] as $error) { |
|
| 1051 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
| 1052 | + } |
|
| 1008 | 1053 | $txt['error_attach_errors'] .= '</div>'; |
| 1009 | 1054 | $post_errors[] = 'attach_errors'; |
| 1010 | 1055 | |
| 1011 | 1056 | // Take out the trash. |
| 1012 | 1057 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1013 | - if (file_exists($attachment['tmp_name'])) |
|
| 1014 | - unlink($attachment['tmp_name']); |
|
| 1058 | + if (file_exists($attachment['tmp_name'])) { |
|
| 1059 | + unlink($attachment['tmp_name']); |
|
| 1060 | + } |
|
| 1015 | 1061 | continue; |
| 1016 | 1062 | } |
| 1017 | 1063 | |
@@ -1024,8 +1070,9 @@ discard block |
||
| 1024 | 1070 | |
| 1025 | 1071 | $context['attachments']['quantity']++; |
| 1026 | 1072 | $context['attachments']['total_size'] += $attachment['size']; |
| 1027 | - if (!isset($context['files_in_session_warning'])) |
|
| 1028 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1073 | + if (!isset($context['files_in_session_warning'])) { |
|
| 1074 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
| 1075 | + } |
|
| 1029 | 1076 | |
| 1030 | 1077 | $context['current_attachments'][$attachID] = array( |
| 1031 | 1078 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1053,8 +1100,9 @@ discard block |
||
| 1053 | 1100 | } |
| 1054 | 1101 | |
| 1055 | 1102 | // If they came from quick reply, and have to enter verification details, give them some notice. |
| 1056 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
| 1057 | - $post_errors[] = 'need_qr_verification'; |
|
| 1103 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
| 1104 | + $post_errors[] = 'need_qr_verification'; |
|
| 1105 | + } |
|
| 1058 | 1106 | |
| 1059 | 1107 | /* |
| 1060 | 1108 | * There are two error types: serious and minor. Serious errors |
@@ -1071,52 +1119,56 @@ discard block |
||
| 1071 | 1119 | { |
| 1072 | 1120 | loadLanguage('Errors'); |
| 1073 | 1121 | $context['error_type'] = 'minor'; |
| 1074 | - foreach ($post_errors as $post_error) |
|
| 1075 | - if (is_array($post_error)) |
|
| 1122 | + foreach ($post_errors as $post_error) { |
|
| 1123 | + if (is_array($post_error)) |
|
| 1076 | 1124 | { |
| 1077 | 1125 | $post_error_id = $post_error[0]; |
| 1126 | + } |
|
| 1078 | 1127 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
| 1079 | 1128 | |
| 1080 | 1129 | // If it's not a minor error flag it as such. |
| 1081 | - if (!in_array($post_error_id, $minor_errors)) |
|
| 1082 | - $context['error_type'] = 'serious'; |
|
| 1083 | - } |
|
| 1084 | - else |
|
| 1130 | + if (!in_array($post_error_id, $minor_errors)) { |
|
| 1131 | + $context['error_type'] = 'serious'; |
|
| 1132 | + } |
|
| 1133 | + } else |
|
| 1085 | 1134 | { |
| 1086 | 1135 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
| 1087 | 1136 | |
| 1088 | 1137 | // If it's not a minor error flag it as such. |
| 1089 | - if (!in_array($post_error, $minor_errors)) |
|
| 1090 | - $context['error_type'] = 'serious'; |
|
| 1138 | + if (!in_array($post_error, $minor_errors)) { |
|
| 1139 | + $context['error_type'] = 'serious'; |
|
| 1140 | + } |
|
| 1091 | 1141 | } |
| 1092 | 1142 | } |
| 1093 | 1143 | |
| 1094 | 1144 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
| 1095 | - if (isset($_REQUEST['poll'])) |
|
| 1096 | - $context['page_title'] = $txt['new_poll']; |
|
| 1097 | - elseif ($context['make_event']) |
|
| 1098 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1099 | - elseif (isset($_REQUEST['msg'])) |
|
| 1100 | - $context['page_title'] = $txt['modify_msg']; |
|
| 1101 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
| 1102 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1103 | - elseif (empty($topic)) |
|
| 1104 | - $context['page_title'] = $txt['start_new_topic']; |
|
| 1105 | - else |
|
| 1106 | - $context['page_title'] = $txt['post_reply']; |
|
| 1145 | + if (isset($_REQUEST['poll'])) { |
|
| 1146 | + $context['page_title'] = $txt['new_poll']; |
|
| 1147 | + } elseif ($context['make_event']) { |
|
| 1148 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
| 1149 | + } elseif (isset($_REQUEST['msg'])) { |
|
| 1150 | + $context['page_title'] = $txt['modify_msg']; |
|
| 1151 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
| 1152 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
| 1153 | + } elseif (empty($topic)) { |
|
| 1154 | + $context['page_title'] = $txt['start_new_topic']; |
|
| 1155 | + } else { |
|
| 1156 | + $context['page_title'] = $txt['post_reply']; |
|
| 1157 | + } |
|
| 1107 | 1158 | |
| 1108 | 1159 | // Build the link tree. |
| 1109 | - if (empty($topic)) |
|
| 1110 | - $context['linktree'][] = array( |
|
| 1160 | + if (empty($topic)) { |
|
| 1161 | + $context['linktree'][] = array( |
|
| 1111 | 1162 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
| 1112 | 1163 | ); |
| 1113 | - else |
|
| 1114 | - $context['linktree'][] = array( |
|
| 1164 | + } else { |
|
| 1165 | + $context['linktree'][] = array( |
|
| 1115 | 1166 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
| 1116 | 1167 | 'name' => $form_subject, |
| 1117 | 1168 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
| 1118 | 1169 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
| 1119 | 1170 | ); |
| 1171 | + } |
|
| 1120 | 1172 | |
| 1121 | 1173 | $context['subject'] = addcslashes($form_subject, '"'); |
| 1122 | 1174 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1160,8 +1212,9 @@ discard block |
||
| 1160 | 1212 | // Message icons - customized icons are off? |
| 1161 | 1213 | $context['icons'] = getMessageIcons($board); |
| 1162 | 1214 | |
| 1163 | - if (!empty($context['icons'])) |
|
| 1164 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1215 | + if (!empty($context['icons'])) { |
|
| 1216 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
| 1217 | + } |
|
| 1165 | 1218 | |
| 1166 | 1219 | // Are we starting a poll? if set the poll icon as selected if its available |
| 1167 | 1220 | if (isset($_REQUEST['poll'])) |
@@ -1181,8 +1234,9 @@ discard block |
||
| 1181 | 1234 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
| 1182 | 1235 | { |
| 1183 | 1236 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
| 1184 | - if ($context['icons'][$i]['selected']) |
|
| 1185 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1237 | + if ($context['icons'][$i]['selected']) { |
|
| 1238 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
| 1239 | + } |
|
| 1186 | 1240 | } |
| 1187 | 1241 | if (empty($context['icon_url'])) |
| 1188 | 1242 | { |
@@ -1196,8 +1250,9 @@ discard block |
||
| 1196 | 1250 | )); |
| 1197 | 1251 | } |
| 1198 | 1252 | |
| 1199 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
| 1200 | - getTopic(); |
|
| 1253 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
| 1254 | + getTopic(); |
|
| 1255 | + } |
|
| 1201 | 1256 | |
| 1202 | 1257 | // If the user can post attachments prepare the warning labels. |
| 1203 | 1258 | if ($context['can_post_attachment']) |
@@ -1208,12 +1263,13 @@ discard block |
||
| 1208 | 1263 | $context['attachment_restrictions'] = array(); |
| 1209 | 1264 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
| 1210 | 1265 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
| 1211 | - foreach ($attachmentRestrictionTypes as $type) |
|
| 1212 | - if (!empty($modSettings[$type])) |
|
| 1266 | + foreach ($attachmentRestrictionTypes as $type) { |
|
| 1267 | + if (!empty($modSettings[$type])) |
|
| 1213 | 1268 | { |
| 1214 | 1269 | // Show the max number of attachments if not 0. |
| 1215 | 1270 | if ($type == 'attachmentNumPerPostLimit') |
| 1216 | 1271 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
| 1272 | + } |
|
| 1217 | 1273 | } |
| 1218 | 1274 | } |
| 1219 | 1275 | |
@@ -1247,8 +1303,8 @@ discard block |
||
| 1247 | 1303 | |
| 1248 | 1304 | if (!empty($context['current_attachments'])) |
| 1249 | 1305 | { |
| 1250 | - foreach ($context['current_attachments'] as $key => $mock) |
|
| 1251 | - addInlineJavaScript(' |
|
| 1306 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
| 1307 | + addInlineJavaScript(' |
|
| 1252 | 1308 | current_attachments.push({ |
| 1253 | 1309 | name: '. JavaScriptEscape($mock['name']) . ', |
| 1254 | 1310 | size: '. $mock['size'] . ', |
@@ -1257,6 +1313,7 @@ discard block |
||
| 1257 | 1313 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
| 1258 | 1314 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
| 1259 | 1315 | });', true); |
| 1316 | + } |
|
| 1260 | 1317 | } |
| 1261 | 1318 | |
| 1262 | 1319 | // File Upload. |
@@ -1301,8 +1358,9 @@ discard block |
||
| 1301 | 1358 | var current_board = '. (empty($context['current_board']) ? 'null' : $context['current_board']) . ';', false); |
| 1302 | 1359 | |
| 1303 | 1360 | // Finally, load the template. |
| 1304 | - if (!isset($_REQUEST['xml'])) |
|
| 1305 | - loadTemplate('Post'); |
|
| 1361 | + if (!isset($_REQUEST['xml'])) { |
|
| 1362 | + loadTemplate('Post'); |
|
| 1363 | + } |
|
| 1306 | 1364 | |
| 1307 | 1365 | call_integration_hook('integrate_post_end'); |
| 1308 | 1366 | } |
@@ -1323,13 +1381,14 @@ discard block |
||
| 1323 | 1381 | // Sneaking off, are we? |
| 1324 | 1382 | if (empty($_POST) && empty($topic)) |
| 1325 | 1383 | { |
| 1326 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
| 1327 | - redirectexit('action=post;board=' . $board . '.0'); |
|
| 1328 | - else |
|
| 1329 | - fatal_lang_error('post_upload_error', false); |
|
| 1384 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
| 1385 | + redirectexit('action=post;board=' . $board . '.0'); |
|
| 1386 | + } else { |
|
| 1387 | + fatal_lang_error('post_upload_error', false); |
|
| 1388 | + } |
|
| 1389 | + } elseif (empty($_POST) && !empty($topic)) { |
|
| 1390 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1330 | 1391 | } |
| 1331 | - elseif (empty($_POST) && !empty($topic)) |
|
| 1332 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
| 1333 | 1392 | |
| 1334 | 1393 | // No need! |
| 1335 | 1394 | $context['robot_no_index'] = true; |
@@ -1341,8 +1400,9 @@ discard block |
||
| 1341 | 1400 | $post_errors = array(); |
| 1342 | 1401 | |
| 1343 | 1402 | // If the session has timed out, let the user re-submit their form. |
| 1344 | - if (checkSession('post', '', false) != '') |
|
| 1345 | - $post_errors[] = 'session_timeout'; |
|
| 1403 | + if (checkSession('post', '', false) != '') { |
|
| 1404 | + $post_errors[] = 'session_timeout'; |
|
| 1405 | + } |
|
| 1346 | 1406 | |
| 1347 | 1407 | // Wrong verification code? |
| 1348 | 1408 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1352,33 +1412,38 @@ discard block |
||
| 1352 | 1412 | 'id' => 'post', |
| 1353 | 1413 | ); |
| 1354 | 1414 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
| 1355 | - if (is_array($context['require_verification'])) |
|
| 1356 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1415 | + if (is_array($context['require_verification'])) { |
|
| 1416 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
| 1417 | + } |
|
| 1357 | 1418 | } |
| 1358 | 1419 | |
| 1359 | 1420 | require_once($sourcedir . '/Subs-Post.php'); |
| 1360 | 1421 | loadLanguage('Post'); |
| 1361 | 1422 | |
| 1362 | 1423 | // Drafts enabled and needed? |
| 1363 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
| 1364 | - require_once($sourcedir . '/Drafts.php'); |
|
| 1424 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
| 1425 | + require_once($sourcedir . '/Drafts.php'); |
|
| 1426 | + } |
|
| 1365 | 1427 | |
| 1366 | 1428 | // First check to see if they are trying to delete any current attachments. |
| 1367 | 1429 | if (isset($_POST['attach_del'])) |
| 1368 | 1430 | { |
| 1369 | 1431 | $keep_temp = array(); |
| 1370 | 1432 | $keep_ids = array(); |
| 1371 | - foreach ($_POST['attach_del'] as $dummy) |
|
| 1372 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1433 | + foreach ($_POST['attach_del'] as $dummy) { |
|
| 1434 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
| 1373 | 1435 | $keep_temp[] = $dummy; |
| 1374 | - else |
|
| 1375 | - $keep_ids[] = (int) $dummy; |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | + $keep_ids[] = (int) $dummy; |
|
| 1439 | + } |
|
| 1376 | 1440 | |
| 1377 | - if (isset($_SESSION['temp_attachments'])) |
|
| 1378 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1441 | + if (isset($_SESSION['temp_attachments'])) { |
|
| 1442 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
| 1379 | 1443 | { |
| 1380 | 1444 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
| 1381 | 1445 | continue; |
| 1446 | + } |
|
| 1382 | 1447 | |
| 1383 | 1448 | unset($_SESSION['temp_attachments'][$attachID]); |
| 1384 | 1449 | unlink($attachment['tmp_name']); |
@@ -1420,24 +1485,28 @@ discard block |
||
| 1420 | 1485 | $smcFunc['db_free_result']($request); |
| 1421 | 1486 | |
| 1422 | 1487 | // Though the topic should be there, it might have vanished. |
| 1423 | - if (!is_array($topic_info)) |
|
| 1424 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1488 | + if (!is_array($topic_info)) { |
|
| 1489 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
| 1490 | + } |
|
| 1425 | 1491 | |
| 1426 | 1492 | // Did this topic suddenly move? Just checking... |
| 1427 | - if ($topic_info['id_board'] != $board) |
|
| 1428 | - fatal_lang_error('not_a_topic'); |
|
| 1493 | + if ($topic_info['id_board'] != $board) { |
|
| 1494 | + fatal_lang_error('not_a_topic'); |
|
| 1495 | + } |
|
| 1429 | 1496 | } |
| 1430 | 1497 | |
| 1431 | 1498 | // Replying to a topic? |
| 1432 | 1499 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
| 1433 | 1500 | { |
| 1434 | 1501 | // Don't allow a post if it's locked. |
| 1435 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
| 1436 | - fatal_lang_error('topic_locked', false); |
|
| 1502 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
| 1503 | + fatal_lang_error('topic_locked', false); |
|
| 1504 | + } |
|
| 1437 | 1505 | |
| 1438 | 1506 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
| 1439 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
| 1440 | - unset($_REQUEST['poll']); |
|
| 1507 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
| 1508 | + unset($_REQUEST['poll']); |
|
| 1509 | + } |
|
| 1441 | 1510 | |
| 1442 | 1511 | // Do the permissions and approval stuff... |
| 1443 | 1512 | $becomesApproved = true; |
@@ -1453,44 +1522,43 @@ discard block |
||
| 1453 | 1522 | |
| 1454 | 1523 | // Set a nice session var... |
| 1455 | 1524 | $_SESSION['becomesUnapproved'] = true; |
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1525 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
| 1459 | 1526 | { |
| 1460 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
| 1461 | - $becomesApproved = false; |
|
| 1462 | - |
|
| 1463 | - else |
|
| 1464 | - isAllowedTo('post_reply_any'); |
|
| 1465 | - } |
|
| 1466 | - elseif (!allowedTo('post_reply_any')) |
|
| 1527 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
| 1528 | + $becomesApproved = false; |
|
| 1529 | + } else { |
|
| 1530 | + isAllowedTo('post_reply_any'); |
|
| 1531 | + } |
|
| 1532 | + } elseif (!allowedTo('post_reply_any')) |
|
| 1467 | 1533 | { |
| 1468 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
| 1469 | - $becomesApproved = false; |
|
| 1470 | - |
|
| 1471 | - else |
|
| 1472 | - isAllowedTo('post_reply_own'); |
|
| 1534 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
| 1535 | + $becomesApproved = false; |
|
| 1536 | + } else { |
|
| 1537 | + isAllowedTo('post_reply_own'); |
|
| 1538 | + } |
|
| 1473 | 1539 | } |
| 1474 | 1540 | |
| 1475 | 1541 | if (isset($_POST['lock'])) |
| 1476 | 1542 | { |
| 1477 | 1543 | // Nothing is changed to the lock. |
| 1478 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1479 | - unset($_POST['lock']); |
|
| 1544 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1545 | + unset($_POST['lock']); |
|
| 1546 | + } |
|
| 1480 | 1547 | |
| 1481 | 1548 | // You're have no permission to lock this topic. |
| 1482 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1483 | - unset($_POST['lock']); |
|
| 1549 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1550 | + unset($_POST['lock']); |
|
| 1551 | + } |
|
| 1484 | 1552 | |
| 1485 | 1553 | // You are allowed to (un)lock your own topic only. |
| 1486 | 1554 | elseif (!allowedTo('lock_any')) |
| 1487 | 1555 | { |
| 1488 | 1556 | // You cannot override a moderator lock. |
| 1489 | - if ($topic_info['locked'] == 1) |
|
| 1490 | - unset($_POST['lock']); |
|
| 1491 | - |
|
| 1492 | - else |
|
| 1493 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1557 | + if ($topic_info['locked'] == 1) { |
|
| 1558 | + unset($_POST['lock']); |
|
| 1559 | + } else { |
|
| 1560 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1561 | + } |
|
| 1494 | 1562 | } |
| 1495 | 1563 | // Hail mighty moderator, (un)lock this topic immediately. |
| 1496 | 1564 | else |
@@ -1498,19 +1566,21 @@ discard block |
||
| 1498 | 1566 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1499 | 1567 | |
| 1500 | 1568 | // Did someone (un)lock this while you were posting? |
| 1501 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1502 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1569 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1570 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1571 | + } |
|
| 1503 | 1572 | } |
| 1504 | 1573 | } |
| 1505 | 1574 | |
| 1506 | 1575 | // So you wanna (un)sticky this...let's see. |
| 1507 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
| 1508 | - unset($_POST['sticky']); |
|
| 1509 | - elseif (isset($_POST['sticky'])) |
|
| 1576 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
| 1577 | + unset($_POST['sticky']); |
|
| 1578 | + } elseif (isset($_POST['sticky'])) |
|
| 1510 | 1579 | { |
| 1511 | 1580 | // Did someone (un)sticky this while you were posting? |
| 1512 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1513 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1581 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1582 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
| 1583 | + } |
|
| 1514 | 1584 | } |
| 1515 | 1585 | |
| 1516 | 1586 | // If drafts are enabled, then pass this off |
@@ -1537,26 +1607,31 @@ discard block |
||
| 1537 | 1607 | |
| 1538 | 1608 | // Do like, the permissions, for safety and stuff... |
| 1539 | 1609 | $becomesApproved = true; |
| 1540 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
| 1541 | - $becomesApproved = false; |
|
| 1542 | - else |
|
| 1543 | - isAllowedTo('post_new'); |
|
| 1610 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
| 1611 | + $becomesApproved = false; |
|
| 1612 | + } else { |
|
| 1613 | + isAllowedTo('post_new'); |
|
| 1614 | + } |
|
| 1544 | 1615 | |
| 1545 | 1616 | if (isset($_POST['lock'])) |
| 1546 | 1617 | { |
| 1547 | 1618 | // New topics are by default not locked. |
| 1548 | - if (empty($_POST['lock'])) |
|
| 1549 | - unset($_POST['lock']); |
|
| 1619 | + if (empty($_POST['lock'])) { |
|
| 1620 | + unset($_POST['lock']); |
|
| 1621 | + } |
|
| 1550 | 1622 | // Besides, you need permission. |
| 1551 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
| 1552 | - unset($_POST['lock']); |
|
| 1623 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
| 1624 | + unset($_POST['lock']); |
|
| 1625 | + } |
|
| 1553 | 1626 | // A moderator-lock (1) can override a user-lock (2). |
| 1554 | - else |
|
| 1555 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1627 | + else { |
|
| 1628 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
| 1629 | + } |
|
| 1556 | 1630 | } |
| 1557 | 1631 | |
| 1558 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
| 1559 | - unset($_POST['sticky']); |
|
| 1632 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
| 1633 | + unset($_POST['sticky']); |
|
| 1634 | + } |
|
| 1560 | 1635 | |
| 1561 | 1636 | // Saving your new topic as a draft first? |
| 1562 | 1637 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1581,31 +1656,37 @@ discard block |
||
| 1581 | 1656 | 'id_msg' => $_REQUEST['msg'], |
| 1582 | 1657 | ) |
| 1583 | 1658 | ); |
| 1584 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 1585 | - fatal_lang_error('cant_find_messages', false); |
|
| 1659 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 1660 | + fatal_lang_error('cant_find_messages', false); |
|
| 1661 | + } |
|
| 1586 | 1662 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1587 | 1663 | $smcFunc['db_free_result']($request); |
| 1588 | 1664 | |
| 1589 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
| 1590 | - fatal_lang_error('topic_locked', false); |
|
| 1665 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
| 1666 | + fatal_lang_error('topic_locked', false); |
|
| 1667 | + } |
|
| 1591 | 1668 | |
| 1592 | 1669 | if (isset($_POST['lock'])) |
| 1593 | 1670 | { |
| 1594 | 1671 | // Nothing changes to the lock status. |
| 1595 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
| 1596 | - unset($_POST['lock']); |
|
| 1672 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
| 1673 | + unset($_POST['lock']); |
|
| 1674 | + } |
|
| 1597 | 1675 | // You're simply not allowed to (un)lock this. |
| 1598 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
| 1599 | - unset($_POST['lock']); |
|
| 1676 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
| 1677 | + unset($_POST['lock']); |
|
| 1678 | + } |
|
| 1600 | 1679 | // You're only allowed to lock your own topics. |
| 1601 | 1680 | elseif (!allowedTo('lock_any')) |
| 1602 | 1681 | { |
| 1603 | 1682 | // You're not allowed to break a moderator's lock. |
| 1604 | - if ($topic_info['locked'] == 1) |
|
| 1605 | - unset($_POST['lock']); |
|
| 1683 | + if ($topic_info['locked'] == 1) { |
|
| 1684 | + unset($_POST['lock']); |
|
| 1685 | + } |
|
| 1606 | 1686 | // Lock it with a soft lock or unlock it. |
| 1607 | - else |
|
| 1608 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1687 | + else { |
|
| 1688 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 1689 | + } |
|
| 1609 | 1690 | } |
| 1610 | 1691 | // You must be the moderator. |
| 1611 | 1692 | else |
@@ -1613,44 +1694,46 @@ discard block |
||
| 1613 | 1694 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
| 1614 | 1695 | |
| 1615 | 1696 | // Did someone (un)lock this while you were posting? |
| 1616 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
| 1617 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1697 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
| 1698 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
| 1699 | + } |
|
| 1618 | 1700 | } |
| 1619 | 1701 | } |
| 1620 | 1702 | |
| 1621 | 1703 | // Change the sticky status of this topic? |
| 1622 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
| 1623 | - unset($_POST['sticky']); |
|
| 1624 | - elseif (isset($_POST['sticky'])) |
|
| 1704 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
| 1705 | + unset($_POST['sticky']); |
|
| 1706 | + } elseif (isset($_POST['sticky'])) |
|
| 1625 | 1707 | { |
| 1626 | 1708 | // Did someone (un)sticky this while you were posting? |
| 1627 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
| 1628 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1709 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
| 1710 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
| 1711 | + } |
|
| 1629 | 1712 | } |
| 1630 | 1713 | |
| 1631 | 1714 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 1632 | 1715 | { |
| 1633 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 1634 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 1635 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 1636 | - isAllowedTo('modify_replies'); |
|
| 1637 | - else |
|
| 1638 | - isAllowedTo('modify_own'); |
|
| 1639 | - } |
|
| 1640 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1716 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 1717 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 1718 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 1719 | + isAllowedTo('modify_replies'); |
|
| 1720 | + } else { |
|
| 1721 | + isAllowedTo('modify_own'); |
|
| 1722 | + } |
|
| 1723 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 1641 | 1724 | { |
| 1642 | 1725 | isAllowedTo('modify_replies'); |
| 1643 | 1726 | |
| 1644 | 1727 | // If you're modifying a reply, I say it better be logged... |
| 1645 | 1728 | $moderationAction = true; |
| 1646 | - } |
|
| 1647 | - else |
|
| 1729 | + } else |
|
| 1648 | 1730 | { |
| 1649 | 1731 | isAllowedTo('modify_any'); |
| 1650 | 1732 | |
| 1651 | 1733 | // Log it, assuming you're not modifying your own post. |
| 1652 | - if ($row['id_member'] != $user_info['id']) |
|
| 1653 | - $moderationAction = true; |
|
| 1734 | + if ($row['id_member'] != $user_info['id']) { |
|
| 1735 | + $moderationAction = true; |
|
| 1736 | + } |
|
| 1654 | 1737 | } |
| 1655 | 1738 | |
| 1656 | 1739 | // If drafts are enabled, then lets send this off to save |
@@ -1687,20 +1770,24 @@ discard block |
||
| 1687 | 1770 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
| 1688 | 1771 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
| 1689 | 1772 | |
| 1690 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
| 1691 | - $post_errors[] = 'no_name'; |
|
| 1692 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
| 1693 | - $post_errors[] = 'long_name'; |
|
| 1773 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
| 1774 | + $post_errors[] = 'no_name'; |
|
| 1775 | + } |
|
| 1776 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
| 1777 | + $post_errors[] = 'long_name'; |
|
| 1778 | + } |
|
| 1694 | 1779 | |
| 1695 | 1780 | if (empty($modSettings['guest_post_no_email'])) |
| 1696 | 1781 | { |
| 1697 | 1782 | // Only check if they changed it! |
| 1698 | 1783 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
| 1699 | 1784 | { |
| 1700 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
| 1701 | - $post_errors[] = 'no_email'; |
|
| 1702 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
| 1703 | - $post_errors[] = 'bad_email'; |
|
| 1785 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
| 1786 | + $post_errors[] = 'no_email'; |
|
| 1787 | + } |
|
| 1788 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 1789 | + $post_errors[] = 'bad_email'; |
|
| 1790 | + } |
|
| 1704 | 1791 | } |
| 1705 | 1792 | |
| 1706 | 1793 | // Now make sure this email address is not banned from posting. |
@@ -1716,75 +1803,89 @@ discard block |
||
| 1716 | 1803 | } |
| 1717 | 1804 | |
| 1718 | 1805 | // Coming from the quickReply? |
| 1719 | - if (isset($_POST['quickReply'])) |
|
| 1720 | - $_POST['message'] = $_POST['quickReply']; |
|
| 1806 | + if (isset($_POST['quickReply'])) { |
|
| 1807 | + $_POST['message'] = $_POST['quickReply']; |
|
| 1808 | + } |
|
| 1721 | 1809 | |
| 1722 | 1810 | // Check the subject and message. |
| 1723 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
| 1724 | - $post_errors[] = 'no_subject'; |
|
| 1725 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
| 1726 | - $post_errors[] = 'no_message'; |
|
| 1727 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 1728 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1729 | - else |
|
| 1811 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
| 1812 | + $post_errors[] = 'no_subject'; |
|
| 1813 | + } |
|
| 1814 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
| 1815 | + $post_errors[] = 'no_message'; |
|
| 1816 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
| 1817 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
| 1818 | + } else |
|
| 1730 | 1819 | { |
| 1731 | 1820 | // Prepare the message a bit for some additional testing. |
| 1732 | 1821 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 1733 | 1822 | |
| 1734 | 1823 | // Preparse code. (Zef) |
| 1735 | - if ($user_info['is_guest']) |
|
| 1736 | - $user_info['name'] = $_POST['guestname']; |
|
| 1824 | + if ($user_info['is_guest']) { |
|
| 1825 | + $user_info['name'] = $_POST['guestname']; |
|
| 1826 | + } |
|
| 1737 | 1827 | preparsecode($_POST['message']); |
| 1738 | 1828 | |
| 1739 | 1829 | // Let's see if there's still some content left without the tags. |
| 1740 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
| 1741 | - $post_errors[] = 'no_message'; |
|
| 1830 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
| 1831 | + $post_errors[] = 'no_message'; |
|
| 1832 | + } |
|
| 1833 | + } |
|
| 1834 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1835 | + $post_errors[] = 'no_event'; |
|
| 1742 | 1836 | } |
| 1743 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 1744 | - $post_errors[] = 'no_event'; |
|
| 1745 | 1837 | // You are not! |
| 1746 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
| 1747 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1838 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
| 1839 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
| 1840 | + } |
|
| 1748 | 1841 | |
| 1749 | 1842 | // Validate the poll... |
| 1750 | 1843 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
| 1751 | 1844 | { |
| 1752 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
| 1753 | - fatal_lang_error('no_access', false); |
|
| 1845 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
| 1846 | + fatal_lang_error('no_access', false); |
|
| 1847 | + } |
|
| 1754 | 1848 | |
| 1755 | 1849 | // This is a new topic... so it's a new poll. |
| 1756 | - if (empty($topic)) |
|
| 1757 | - isAllowedTo('poll_post'); |
|
| 1850 | + if (empty($topic)) { |
|
| 1851 | + isAllowedTo('poll_post'); |
|
| 1852 | + } |
|
| 1758 | 1853 | // Can you add to your own topics? |
| 1759 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
| 1760 | - isAllowedTo('poll_add_own'); |
|
| 1854 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
| 1855 | + isAllowedTo('poll_add_own'); |
|
| 1856 | + } |
|
| 1761 | 1857 | // Can you add polls to any topic, then? |
| 1762 | - else |
|
| 1763 | - isAllowedTo('poll_add_any'); |
|
| 1858 | + else { |
|
| 1859 | + isAllowedTo('poll_add_any'); |
|
| 1860 | + } |
|
| 1764 | 1861 | |
| 1765 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
| 1766 | - $post_errors[] = 'no_question'; |
|
| 1862 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
| 1863 | + $post_errors[] = 'no_question'; |
|
| 1864 | + } |
|
| 1767 | 1865 | |
| 1768 | 1866 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
| 1769 | 1867 | |
| 1770 | 1868 | // Get rid of empty ones. |
| 1771 | - foreach ($_POST['options'] as $k => $option) |
|
| 1772 | - if ($option == '') |
|
| 1869 | + foreach ($_POST['options'] as $k => $option) { |
|
| 1870 | + if ($option == '') |
|
| 1773 | 1871 | unset($_POST['options'][$k], $_POST['options'][$k]); |
| 1872 | + } |
|
| 1774 | 1873 | |
| 1775 | 1874 | // What are you going to vote between with one choice?!? |
| 1776 | - if (count($_POST['options']) < 2) |
|
| 1777 | - $post_errors[] = 'poll_few'; |
|
| 1778 | - elseif (count($_POST['options']) > 256) |
|
| 1779 | - $post_errors[] = 'poll_many'; |
|
| 1875 | + if (count($_POST['options']) < 2) { |
|
| 1876 | + $post_errors[] = 'poll_few'; |
|
| 1877 | + } elseif (count($_POST['options']) > 256) { |
|
| 1878 | + $post_errors[] = 'poll_many'; |
|
| 1879 | + } |
|
| 1780 | 1880 | } |
| 1781 | 1881 | |
| 1782 | 1882 | if ($posterIsGuest) |
| 1783 | 1883 | { |
| 1784 | 1884 | // If user is a guest, make sure the chosen name isn't taken. |
| 1785 | 1885 | require_once($sourcedir . '/Subs-Members.php'); |
| 1786 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
| 1787 | - $post_errors[] = 'bad_name'; |
|
| 1886 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
| 1887 | + $post_errors[] = 'bad_name'; |
|
| 1888 | + } |
|
| 1788 | 1889 | } |
| 1789 | 1890 | // If the user isn't a guest, get his or her name and email. |
| 1790 | 1891 | elseif (!isset($_REQUEST['msg'])) |
@@ -1815,8 +1916,9 @@ discard block |
||
| 1815 | 1916 | } |
| 1816 | 1917 | |
| 1817 | 1918 | // Make sure the user isn't spamming the board. |
| 1818 | - if (!isset($_REQUEST['msg'])) |
|
| 1819 | - spamProtection('post'); |
|
| 1919 | + if (!isset($_REQUEST['msg'])) { |
|
| 1920 | + spamProtection('post'); |
|
| 1921 | + } |
|
| 1820 | 1922 | |
| 1821 | 1923 | // At about this point, we're posting and that's that. |
| 1822 | 1924 | ignore_user_abort(true); |
@@ -1829,32 +1931,36 @@ discard block |
||
| 1829 | 1931 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 1830 | 1932 | |
| 1831 | 1933 | // At this point, we want to make sure the subject isn't too long. |
| 1832 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 1833 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1934 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 1935 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 1936 | + } |
|
| 1834 | 1937 | |
| 1835 | 1938 | // Same with the "why did you edit this" text. |
| 1836 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 1837 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1939 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 1940 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 1941 | + } |
|
| 1838 | 1942 | |
| 1839 | 1943 | // Make the poll... |
| 1840 | 1944 | if (isset($_REQUEST['poll'])) |
| 1841 | 1945 | { |
| 1842 | 1946 | // Make sure that the user has not entered a ridiculous number of options.. |
| 1843 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
| 1844 | - $_POST['poll_max_votes'] = 1; |
|
| 1845 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
| 1846 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1847 | - else |
|
| 1848 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1947 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
| 1948 | + $_POST['poll_max_votes'] = 1; |
|
| 1949 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
| 1950 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
| 1951 | + } else { |
|
| 1952 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
| 1953 | + } |
|
| 1849 | 1954 | |
| 1850 | 1955 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
| 1851 | 1956 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
| 1852 | 1957 | |
| 1853 | 1958 | // Just set it to zero if it's not there.. |
| 1854 | - if (!isset($_POST['poll_hide'])) |
|
| 1855 | - $_POST['poll_hide'] = 0; |
|
| 1856 | - else |
|
| 1857 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1959 | + if (!isset($_POST['poll_hide'])) { |
|
| 1960 | + $_POST['poll_hide'] = 0; |
|
| 1961 | + } else { |
|
| 1962 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
| 1963 | + } |
|
| 1858 | 1964 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
| 1859 | 1965 | |
| 1860 | 1966 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1863,16 +1969,19 @@ discard block |
||
| 1863 | 1969 | { |
| 1864 | 1970 | require_once($sourcedir . '/Subs-Members.php'); |
| 1865 | 1971 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
| 1866 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
| 1867 | - $_POST['poll_guest_vote'] = 0; |
|
| 1972 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
| 1973 | + $_POST['poll_guest_vote'] = 0; |
|
| 1974 | + } |
|
| 1868 | 1975 | } |
| 1869 | 1976 | |
| 1870 | 1977 | // If the user tries to set the poll too far in advance, don't let them. |
| 1871 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
| 1872 | - fatal_lang_error('poll_range_error', false); |
|
| 1978 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
| 1979 | + fatal_lang_error('poll_range_error', false); |
|
| 1980 | + } |
|
| 1873 | 1981 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
| 1874 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
| 1875 | - $_POST['poll_hide'] = 1; |
|
| 1982 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
| 1983 | + $_POST['poll_hide'] = 1; |
|
| 1984 | + } |
|
| 1876 | 1985 | |
| 1877 | 1986 | // Clean up the question and answers. |
| 1878 | 1987 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1886,13 +1995,15 @@ discard block |
||
| 1886 | 1995 | { |
| 1887 | 1996 | $attachIDs = array(); |
| 1888 | 1997 | $attach_errors = array(); |
| 1889 | - if (!empty($context['we_are_history'])) |
|
| 1890 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 1998 | + if (!empty($context['we_are_history'])) { |
|
| 1999 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
| 2000 | + } |
|
| 1891 | 2001 | |
| 1892 | 2002 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
| 1893 | 2003 | { |
| 1894 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
| 1895 | - continue; |
|
| 2004 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
| 2005 | + continue; |
|
| 2006 | + } |
|
| 1896 | 2007 | |
| 1897 | 2008 | // If there was an initial error just show that message. |
| 1898 | 2009 | if ($attachID == 'initial_error') |
@@ -1921,12 +2032,13 @@ discard block |
||
| 1921 | 2032 | if (createAttachment($attachmentOptions)) |
| 1922 | 2033 | { |
| 1923 | 2034 | $attachIDs[] = $attachmentOptions['id']; |
| 1924 | - if (!empty($attachmentOptions['thumb'])) |
|
| 1925 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2035 | + if (!empty($attachmentOptions['thumb'])) { |
|
| 2036 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
| 2037 | + } |
|
| 1926 | 2038 | } |
| 2039 | + } else { |
|
| 2040 | + $attach_errors[] = '<dt> </dt>'; |
|
| 1927 | 2041 | } |
| 1928 | - else |
|
| 1929 | - $attach_errors[] = '<dt> </dt>'; |
|
| 1930 | 2042 | |
| 1931 | 2043 | if (!empty($attachmentOptions['errors'])) |
| 1932 | 2044 | { |
@@ -1938,14 +2050,16 @@ discard block |
||
| 1938 | 2050 | if (!is_array($error)) |
| 1939 | 2051 | { |
| 1940 | 2052 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
| 1941 | - if (in_array($error, $log_these)) |
|
| 1942 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2053 | + if (in_array($error, $log_these)) { |
|
| 2054 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
| 2055 | + } |
|
| 2056 | + } else { |
|
| 2057 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1943 | 2058 | } |
| 1944 | - else |
|
| 1945 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
| 1946 | 2059 | } |
| 1947 | - if (file_exists($attachment['tmp_name'])) |
|
| 1948 | - unlink($attachment['tmp_name']); |
|
| 2060 | + if (file_exists($attachment['tmp_name'])) { |
|
| 2061 | + unlink($attachment['tmp_name']); |
|
| 2062 | + } |
|
| 1949 | 2063 | } |
| 1950 | 2064 | } |
| 1951 | 2065 | unset($_SESSION['temp_attachments']); |
@@ -1986,24 +2100,24 @@ discard block |
||
| 1986 | 2100 | ); |
| 1987 | 2101 | |
| 1988 | 2102 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
| 2103 | + } else { |
|
| 2104 | + $id_poll = 0; |
|
| 1989 | 2105 | } |
| 1990 | - else |
|
| 1991 | - $id_poll = 0; |
|
| 1992 | 2106 | |
| 1993 | 2107 | // Creating a new topic? |
| 1994 | 2108 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
| 1995 | 2109 | |
| 1996 | 2110 | // Check the icon. |
| 1997 | - if (!isset($_POST['icon'])) |
|
| 1998 | - $_POST['icon'] = 'xx'; |
|
| 1999 | - |
|
| 2000 | - else |
|
| 2111 | + if (!isset($_POST['icon'])) { |
|
| 2112 | + $_POST['icon'] = 'xx'; |
|
| 2113 | + } else |
|
| 2001 | 2114 | { |
| 2002 | 2115 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
| 2003 | 2116 | |
| 2004 | 2117 | // Need to figure it out if this is a valid icon name. |
| 2005 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
| 2006 | - $_POST['icon'] = 'xx'; |
|
| 2118 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
| 2119 | + $_POST['icon'] = 'xx'; |
|
| 2120 | + } |
|
| 2007 | 2121 | } |
| 2008 | 2122 | |
| 2009 | 2123 | // Collect all parameters for the creation or modification of a post. |
@@ -2044,8 +2158,9 @@ discard block |
||
| 2044 | 2158 | } |
| 2045 | 2159 | |
| 2046 | 2160 | // This will save some time... |
| 2047 | - if (empty($approve_has_changed)) |
|
| 2048 | - unset($msgOptions['approved']); |
|
| 2161 | + if (empty($approve_has_changed)) { |
|
| 2162 | + unset($msgOptions['approved']); |
|
| 2163 | + } |
|
| 2049 | 2164 | |
| 2050 | 2165 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2051 | 2166 | } |
@@ -2054,8 +2169,9 @@ discard block |
||
| 2054 | 2169 | { |
| 2055 | 2170 | createPost($msgOptions, $topicOptions, $posterOptions); |
| 2056 | 2171 | |
| 2057 | - if (isset($topicOptions['id'])) |
|
| 2058 | - $topic = $topicOptions['id']; |
|
| 2172 | + if (isset($topicOptions['id'])) { |
|
| 2173 | + $topic = $topicOptions['id']; |
|
| 2174 | + } |
|
| 2059 | 2175 | } |
| 2060 | 2176 | |
| 2061 | 2177 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2067,8 +2183,9 @@ discard block |
||
| 2067 | 2183 | } |
| 2068 | 2184 | |
| 2069 | 2185 | // If we had a draft for this, its time to remove it since it was just posted |
| 2070 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
| 2071 | - DeleteDraft($_POST['id_draft']); |
|
| 2186 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
| 2187 | + DeleteDraft($_POST['id_draft']); |
|
| 2188 | + } |
|
| 2072 | 2189 | |
| 2073 | 2190 | // Editing or posting an event? |
| 2074 | 2191 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2087,8 +2204,7 @@ discard block |
||
| 2087 | 2204 | 'member' => $user_info['id'], |
| 2088 | 2205 | ); |
| 2089 | 2206 | insertEvent($eventOptions); |
| 2090 | - } |
|
| 2091 | - elseif (isset($_POST['calendar'])) |
|
| 2207 | + } elseif (isset($_POST['calendar'])) |
|
| 2092 | 2208 | { |
| 2093 | 2209 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
| 2094 | 2210 | |
@@ -2116,14 +2232,15 @@ discard block |
||
| 2116 | 2232 | } |
| 2117 | 2233 | |
| 2118 | 2234 | // Delete it? |
| 2119 | - if (isset($_REQUEST['deleteevent'])) |
|
| 2120 | - $smcFunc['db_query']('', ' |
|
| 2235 | + if (isset($_REQUEST['deleteevent'])) { |
|
| 2236 | + $smcFunc['db_query']('', ' |
|
| 2121 | 2237 | DELETE FROM {db_prefix}calendar |
| 2122 | 2238 | WHERE id_event = {int:id_event}', |
| 2123 | 2239 | array( |
| 2124 | 2240 | 'id_event' => $_REQUEST['eventid'], |
| 2125 | 2241 | ) |
| 2126 | 2242 | ); |
| 2243 | + } |
|
| 2127 | 2244 | // ... or just update it? |
| 2128 | 2245 | else |
| 2129 | 2246 | { |
@@ -2165,9 +2282,8 @@ discard block |
||
| 2165 | 2282 | array($user_info['id'], $topic, 0), |
| 2166 | 2283 | array('id_member', 'id_topic', 'id_board') |
| 2167 | 2284 | ); |
| 2168 | - } |
|
| 2169 | - elseif (!$newTopic) |
|
| 2170 | - $smcFunc['db_query']('', ' |
|
| 2285 | + } elseif (!$newTopic) { |
|
| 2286 | + $smcFunc['db_query']('', ' |
|
| 2171 | 2287 | DELETE FROM {db_prefix}log_notify |
| 2172 | 2288 | WHERE id_member = {int:current_member} |
| 2173 | 2289 | AND id_topic = {int:current_topic}', |
@@ -2176,16 +2292,20 @@ discard block |
||
| 2176 | 2292 | 'current_topic' => $topic, |
| 2177 | 2293 | ) |
| 2178 | 2294 | ); |
| 2295 | + } |
|
| 2179 | 2296 | |
| 2180 | 2297 | // Log an act of moderation - modifying. |
| 2181 | - if (!empty($moderationAction)) |
|
| 2182 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2298 | + if (!empty($moderationAction)) { |
|
| 2299 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 2300 | + } |
|
| 2183 | 2301 | |
| 2184 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
| 2185 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2302 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
| 2303 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2304 | + } |
|
| 2186 | 2305 | |
| 2187 | - if (isset($_POST['sticky'])) |
|
| 2188 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2306 | + if (isset($_POST['sticky'])) { |
|
| 2307 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
| 2308 | + } |
|
| 2189 | 2309 | |
| 2190 | 2310 | // Returning to the topic? |
| 2191 | 2311 | if (!empty($_REQUEST['goback'])) |
@@ -2204,26 +2324,31 @@ discard block |
||
| 2204 | 2324 | ); |
| 2205 | 2325 | } |
| 2206 | 2326 | |
| 2207 | - if ($board_info['num_topics'] == 0) |
|
| 2208 | - cache_put_data('board-' . $board, null, 120); |
|
| 2327 | + if ($board_info['num_topics'] == 0) { |
|
| 2328 | + cache_put_data('board-' . $board, null, 120); |
|
| 2329 | + } |
|
| 2209 | 2330 | |
| 2210 | 2331 | call_integration_hook('integrate_post2_end'); |
| 2211 | 2332 | |
| 2212 | - if (!empty($_POST['announce_topic'])) |
|
| 2213 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2333 | + if (!empty($_POST['announce_topic'])) { |
|
| 2334 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2335 | + } |
|
| 2214 | 2336 | |
| 2215 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
| 2216 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2337 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
| 2338 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2339 | + } |
|
| 2217 | 2340 | |
| 2218 | 2341 | // Return to post if the mod is on. |
| 2219 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
| 2220 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2221 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2222 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2342 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
| 2343 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
| 2344 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2345 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
| 2346 | + } |
|
| 2223 | 2347 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
| 2224 | - else |
|
| 2225 | - redirectexit('board=' . $board . '.0'); |
|
| 2226 | -} |
|
| 2348 | + else { |
|
| 2349 | + redirectexit('board=' . $board . '.0'); |
|
| 2350 | + } |
|
| 2351 | + } |
|
| 2227 | 2352 | |
| 2228 | 2353 | /** |
| 2229 | 2354 | * Handle the announce topic function (action=announce). |
@@ -2241,8 +2366,9 @@ discard block |
||
| 2241 | 2366 | |
| 2242 | 2367 | validateSession(); |
| 2243 | 2368 | |
| 2244 | - if (empty($topic)) |
|
| 2245 | - fatal_lang_error('topic_gone', false); |
|
| 2369 | + if (empty($topic)) { |
|
| 2370 | + fatal_lang_error('topic_gone', false); |
|
| 2371 | + } |
|
| 2246 | 2372 | |
| 2247 | 2373 | loadLanguage('Post'); |
| 2248 | 2374 | loadTemplate('Post'); |
@@ -2269,8 +2395,9 @@ discard block |
||
| 2269 | 2395 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
| 2270 | 2396 | |
| 2271 | 2397 | $groups = array_merge($board_info['groups'], array(1)); |
| 2272 | - foreach ($groups as $id => $group) |
|
| 2273 | - $groups[$id] = (int) $group; |
|
| 2398 | + foreach ($groups as $id => $group) { |
|
| 2399 | + $groups[$id] = (int) $group; |
|
| 2400 | + } |
|
| 2274 | 2401 | |
| 2275 | 2402 | $context['groups'] = array(); |
| 2276 | 2403 | if (in_array(0, $groups)) |
@@ -2313,8 +2440,9 @@ discard block |
||
| 2313 | 2440 | 'group_list' => $groups, |
| 2314 | 2441 | ) |
| 2315 | 2442 | ); |
| 2316 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2317 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2443 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2444 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
| 2445 | + } |
|
| 2318 | 2446 | $smcFunc['db_free_result']($request); |
| 2319 | 2447 | |
| 2320 | 2448 | // Get the subject of the topic we're about to announce. |
@@ -2356,16 +2484,19 @@ discard block |
||
| 2356 | 2484 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
| 2357 | 2485 | $groups = array_merge($board_info['groups'], array(1)); |
| 2358 | 2486 | |
| 2359 | - if (isset($_POST['membergroups'])) |
|
| 2360 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2487 | + if (isset($_POST['membergroups'])) { |
|
| 2488 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
| 2489 | + } |
|
| 2361 | 2490 | |
| 2362 | 2491 | // Check whether at least one membergroup was selected. |
| 2363 | - if (empty($_POST['who'])) |
|
| 2364 | - fatal_lang_error('no_membergroup_selected'); |
|
| 2492 | + if (empty($_POST['who'])) { |
|
| 2493 | + fatal_lang_error('no_membergroup_selected'); |
|
| 2494 | + } |
|
| 2365 | 2495 | |
| 2366 | 2496 | // Make sure all membergroups are integers and can access the board of the announcement. |
| 2367 | - foreach ($_POST['who'] as $id => $mg) |
|
| 2368 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2497 | + foreach ($_POST['who'] as $id => $mg) { |
|
| 2498 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
| 2499 | + } |
|
| 2369 | 2500 | |
| 2370 | 2501 | // Get the topic subject and censor it. |
| 2371 | 2502 | $request = $smcFunc['db_query']('', ' |
@@ -2411,12 +2542,13 @@ discard block |
||
| 2411 | 2542 | if ($smcFunc['db_num_rows']($request) == 0) |
| 2412 | 2543 | { |
| 2413 | 2544 | logAction('announce_topic', array('topic' => $topic), 'user'); |
| 2414 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
| 2415 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2416 | - elseif (!empty($_REQUEST['goback'])) |
|
| 2417 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2418 | - else |
|
| 2419 | - redirectexit('board=' . $board . '.0'); |
|
| 2545 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
| 2546 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
| 2547 | + } elseif (!empty($_REQUEST['goback'])) { |
|
| 2548 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
| 2549 | + } else { |
|
| 2550 | + redirectexit('board=' . $board . '.0'); |
|
| 2551 | + } |
|
| 2420 | 2552 | } |
| 2421 | 2553 | |
| 2422 | 2554 | $announcements = array(); |
@@ -2435,8 +2567,9 @@ discard block |
||
| 2435 | 2567 | foreach ($rows as $row) |
| 2436 | 2568 | { |
| 2437 | 2569 | // Force them to have it? |
| 2438 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
| 2439 | - continue; |
|
| 2570 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
| 2571 | + continue; |
|
| 2572 | + } |
|
| 2440 | 2573 | |
| 2441 | 2574 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
| 2442 | 2575 | |
@@ -2464,8 +2597,9 @@ discard block |
||
| 2464 | 2597 | } |
| 2465 | 2598 | |
| 2466 | 2599 | // For each language send a different mail - low priority... |
| 2467 | - foreach ($announcements as $lang => $mail) |
|
| 2468 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2600 | + foreach ($announcements as $lang => $mail) { |
|
| 2601 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
| 2602 | + } |
|
| 2469 | 2603 | |
| 2470 | 2604 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
| 2471 | 2605 | |
@@ -2475,9 +2609,10 @@ discard block |
||
| 2475 | 2609 | $context['sub_template'] = 'announcement_send'; |
| 2476 | 2610 | |
| 2477 | 2611 | // Go back to the correct language for the user ;). |
| 2478 | - if (!empty($modSettings['userLanguage'])) |
|
| 2479 | - loadLanguage('Post'); |
|
| 2480 | -} |
|
| 2612 | + if (!empty($modSettings['userLanguage'])) { |
|
| 2613 | + loadLanguage('Post'); |
|
| 2614 | + } |
|
| 2615 | + } |
|
| 2481 | 2616 | |
| 2482 | 2617 | /** |
| 2483 | 2618 | * Get the topic for display purposes. |
@@ -2490,12 +2625,13 @@ discard block |
||
| 2490 | 2625 | { |
| 2491 | 2626 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
| 2492 | 2627 | |
| 2493 | - if (isset($_REQUEST['xml'])) |
|
| 2494 | - $limit = ' |
|
| 2628 | + if (isset($_REQUEST['xml'])) { |
|
| 2629 | + $limit = ' |
|
| 2495 | 2630 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
| 2496 | - else |
|
| 2497 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2631 | + } else { |
|
| 2632 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
| 2498 | 2633 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
| 2634 | + } |
|
| 2499 | 2635 | |
| 2500 | 2636 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
| 2501 | 2637 | $request = $smcFunc['db_query']('', ' |
@@ -2533,8 +2669,9 @@ discard block |
||
| 2533 | 2669 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
| 2534 | 2670 | ); |
| 2535 | 2671 | |
| 2536 | - if (!empty($context['new_replies'])) |
|
| 2537 | - $context['new_replies']--; |
|
| 2672 | + if (!empty($context['new_replies'])) { |
|
| 2673 | + $context['new_replies']--; |
|
| 2674 | + } |
|
| 2538 | 2675 | } |
| 2539 | 2676 | $smcFunc['db_free_result']($request); |
| 2540 | 2677 | } |
@@ -2551,8 +2688,9 @@ discard block |
||
| 2551 | 2688 | global $sourcedir, $smcFunc; |
| 2552 | 2689 | |
| 2553 | 2690 | loadLanguage('Post'); |
| 2554 | - if (!isset($_REQUEST['xml'])) |
|
| 2555 | - loadTemplate('Post'); |
|
| 2691 | + if (!isset($_REQUEST['xml'])) { |
|
| 2692 | + loadTemplate('Post'); |
|
| 2693 | + } |
|
| 2556 | 2694 | |
| 2557 | 2695 | include_once($sourcedir . '/Subs-Post.php'); |
| 2558 | 2696 | |
@@ -2583,8 +2721,9 @@ discard block |
||
| 2583 | 2721 | $smcFunc['db_free_result']($request); |
| 2584 | 2722 | |
| 2585 | 2723 | $context['sub_template'] = 'quotefast'; |
| 2586 | - if (!empty($row)) |
|
| 2587 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2724 | + if (!empty($row)) { |
|
| 2725 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
| 2726 | + } |
|
| 2588 | 2727 | |
| 2589 | 2728 | if (!empty($can_view_post)) |
| 2590 | 2729 | { |
@@ -2617,8 +2756,9 @@ discard block |
||
| 2617 | 2756 | } |
| 2618 | 2757 | |
| 2619 | 2758 | // Remove any nested quotes. |
| 2620 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
| 2621 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2759 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
| 2760 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
| 2761 | + } |
|
| 2622 | 2762 | |
| 2623 | 2763 | $lb = "\n"; |
| 2624 | 2764 | |
@@ -2644,14 +2784,14 @@ discard block |
||
| 2644 | 2784 | 'time' => '', |
| 2645 | 2785 | ), |
| 2646 | 2786 | ); |
| 2647 | - } |
|
| 2648 | - else |
|
| 2649 | - $context['quote'] = array( |
|
| 2787 | + } else { |
|
| 2788 | + $context['quote'] = array( |
|
| 2650 | 2789 | 'xml' => '', |
| 2651 | 2790 | 'mozilla' => '', |
| 2652 | 2791 | 'text' => '', |
| 2653 | 2792 | ); |
| 2654 | -} |
|
| 2793 | + } |
|
| 2794 | + } |
|
| 2655 | 2795 | |
| 2656 | 2796 | /** |
| 2657 | 2797 | * Used to edit the body or subject of a message inline |
@@ -2663,8 +2803,9 @@ discard block |
||
| 2663 | 2803 | global $user_info, $context, $smcFunc, $language, $board_info; |
| 2664 | 2804 | |
| 2665 | 2805 | // We have to have a topic! |
| 2666 | - if (empty($topic)) |
|
| 2667 | - obExit(false); |
|
| 2806 | + if (empty($topic)) { |
|
| 2807 | + obExit(false); |
|
| 2808 | + } |
|
| 2668 | 2809 | |
| 2669 | 2810 | checkSession('get'); |
| 2670 | 2811 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2690,31 +2831,35 @@ discard block |
||
| 2690 | 2831 | 'guest_id' => 0, |
| 2691 | 2832 | ) |
| 2692 | 2833 | ); |
| 2693 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 2694 | - fatal_lang_error('no_board', false); |
|
| 2834 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 2835 | + fatal_lang_error('no_board', false); |
|
| 2836 | + } |
|
| 2695 | 2837 | $row = $smcFunc['db_fetch_assoc']($request); |
| 2696 | 2838 | $smcFunc['db_free_result']($request); |
| 2697 | 2839 | |
| 2698 | 2840 | // Change either body or subject requires permissions to modify messages. |
| 2699 | 2841 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
| 2700 | 2842 | { |
| 2701 | - if (!empty($row['locked'])) |
|
| 2702 | - isAllowedTo('moderate_board'); |
|
| 2843 | + if (!empty($row['locked'])) { |
|
| 2844 | + isAllowedTo('moderate_board'); |
|
| 2845 | + } |
|
| 2703 | 2846 | |
| 2704 | 2847 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
| 2705 | 2848 | { |
| 2706 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
| 2707 | - fatal_lang_error('modify_post_time_passed', false); |
|
| 2708 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
| 2709 | - isAllowedTo('modify_replies'); |
|
| 2710 | - else |
|
| 2711 | - isAllowedTo('modify_own'); |
|
| 2849 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
| 2850 | + fatal_lang_error('modify_post_time_passed', false); |
|
| 2851 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
| 2852 | + isAllowedTo('modify_replies'); |
|
| 2853 | + } else { |
|
| 2854 | + isAllowedTo('modify_own'); |
|
| 2855 | + } |
|
| 2712 | 2856 | } |
| 2713 | 2857 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
| 2714 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
| 2715 | - isAllowedTo('modify_replies'); |
|
| 2716 | - else |
|
| 2717 | - isAllowedTo('modify_any'); |
|
| 2858 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
| 2859 | + isAllowedTo('modify_replies'); |
|
| 2860 | + } else { |
|
| 2861 | + isAllowedTo('modify_any'); |
|
| 2862 | + } |
|
| 2718 | 2863 | |
| 2719 | 2864 | // Only log this action if it wasn't your message. |
| 2720 | 2865 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2726,10 +2871,10 @@ discard block |
||
| 2726 | 2871 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2727 | 2872 | |
| 2728 | 2873 | // Maximum number of characters. |
| 2729 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
| 2730 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2731 | - } |
|
| 2732 | - elseif (isset($_POST['subject'])) |
|
| 2874 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
| 2875 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
| 2876 | + } |
|
| 2877 | + } elseif (isset($_POST['subject'])) |
|
| 2733 | 2878 | { |
| 2734 | 2879 | $post_errors[] = 'no_subject'; |
| 2735 | 2880 | unset($_POST['subject']); |
@@ -2741,13 +2886,11 @@ discard block |
||
| 2741 | 2886 | { |
| 2742 | 2887 | $post_errors[] = 'no_message'; |
| 2743 | 2888 | unset($_POST['message']); |
| 2744 | - } |
|
| 2745 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2889 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
| 2746 | 2890 | { |
| 2747 | 2891 | $post_errors[] = 'long_message'; |
| 2748 | 2892 | unset($_POST['message']); |
| 2749 | - } |
|
| 2750 | - else |
|
| 2893 | + } else |
|
| 2751 | 2894 | { |
| 2752 | 2895 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
| 2753 | 2896 | |
@@ -2763,31 +2906,34 @@ discard block |
||
| 2763 | 2906 | |
| 2764 | 2907 | if (isset($_POST['lock'])) |
| 2765 | 2908 | { |
| 2766 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
| 2767 | - unset($_POST['lock']); |
|
| 2768 | - elseif (!allowedTo('lock_any')) |
|
| 2909 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
| 2910 | + unset($_POST['lock']); |
|
| 2911 | + } elseif (!allowedTo('lock_any')) |
|
| 2769 | 2912 | { |
| 2770 | - if ($row['locked'] == 1) |
|
| 2771 | - unset($_POST['lock']); |
|
| 2772 | - else |
|
| 2773 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2913 | + if ($row['locked'] == 1) { |
|
| 2914 | + unset($_POST['lock']); |
|
| 2915 | + } else { |
|
| 2916 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
| 2917 | + } |
|
| 2918 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
| 2919 | + unset($_POST['lock']); |
|
| 2920 | + } else { |
|
| 2921 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2774 | 2922 | } |
| 2775 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
| 2776 | - unset($_POST['lock']); |
|
| 2777 | - else |
|
| 2778 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
| 2779 | 2923 | } |
| 2780 | 2924 | |
| 2781 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
| 2782 | - unset($_POST['sticky']); |
|
| 2925 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
| 2926 | + unset($_POST['sticky']); |
|
| 2927 | + } |
|
| 2783 | 2928 | |
| 2784 | 2929 | if (isset($_POST['modify_reason'])) |
| 2785 | 2930 | { |
| 2786 | 2931 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
| 2787 | 2932 | |
| 2788 | 2933 | // Maximum number of characters. |
| 2789 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
| 2790 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2934 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
| 2935 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
| 2936 | + } |
|
| 2791 | 2937 | } |
| 2792 | 2938 | |
| 2793 | 2939 | if (empty($post_errors)) |
@@ -2824,8 +2970,9 @@ discard block |
||
| 2824 | 2970 | } |
| 2825 | 2971 | } |
| 2826 | 2972 | // If nothing was changed there's no need to add an entry to the moderation log. |
| 2827 | - else |
|
| 2828 | - $moderationAction = false; |
|
| 2973 | + else { |
|
| 2974 | + $moderationAction = false; |
|
| 2975 | + } |
|
| 2829 | 2976 | |
| 2830 | 2977 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
| 2831 | 2978 | |
@@ -2843,9 +2990,9 @@ discard block |
||
| 2843 | 2990 | // Get the proper (default language) response prefix first. |
| 2844 | 2991 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
| 2845 | 2992 | { |
| 2846 | - if ($language === $user_info['language']) |
|
| 2847 | - $context['response_prefix'] = $txt['response_prefix']; |
|
| 2848 | - else |
|
| 2993 | + if ($language === $user_info['language']) { |
|
| 2994 | + $context['response_prefix'] = $txt['response_prefix']; |
|
| 2995 | + } else |
|
| 2849 | 2996 | { |
| 2850 | 2997 | loadLanguage('index', $language, false); |
| 2851 | 2998 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2867,8 +3014,9 @@ discard block |
||
| 2867 | 3014 | ); |
| 2868 | 3015 | } |
| 2869 | 3016 | |
| 2870 | - if (!empty($moderationAction)) |
|
| 2871 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3017 | + if (!empty($moderationAction)) { |
|
| 3018 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
| 3019 | + } |
|
| 2872 | 3020 | } |
| 2873 | 3021 | |
| 2874 | 3022 | if (isset($_REQUEST['xml'])) |
@@ -2909,8 +3057,7 @@ discard block |
||
| 2909 | 3057 | ); |
| 2910 | 3058 | |
| 2911 | 3059 | censorText($context['message']['subject']); |
| 2912 | - } |
|
| 2913 | - else |
|
| 3060 | + } else |
|
| 2914 | 3061 | { |
| 2915 | 3062 | $context['message'] = array( |
| 2916 | 3063 | 'id' => $row['id_msg'], |
@@ -2922,15 +3069,16 @@ discard block |
||
| 2922 | 3069 | loadLanguage('Errors'); |
| 2923 | 3070 | foreach ($post_errors as $post_error) |
| 2924 | 3071 | { |
| 2925 | - if ($post_error == 'long_message') |
|
| 2926 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 2927 | - else |
|
| 2928 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3072 | + if ($post_error == 'long_message') { |
|
| 3073 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
| 3074 | + } else { |
|
| 3075 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
| 3076 | + } |
|
| 2929 | 3077 | } |
| 2930 | 3078 | } |
| 3079 | + } else { |
|
| 3080 | + obExit(false); |
|
| 3081 | + } |
|
| 2931 | 3082 | } |
| 2932 | - else |
|
| 2933 | - obExit(false); |
|
| 2934 | -} |
|
| 2935 | 3083 | |
| 2936 | 3084 | ?> |
| 2937 | 3085 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $txt, $context, $scripturl, $user_info; |
| 30 | 31 | |
| 31 | 32 | // You are already logged in, go take a tour of the boards |
| 32 | - if (!empty($user_info['id'])) |
|
| 33 | - redirectexit(); |
|
| 33 | + if (!empty($user_info['id'])) { |
|
| 34 | + redirectexit(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // We need to load the Login template/language file. |
| 36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
| 60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
| 61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
| 63 | - unset($_SESSION['login_url']); |
|
| 62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
| 63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
| 65 | + unset($_SESSION['login_url']); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // Create a one time token. |
| 66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
| 84 | 87 | |
| 85 | 88 | // Check to ensure we're forcing SSL for authentication |
| 86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 87 | - fatal_lang_error('login_ssl_required'); |
|
| 89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 90 | + fatal_lang_error('login_ssl_required'); |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | // Load cookie authentication stuff. |
| 90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
| 102 | 106 | list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true); |
| 103 | 107 | |
| 104 | 108 | // That didn't work... Maybe it's using serialize? |
| 105 | - if (is_null($timeout)) |
|
| 106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 107 | - } |
|
| 108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | + if (is_null($timeout)) { |
|
| 110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 111 | + } |
|
| 112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | 113 | { |
| 110 | 114 | list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 111 | 115 | |
| 112 | 116 | // Try for old format |
| 113 | - if (is_null($timeout)) |
|
| 114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 117 | + if (is_null($timeout)) { |
|
| 118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 115 | 122 | } |
| 116 | - else |
|
| 117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 118 | 123 | |
| 119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
| 120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -125,16 +130,18 @@ discard block |
||
| 125 | 130 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 126 | 131 | |
| 127 | 132 | // If that didn't work, try unserialize instead... |
| 128 | - if (is_null($tfadata)) |
|
| 129 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 133 | + if (is_null($tfadata)) { |
|
| 134 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 132 | 138 | |
| 133 | 139 | // If we're preserving the cookie, reset it with updated salt |
| 134 | - if ($preserve && time() < $exp) |
|
| 135 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 136 | - else |
|
| 137 | - setTFACookie(-3600, 0, ''); |
|
| 140 | + if ($preserve && time() < $exp) { |
|
| 141 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 142 | + } else { |
|
| 143 | + setTFACookie(-3600, 0, ''); |
|
| 144 | + } |
|
| 138 | 145 | } |
| 139 | 146 | |
| 140 | 147 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -145,20 +152,20 @@ discard block |
||
| 145 | 152 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
| 146 | 153 | { |
| 147 | 154 | // Strike! You're outta there! |
| 148 | - if ($_GET['member'] != $user_info['id']) |
|
| 149 | - fatal_lang_error('login_cookie_error', false); |
|
| 155 | + if ($_GET['member'] != $user_info['id']) { |
|
| 156 | + fatal_lang_error('login_cookie_error', false); |
|
| 157 | + } |
|
| 150 | 158 | |
| 151 | 159 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
| 152 | 160 | |
| 153 | 161 | // Some whitelisting for login_url... |
| 154 | - if (empty($_SESSION['login_url'])) |
|
| 155 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 156 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 162 | + if (empty($_SESSION['login_url'])) { |
|
| 163 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 164 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 157 | 165 | { |
| 158 | 166 | unset ($_SESSION['login_url']); |
| 159 | 167 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
| 160 | - } |
|
| 161 | - else |
|
| 168 | + } else |
|
| 162 | 169 | { |
| 163 | 170 | // Best not to clutter the session data too much... |
| 164 | 171 | $temp = $_SESSION['login_url']; |
@@ -169,8 +176,9 @@ discard block |
||
| 169 | 176 | } |
| 170 | 177 | |
| 171 | 178 | // Beyond this point you are assumed to be a guest trying to login. |
| 172 | - if (!$user_info['is_guest']) |
|
| 173 | - redirectexit(); |
|
| 179 | + if (!$user_info['is_guest']) { |
|
| 180 | + redirectexit(); |
|
| 181 | + } |
|
| 174 | 182 | |
| 175 | 183 | // Are you guessing with a script? |
| 176 | 184 | checkSession(); |
@@ -178,18 +186,21 @@ discard block |
||
| 178 | 186 | spamProtection('login'); |
| 179 | 187 | |
| 180 | 188 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
| 181 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
| 182 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 189 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
| 190 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 191 | + } |
|
| 183 | 192 | |
| 184 | 193 | // Been guessing a lot, haven't we? |
| 185 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
| 186 | - fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 194 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
| 195 | + fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 196 | + } |
|
| 187 | 197 | |
| 188 | 198 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
| 189 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
| 190 | - $modSettings['cookieTime'] = 3153600; |
|
| 191 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
| 192 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 199 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
| 200 | + $modSettings['cookieTime'] = 3153600; |
|
| 201 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
| 202 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 203 | + } |
|
| 193 | 204 | |
| 194 | 205 | loadLanguage('Login'); |
| 195 | 206 | // Load the template stuff. |
@@ -309,8 +320,9 @@ discard block |
||
| 309 | 320 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
| 310 | 321 | |
| 311 | 322 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
| 312 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
| 313 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 323 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
| 324 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 325 | + } |
|
| 314 | 326 | |
| 315 | 327 | // phpBB3 users new hashing. We now support it as well ;). |
| 316 | 328 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -330,27 +342,29 @@ discard block |
||
| 330 | 342 | // Some common md5 ones. |
| 331 | 343 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
| 332 | 344 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
| 333 | - } |
|
| 334 | - elseif (strlen($user_settings['passwd']) == 40) |
|
| 345 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
| 335 | 346 | { |
| 336 | 347 | // Maybe they are using a hash from before the password fix. |
| 337 | 348 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
| 338 | 349 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
| 339 | 350 | |
| 340 | 351 | // BurningBoard3 style of hashing. |
| 341 | - if (!empty($modSettings['enable_password_conversion'])) |
|
| 342 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 352 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
| 353 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 354 | + } |
|
| 343 | 355 | |
| 344 | 356 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
| 345 | 357 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
| 346 | 358 | { |
| 347 | 359 | // Try iconv first, for no particular reason. |
| 348 | - if (function_exists('iconv')) |
|
| 349 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 360 | + if (function_exists('iconv')) { |
|
| 361 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Say it aint so, iconv failed! |
| 352 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
| 353 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 365 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
| 366 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 367 | + } |
|
| 354 | 368 | } |
| 355 | 369 | } |
| 356 | 370 | |
@@ -380,8 +394,9 @@ discard block |
||
| 380 | 394 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
| 381 | 395 | |
| 382 | 396 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
| 383 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
| 384 | - redirectexit('action=reminder'); |
|
| 397 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
| 398 | + redirectexit('action=reminder'); |
|
| 399 | + } |
|
| 385 | 400 | // We'll give you another chance... |
| 386 | 401 | else |
| 387 | 402 | { |
@@ -392,8 +407,7 @@ discard block |
||
| 392 | 407 | return; |
| 393 | 408 | } |
| 394 | 409 | } |
| 395 | - } |
|
| 396 | - elseif (!empty($user_settings['passwd_flood'])) |
|
| 410 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
| 397 | 411 | { |
| 398 | 412 | // Let's be sure they weren't a little hacker. |
| 399 | 413 | validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true); |
@@ -410,8 +424,9 @@ discard block |
||
| 410 | 424 | } |
| 411 | 425 | |
| 412 | 426 | // Check their activation status. |
| 413 | - if (!checkActivation()) |
|
| 414 | - return; |
|
| 427 | + if (!checkActivation()) { |
|
| 428 | + return; |
|
| 429 | + } |
|
| 415 | 430 | |
| 416 | 431 | DoLogin(); |
| 417 | 432 | } |
@@ -423,8 +438,9 @@ discard block |
||
| 423 | 438 | { |
| 424 | 439 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
| 425 | 440 | |
| 426 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
| 427 | - fatal_lang_error('no_access', false); |
|
| 441 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
| 442 | + fatal_lang_error('no_access', false); |
|
| 443 | + } |
|
| 428 | 444 | |
| 429 | 445 | loadLanguage('Profile'); |
| 430 | 446 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -432,8 +448,9 @@ discard block |
||
| 432 | 448 | $member = $context['tfa_member']; |
| 433 | 449 | |
| 434 | 450 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
| 435 | - if (time() - $member['last_login'] < 120) |
|
| 436 | - fatal_lang_error('tfa_wait', false); |
|
| 451 | + if (time() - $member['last_login'] < 120) { |
|
| 452 | + fatal_lang_error('tfa_wait', false); |
|
| 453 | + } |
|
| 437 | 454 | |
| 438 | 455 | $totp = new \TOTP\Auth($member['tfa_secret']); |
| 439 | 456 | $totp->setRange(1); |
@@ -447,8 +464,9 @@ discard block |
||
| 447 | 464 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
| 448 | 465 | { |
| 449 | 466 | // Check to ensure we're forcing SSL for authentication |
| 450 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 451 | - fatal_lang_error('login_ssl_required'); |
|
| 467 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 468 | + fatal_lang_error('login_ssl_required'); |
|
| 469 | + } |
|
| 452 | 470 | |
| 453 | 471 | $code = $_POST['tfa_code']; |
| 454 | 472 | |
@@ -458,20 +476,19 @@ discard block |
||
| 458 | 476 | |
| 459 | 477 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
| 460 | 478 | redirectexit(); |
| 461 | - } |
|
| 462 | - else |
|
| 479 | + } else |
|
| 463 | 480 | { |
| 464 | 481 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 465 | 482 | |
| 466 | 483 | $context['tfa_error'] = true; |
| 467 | 484 | $context['tfa_value'] = $_POST['tfa_code']; |
| 468 | 485 | } |
| 469 | - } |
|
| 470 | - elseif (!empty($_POST['tfa_backup'])) |
|
| 486 | + } elseif (!empty($_POST['tfa_backup'])) |
|
| 471 | 487 | { |
| 472 | 488 | // Check to ensure we're forcing SSL for authentication |
| 473 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 474 | - fatal_lang_error('login_ssl_required'); |
|
| 489 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 490 | + fatal_lang_error('login_ssl_required'); |
|
| 491 | + } |
|
| 475 | 492 | |
| 476 | 493 | $backup = $_POST['tfa_backup']; |
| 477 | 494 | |
@@ -485,8 +502,7 @@ discard block |
||
| 485 | 502 | )); |
| 486 | 503 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 487 | 504 | redirectexit('action=profile;area=tfasetup;backup'); |
| 488 | - } |
|
| 489 | - else |
|
| 505 | + } else |
|
| 490 | 506 | { |
| 491 | 507 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 492 | 508 | |
@@ -509,8 +525,9 @@ discard block |
||
| 509 | 525 | { |
| 510 | 526 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
| 511 | 527 | |
| 512 | - if (!isset($context['login_errors'])) |
|
| 513 | - $context['login_errors'] = array(); |
|
| 528 | + if (!isset($context['login_errors'])) { |
|
| 529 | + $context['login_errors'] = array(); |
|
| 530 | + } |
|
| 514 | 531 | |
| 515 | 532 | // What is the true activation status of this account? |
| 516 | 533 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -522,8 +539,9 @@ discard block |
||
| 522 | 539 | return false; |
| 523 | 540 | } |
| 524 | 541 | // Awaiting approval still? |
| 525 | - elseif ($activation_status == 3) |
|
| 526 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 542 | + elseif ($activation_status == 3) { |
|
| 543 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 544 | + } |
|
| 527 | 545 | // Awaiting deletion, changed their mind? |
| 528 | 546 | elseif ($activation_status == 4) |
| 529 | 547 | { |
@@ -531,8 +549,7 @@ discard block |
||
| 531 | 549 | { |
| 532 | 550 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
| 533 | 551 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
| 534 | - } |
|
| 535 | - else |
|
| 552 | + } else |
|
| 536 | 553 | { |
| 537 | 554 | $context['disable_login_hashing'] = true; |
| 538 | 555 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -573,8 +590,9 @@ discard block |
||
| 573 | 590 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
| 574 | 591 | |
| 575 | 592 | // Reset the login threshold. |
| 576 | - if (isset($_SESSION['failed_login'])) |
|
| 577 | - unset($_SESSION['failed_login']); |
|
| 593 | + if (isset($_SESSION['failed_login'])) { |
|
| 594 | + unset($_SESSION['failed_login']); |
|
| 595 | + } |
|
| 578 | 596 | |
| 579 | 597 | $user_info['is_guest'] = false; |
| 580 | 598 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -596,16 +614,18 @@ discard block |
||
| 596 | 614 | 'id_member' => $user_info['id'], |
| 597 | 615 | ) |
| 598 | 616 | ); |
| 599 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 600 | - $_SESSION['first_login'] = true; |
|
| 601 | - else |
|
| 602 | - unset($_SESSION['first_login']); |
|
| 617 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 618 | + $_SESSION['first_login'] = true; |
|
| 619 | + } else { |
|
| 620 | + unset($_SESSION['first_login']); |
|
| 621 | + } |
|
| 603 | 622 | $smcFunc['db_free_result']($request); |
| 604 | 623 | |
| 605 | 624 | // You've logged in, haven't you? |
| 606 | 625 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
| 607 | - if (empty($user_settings['tfa_secret'])) |
|
| 608 | - $update['last_login'] = time(); |
|
| 626 | + if (empty($user_settings['tfa_secret'])) { |
|
| 627 | + $update['last_login'] = time(); |
|
| 628 | + } |
|
| 609 | 629 | updateMemberData($user_info['id'], $update); |
| 610 | 630 | |
| 611 | 631 | // Get rid of the online entry for that old guest.... |
@@ -619,8 +639,8 @@ discard block |
||
| 619 | 639 | $_SESSION['log_time'] = 0; |
| 620 | 640 | |
| 621 | 641 | // Log this entry, only if we have it enabled. |
| 622 | - if (!empty($modSettings['loginHistoryDays'])) |
|
| 623 | - $smcFunc['db_insert']('insert', |
|
| 642 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
| 643 | + $smcFunc['db_insert']('insert', |
|
| 624 | 644 | '{db_prefix}member_logins', |
| 625 | 645 | array( |
| 626 | 646 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -632,13 +652,15 @@ discard block |
||
| 632 | 652 | 'id_member', 'time' |
| 633 | 653 | ) |
| 634 | 654 | ); |
| 655 | + } |
|
| 635 | 656 | |
| 636 | 657 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
| 637 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
| 638 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 639 | - else |
|
| 640 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 641 | -} |
|
| 658 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
| 659 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 660 | + } else { |
|
| 661 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 662 | + } |
|
| 663 | + } |
|
| 642 | 664 | |
| 643 | 665 | /** |
| 644 | 666 | * Logs the current user out of their account. |
@@ -654,13 +676,15 @@ discard block |
||
| 654 | 676 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
| 655 | 677 | |
| 656 | 678 | // Make sure they aren't being auto-logged out. |
| 657 | - if (!$internal) |
|
| 658 | - checkSession('get'); |
|
| 679 | + if (!$internal) { |
|
| 680 | + checkSession('get'); |
|
| 681 | + } |
|
| 659 | 682 | |
| 660 | 683 | require_once($sourcedir . '/Subs-Auth.php'); |
| 661 | 684 | |
| 662 | - if (isset($_SESSION['pack_ftp'])) |
|
| 663 | - $_SESSION['pack_ftp'] = null; |
|
| 685 | + if (isset($_SESSION['pack_ftp'])) { |
|
| 686 | + $_SESSION['pack_ftp'] = null; |
|
| 687 | + } |
|
| 664 | 688 | |
| 665 | 689 | // It won't be first login anymore. |
| 666 | 690 | unset($_SESSION['first_login']); |
@@ -688,24 +712,27 @@ discard block |
||
| 688 | 712 | |
| 689 | 713 | // And some other housekeeping while we're at it. |
| 690 | 714 | $salt = substr(md5(mt_rand()), 0, 4); |
| 691 | - if (!empty($user_info['id'])) |
|
| 692 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 715 | + if (!empty($user_info['id'])) { |
|
| 716 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 717 | + } |
|
| 693 | 718 | |
| 694 | 719 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
| 695 | 720 | { |
| 696 | 721 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 697 | 722 | |
| 698 | 723 | // If that failed, try the old method |
| 699 | - if (is_null($tfadata)) |
|
| 700 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 724 | + if (is_null($tfadata)) { |
|
| 725 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 726 | + } |
|
| 701 | 727 | |
| 702 | 728 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 703 | 729 | |
| 704 | 730 | // If we're preserving the cookie, reset it with updated salt |
| 705 | - if ($preserve && time() < $exp) |
|
| 706 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 707 | - else |
|
| 708 | - setTFACookie(-3600, 0, ''); |
|
| 731 | + if ($preserve && time() < $exp) { |
|
| 732 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 733 | + } else { |
|
| 734 | + setTFACookie(-3600, 0, ''); |
|
| 735 | + } |
|
| 709 | 736 | } |
| 710 | 737 | |
| 711 | 738 | session_destroy(); |
@@ -713,14 +740,13 @@ discard block |
||
| 713 | 740 | // Off to the merry board index we go! |
| 714 | 741 | if ($redirect) |
| 715 | 742 | { |
| 716 | - if (empty($_SESSION['logout_url'])) |
|
| 717 | - redirectexit('', $context['server']['needs_login_fix']); |
|
| 718 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 743 | + if (empty($_SESSION['logout_url'])) { |
|
| 744 | + redirectexit('', $context['server']['needs_login_fix']); |
|
| 745 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 719 | 746 | { |
| 720 | 747 | unset ($_SESSION['logout_url']); |
| 721 | 748 | redirectexit(); |
| 722 | - } |
|
| 723 | - else |
|
| 749 | + } else |
|
| 724 | 750 | { |
| 725 | 751 | $temp = $_SESSION['logout_url']; |
| 726 | 752 | unset($_SESSION['logout_url']); |
@@ -753,8 +779,9 @@ discard block |
||
| 753 | 779 | function phpBB3_password_check($passwd, $passwd_hash) |
| 754 | 780 | { |
| 755 | 781 | // Too long or too short? |
| 756 | - if (strlen($passwd_hash) != 34) |
|
| 757 | - return; |
|
| 782 | + if (strlen($passwd_hash) != 34) { |
|
| 783 | + return; |
|
| 784 | + } |
|
| 758 | 785 | |
| 759 | 786 | // Range of characters allowed. |
| 760 | 787 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -766,8 +793,9 @@ discard block |
||
| 766 | 793 | $salt = substr($passwd_hash, 4, 8); |
| 767 | 794 | |
| 768 | 795 | $hash = md5($salt . $passwd, true); |
| 769 | - for (; $count != 0; --$count) |
|
| 770 | - $hash = md5($hash . $passwd, true); |
|
| 796 | + for (; $count != 0; --$count) { |
|
| 797 | + $hash = md5($hash . $passwd, true); |
|
| 798 | + } |
|
| 771 | 799 | |
| 772 | 800 | $output = substr($passwd_hash, 0, 12); |
| 773 | 801 | $i = 0; |
@@ -776,21 +804,25 @@ discard block |
||
| 776 | 804 | $value = ord($hash[$i++]); |
| 777 | 805 | $output .= $range[$value & 0x3f]; |
| 778 | 806 | |
| 779 | - if ($i < 16) |
|
| 780 | - $value |= ord($hash[$i]) << 8; |
|
| 807 | + if ($i < 16) { |
|
| 808 | + $value |= ord($hash[$i]) << 8; |
|
| 809 | + } |
|
| 781 | 810 | |
| 782 | 811 | $output .= $range[($value >> 6) & 0x3f]; |
| 783 | 812 | |
| 784 | - if ($i++ >= 16) |
|
| 785 | - break; |
|
| 813 | + if ($i++ >= 16) { |
|
| 814 | + break; |
|
| 815 | + } |
|
| 786 | 816 | |
| 787 | - if ($i < 16) |
|
| 788 | - $value |= ord($hash[$i]) << 16; |
|
| 817 | + if ($i < 16) { |
|
| 818 | + $value |= ord($hash[$i]) << 16; |
|
| 819 | + } |
|
| 789 | 820 | |
| 790 | 821 | $output .= $range[($value >> 12) & 0x3f]; |
| 791 | 822 | |
| 792 | - if ($i++ >= 16) |
|
| 793 | - break; |
|
| 823 | + if ($i++ >= 16) { |
|
| 824 | + break; |
|
| 825 | + } |
|
| 794 | 826 | |
| 795 | 827 | $output .= $range[($value >> 18) & 0x3f]; |
| 796 | 828 | } |
@@ -821,8 +853,9 @@ discard block |
||
| 821 | 853 | require_once($sourcedir . '/Subs-Auth.php'); |
| 822 | 854 | setLoginCookie(-3600, 0); |
| 823 | 855 | |
| 824 | - if (isset($_SESSION['login_' . $cookiename])) |
|
| 825 | - unset($_SESSION['login_' . $cookiename]); |
|
| 856 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
| 857 | + unset($_SESSION['login_' . $cookiename]); |
|
| 858 | + } |
|
| 826 | 859 | } |
| 827 | 860 | |
| 828 | 861 | // We need a member! |
@@ -836,8 +869,9 @@ discard block |
||
| 836 | 869 | } |
| 837 | 870 | |
| 838 | 871 | // Right, have we got a flood value? |
| 839 | - if ($password_flood_value !== false) |
|
| 840 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 872 | + if ($password_flood_value !== false) { |
|
| 873 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 874 | + } |
|
| 841 | 875 | |
| 842 | 876 | // Timestamp or number of tries invalid? |
| 843 | 877 | if (empty($number_tries) || empty($time_stamp)) |
@@ -853,15 +887,17 @@ discard block |
||
| 853 | 887 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
| 854 | 888 | |
| 855 | 889 | // They are trying too fast, make them wait longer |
| 856 | - if ($time_stamp < time() - 10) |
|
| 857 | - $time_stamp = time(); |
|
| 890 | + if ($time_stamp < time() - 10) { |
|
| 891 | + $time_stamp = time(); |
|
| 892 | + } |
|
| 858 | 893 | } |
| 859 | 894 | |
| 860 | 895 | $number_tries++; |
| 861 | 896 | |
| 862 | 897 | // Broken the law? |
| 863 | - if ($number_tries > 5) |
|
| 864 | - fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 898 | + if ($number_tries > 5) { |
|
| 899 | + fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 900 | + } |
|
| 865 | 901 | |
| 866 | 902 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
| 867 | 903 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
| 23 | 24 | { |
| 24 | 25 | global $smcFunc; |
| 25 | 26 | |
| 26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
| 27 | - $smcFunc += array( |
|
| 27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
| 28 | + $smcFunc += array( |
|
| 28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
| 29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
| 30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | 'db_get_version' => 'smf_db_get_version', |
| 33 | 34 | 'db_get_engine' => 'smf_db_get_engine', |
| 34 | 35 | ); |
| 35 | -} |
|
| 36 | + } |
|
| 37 | + } |
|
| 36 | 38 | |
| 37 | 39 | /** |
| 38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
| 74 | 76 | )); |
| 75 | 77 | |
| 76 | 78 | // Old school or no school? |
| 77 | - if ($request) |
|
| 78 | - return $request; |
|
| 79 | + if ($request) { |
|
| 80 | + return $request; |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | foreach ($create as $k => $l) |
| 100 | 103 | { |
| 101 | 104 | // Get the name of the auto_increment column. |
| 102 | - if (strpos($l, 'auto_increment')) |
|
| 103 | - $auto_inc = trim($l); |
|
| 105 | + if (strpos($l, 'auto_increment')) { |
|
| 106 | + $auto_inc = trim($l); |
|
| 107 | + } |
|
| 104 | 108 | |
| 105 | 109 | // For the engine type, see if we can work out what it is. |
| 106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
| 108 | 112 | // Extract the engine type. |
| 109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
| 110 | 114 | |
| 111 | - if (!empty($match[1])) |
|
| 112 | - $engine = $match[1]; |
|
| 115 | + if (!empty($match[1])) { |
|
| 116 | + $engine = $match[1]; |
|
| 117 | + } |
|
| 113 | 118 | |
| 114 | - if (!empty($match[2])) |
|
| 115 | - $engine = $match[2]; |
|
| 119 | + if (!empty($match[2])) { |
|
| 120 | + $engine = $match[2]; |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | - if (!empty($match[5])) |
|
| 118 | - $charset = $match[5]; |
|
| 123 | + if (!empty($match[5])) { |
|
| 124 | + $charset = $match[5]; |
|
| 125 | + } |
|
| 119 | 126 | |
| 120 | - if (!empty($match[7])) |
|
| 121 | - $collate = $match[7]; |
|
| 127 | + if (!empty($match[7])) { |
|
| 128 | + $collate = $match[7]; |
|
| 129 | + } |
|
| 122 | 130 | } |
| 123 | 131 | |
| 124 | 132 | // Skip everything but keys... |
| 125 | - if (strpos($l, 'KEY') === false) |
|
| 126 | - unset($create[$k]); |
|
| 133 | + if (strpos($l, 'KEY') === false) { |
|
| 134 | + unset($create[$k]); |
|
| 135 | + } |
|
| 127 | 136 | } |
| 128 | 137 | |
| 129 | - if (!empty($create)) |
|
| 130 | - $create = '( |
|
| 138 | + if (!empty($create)) { |
|
| 139 | + $create = '( |
|
| 131 | 140 | ' . implode(' |
| 132 | 141 | ', $create) . ')'; |
| 133 | - else |
|
| 134 | - $create = ''; |
|
| 142 | + } else { |
|
| 143 | + $create = ''; |
|
| 144 | + } |
|
| 135 | 145 | |
| 136 | 146 | $request = $smcFunc['db_query']('', ' |
| 137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
| 150 | 160 | |
| 151 | 161 | if ($auto_inc != '') |
| 152 | 162 | { |
| 153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
| 154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
| 163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
| 164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
| 165 | + } |
|
| 155 | 166 | |
| 156 | 167 | $smcFunc['db_query']('', ' |
| 157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
| 195 | 206 | 'table' => $table, |
| 196 | 207 | ) |
| 197 | 208 | ); |
| 198 | - if (!$request) |
|
| 199 | - return -1; |
|
| 209 | + if (!$request) { |
|
| 210 | + return -1; |
|
| 211 | + } |
|
| 200 | 212 | |
| 201 | 213 | // How much left? |
| 202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
| 239 | 251 | ) |
| 240 | 252 | ); |
| 241 | 253 | $tables = array(); |
| 242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
| 243 | - $tables[] = $row[0]; |
|
| 254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
| 255 | + $tables[] = $row[0]; |
|
| 256 | + } |
|
| 244 | 257 | $smcFunc['db_free_result']($request); |
| 245 | 258 | |
| 246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
| 284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
| 285 | 298 | { |
| 286 | 299 | // Make a special case of auto-timestamp. |
| 287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
| 288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
| 301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
| 302 | + } |
|
| 289 | 303 | // Text shouldn't have a default. |
| 290 | 304 | elseif ($row['Default'] !== null) |
| 291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
| 320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
| 321 | 335 | |
| 322 | 336 | // Is this the first column in the index? |
| 323 | - if (empty($indexes[$row['Key_name']])) |
|
| 324 | - $indexes[$row['Key_name']] = array(); |
|
| 337 | + if (empty($indexes[$row['Key_name']])) { |
|
| 338 | + $indexes[$row['Key_name']] = array(); |
|
| 339 | + } |
|
| 325 | 340 | |
| 326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
| 327 | - if (!empty($row['Sub_part'])) |
|
| 328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 329 | - else |
|
| 330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 342 | + if (!empty($row['Sub_part'])) { |
|
| 343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
| 344 | + } else { |
|
| 345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
| 346 | + } |
|
| 331 | 347 | } |
| 332 | 348 | $smcFunc['db_free_result']($result); |
| 333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
| 365 | 381 | { |
| 366 | 382 | static $ver; |
| 367 | 383 | |
| 368 | - if (!empty($ver)) |
|
| 369 | - return $ver; |
|
| 384 | + if (!empty($ver)) { |
|
| 385 | + return $ver; |
|
| 386 | + } |
|
| 370 | 387 | |
| 371 | 388 | global $smcFunc; |
| 372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
| 391 | 408 | global $smcFunc; |
| 392 | 409 | static $db_type; |
| 393 | 410 | |
| 394 | - if (!empty($db_type)) |
|
| 395 | - return $db_type; |
|
| 411 | + if (!empty($db_type)) { |
|
| 412 | + return $db_type; |
|
| 413 | + } |
|
| 396 | 414 | |
| 397 | 415 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
| 398 | 416 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -401,13 +419,15 @@ discard block |
||
| 401 | 419 | // Skip these if we don't have a comment. |
| 402 | 420 | if (!empty($comment)) |
| 403 | 421 | { |
| 404 | - if (stripos($comment, 'percona') !== false) |
|
| 405 | - return 'Percona'; |
|
| 406 | - if (stripos($comment, 'mariadb') !== false) |
|
| 407 | - return 'MariaDB'; |
|
| 422 | + if (stripos($comment, 'percona') !== false) { |
|
| 423 | + return 'Percona'; |
|
| 424 | + } |
|
| 425 | + if (stripos($comment, 'mariadb') !== false) { |
|
| 426 | + return 'MariaDB'; |
|
| 427 | + } |
|
| 428 | + } else { |
|
| 429 | + return 'fail'; |
|
| 408 | 430 | } |
| 409 | - else |
|
| 410 | - return 'fail'; |
|
| 411 | 431 | |
| 412 | 432 | return 'MySQL'; |
| 413 | 433 | } |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
| 109 | 110 | |
| 110 | 111 | // We do not want to output debug information here. |
| 111 | - if ($this->_js) |
|
| 112 | - $db_show_debug = false; |
|
| 112 | + if ($this->_js) { |
|
| 113 | + $db_show_debug = false; |
|
| 114 | + } |
|
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
| 143 | 145 | $call = $this->_sa; |
| 144 | 146 | |
| 145 | 147 | // Guest can only view likes. |
| 146 | - if ($call != 'view') |
|
| 147 | - is_not_guest(); |
|
| 148 | + if ($call != 'view') { |
|
| 149 | + is_not_guest(); |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | checkSession('get'); |
| 150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
| 182 | 185 | global $smcFunc, $modSettings; |
| 183 | 186 | |
| 184 | 187 | // This feature is currently disable. |
| 185 | - if (empty($modSettings['enable_likes'])) |
|
| 186 | - return $this->_error = 'like_disable'; |
|
| 188 | + if (empty($modSettings['enable_likes'])) { |
|
| 189 | + return $this->_error = 'like_disable'; |
|
| 190 | + } |
|
| 187 | 191 | |
| 188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
| 189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
| 190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
| 191 | 195 | |
| 192 | - if ($this->_type == '' || $this->_content <= 0) |
|
| 193 | - return $this->_error = 'cannot_'; |
|
| 196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
| 197 | + return $this->_error = 'cannot_'; |
|
| 198 | + } |
|
| 194 | 199 | |
| 195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
| 196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
| 209 | 214 | 'msg' => $this->_content, |
| 210 | 215 | ) |
| 211 | 216 | ); |
| 212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
| 219 | + } |
|
| 214 | 220 | |
| 215 | 221 | $smcFunc['db_free_result']($request); |
| 216 | - if (empty($this->_idTopic)) |
|
| 217 | - return $this->_error = 'cannot_'; |
|
| 222 | + if (empty($this->_idTopic)) { |
|
| 223 | + return $this->_error = 'cannot_'; |
|
| 224 | + } |
|
| 218 | 225 | |
| 219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
| 220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
| 224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
| 225 | 232 | |
| 226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
| 227 | - } |
|
| 228 | - |
|
| 229 | - else |
|
| 234 | + } else |
|
| 230 | 235 | { |
| 231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
| 232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
| 244 | 249 | if ($result !== false) |
| 245 | 250 | { |
| 246 | 251 | // Match the type with what we already have. |
| 247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
| 248 | - return $this->_error = 'not_valid_like_type'; |
|
| 252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
| 253 | + return $this->_error = 'not_valid_like_type'; |
|
| 254 | + } |
|
| 249 | 255 | |
| 250 | 256 | // Fill out the rest. |
| 251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | |
| 259 | - if (!$found) |
|
| 260 | - return $this->_error = 'cannot_'; |
|
| 265 | + if (!$found) { |
|
| 266 | + return $this->_error = 'cannot_'; |
|
| 267 | + } |
|
| 261 | 268 | } |
| 262 | 269 | |
| 263 | 270 | // Does the user can see this? |
| 264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
| 265 | - return $this->_error = $this->_validLikes['can_see']; |
|
| 271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
| 272 | + return $this->_error = $this->_validLikes['can_see']; |
|
| 273 | + } |
|
| 266 | 274 | |
| 267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
| 268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
| 269 | - return $this->_error = $this->_validLikes['can_like']; |
|
| 276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
| 277 | + return $this->_error = $this->_validLikes['can_like']; |
|
| 278 | + } |
|
| 270 | 279 | } |
| 271 | 280 | |
| 272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
| 291 | 300 | ); |
| 292 | 301 | |
| 293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 294 | - if ($this->_sa == __FUNCTION__) |
|
| 295 | - $this->_data = __FUNCTION__; |
|
| 303 | + if ($this->_sa == __FUNCTION__) { |
|
| 304 | + $this->_data = __FUNCTION__; |
|
| 305 | + } |
|
| 296 | 306 | } |
| 297 | 307 | |
| 298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
| 322 | 332 | |
| 323 | 333 | // Add a background task to process sending alerts. |
| 324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
| 325 | - if ($this->_type == 'msg') |
|
| 326 | - $smcFunc['db_insert']('insert', |
|
| 335 | + if ($this->_type == 'msg') { |
|
| 336 | + $smcFunc['db_insert']('insert', |
|
| 327 | 337 | '{db_prefix}background_tasks', |
| 328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
| 329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array( |
@@ -335,10 +345,12 @@ discard block |
||
| 335 | 345 | )), 0), |
| 336 | 346 | array('id_task') |
| 337 | 347 | ); |
| 348 | + } |
|
| 338 | 349 | |
| 339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
| 340 | - if ($this->_sa == __FUNCTION__) |
|
| 341 | - $this->_data = __FUNCTION__; |
|
| 351 | + if ($this->_sa == __FUNCTION__) { |
|
| 352 | + $this->_data = __FUNCTION__; |
|
| 353 | + } |
|
| 342 | 354 | } |
| 343 | 355 | |
| 344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
| 364 | 376 | $smcFunc['db_free_result']($request); |
| 365 | 377 | |
| 366 | 378 | // If you want to call this directly, fill out _data property too. |
| 367 | - if ($this->_sa == __FUNCTION__) |
|
| 368 | - $this->_data = $this->_numLikes; |
|
| 379 | + if ($this->_sa == __FUNCTION__) { |
|
| 380 | + $this->_data = $this->_numLikes; |
|
| 381 | + } |
|
| 369 | 382 | } |
| 370 | 383 | |
| 371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
| 378 | 391 | global $smcFunc; |
| 379 | 392 | |
| 380 | 393 | // Safety first! |
| 381 | - if (empty($this->_type) || empty($this->_content)) |
|
| 382 | - return $this->_error = 'cannot_'; |
|
| 394 | + if (empty($this->_type) || empty($this->_content)) { |
|
| 395 | + return $this->_error = 'cannot_'; |
|
| 396 | + } |
|
| 383 | 397 | |
| 384 | 398 | // Do we already like this? |
| 385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
| 397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
| 398 | 412 | $smcFunc['db_free_result']($request); |
| 399 | 413 | |
| 400 | - if ($this->_alreadyLiked) |
|
| 401 | - $this->delete(); |
|
| 402 | - |
|
| 403 | - else |
|
| 404 | - $this->insert(); |
|
| 414 | + if ($this->_alreadyLiked) { |
|
| 415 | + $this->delete(); |
|
| 416 | + } else { |
|
| 417 | + $this->insert(); |
|
| 418 | + } |
|
| 405 | 419 | |
| 406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
| 407 | 421 | $this->_count(); |
| 408 | 422 | |
| 409 | 423 | // Update the likes count for messages. |
| 410 | - if ($this->_type == 'msg') |
|
| 411 | - $this->msgIssueLike(); |
|
| 424 | + if ($this->_type == 'msg') { |
|
| 425 | + $this->msgIssueLike(); |
|
| 426 | + } |
|
| 412 | 427 | |
| 413 | 428 | // Any callbacks? |
| 414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
| 415 | 430 | { |
| 416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
| 417 | 432 | |
| 418 | - if (!empty($call)) |
|
| 419 | - call_user_func_array($call, array($this)); |
|
| 433 | + if (!empty($call)) { |
|
| 434 | + call_user_func_array($call, array($this)); |
|
| 435 | + } |
|
| 420 | 436 | } |
| 421 | 437 | |
| 422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
| 425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
| 426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
| 427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
| 428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
| 429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
| 445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
| 446 | + } |
|
| 430 | 447 | |
| 431 | 448 | // All done, start building the data to pass as response. |
| 432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
| 450 | 467 | { |
| 451 | 468 | global $smcFunc; |
| 452 | 469 | |
| 453 | - if ($this->_type !== 'msg') |
|
| 454 | - return; |
|
| 470 | + if ($this->_type !== 'msg') { |
|
| 471 | + return; |
|
| 472 | + } |
|
| 455 | 473 | |
| 456 | 474 | $smcFunc['db_query']('', ' |
| 457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
| 492 | 510 | 'like_type' => $this->_type, |
| 493 | 511 | ) |
| 494 | 512 | ); |
| 495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
| 515 | + } |
|
| 497 | 516 | |
| 498 | 517 | // Now to get member data, including avatars and so on. |
| 499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
| 501 | 520 | if (count($loaded) != count($members)) |
| 502 | 521 | { |
| 503 | 522 | $members = array_diff($members, $loaded); |
| 504 | - foreach ($members as $not_loaded) |
|
| 505 | - unset ($context['likers'][$not_loaded]); |
|
| 523 | + foreach ($members as $not_loaded) { |
|
| 524 | + unset ($context['likers'][$not_loaded]); |
|
| 525 | + } |
|
| 506 | 526 | } |
| 507 | 527 | |
| 508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
| 544 | 564 | global $context, $txt; |
| 545 | 565 | |
| 546 | 566 | // Don't do anything if someone else has already take care of the response. |
| 547 | - if (!$this->_setResponse) |
|
| 548 | - return; |
|
| 567 | + if (!$this->_setResponse) { |
|
| 568 | + return; |
|
| 569 | + } |
|
| 549 | 570 | |
| 550 | 571 | // Want a json response huh? |
| 551 | - if ($this->_validLikes['json']) |
|
| 552 | - return $this->jsonResponse(); |
|
| 572 | + if ($this->_validLikes['json']) { |
|
| 573 | + return $this->jsonResponse(); |
|
| 574 | + } |
|
| 553 | 575 | |
| 554 | 576 | // Set everything up for display. |
| 555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
| 559 | 581 | if ($this->_error) |
| 560 | 582 | { |
| 561 | 583 | // If this is a generic error, set it up good. |
| 562 | - if ($this->_error == 'cannot_') |
|
| 563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 584 | + if ($this->_error == 'cannot_') { |
|
| 585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 586 | + } |
|
| 564 | 587 | |
| 565 | 588 | // Is this request coming from an ajax call? |
| 566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
| 570 | 593 | } |
| 571 | 594 | |
| 572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
| 573 | - else |
|
| 574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 596 | + else { |
|
| 597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
| 598 | + } |
|
| 575 | 599 | |
| 576 | 600 | return; |
| 577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
| 580 | 604 | else |
| 581 | 605 | { |
| 582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
| 583 | - if (!$this->_js) |
|
| 584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 607 | + if (!$this->_js) { |
|
| 608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
| 609 | + } |
|
| 585 | 610 | |
| 586 | 611 | // These fine gentlemen all share the same template. |
| 587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -612,8 +637,9 @@ discard block |
||
| 612 | 637 | // If there is an error, send it. |
| 613 | 638 | if ($this->_error) |
| 614 | 639 | { |
| 615 | - if ($this->_error == 'cannot_') |
|
| 616 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 640 | + if ($this->_error == 'cannot_') { |
|
| 641 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
| 642 | + } |
|
| 617 | 643 | |
| 618 | 644 | $print['error'] = $this->_error; |
| 619 | 645 | } |
@@ -649,33 +675,36 @@ discard block |
||
| 649 | 675 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
| 650 | 676 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
| 651 | 677 | |
| 652 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
| 653 | - $_GET['verse'] = '4:16'; |
|
| 678 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
| 679 | + $_GET['verse'] = '4:16'; |
|
| 680 | + } |
|
| 654 | 681 | |
| 655 | - if ($_GET['verse'] == '2:18') |
|
| 656 | - echo ' |
|
| 682 | + if ($_GET['verse'] == '2:18') { |
|
| 683 | + echo ' |
|
| 657 | 684 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
| 658 | - elseif ($_GET['verse'] == '4:16') |
|
| 659 | - echo ' |
|
| 685 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 686 | + echo ' |
|
| 660 | 687 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
| 661 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 662 | - echo ' |
|
| 688 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 689 | + echo ' |
|
| 663 | 690 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
| 664 | 691 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
| 692 | + } |
|
| 665 | 693 | |
| 666 | 694 | echo ' |
| 667 | 695 | </div> |
| 668 | 696 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
| 669 | 697 | |
| 670 | - if ($_GET['verse'] == '2:18') |
|
| 671 | - echo ' |
|
| 698 | + if ($_GET['verse'] == '2:18') { |
|
| 699 | + echo ' |
|
| 672 | 700 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
| 673 | - elseif ($_GET['verse'] == '4:16') |
|
| 674 | - echo ' |
|
| 701 | + } elseif ($_GET['verse'] == '4:16') { |
|
| 702 | + echo ' |
|
| 675 | 703 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
| 676 | - elseif ($_GET['verse'] == '22:1-2') |
|
| 677 | - echo ' |
|
| 704 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
| 705 | + echo ' |
|
| 678 | 706 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
| 707 | + } |
|
| 679 | 708 | |
| 680 | 709 | echo ' |
| 681 | 710 | </div> |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 3 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * This is the notoriously defunct package manager..... :/. |
@@ -57,10 +58,11 @@ discard block |
||
| 57 | 58 | ); |
| 58 | 59 | |
| 59 | 60 | // Work out exactly who it is we are calling. |
| 60 | - if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) |
|
| 61 | - $context['sub_action'] = $_REQUEST['sa']; |
|
| 62 | - else |
|
| 63 | - $context['sub_action'] = 'browse'; |
|
| 61 | + if (isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']])) { |
|
| 62 | + $context['sub_action'] = $_REQUEST['sa']; |
|
| 63 | + } else { |
|
| 64 | + $context['sub_action'] = 'browse'; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | 67 | // Set up some tabs... |
| 66 | 68 | $context[$context['admin_menu_name']]['tab_data'] = array( |
@@ -82,8 +84,9 @@ discard block |
||
| 82 | 84 | ), |
| 83 | 85 | ); |
| 84 | 86 | |
| 85 | - if ($context['sub_action'] == 'browse') |
|
| 86 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 87 | + if ($context['sub_action'] == 'browse') { |
|
| 88 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
| 89 | + } |
|
| 87 | 90 | |
| 88 | 91 | call_integration_hook('integrate_manage_packages', array(&$subActions)); |
| 89 | 92 | |
@@ -99,8 +102,9 @@ discard block |
||
| 99 | 102 | global $boarddir, $txt, $context, $scripturl, $sourcedir, $packagesdir, $modSettings, $smcFunc, $settings; |
| 100 | 103 | |
| 101 | 104 | // You have to specify a file!! |
| 102 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 103 | - redirectexit('action=admin;area=packages'); |
|
| 105 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 106 | + redirectexit('action=admin;area=packages'); |
|
| 107 | + } |
|
| 104 | 108 | $context['filename'] = preg_replace('~[\.]+~', '.', $_REQUEST['package']); |
| 105 | 109 | |
| 106 | 110 | // Do we have an existing id, for uninstalls and the like. |
@@ -112,8 +116,9 @@ discard block |
||
| 112 | 116 | create_chmod_control(); |
| 113 | 117 | |
| 114 | 118 | // Make sure temp directory exists and is empty. |
| 115 | - if (file_exists($packagesdir . '/temp')) |
|
| 116 | - deltree($packagesdir . '/temp', false); |
|
| 119 | + if (file_exists($packagesdir . '/temp')) { |
|
| 120 | + deltree($packagesdir . '/temp', false); |
|
| 121 | + } |
|
| 117 | 122 | |
| 118 | 123 | if (!mktree($packagesdir . '/temp', 0755)) |
| 119 | 124 | { |
@@ -124,8 +129,9 @@ discard block |
||
| 124 | 129 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'], 'crash_on_error' => true)); |
| 125 | 130 | |
| 126 | 131 | deltree($packagesdir . '/temp', false); |
| 127 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
| 128 | - fatal_lang_error('package_cant_download', false); |
|
| 132 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
| 133 | + fatal_lang_error('package_cant_download', false); |
|
| 134 | + } |
|
| 129 | 135 | } |
| 130 | 136 | } |
| 131 | 137 | |
@@ -151,25 +157,26 @@ discard block |
||
| 151 | 157 | { |
| 152 | 158 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 153 | 159 | |
| 154 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 155 | - foreach ($context['extracted_files'] as $file) |
|
| 160 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 161 | + foreach ($context['extracted_files'] as $file) |
|
| 156 | 162 | if (basename($file['filename']) == 'package-info.xml') |
| 157 | 163 | { |
| 158 | 164 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 165 | + } |
|
| 159 | 166 | break; |
| 160 | 167 | } |
| 161 | 168 | |
| 162 | - if (!isset($context['base_path'])) |
|
| 163 | - $context['base_path'] = ''; |
|
| 164 | - } |
|
| 165 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 169 | + if (!isset($context['base_path'])) { |
|
| 170 | + $context['base_path'] = ''; |
|
| 171 | + } |
|
| 172 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 166 | 173 | { |
| 167 | 174 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 168 | 175 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 169 | 176 | $context['base_path'] = ''; |
| 177 | + } else { |
|
| 178 | + fatal_lang_error('no_access', false); |
|
| 170 | 179 | } |
| 171 | - else |
|
| 172 | - fatal_lang_error('no_access', false); |
|
| 173 | 180 | |
| 174 | 181 | // Load up any custom themes we may want to install into... |
| 175 | 182 | $request = $smcFunc['db_query']('', ' |
@@ -185,15 +192,17 @@ discard block |
||
| 185 | 192 | ) |
| 186 | 193 | ); |
| 187 | 194 | $theme_paths = array(); |
| 188 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 189 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 195 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 196 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 197 | + } |
|
| 190 | 198 | $smcFunc['db_free_result']($request); |
| 191 | 199 | |
| 192 | 200 | // Get the package info... |
| 193 | 201 | $packageInfo = getPackageInfo($context['filename']); |
| 194 | 202 | |
| 195 | - if (!is_array($packageInfo)) |
|
| 196 | - fatal_lang_error($packageInfo); |
|
| 203 | + if (!is_array($packageInfo)) { |
|
| 204 | + fatal_lang_error($packageInfo); |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | $packageInfo['filename'] = $context['filename']; |
| 199 | 208 | $context['package_name'] = isset($packageInfo['name']) ? $packageInfo['name'] : $context['filename']; |
@@ -227,18 +236,19 @@ discard block |
||
| 227 | 236 | $smcFunc['db_free_result']($request); |
| 228 | 237 | |
| 229 | 238 | $context['database_changes'] = array(); |
| 230 | - if (isset($packageInfo['uninstall']['database'])) |
|
| 231 | - $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 232 | - elseif (!empty($db_changes)) |
|
| 239 | + if (isset($packageInfo['uninstall']['database'])) { |
|
| 240 | + $context['database_changes'][] = $txt['execute_database_changes'] . ' - ' . $packageInfo['uninstall']['database']; |
|
| 241 | + } elseif (!empty($db_changes)) |
|
| 233 | 242 | { |
| 234 | 243 | foreach ($db_changes as $change) |
| 235 | 244 | { |
| 236 | - if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) |
|
| 237 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 238 | - elseif (isset($txt['package_db_' . $change[0]])) |
|
| 239 | - $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 240 | - else |
|
| 241 | - $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 245 | + if (isset($change[2]) && isset($txt['package_db_' . $change[0]])) { |
|
| 246 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1], $change[2]); |
|
| 247 | + } elseif (isset($txt['package_db_' . $change[0]])) { |
|
| 248 | + $context['database_changes'][] = sprintf($txt['package_db_' . $change[0]], $change[1]); |
|
| 249 | + } else { |
|
| 250 | + $context['database_changes'][] = $change[0] . '-' . $change[1] . (isset($change[2]) ? '-' . $change[2] : ''); |
|
| 251 | + } |
|
| 242 | 252 | } |
| 243 | 253 | } |
| 244 | 254 | |
@@ -265,31 +275,33 @@ discard block |
||
| 265 | 275 | $context['themes_locked'] = true; |
| 266 | 276 | |
| 267 | 277 | // Only let them uninstall themes it was installed into. |
| 268 | - foreach ($theme_paths as $id => $data) |
|
| 269 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 278 | + foreach ($theme_paths as $id => $data) { |
|
| 279 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 270 | 280 | unset($theme_paths[$id]); |
| 271 | - } |
|
| 272 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 281 | + } |
|
| 282 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 273 | 283 | { |
| 274 | 284 | // Look for an upgrade... |
| 275 | 285 | $actions = parsePackageInfo($packageInfo['xml'], true, 'upgrade', $old_version); |
| 276 | 286 | |
| 277 | 287 | // There was no upgrade.... |
| 278 | - if (empty($actions)) |
|
| 279 | - $context['is_installed'] = true; |
|
| 280 | - else |
|
| 288 | + if (empty($actions)) { |
|
| 289 | + $context['is_installed'] = true; |
|
| 290 | + } else |
|
| 281 | 291 | { |
| 282 | 292 | // Otherwise they can only upgrade themes from the first time around. |
| 283 | - foreach ($theme_paths as $id => $data) |
|
| 284 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 293 | + foreach ($theme_paths as $id => $data) { |
|
| 294 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 285 | 295 | unset($theme_paths[$id]); |
| 296 | + } |
|
| 286 | 297 | } |
| 298 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 299 | + $context['is_installed'] = true; |
|
| 287 | 300 | } |
| 288 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 289 | - $context['is_installed'] = true; |
|
| 290 | 301 | |
| 291 | - if (!isset($old_version) || $context['is_installed']) |
|
| 292 | - $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 302 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 303 | + $actions = parsePackageInfo($packageInfo['xml'], true, 'install'); |
|
| 304 | + } |
|
| 293 | 305 | |
| 294 | 306 | $context['actions'] = array(); |
| 295 | 307 | $context['ftp_needed'] = false; |
@@ -297,8 +309,9 @@ discard block |
||
| 297 | 309 | $chmod_files = array(); |
| 298 | 310 | |
| 299 | 311 | // no actions found, return so we can display an error |
| 300 | - if (empty($actions)) |
|
| 301 | - return; |
|
| 312 | + if (empty($actions)) { |
|
| 313 | + return; |
|
| 314 | + } |
|
| 302 | 315 | |
| 303 | 316 | // This will hold data about anything that can be installed in other themes. |
| 304 | 317 | $themeFinds = array( |
@@ -317,14 +330,14 @@ discard block |
||
| 317 | 330 | { |
| 318 | 331 | $chmod_files[] = $action['filename']; |
| 319 | 332 | continue; |
| 320 | - } |
|
| 321 | - elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 333 | + } elseif ($action['type'] == 'readme' || $action['type'] == 'license') |
|
| 322 | 334 | { |
| 323 | 335 | $type = 'package_' . $action['type']; |
| 324 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 325 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 326 | - elseif (file_exists($action['filename'])) |
|
| 327 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 336 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 337 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), "\n\r")); |
|
| 338 | + } elseif (file_exists($action['filename'])) { |
|
| 339 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
| 340 | + } |
|
| 328 | 341 | |
| 329 | 342 | if (!empty($action['parse_bbc'])) |
| 330 | 343 | { |
@@ -332,24 +345,24 @@ discard block |
||
| 332 | 345 | $context[$type] = preg_replace('~\[[/]?html\]~i', '', $context[$type]); |
| 333 | 346 | preparsecode($context[$type]); |
| 334 | 347 | $context[$type] = parse_bbc($context[$type]); |
| 348 | + } else { |
|
| 349 | + $context[$type] = nl2br($context[$type]); |
|
| 335 | 350 | } |
| 336 | - else |
|
| 337 | - $context[$type] = nl2br($context[$type]); |
|
| 338 | 351 | |
| 339 | 352 | continue; |
| 340 | 353 | } |
| 341 | 354 | // Don't show redirects. |
| 342 | - elseif ($action['type'] == 'redirect') |
|
| 343 | - continue; |
|
| 344 | - elseif ($action['type'] == 'error') |
|
| 355 | + elseif ($action['type'] == 'redirect') { |
|
| 356 | + continue; |
|
| 357 | + } elseif ($action['type'] == 'error') |
|
| 345 | 358 | { |
| 346 | 359 | $context['has_failure'] = true; |
| 347 | - if (isset($action['error_msg']) && isset($action['error_var'])) |
|
| 348 | - $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 349 | - elseif (isset($action['error_msg'])) |
|
| 350 | - $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 351 | - } |
|
| 352 | - elseif ($action['type'] == 'modification') |
|
| 360 | + if (isset($action['error_msg']) && isset($action['error_var'])) { |
|
| 361 | + $context['failure_details'] = sprintf($txt['package_will_fail_' . $action['error_msg']], $action['error_var']); |
|
| 362 | + } elseif (isset($action['error_msg'])) { |
|
| 363 | + $context['failure_details'] = isset($txt['package_will_fail_' . $action['error_msg']]) ? $txt['package_will_fail_' . $action['error_msg']] : $action['error_msg']; |
|
| 364 | + } |
|
| 365 | + } elseif ($action['type'] == 'modification') |
|
| 353 | 366 | { |
| 354 | 367 | if (!file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
| 355 | 368 | { |
@@ -361,52 +374,54 @@ discard block |
||
| 361 | 374 | 'description' => $txt['package_action_missing'], |
| 362 | 375 | 'failed' => true, |
| 363 | 376 | ); |
| 364 | - } |
|
| 365 | - else |
|
| 377 | + } else |
|
| 366 | 378 | { |
| 367 | 379 | |
| 368 | - if ($action['boardmod']) |
|
| 369 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 370 | - else |
|
| 371 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 380 | + if ($action['boardmod']) { |
|
| 381 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 382 | + } else { |
|
| 383 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), true, $action['reverse'], $theme_paths); |
|
| 384 | + } |
|
| 372 | 385 | |
| 373 | - if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') |
|
| 374 | - $mod_actions[0]['filename'] = $action['filename']; |
|
| 386 | + if (count($mod_actions) == 1 && isset($mod_actions[0]) && $mod_actions[0]['type'] == 'error' && $mod_actions[0]['filename'] == '-') { |
|
| 387 | + $mod_actions[0]['filename'] = $action['filename']; |
|
| 388 | + } |
|
| 375 | 389 | |
| 376 | 390 | foreach ($mod_actions as $key => $mod_action) |
| 377 | 391 | { |
| 378 | 392 | // Lets get the last section of the file name. |
| 379 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 380 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 381 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 382 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 383 | - else |
|
| 384 | - $actual_filename = $key; |
|
| 385 | - |
|
| 386 | - if ($mod_action['type'] == 'opened') |
|
| 387 | - $failed = false; |
|
| 388 | - elseif ($mod_action['type'] == 'failure') |
|
| 393 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 394 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 395 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 396 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 397 | + } else { |
|
| 398 | + $actual_filename = $key; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if ($mod_action['type'] == 'opened') { |
|
| 402 | + $failed = false; |
|
| 403 | + } elseif ($mod_action['type'] == 'failure') |
|
| 389 | 404 | { |
| 390 | - if (empty($mod_action['is_custom'])) |
|
| 391 | - $context['has_failure'] = true; |
|
| 405 | + if (empty($mod_action['is_custom'])) { |
|
| 406 | + $context['has_failure'] = true; |
|
| 407 | + } |
|
| 392 | 408 | $failed = true; |
| 393 | - } |
|
| 394 | - elseif ($mod_action['type'] == 'chmod') |
|
| 409 | + } elseif ($mod_action['type'] == 'chmod') |
|
| 395 | 410 | { |
| 396 | 411 | $chmod_files[] = $mod_action['filename']; |
| 397 | - } |
|
| 398 | - elseif ($mod_action['type'] == 'saved') |
|
| 412 | + } elseif ($mod_action['type'] == 'saved') |
|
| 399 | 413 | { |
| 400 | 414 | if (!empty($mod_action['is_custom'])) |
| 401 | 415 | { |
| 402 | - if (!isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 403 | - $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 416 | + if (!isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 417 | + $context['theme_actions'][$mod_action['is_custom']] = array( |
|
| 404 | 418 | 'name' => $theme_paths[$mod_action['is_custom']]['name'], |
| 405 | 419 | 'actions' => array(), |
| 406 | 420 | 'has_failure' => $failed, |
| 407 | 421 | ); |
| 408 | - else |
|
| 409 | - $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 422 | + } else { |
|
| 423 | + $context['theme_actions'][$mod_action['is_custom']]['has_failure'] |= $failed; |
|
| 424 | + } |
|
| 410 | 425 | |
| 411 | 426 | $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename] = array( |
| 412 | 427 | 'type' => $txt['execute_modification'], |
@@ -414,8 +429,7 @@ discard block |
||
| 414 | 429 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 415 | 430 | 'failed' => $failed, |
| 416 | 431 | ); |
| 417 | - } |
|
| 418 | - elseif (!isset($context['actions'][$actual_filename])) |
|
| 432 | + } elseif (!isset($context['actions'][$actual_filename])) |
|
| 419 | 433 | { |
| 420 | 434 | $context['actions'][$actual_filename] = array( |
| 421 | 435 | 'type' => $txt['execute_modification'], |
@@ -423,22 +437,19 @@ discard block |
||
| 423 | 437 | 'description' => $failed ? $txt['package_action_failure'] : $txt['package_action_success'], |
| 424 | 438 | 'failed' => $failed, |
| 425 | 439 | ); |
| 426 | - } |
|
| 427 | - else |
|
| 440 | + } else |
|
| 428 | 441 | { |
| 429 | 442 | $context['actions'][$actual_filename]['failed'] |= $failed; |
| 430 | 443 | $context['actions'][$actual_filename]['description'] = $context['actions'][$actual_filename]['failed'] ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 431 | 444 | } |
| 432 | - } |
|
| 433 | - elseif ($mod_action['type'] == 'skipping') |
|
| 445 | + } elseif ($mod_action['type'] == 'skipping') |
|
| 434 | 446 | { |
| 435 | 447 | $context['actions'][$actual_filename] = array( |
| 436 | 448 | 'type' => $txt['execute_modification'], |
| 437 | 449 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 438 | 450 | 'description' => $txt['package_action_skipping'] |
| 439 | 451 | ); |
| 440 | - } |
|
| 441 | - elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 452 | + } elseif ($mod_action['type'] == 'missing' && empty($mod_action['is_custom'])) |
|
| 442 | 453 | { |
| 443 | 454 | $context['has_failure'] = true; |
| 444 | 455 | $context['actions'][$actual_filename] = array( |
@@ -447,32 +458,33 @@ discard block |
||
| 447 | 458 | 'description' => $txt['package_action_missing'], |
| 448 | 459 | 'failed' => true, |
| 449 | 460 | ); |
| 450 | - } |
|
| 451 | - elseif ($mod_action['type'] == 'error') |
|
| 452 | - $context['actions'][$actual_filename] = array( |
|
| 461 | + } elseif ($mod_action['type'] == 'error') { |
|
| 462 | + $context['actions'][$actual_filename] = array( |
|
| 453 | 463 | 'type' => $txt['execute_modification'], |
| 454 | 464 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 455 | 465 | 'description' => $txt['package_action_error'], |
| 456 | 466 | 'failed' => true, |
| 457 | 467 | ); |
| 468 | + } |
|
| 458 | 469 | } |
| 459 | 470 | |
| 460 | 471 | // We need to loop again just to get the operations down correctly. |
| 461 | 472 | foreach ($mod_actions as $operation_key => $mod_action) |
| 462 | 473 | { |
| 463 | 474 | // Lets get the last section of the file name. |
| 464 | - if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') |
|
| 465 | - $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 466 | - elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) |
|
| 467 | - $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 468 | - else |
|
| 469 | - $actual_filename = $key; |
|
| 475 | + if (isset($mod_action['filename']) && substr($mod_action['filename'], -13) != '.template.php') { |
|
| 476 | + $actual_filename = strtolower(substr(strrchr($mod_action['filename'], '/'), 1) . '||' . $action['filename']); |
|
| 477 | + } elseif (isset($mod_action['filename']) && preg_match('~([\w]*)/([\w]*)\.template\.php$~', $mod_action['filename'], $matches)) { |
|
| 478 | + $actual_filename = strtolower($matches[1] . '/' . $matches[2] . '.template.php' . '||' . $action['filename']); |
|
| 479 | + } else { |
|
| 480 | + $actual_filename = $key; |
|
| 481 | + } |
|
| 470 | 482 | |
| 471 | 483 | // We just need it for actual parse changes. |
| 472 | 484 | if (!in_array($mod_action['type'], array('error', 'result', 'opened', 'saved', 'end', 'missing', 'skipping', 'chmod'))) |
| 473 | 485 | { |
| 474 | - if (empty($mod_action['is_custom'])) |
|
| 475 | - $context['actions'][$actual_filename]['operations'][] = array( |
|
| 486 | + if (empty($mod_action['is_custom'])) { |
|
| 487 | + $context['actions'][$actual_filename]['operations'][] = array( |
|
| 476 | 488 | 'type' => $txt['execute_modification'], |
| 477 | 489 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 478 | 490 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -483,10 +495,11 @@ discard block |
||
| 483 | 495 | 'failed' => $mod_action['failed'], |
| 484 | 496 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 485 | 497 | ); |
| 498 | + } |
|
| 486 | 499 | |
| 487 | 500 | // Themes are under the saved type. |
| 488 | - if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) |
|
| 489 | - $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 501 | + if (isset($mod_action['is_custom']) && isset($context['theme_actions'][$mod_action['is_custom']])) { |
|
| 502 | + $context['theme_actions'][$mod_action['is_custom']]['actions'][$actual_filename]['operations'][] = array( |
|
| 490 | 503 | 'type' => $txt['execute_modification'], |
| 491 | 504 | 'action' => $smcFunc['htmlspecialchars'](strtr($mod_action['filename'], array($boarddir => '.'))), |
| 492 | 505 | 'description' => $mod_action['failed'] ? $txt['package_action_failure'] : $txt['package_action_success'], |
@@ -497,59 +510,55 @@ discard block |
||
| 497 | 510 | 'failed' => $mod_action['failed'], |
| 498 | 511 | 'ignore_failure' => !empty($mod_action['ignore_failure']), |
| 499 | 512 | ); |
| 513 | + } |
|
| 500 | 514 | } |
| 501 | 515 | } |
| 502 | 516 | } |
| 503 | - } |
|
| 504 | - elseif ($action['type'] == 'code') |
|
| 517 | + } elseif ($action['type'] == 'code') |
|
| 505 | 518 | { |
| 506 | 519 | $thisAction = array( |
| 507 | 520 | 'type' => $txt['execute_code'], |
| 508 | 521 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 509 | 522 | ); |
| 510 | - } |
|
| 511 | - elseif ($action['type'] == 'database') |
|
| 523 | + } elseif ($action['type'] == 'database') |
|
| 512 | 524 | { |
| 513 | 525 | $thisAction = array( |
| 514 | 526 | 'type' => $txt['execute_database_changes'], |
| 515 | 527 | 'action' => $smcFunc['htmlspecialchars']($action['filename']), |
| 516 | 528 | ); |
| 517 | - } |
|
| 518 | - elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 529 | + } elseif (in_array($action['type'], array('create-dir', 'create-file'))) |
|
| 519 | 530 | { |
| 520 | 531 | $thisAction = array( |
| 521 | 532 | 'type' => $txt['package_create'] . ' ' . ($action['type'] == 'create-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 522 | 533 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 523 | 534 | ); |
| 524 | - } |
|
| 525 | - elseif ($action['type'] == 'hook') |
|
| 535 | + } elseif ($action['type'] == 'hook') |
|
| 526 | 536 | { |
| 527 | 537 | $action['description'] = !isset($action['hook'], $action['function']) ? $txt['package_action_failure'] : $txt['package_action_success']; |
| 528 | 538 | |
| 529 | - if (!isset($action['hook'], $action['function'])) |
|
| 530 | - $context['has_failure'] = true; |
|
| 539 | + if (!isset($action['hook'], $action['function'])) { |
|
| 540 | + $context['has_failure'] = true; |
|
| 541 | + } |
|
| 531 | 542 | |
| 532 | 543 | $thisAction = array( |
| 533 | 544 | 'type' => $action['reverse'] ? $txt['execute_hook_remove'] : $txt['execute_hook_add'], |
| 534 | 545 | 'action' => sprintf($txt['execute_hook_action' . ($action['reverse'] ? '_inverse' : '')], $smcFunc['htmlspecialchars']($action['hook'])), |
| 535 | 546 | ); |
| 536 | - } |
|
| 537 | - elseif ($action['type'] == 'credits') |
|
| 547 | + } elseif ($action['type'] == 'credits') |
|
| 538 | 548 | { |
| 539 | 549 | $thisAction = array( |
| 540 | 550 | 'type' => $txt['execute_credits_add'], |
| 541 | 551 | 'action' => sprintf($txt['execute_credits_action'], $smcFunc['htmlspecialchars']($action['title'])), |
| 542 | 552 | ); |
| 543 | - } |
|
| 544 | - elseif ($action['type'] == 'requires') |
|
| 553 | + } elseif ($action['type'] == 'requires') |
|
| 545 | 554 | { |
| 546 | 555 | $installed = false; |
| 547 | 556 | $version = true; |
| 548 | 557 | |
| 549 | 558 | // package missing required values? |
| 550 | - if (!isset($action['id'])) |
|
| 551 | - $context['has_failure'] = true; |
|
| 552 | - else |
|
| 559 | + if (!isset($action['id'])) { |
|
| 560 | + $context['has_failure'] = true; |
|
| 561 | + } else |
|
| 553 | 562 | { |
| 554 | 563 | // See if this dependancy is installed |
| 555 | 564 | $request = $smcFunc['db_query']('', ' |
@@ -565,8 +574,9 @@ discard block |
||
| 565 | 574 | ) |
| 566 | 575 | ); |
| 567 | 576 | $installed = ($smcFunc['db_num_rows']($request) !== 0); |
| 568 | - if ($installed) |
|
| 569 | - list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 577 | + if ($installed) { |
|
| 578 | + list ($version) = $smcFunc['db_fetch_row']($request); |
|
| 579 | + } |
|
| 570 | 580 | $smcFunc['db_free_result']($request); |
| 571 | 581 | |
| 572 | 582 | // do a version level check (if requested) in the most basic way |
@@ -581,8 +591,7 @@ discard block |
||
| 581 | 591 | 'type' => $txt['package_requires'], |
| 582 | 592 | 'action' => $txt['package_check_for'] . ' ' . $action['id'] . (isset($action['version']) ? (' / ' . ($version ? $action['version'] : '<span class="error">' . $action['version'] . '</span>')) : ''), |
| 583 | 593 | ); |
| 584 | - } |
|
| 585 | - elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 594 | + } elseif (in_array($action['type'], array('require-dir', 'require-file'))) |
|
| 586 | 595 | { |
| 587 | 596 | // Do this one... |
| 588 | 597 | $thisAction = array( |
@@ -596,26 +605,29 @@ discard block |
||
| 596 | 605 | // Is the action already stated? |
| 597 | 606 | $theme_action = !empty($action['theme_action']) && in_array($action['theme_action'], array('no', 'yes', 'auto')) ? $action['theme_action'] : 'auto'; |
| 598 | 607 | // If it's not auto do we think we have something we can act upon? |
| 599 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 600 | - $theme_action = ''; |
|
| 608 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 609 | + $theme_action = ''; |
|
| 610 | + } |
|
| 601 | 611 | // ... or if it's auto do we even want to do anything? |
| 602 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 603 | - $theme_action = ''; |
|
| 612 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 613 | + $theme_action = ''; |
|
| 614 | + } |
|
| 604 | 615 | |
| 605 | 616 | // So, we still want to do something? |
| 606 | - if ($theme_action != '') |
|
| 607 | - $themeFinds['candidates'][] = $action; |
|
| 617 | + if ($theme_action != '') { |
|
| 618 | + $themeFinds['candidates'][] = $action; |
|
| 619 | + } |
|
| 608 | 620 | // Otherwise is this is going into another theme record it. |
| 609 | - elseif ($matches[1] == 'themes_dir') |
|
| 610 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 621 | + elseif ($matches[1] == 'themes_dir') { |
|
| 622 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_destination']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 623 | + } |
|
| 611 | 624 | } |
| 612 | - } |
|
| 613 | - elseif (in_array($action['type'], array('move-dir', 'move-file'))) |
|
| 614 | - $thisAction = array( |
|
| 625 | + } elseif (in_array($action['type'], array('move-dir', 'move-file'))) { |
|
| 626 | + $thisAction = array( |
|
| 615 | 627 | 'type' => $txt['package_move'] . ' ' . ($action['type'] == 'move-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 616 | 628 | 'action' => $smcFunc['htmlspecialchars'](strtr($action['source'], array($boarddir => '.'))) . ' => ' . $smcFunc['htmlspecialchars'](strtr($action['destination'], array($boarddir => '.'))) |
| 617 | 629 | ); |
| 618 | - elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 630 | + } elseif (in_array($action['type'], array('remove-dir', 'remove-file'))) |
|
| 619 | 631 | { |
| 620 | 632 | $thisAction = array( |
| 621 | 633 | 'type' => $txt['package_delete'] . ' ' . ($action['type'] == 'remove-dir' ? $txt['package_tree'] : $txt['package_file']), |
@@ -631,30 +643,36 @@ discard block |
||
| 631 | 643 | $action['unparsed_destination'] = $action['unparsed_filename']; |
| 632 | 644 | |
| 633 | 645 | // If it's not auto do we think we have something we can act upon? |
| 634 | - if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) |
|
| 635 | - $theme_action = ''; |
|
| 646 | + if ($theme_action != 'auto' && !in_array($matches[1], array('languagedir', 'languages_dir', 'imagesdir', 'themedir'))) { |
|
| 647 | + $theme_action = ''; |
|
| 648 | + } |
|
| 636 | 649 | // ... or if it's auto do we even want to do anything? |
| 637 | - elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') |
|
| 638 | - $theme_action = ''; |
|
| 650 | + elseif ($theme_action == 'auto' && $matches[1] != 'imagesdir') { |
|
| 651 | + $theme_action = ''; |
|
| 652 | + } |
|
| 639 | 653 | |
| 640 | 654 | // So, we still want to do something? |
| 641 | - if ($theme_action != '') |
|
| 642 | - $themeFinds['candidates'][] = $action; |
|
| 655 | + if ($theme_action != '') { |
|
| 656 | + $themeFinds['candidates'][] = $action; |
|
| 657 | + } |
|
| 643 | 658 | // Otherwise is this is going into another theme record it. |
| 644 | - elseif ($matches[1] == 'themes_dir') |
|
| 645 | - $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 659 | + elseif ($matches[1] == 'themes_dir') { |
|
| 660 | + $themeFinds['other_themes'][] = strtolower(strtr(parse_path($action['unparsed_filename']), array('\\' => '/')) . '/' . basename($action['filename'])); |
|
| 661 | + } |
|
| 646 | 662 | } |
| 647 | 663 | } |
| 648 | 664 | |
| 649 | - if (empty($thisAction)) |
|
| 650 | - continue; |
|
| 665 | + if (empty($thisAction)) { |
|
| 666 | + continue; |
|
| 667 | + } |
|
| 651 | 668 | |
| 652 | 669 | if (!in_array($action['type'], array('hook', 'credits'))) |
| 653 | 670 | { |
| 654 | - if ($context['uninstalling']) |
|
| 655 | - $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 656 | - else |
|
| 657 | - $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 671 | + if ($context['uninstalling']) { |
|
| 672 | + $file = in_array($action['type'], array('remove-dir', 'remove-file')) ? $action['filename'] : $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 673 | + } else { |
|
| 674 | + $file = $packagesdir . '/temp/' . $context['base_path'] . $action['filename']; |
|
| 675 | + } |
|
| 658 | 676 | } |
| 659 | 677 | |
| 660 | 678 | // Don't fail if a file/directory we're trying to create doesn't exist... |
@@ -669,8 +687,9 @@ discard block |
||
| 669 | 687 | } |
| 670 | 688 | |
| 671 | 689 | // @todo None given? |
| 672 | - if (empty($thisAction['description'])) |
|
| 673 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 690 | + if (empty($thisAction['description'])) { |
|
| 691 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
| 692 | + } |
|
| 674 | 693 | |
| 675 | 694 | $context['actions'][] = $thisAction; |
| 676 | 695 | } |
@@ -683,18 +702,21 @@ discard block |
||
| 683 | 702 | // Get the part of the file we'll be dealing with. |
| 684 | 703 | preg_match('~^\$(languagedir|languages_dir|imagesdir|themedir)(\\|/)*(.+)*~i', $action_data['unparsed_destination'], $matches); |
| 685 | 704 | |
| 686 | - if ($matches[1] == 'imagesdir') |
|
| 687 | - $path = '/' . basename($settings['default_images_url']); |
|
| 688 | - elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') |
|
| 689 | - $path = '/languages'; |
|
| 690 | - else |
|
| 691 | - $path = ''; |
|
| 705 | + if ($matches[1] == 'imagesdir') { |
|
| 706 | + $path = '/' . basename($settings['default_images_url']); |
|
| 707 | + } elseif ($matches[1] == 'languagedir' || $matches[1] == 'languages_dir') { |
|
| 708 | + $path = '/languages'; |
|
| 709 | + } else { |
|
| 710 | + $path = ''; |
|
| 711 | + } |
|
| 692 | 712 | |
| 693 | - if (!empty($matches[3])) |
|
| 694 | - $path .= $matches[3]; |
|
| 713 | + if (!empty($matches[3])) { |
|
| 714 | + $path .= $matches[3]; |
|
| 715 | + } |
|
| 695 | 716 | |
| 696 | - if (!$context['uninstalling']) |
|
| 697 | - $path .= '/' . basename($action_data['filename']); |
|
| 717 | + if (!$context['uninstalling']) { |
|
| 718 | + $path .= '/' . basename($action_data['filename']); |
|
| 719 | + } |
|
| 698 | 720 | |
| 699 | 721 | // Loop through each custom theme to note it's candidacy! |
| 700 | 722 | foreach ($theme_paths as $id => $theme_data) |
@@ -710,36 +732,40 @@ discard block |
||
| 710 | 732 | if (!mktree(dirname($real_path), false)) |
| 711 | 733 | { |
| 712 | 734 | $temp = dirname($real_path); |
| 713 | - while (!file_exists($temp) && strlen($temp) > 1) |
|
| 714 | - $temp = dirname($temp); |
|
| 735 | + while (!file_exists($temp) && strlen($temp) > 1) { |
|
| 736 | + $temp = dirname($temp); |
|
| 737 | + } |
|
| 715 | 738 | $chmod_files[] = $temp; |
| 716 | 739 | } |
| 717 | 740 | |
| 718 | - if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) |
|
| 719 | - $chmod_files[] = $real_path; |
|
| 741 | + if ($action_data['type'] == 'require-dir' && !is_writable($real_path) && (file_exists($real_path) || !is_writable(dirname($real_path)))) { |
|
| 742 | + $chmod_files[] = $real_path; |
|
| 743 | + } |
|
| 720 | 744 | |
| 721 | - if (!isset($context['theme_actions'][$id])) |
|
| 722 | - $context['theme_actions'][$id] = array( |
|
| 745 | + if (!isset($context['theme_actions'][$id])) { |
|
| 746 | + $context['theme_actions'][$id] = array( |
|
| 723 | 747 | 'name' => $theme_data['name'], |
| 724 | 748 | 'actions' => array(), |
| 725 | 749 | ); |
| 750 | + } |
|
| 726 | 751 | |
| 727 | - if ($context['uninstalling']) |
|
| 728 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 752 | + if ($context['uninstalling']) { |
|
| 753 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 729 | 754 | 'type' => $txt['package_delete'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 730 | 755 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 731 | 756 | 'description' => '', |
| 732 | 757 | 'value' => base64_encode(json_encode(array('type' => $action_data['type'], 'orig' => $action_data['filename'], 'future' => $real_path, 'id' => $id))), |
| 733 | 758 | 'not_mod' => true, |
| 734 | 759 | ); |
| 735 | - else |
|
| 736 | - $context['theme_actions'][$id]['actions'][] = array( |
|
| 760 | + } else { |
|
| 761 | + $context['theme_actions'][$id]['actions'][] = array( |
|
| 737 | 762 | 'type' => $txt['package_extract'] . ' ' . ($action_data['type'] == 'require-dir' ? $txt['package_tree'] : $txt['package_file']), |
| 738 | 763 | 'action' => strtr($real_path, array('\\' => '/', $boarddir => '.')), |
| 739 | 764 | 'description' => '', |
| 740 | 765 | 'value' => base64_encode(json_encode(array('type' => $action_data['type'], 'orig' => $action_data['destination'], 'future' => $real_path, 'id' => $id))), |
| 741 | 766 | 'not_mod' => true, |
| 742 | 767 | ); |
| 768 | + } |
|
| 743 | 769 | } |
| 744 | 770 | } |
| 745 | 771 | } |
@@ -749,8 +775,9 @@ discard block |
||
| 749 | 775 | // Trash the cache... which will also check permissions for us! |
| 750 | 776 | package_flush_cache(true); |
| 751 | 777 | |
| 752 | - if (file_exists($packagesdir . '/temp')) |
|
| 753 | - deltree($packagesdir . '/temp'); |
|
| 778 | + if (file_exists($packagesdir . '/temp')) { |
|
| 779 | + deltree($packagesdir . '/temp'); |
|
| 780 | + } |
|
| 754 | 781 | |
| 755 | 782 | if (!empty($chmod_files)) |
| 756 | 783 | { |
@@ -775,8 +802,9 @@ discard block |
||
| 775 | 802 | checkSession(); |
| 776 | 803 | |
| 777 | 804 | // If there's no file, what are we installing? |
| 778 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 779 | - redirectexit('action=admin;area=packages'); |
|
| 805 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 806 | + redirectexit('action=admin;area=packages'); |
|
| 807 | + } |
|
| 780 | 808 | $context['filename'] = $_REQUEST['package']; |
| 781 | 809 | |
| 782 | 810 | // If this is an uninstall, we'll have an id. |
@@ -797,51 +825,55 @@ discard block |
||
| 797 | 825 | |
| 798 | 826 | $context['sub_template'] = 'extract_package'; |
| 799 | 827 | |
| 800 | - if (!file_exists($packagesdir . '/' . $context['filename'])) |
|
| 801 | - fatal_lang_error('package_no_file', false); |
|
| 828 | + if (!file_exists($packagesdir . '/' . $context['filename'])) { |
|
| 829 | + fatal_lang_error('package_no_file', false); |
|
| 830 | + } |
|
| 802 | 831 | |
| 803 | 832 | // Load up the package FTP information? |
| 804 | 833 | create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); |
| 805 | 834 | |
| 806 | 835 | // Make sure temp directory exists and is empty! |
| 807 | - if (file_exists($packagesdir . '/temp')) |
|
| 808 | - deltree($packagesdir . '/temp', false); |
|
| 809 | - else |
|
| 810 | - mktree($packagesdir . '/temp', 0777); |
|
| 836 | + if (file_exists($packagesdir . '/temp')) { |
|
| 837 | + deltree($packagesdir . '/temp', false); |
|
| 838 | + } else { |
|
| 839 | + mktree($packagesdir . '/temp', 0777); |
|
| 840 | + } |
|
| 811 | 841 | |
| 812 | 842 | // Let the unpacker do the work. |
| 813 | 843 | if (is_file($packagesdir . '/' . $context['filename'])) |
| 814 | 844 | { |
| 815 | 845 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 816 | 846 | |
| 817 | - if (!file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 818 | - foreach ($context['extracted_files'] as $file) |
|
| 847 | + if (!file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 848 | + foreach ($context['extracted_files'] as $file) |
|
| 819 | 849 | if (basename($file['filename']) == 'package-info.xml') |
| 820 | 850 | { |
| 821 | 851 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 852 | + } |
|
| 822 | 853 | break; |
| 823 | 854 | } |
| 824 | 855 | |
| 825 | - if (!isset($context['base_path'])) |
|
| 826 | - $context['base_path'] = ''; |
|
| 827 | - } |
|
| 828 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 856 | + if (!isset($context['base_path'])) { |
|
| 857 | + $context['base_path'] = ''; |
|
| 858 | + } |
|
| 859 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 829 | 860 | { |
| 830 | 861 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 831 | 862 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
| 832 | 863 | $context['base_path'] = ''; |
| 864 | + } else { |
|
| 865 | + fatal_lang_error('no_access', false); |
|
| 833 | 866 | } |
| 834 | - else |
|
| 835 | - fatal_lang_error('no_access', false); |
|
| 836 | 867 | |
| 837 | 868 | // Are we installing this into any custom themes? |
| 838 | 869 | $custom_themes = array(1); |
| 839 | 870 | $known_themes = explode(',', $modSettings['knownThemes']); |
| 840 | 871 | if (!empty($_POST['custom_theme'])) |
| 841 | 872 | { |
| 842 | - foreach ($_POST['custom_theme'] as $tid) |
|
| 843 | - if (in_array($tid, $known_themes)) |
|
| 873 | + foreach ($_POST['custom_theme'] as $tid) { |
|
| 874 | + if (in_array($tid, $known_themes)) |
|
| 844 | 875 | $custom_themes[] = (int) $tid; |
| 876 | + } |
|
| 845 | 877 | } |
| 846 | 878 | |
| 847 | 879 | // Now load up the paths of the themes that we need to know about. |
@@ -858,8 +890,9 @@ discard block |
||
| 858 | 890 | ); |
| 859 | 891 | $theme_paths = array(); |
| 860 | 892 | $themes_installed = array(1); |
| 861 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 862 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 893 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 894 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 895 | + } |
|
| 863 | 896 | $smcFunc['db_free_result']($request); |
| 864 | 897 | |
| 865 | 898 | // Are there any theme copying that we want to take place? |
@@ -871,11 +904,13 @@ discard block |
||
| 871 | 904 | { |
| 872 | 905 | foreach ($_POST['theme_changes'] as $change) |
| 873 | 906 | { |
| 874 | - if (empty($change)) |
|
| 875 | - continue; |
|
| 907 | + if (empty($change)) { |
|
| 908 | + continue; |
|
| 909 | + } |
|
| 876 | 910 | $theme_data = smf_json_decode(base64_decode($change), true); |
| 877 | - if (empty($theme_data['type'])) |
|
| 878 | - continue; |
|
| 911 | + if (empty($theme_data['type'])) { |
|
| 912 | + continue; |
|
| 913 | + } |
|
| 879 | 914 | |
| 880 | 915 | $themes_installed[] = $theme_data['id']; |
| 881 | 916 | $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; |
@@ -884,8 +919,9 @@ discard block |
||
| 884 | 919 | |
| 885 | 920 | // Get the package info... |
| 886 | 921 | $packageInfo = getPackageInfo($context['filename']); |
| 887 | - if (!is_array($packageInfo)) |
|
| 888 | - fatal_lang_error($packageInfo); |
|
| 922 | + if (!is_array($packageInfo)) { |
|
| 923 | + fatal_lang_error($packageInfo); |
|
| 924 | + } |
|
| 889 | 925 | |
| 890 | 926 | $packageInfo['filename'] = $context['filename']; |
| 891 | 927 | |
@@ -897,8 +933,9 @@ discard block |
||
| 897 | 933 | { |
| 898 | 934 | $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); |
| 899 | 935 | $result = package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); |
| 900 | - if (!$result) |
|
| 901 | - fatal_lang_error('could_not_package_backup', false); |
|
| 936 | + if (!$result) { |
|
| 937 | + fatal_lang_error('could_not_package_backup', false); |
|
| 938 | + } |
|
| 902 | 939 | } |
| 903 | 940 | |
| 904 | 941 | // The mod isn't installed.... unless proven otherwise. |
@@ -938,35 +975,38 @@ discard block |
||
| 938 | 975 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); |
| 939 | 976 | |
| 940 | 977 | // Gadzooks! There's no uninstaller at all!? |
| 941 | - if (empty($install_log)) |
|
| 942 | - fatal_lang_error('package_uninstall_cannot', false); |
|
| 978 | + if (empty($install_log)) { |
|
| 979 | + fatal_lang_error('package_uninstall_cannot', false); |
|
| 980 | + } |
|
| 943 | 981 | |
| 944 | 982 | // They can only uninstall from what it was originally installed into. |
| 945 | - foreach ($theme_paths as $id => $data) |
|
| 946 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 983 | + foreach ($theme_paths as $id => $data) { |
|
| 984 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 947 | 985 | unset($theme_paths[$id]); |
| 948 | - } |
|
| 949 | - elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 986 | + } |
|
| 987 | + } elseif (isset($old_version) && $old_version != $packageInfo['version']) |
|
| 950 | 988 | { |
| 951 | 989 | // Look for an upgrade... |
| 952 | 990 | $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $old_version); |
| 953 | 991 | |
| 954 | 992 | // There was no upgrade.... |
| 955 | - if (empty($install_log)) |
|
| 956 | - $context['is_installed'] = true; |
|
| 957 | - else |
|
| 993 | + if (empty($install_log)) { |
|
| 994 | + $context['is_installed'] = true; |
|
| 995 | + } else |
|
| 958 | 996 | { |
| 959 | 997 | // Upgrade previous themes only! |
| 960 | - foreach ($theme_paths as $id => $data) |
|
| 961 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 998 | + foreach ($theme_paths as $id => $data) { |
|
| 999 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 962 | 1000 | unset($theme_paths[$id]); |
| 1001 | + } |
|
| 963 | 1002 | } |
| 1003 | + } elseif (isset($old_version) && $old_version == $packageInfo['version']) { |
|
| 1004 | + $context['is_installed'] = true; |
|
| 964 | 1005 | } |
| 965 | - elseif (isset($old_version) && $old_version == $packageInfo['version']) |
|
| 966 | - $context['is_installed'] = true; |
|
| 967 | 1006 | |
| 968 | - if (!isset($old_version) || $context['is_installed']) |
|
| 969 | - $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1007 | + if (!isset($old_version) || $context['is_installed']) { |
|
| 1008 | + $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); |
|
| 1009 | + } |
|
| 970 | 1010 | |
| 971 | 1011 | $context['install_finished'] = false; |
| 972 | 1012 | |
@@ -983,37 +1023,39 @@ discard block |
||
| 983 | 1023 | |
| 984 | 1024 | if ($action['type'] == 'modification' && !empty($action['filename'])) |
| 985 | 1025 | { |
| 986 | - if ($action['boardmod']) |
|
| 987 | - $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 988 | - else |
|
| 989 | - $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1026 | + if ($action['boardmod']) { |
|
| 1027 | + $mod_actions = parseBoardMod(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1028 | + } else { |
|
| 1029 | + $mod_actions = parseModification(file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); |
|
| 1030 | + } |
|
| 990 | 1031 | |
| 991 | 1032 | // Any errors worth noting? |
| 992 | 1033 | foreach ($mod_actions as $key => $action) |
| 993 | 1034 | { |
| 994 | - if ($action['type'] == 'failure') |
|
| 995 | - $failed_steps[] = array( |
|
| 1035 | + if ($action['type'] == 'failure') { |
|
| 1036 | + $failed_steps[] = array( |
|
| 996 | 1037 | 'file' => $action['filename'], |
| 997 | 1038 | 'large_step' => $failed_count, |
| 998 | 1039 | 'sub_step' => $key, |
| 999 | 1040 | 'theme' => 1, |
| 1000 | 1041 | ); |
| 1042 | + } |
|
| 1001 | 1043 | |
| 1002 | 1044 | // Gather the themes we installed into. |
| 1003 | - if (!empty($action['is_custom'])) |
|
| 1004 | - $themes_installed[] = $action['is_custom']; |
|
| 1045 | + if (!empty($action['is_custom'])) { |
|
| 1046 | + $themes_installed[] = $action['is_custom']; |
|
| 1047 | + } |
|
| 1005 | 1048 | } |
| 1006 | - } |
|
| 1007 | - elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1049 | + } elseif ($action['type'] == 'code' && !empty($action['filename'])) |
|
| 1008 | 1050 | { |
| 1009 | 1051 | // This is just here as reference for what is available. |
| 1010 | 1052 | global $txt, $boarddir, $sourcedir, $modSettings, $context, $settings, $forum_version, $smcFunc; |
| 1011 | 1053 | |
| 1012 | 1054 | // Now include the file and be done with it ;). |
| 1013 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1014 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1015 | - } |
|
| 1016 | - elseif ($action['type'] == 'credits') |
|
| 1055 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1056 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1057 | + } |
|
| 1058 | + } elseif ($action['type'] == 'credits') |
|
| 1017 | 1059 | { |
| 1018 | 1060 | // Time to build the billboard |
| 1019 | 1061 | $credits_tag = array( |
@@ -1023,13 +1065,13 @@ discard block |
||
| 1023 | 1065 | 'copyright' => $action['copyright'], |
| 1024 | 1066 | 'title' => $action['title'], |
| 1025 | 1067 | ); |
| 1026 | - } |
|
| 1027 | - elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1068 | + } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) |
|
| 1028 | 1069 | { |
| 1029 | - if ($action['reverse']) |
|
| 1030 | - remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1031 | - else |
|
| 1032 | - add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1070 | + if ($action['reverse']) { |
|
| 1071 | + remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1072 | + } else { |
|
| 1073 | + add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); |
|
| 1074 | + } |
|
| 1033 | 1075 | } |
| 1034 | 1076 | // Only do the database changes on uninstall if requested. |
| 1035 | 1077 | elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) |
@@ -1042,8 +1084,9 @@ discard block |
||
| 1042 | 1084 | db_extend('packages'); |
| 1043 | 1085 | |
| 1044 | 1086 | // Let the file work its magic ;) |
| 1045 | - if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) |
|
| 1046 | - require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1087 | + if (file_exists($packagesdir . '/temp/' . $context['base_path'] . $action['filename'])) { |
|
| 1088 | + require($packagesdir . '/temp/' . $context['base_path'] . $action['filename']); |
|
| 1089 | + } |
|
| 1047 | 1090 | } |
| 1048 | 1091 | // Handle a redirect... |
| 1049 | 1092 | elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) |
@@ -1125,8 +1168,9 @@ discard block |
||
| 1125 | 1168 | reloadSettings(); |
| 1126 | 1169 | |
| 1127 | 1170 | // Any db changes from older version? |
| 1128 | - if (!empty($old_db_changes)) |
|
| 1129 | - $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1171 | + if (!empty($old_db_changes)) { |
|
| 1172 | + $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log); |
|
| 1173 | + } |
|
| 1130 | 1174 | |
| 1131 | 1175 | // If there are some database changes we might want to remove then filter them out. |
| 1132 | 1176 | if (!empty($db_package_log)) |
@@ -1142,22 +1186,24 @@ discard block |
||
| 1142 | 1186 | */ |
| 1143 | 1187 | function sort_table_first($a, $b) |
| 1144 | 1188 | { |
| 1145 | - if ($a[0] == $b[0]) |
|
| 1146 | - return 0; |
|
| 1189 | + if ($a[0] == $b[0]) { |
|
| 1190 | + return 0; |
|
| 1191 | + } |
|
| 1147 | 1192 | return $a[0] == 'remove_table' ? -1 : 1; |
| 1148 | 1193 | } |
| 1149 | 1194 | usort($db_package_log, 'sort_table_first'); |
| 1150 | 1195 | foreach ($db_package_log as $k => $log) |
| 1151 | 1196 | { |
| 1152 | - if ($log[0] == 'remove_table') |
|
| 1153 | - $tables[] = $log[1]; |
|
| 1154 | - elseif (in_array($log[1], $tables)) |
|
| 1155 | - unset($db_package_log[$k]); |
|
| 1197 | + if ($log[0] == 'remove_table') { |
|
| 1198 | + $tables[] = $log[1]; |
|
| 1199 | + } elseif (in_array($log[1], $tables)) { |
|
| 1200 | + unset($db_package_log[$k]); |
|
| 1201 | + } |
|
| 1156 | 1202 | } |
| 1157 | 1203 | $db_changes = json_encode($db_package_log); |
| 1204 | + } else { |
|
| 1205 | + $db_changes = ''; |
|
| 1158 | 1206 | } |
| 1159 | - else |
|
| 1160 | - $db_changes = ''; |
|
| 1161 | 1207 | |
| 1162 | 1208 | // What themes did we actually install? |
| 1163 | 1209 | $themes_installed = array_unique($themes_installed); |
@@ -1206,18 +1252,20 @@ discard block |
||
| 1206 | 1252 | |
| 1207 | 1253 | foreach ($db_changes as $change) |
| 1208 | 1254 | { |
| 1209 | - if ($change[0] == 'remove_table' && isset($change[1])) |
|
| 1210 | - $smcFunc['db_drop_table']($change[1]); |
|
| 1211 | - elseif ($change[0] == 'remove_column' && isset($change[2])) |
|
| 1212 | - $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1213 | - elseif ($change[0] == 'remove_index' && isset($change[2])) |
|
| 1214 | - $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1255 | + if ($change[0] == 'remove_table' && isset($change[1])) { |
|
| 1256 | + $smcFunc['db_drop_table']($change[1]); |
|
| 1257 | + } elseif ($change[0] == 'remove_column' && isset($change[2])) { |
|
| 1258 | + $smcFunc['db_remove_column']($change[1], $change[2]); |
|
| 1259 | + } elseif ($change[0] == 'remove_index' && isset($change[2])) { |
|
| 1260 | + $smcFunc['db_remove_index']($change[1], $change[2]); |
|
| 1261 | + } |
|
| 1215 | 1262 | } |
| 1216 | 1263 | } |
| 1217 | 1264 | |
| 1218 | 1265 | // Clean house... get rid of the evidence ;). |
| 1219 | - if (file_exists($packagesdir . '/temp')) |
|
| 1220 | - deltree($packagesdir . '/temp'); |
|
| 1266 | + if (file_exists($packagesdir . '/temp')) { |
|
| 1267 | + deltree($packagesdir . '/temp'); |
|
| 1268 | + } |
|
| 1221 | 1269 | |
| 1222 | 1270 | // Log what we just did. |
| 1223 | 1271 | logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => $smcFunc['htmlspecialchars']($packageInfo['name']), 'version' => $smcFunc['htmlspecialchars']($packageInfo['version'])), 'admin'); |
@@ -1239,8 +1287,9 @@ discard block |
||
| 1239 | 1287 | require_once($sourcedir . '/Subs-Package.php'); |
| 1240 | 1288 | |
| 1241 | 1289 | // No package? Show him or her the door. |
| 1242 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1243 | - redirectexit('action=admin;area=packages'); |
|
| 1290 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1291 | + redirectexit('action=admin;area=packages'); |
|
| 1292 | + } |
|
| 1244 | 1293 | |
| 1245 | 1294 | $context['linktree'][] = array( |
| 1246 | 1295 | 'url' => $scripturl . '?action=admin;area=packages;sa=list;package=' . $_REQUEST['package'], |
@@ -1253,11 +1302,12 @@ discard block |
||
| 1253 | 1302 | $context['filename'] = $_REQUEST['package']; |
| 1254 | 1303 | |
| 1255 | 1304 | // Let the unpacker do the work. |
| 1256 | - if (is_file($packagesdir . '/' . $context['filename'])) |
|
| 1257 | - $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1258 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1259 | - $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1260 | -} |
|
| 1305 | + if (is_file($packagesdir . '/' . $context['filename'])) { |
|
| 1306 | + $context['files'] = read_tgz_file($packagesdir . '/' . $context['filename'], null); |
|
| 1307 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) { |
|
| 1308 | + $context['files'] = listtree($packagesdir . '/' . $context['filename']); |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1261 | 1311 | |
| 1262 | 1312 | /** |
| 1263 | 1313 | * Display one of the files in a package. |
@@ -1269,22 +1319,25 @@ discard block |
||
| 1269 | 1319 | require_once($sourcedir . '/Subs-Package.php'); |
| 1270 | 1320 | |
| 1271 | 1321 | // No package? Show him or her the door. |
| 1272 | - if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') |
|
| 1273 | - redirectexit('action=admin;area=packages'); |
|
| 1322 | + if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { |
|
| 1323 | + redirectexit('action=admin;area=packages'); |
|
| 1324 | + } |
|
| 1274 | 1325 | |
| 1275 | 1326 | // No file? Show him or her the door. |
| 1276 | - if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') |
|
| 1277 | - redirectexit('action=admin;area=packages'); |
|
| 1327 | + if (!isset($_REQUEST['file']) || $_REQUEST['file'] == '') { |
|
| 1328 | + redirectexit('action=admin;area=packages'); |
|
| 1329 | + } |
|
| 1278 | 1330 | |
| 1279 | 1331 | $_REQUEST['package'] = preg_replace('~[\.]+~', '.', strtr($_REQUEST['package'], array('/' => '_', '\\' => '_'))); |
| 1280 | 1332 | $_REQUEST['file'] = preg_replace('~[\.]+~', '.', $_REQUEST['file']); |
| 1281 | 1333 | |
| 1282 | 1334 | if (isset($_REQUEST['raw'])) |
| 1283 | 1335 | { |
| 1284 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1285 | - echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1286 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1287 | - echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1336 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1337 | + echo read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true); |
|
| 1338 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1339 | + echo file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file']); |
|
| 1340 | + } |
|
| 1288 | 1341 | |
| 1289 | 1342 | obExit(false); |
| 1290 | 1343 | } |
@@ -1301,17 +1354,19 @@ discard block |
||
| 1301 | 1354 | $context['filename'] = $_REQUEST['file']; |
| 1302 | 1355 | |
| 1303 | 1356 | // Let the unpacker do the work.... but make sure we handle images properly. |
| 1304 | - if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) |
|
| 1305 | - $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1306 | - else |
|
| 1357 | + if (in_array(strtolower(strrchr($_REQUEST['file'], '.')), array('.bmp', '.gif', '.jpeg', '.jpg', '.png'))) { |
|
| 1358 | + $context['filedata'] = '<img src="' . $scripturl . '?action=admin;area=packages;sa=examine;package=' . $_REQUEST['package'] . ';file=' . $_REQUEST['file'] . ';raw" alt="' . $_REQUEST['file'] . '">'; |
|
| 1359 | + } else |
|
| 1307 | 1360 | { |
| 1308 | - if (is_file($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1309 | - $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1310 | - elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) |
|
| 1311 | - $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1361 | + if (is_file($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1362 | + $context['filedata'] = $smcFunc['htmlspecialchars'](read_tgz_file($packagesdir . '/' . $_REQUEST['package'], $_REQUEST['file'], true)); |
|
| 1363 | + } elseif (is_dir($packagesdir . '/' . $_REQUEST['package'])) { |
|
| 1364 | + $context['filedata'] = $smcFunc['htmlspecialchars'](file_get_contents($packagesdir . '/' . $_REQUEST['package'] . '/' . $_REQUEST['file'])); |
|
| 1365 | + } |
|
| 1312 | 1366 | |
| 1313 | - if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') |
|
| 1314 | - $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1367 | + if (strtolower(strrchr($_REQUEST['file'], '.')) == '.php') { |
|
| 1368 | + $context['filedata'] = highlight_php_code($context['filedata']); |
|
| 1369 | + } |
|
| 1315 | 1370 | } |
| 1316 | 1371 | } |
| 1317 | 1372 | |
@@ -1326,8 +1381,9 @@ discard block |
||
| 1326 | 1381 | checkSession('get'); |
| 1327 | 1382 | |
| 1328 | 1383 | // Ack, don't allow deletion of arbitrary files here, could become a security hole somehow! |
| 1329 | - if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') |
|
| 1330 | - redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1384 | + if (!isset($_GET['package']) || $_GET['package'] == 'index.php' || $_GET['package'] == 'backups') { |
|
| 1385 | + redirectexit('action=admin;area=packages;sa=browse'); |
|
| 1386 | + } |
|
| 1331 | 1387 | $_GET['package'] = preg_replace('~[\.]+~', '.', strtr($_GET['package'], array('/' => '_', '\\' => '_'))); |
| 1332 | 1388 | |
| 1333 | 1389 | // Can't delete what's not there. |
@@ -1335,9 +1391,9 @@ discard block |
||
| 1335 | 1391 | { |
| 1336 | 1392 | create_chmod_control(array($packagesdir . '/' . $_GET['package']), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=remove;package=' . $_GET['package'], 'crash_on_error' => true)); |
| 1337 | 1393 | |
| 1338 | - if (is_dir($packagesdir . '/' . $_GET['package'])) |
|
| 1339 | - deltree($packagesdir . '/' . $_GET['package']); |
|
| 1340 | - else |
|
| 1394 | + if (is_dir($packagesdir . '/' . $_GET['package'])) { |
|
| 1395 | + deltree($packagesdir . '/' . $_GET['package']); |
|
| 1396 | + } else |
|
| 1341 | 1397 | { |
| 1342 | 1398 | smf_chmod($packagesdir . '/' . $_GET['package'], 0777); |
| 1343 | 1399 | unlink($packagesdir . '/' . $_GET['package']); |
@@ -1385,8 +1441,9 @@ discard block |
||
| 1385 | 1441 | 'data' => array( |
| 1386 | 1442 | 'function' => function($package_md5) use ($type, &$context) |
| 1387 | 1443 | { |
| 1388 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1389 | - return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1444 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1445 | + return $context['available_' . $type . ''][$package_md5]['sort_id']; |
|
| 1446 | + } |
|
| 1390 | 1447 | }, |
| 1391 | 1448 | ), |
| 1392 | 1449 | 'sort' => array( |
@@ -1402,8 +1459,9 @@ discard block |
||
| 1402 | 1459 | 'data' => array( |
| 1403 | 1460 | 'function' => function($package_md5) use ($type, &$context) |
| 1404 | 1461 | { |
| 1405 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1406 | - return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1462 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1463 | + return $context['available_' . $type . ''][$package_md5]['name']; |
|
| 1464 | + } |
|
| 1407 | 1465 | }, |
| 1408 | 1466 | ), |
| 1409 | 1467 | 'sort' => array( |
@@ -1418,8 +1476,9 @@ discard block |
||
| 1418 | 1476 | 'data' => array( |
| 1419 | 1477 | 'function' => function($package_md5) use ($type, &$context) |
| 1420 | 1478 | { |
| 1421 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1422 | - return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1479 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1480 | + return $context['available_' . $type . ''][$package_md5]['version']; |
|
| 1481 | + } |
|
| 1423 | 1482 | }, |
| 1424 | 1483 | ), |
| 1425 | 1484 | 'sort' => array( |
@@ -1434,8 +1493,9 @@ discard block |
||
| 1434 | 1493 | 'data' => array( |
| 1435 | 1494 | 'function' => function($package_md5) use ($type, $txt, &$context) |
| 1436 | 1495 | { |
| 1437 | - if (isset($context['available_' . $type . ''][$package_md5])) |
|
| 1438 | - return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1496 | + if (isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1497 | + return !empty($context['available_' . $type . ''][$package_md5]['time_installed']) ? timeformat($context['available_' . $type . ''][$package_md5]['time_installed']) : $txt['not_applicable']; |
|
| 1498 | + } |
|
| 1439 | 1499 | }, |
| 1440 | 1500 | 'class' => 'smalltext', |
| 1441 | 1501 | ), |
@@ -1451,28 +1511,30 @@ discard block |
||
| 1451 | 1511 | 'data' => array( |
| 1452 | 1512 | 'function' => function($package_md5) use ($type, &$context, $scripturl, $txt) |
| 1453 | 1513 | { |
| 1454 | - if (!isset($context['available_' . $type . ''][$package_md5])) |
|
| 1455 | - return ''; |
|
| 1514 | + if (!isset($context['available_' . $type . ''][$package_md5])) { |
|
| 1515 | + return ''; |
|
| 1516 | + } |
|
| 1456 | 1517 | |
| 1457 | 1518 | // Rewrite shortcut |
| 1458 | 1519 | $package = $context['available_' . $type . ''][$package_md5]; |
| 1459 | 1520 | $return = ''; |
| 1460 | 1521 | |
| 1461 | - if ($package['can_uninstall']) |
|
| 1462 | - $return = ' |
|
| 1522 | + if ($package['can_uninstall']) { |
|
| 1523 | + $return = ' |
|
| 1463 | 1524 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['uninstall'] . '</a>'; |
| 1464 | - elseif ($package['can_emulate_uninstall']) |
|
| 1465 | - $return = ' |
|
| 1525 | + } elseif ($package['can_emulate_uninstall']) { |
|
| 1526 | + $return = ' |
|
| 1466 | 1527 | <a href="' . $scripturl . '?action=admin;area=packages;sa=uninstall;ve=' . $package['can_emulate_uninstall'] . ';package=' . $package['filename'] . ';pid=' . $package['installed_id'] . '" class="button">' . $txt['package_emulate_uninstall'] . ' ' . $package['can_emulate_uninstall'] . '</a>'; |
| 1467 | - elseif ($package['can_upgrade']) |
|
| 1468 | - $return = ' |
|
| 1528 | + } elseif ($package['can_upgrade']) { |
|
| 1529 | + $return = ' |
|
| 1469 | 1530 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['package_upgrade'] . '</a>'; |
| 1470 | - elseif ($package['can_install']) |
|
| 1471 | - $return = ' |
|
| 1531 | + } elseif ($package['can_install']) { |
|
| 1532 | + $return = ' |
|
| 1472 | 1533 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;package=' . $package['filename'] . '" class="button">' . $txt['install_mod'] . '</a>'; |
| 1473 | - elseif ($package['can_emulate_install']) |
|
| 1474 | - $return = ' |
|
| 1534 | + } elseif ($package['can_emulate_install']) { |
|
| 1535 | + $return = ' |
|
| 1475 | 1536 | <a href="' . $scripturl . '?action=admin;area=packages;sa=install;ve=' . $package['can_emulate_install'] . ';package=' . $package['filename'] . '" class="button">' . $txt['package_emulate_install'] . ' ' . $package['can_emulate_install'] . '</a>'; |
| 1537 | + } |
|
| 1476 | 1538 | |
| 1477 | 1539 | return $return . ' |
| 1478 | 1540 | <a href="' . $scripturl . '?action=admin;area=packages;sa=list;package=' . $package['filename'] . '" class="button">' . $txt['list_files'] . '</a> |
@@ -1537,12 +1599,14 @@ discard block |
||
| 1537 | 1599 | static $packages, $installed_mods; |
| 1538 | 1600 | |
| 1539 | 1601 | // Start things up |
| 1540 | - if (!isset($packages[$params])) |
|
| 1541 | - $packages[$params] = array(); |
|
| 1602 | + if (!isset($packages[$params])) { |
|
| 1603 | + $packages[$params] = array(); |
|
| 1604 | + } |
|
| 1542 | 1605 | |
| 1543 | 1606 | // We need the packages directory to be writable for this. |
| 1544 | - if (!@is_writable($packagesdir)) |
|
| 1545 | - create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1607 | + if (!@is_writable($packagesdir)) { |
|
| 1608 | + create_chmod_control(array($packagesdir), array('destination_url' => $scripturl . '?action=admin;area=packages', 'crash_on_error' => true)); |
|
| 1609 | + } |
|
| 1546 | 1610 | |
| 1547 | 1611 | $the_version = strtr($forum_version, array('SMF ' => '')); |
| 1548 | 1612 | |
@@ -1550,41 +1614,44 @@ discard block |
||
| 1550 | 1614 | if (isset($_GET['version_emulate']) && strtr($_GET['version_emulate'], array('SMF ' => '')) == $the_version) |
| 1551 | 1615 | { |
| 1552 | 1616 | unset($_SESSION['version_emulate']); |
| 1553 | - } |
|
| 1554 | - elseif (isset($_GET['version_emulate'])) |
|
| 1617 | + } elseif (isset($_GET['version_emulate'])) |
|
| 1555 | 1618 | { |
| 1556 | - if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) |
|
| 1557 | - unset($_SESSION['version_emulate']); |
|
| 1558 | - elseif ($_GET['version_emulate'] !== 0) |
|
| 1559 | - $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1619 | + if (($_GET['version_emulate'] === 0 || $_GET['version_emulate'] === $forum_version) && isset($_SESSION['version_emulate'])) { |
|
| 1620 | + unset($_SESSION['version_emulate']); |
|
| 1621 | + } elseif ($_GET['version_emulate'] !== 0) { |
|
| 1622 | + $_SESSION['version_emulate'] = strtr($_GET['version_emulate'], array('-' => ' ', '+' => ' ', 'SMF ' => '')); |
|
| 1623 | + } |
|
| 1560 | 1624 | } |
| 1561 | 1625 | if (!empty($_SESSION['version_emulate'])) |
| 1562 | 1626 | { |
| 1563 | 1627 | $context['forum_version'] = 'SMF ' . $_SESSION['version_emulate']; |
| 1564 | 1628 | $the_version = $_SESSION['version_emulate']; |
| 1565 | 1629 | } |
| 1566 | - if (isset($_SESSION['single_version_emulate'])) |
|
| 1567 | - unset($_SESSION['single_version_emulate']); |
|
| 1630 | + if (isset($_SESSION['single_version_emulate'])) { |
|
| 1631 | + unset($_SESSION['single_version_emulate']); |
|
| 1632 | + } |
|
| 1568 | 1633 | |
| 1569 | 1634 | if (empty($installed_mods)) |
| 1570 | 1635 | { |
| 1571 | 1636 | $instmods = loadInstalledPackages(); |
| 1572 | 1637 | $installed_mods = array(); |
| 1573 | 1638 | // Look through the list of installed mods... |
| 1574 | - foreach ($instmods as $installed_mod) |
|
| 1575 | - $installed_mods[$installed_mod['package_id']] = array( |
|
| 1639 | + foreach ($instmods as $installed_mod) { |
|
| 1640 | + $installed_mods[$installed_mod['package_id']] = array( |
|
| 1576 | 1641 | 'id' => $installed_mod['id'], |
| 1577 | 1642 | 'version' => $installed_mod['version'], |
| 1578 | 1643 | 'time_installed' => $installed_mod['time_installed'], |
| 1579 | 1644 | ); |
| 1645 | + } |
|
| 1580 | 1646 | |
| 1581 | 1647 | // Get a list of all the ids installed, so the latest packages won't include already installed ones. |
| 1582 | 1648 | $context['installed_mods'] = array_keys($installed_mods); |
| 1583 | 1649 | } |
| 1584 | 1650 | |
| 1585 | - if (empty($packages)) |
|
| 1586 | - foreach ($context['modification_types'] as $type) |
|
| 1651 | + if (empty($packages)) { |
|
| 1652 | + foreach ($context['modification_types'] as $type) |
|
| 1587 | 1653 | $packages[$type] = array(); |
| 1654 | + } |
|
| 1588 | 1655 | |
| 1589 | 1656 | if ($dir = @opendir($packagesdir)) |
| 1590 | 1657 | { |
@@ -1600,50 +1667,56 @@ discard block |
||
| 1600 | 1667 | |
| 1601 | 1668 | while ($package = readdir($dir)) |
| 1602 | 1669 | { |
| 1603 | - if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) |
|
| 1604 | - continue; |
|
| 1670 | + if ($package == '.' || $package == '..' || $package == 'temp' || (!(is_dir($packagesdir . '/' . $package) && file_exists($packagesdir . '/' . $package . '/package-info.xml')) && substr(strtolower($package), -7) != '.tar.gz' && substr(strtolower($package), -4) != '.tgz' && substr(strtolower($package), -4) != '.zip')) { |
|
| 1671 | + continue; |
|
| 1672 | + } |
|
| 1605 | 1673 | |
| 1606 | 1674 | $skip = false; |
| 1607 | - foreach ($context['modification_types'] as $type) |
|
| 1608 | - if (isset($context['available_' . $type][md5($package)])) |
|
| 1675 | + foreach ($context['modification_types'] as $type) { |
|
| 1676 | + if (isset($context['available_' . $type][md5($package)])) |
|
| 1609 | 1677 | $skip = true; |
| 1678 | + } |
|
| 1610 | 1679 | |
| 1611 | - if ($skip) |
|
| 1612 | - continue; |
|
| 1680 | + if ($skip) { |
|
| 1681 | + continue; |
|
| 1682 | + } |
|
| 1613 | 1683 | |
| 1614 | 1684 | // Skip directories or files that are named the same. |
| 1615 | 1685 | if (is_dir($packagesdir . '/' . $package)) |
| 1616 | 1686 | { |
| 1617 | - if (in_array($package, $dirs)) |
|
| 1618 | - continue; |
|
| 1687 | + if (in_array($package, $dirs)) { |
|
| 1688 | + continue; |
|
| 1689 | + } |
|
| 1619 | 1690 | $dirs[] = $package; |
| 1620 | - } |
|
| 1621 | - elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1691 | + } elseif (substr(strtolower($package), -7) == '.tar.gz') |
|
| 1622 | 1692 | { |
| 1623 | - if (in_array(substr($package, 0, -7), $dirs)) |
|
| 1624 | - continue; |
|
| 1693 | + if (in_array(substr($package, 0, -7), $dirs)) { |
|
| 1694 | + continue; |
|
| 1695 | + } |
|
| 1625 | 1696 | $dirs[] = substr($package, 0, -7); |
| 1626 | - } |
|
| 1627 | - elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1697 | + } elseif (substr(strtolower($package), -4) == '.zip' || substr(strtolower($package), -4) == '.tgz') |
|
| 1628 | 1698 | { |
| 1629 | - if (in_array(substr($package, 0, -4), $dirs)) |
|
| 1630 | - continue; |
|
| 1699 | + if (in_array(substr($package, 0, -4), $dirs)) { |
|
| 1700 | + continue; |
|
| 1701 | + } |
|
| 1631 | 1702 | $dirs[] = substr($package, 0, -4); |
| 1632 | 1703 | } |
| 1633 | 1704 | |
| 1634 | 1705 | $packageInfo = getPackageInfo($package); |
| 1635 | - if (!is_array($packageInfo)) |
|
| 1636 | - continue; |
|
| 1706 | + if (!is_array($packageInfo)) { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1637 | 1709 | |
| 1638 | 1710 | if (!empty($packageInfo)) |
| 1639 | 1711 | { |
| 1640 | 1712 | $packageInfo['installed_id'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['id'] : 0; |
| 1641 | 1713 | $packageInfo['time_installed'] = isset($installed_mods[$packageInfo['id']]) ? $installed_mods[$packageInfo['id']]['time_installed'] : 0; |
| 1642 | 1714 | |
| 1643 | - if (!isset($sort_id[$packageInfo['type']])) |
|
| 1644 | - $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1645 | - else |
|
| 1646 | - $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1715 | + if (!isset($sort_id[$packageInfo['type']])) { |
|
| 1716 | + $packageInfo['sort_id'] = $sort_id['unknown']; |
|
| 1717 | + } else { |
|
| 1718 | + $packageInfo['sort_id'] = $sort_id[$packageInfo['type']]; |
|
| 1719 | + } |
|
| 1647 | 1720 | |
| 1648 | 1721 | $packageInfo['is_installed'] = isset($installed_mods[$packageInfo['id']]); |
| 1649 | 1722 | $packageInfo['is_current'] = $packageInfo['is_installed'] && ($installed_mods[$packageInfo['id']]['version'] == $packageInfo['version']); |
@@ -1692,10 +1765,11 @@ discard block |
||
| 1692 | 1765 | foreach ($upgrades as $upgrade) |
| 1693 | 1766 | { |
| 1694 | 1767 | // Even if it is for this SMF, is it for the installed version of the mod? |
| 1695 | - if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) |
|
| 1696 | - if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1768 | + if (!$upgrade->exists('@for') || matchPackageVersion($the_version, $upgrade->fetch('@for'))) { |
|
| 1769 | + if (!$upgrade->exists('@from') || matchPackageVersion($installed_mods[$packageInfo['id']]['version'], $upgrade->fetch('@from'))) |
|
| 1697 | 1770 | { |
| 1698 | 1771 | $packageInfo['can_upgrade'] = true; |
| 1772 | + } |
|
| 1699 | 1773 | break; |
| 1700 | 1774 | } |
| 1701 | 1775 | } |
@@ -1772,10 +1846,11 @@ discard block |
||
| 1772 | 1846 | |
| 1773 | 1847 | if (isset($_GET['type']) && $_GET['type'] == $params) |
| 1774 | 1848 | { |
| 1775 | - if (isset($_GET['desc'])) |
|
| 1776 | - krsort($packages[$params]); |
|
| 1777 | - else |
|
| 1778 | - ksort($packages[$params]); |
|
| 1849 | + if (isset($_GET['desc'])) { |
|
| 1850 | + krsort($packages[$params]); |
|
| 1851 | + } else { |
|
| 1852 | + ksort($packages[$params]); |
|
| 1853 | + } |
|
| 1779 | 1854 | } |
| 1780 | 1855 | |
| 1781 | 1856 | return $packages[$params]; |
@@ -1804,10 +1879,11 @@ discard block |
||
| 1804 | 1879 | redirectexit('action=admin;area=packages;sa=options'); |
| 1805 | 1880 | } |
| 1806 | 1881 | |
| 1807 | - if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) |
|
| 1808 | - $default_username = $match[1]; |
|
| 1809 | - else |
|
| 1810 | - $default_username = ''; |
|
| 1882 | + if (preg_match('~^/home\d*/([^/]+?)/public_html~', $_SERVER['DOCUMENT_ROOT'], $match)) { |
|
| 1883 | + $default_username = $match[1]; |
|
| 1884 | + } else { |
|
| 1885 | + $default_username = ''; |
|
| 1886 | + } |
|
| 1811 | 1887 | |
| 1812 | 1888 | $context['page_title'] = $txt['package_settings']; |
| 1813 | 1889 | $context['sub_template'] = 'install_options'; |
@@ -1836,8 +1912,9 @@ discard block |
||
| 1836 | 1912 | isAllowedTo('admin_forum'); |
| 1837 | 1913 | |
| 1838 | 1914 | // We need to know the operation key for the search and replace, mod file looking at, is it a board mod? |
| 1839 | - if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) |
|
| 1840 | - fatal_lang_error('operation_invalid', 'general'); |
|
| 1915 | + if (!isset($_REQUEST['operation_key'], $_REQUEST['filename']) && !is_numeric($_REQUEST['operation_key'])) { |
|
| 1916 | + fatal_lang_error('operation_invalid', 'general'); |
|
| 1917 | + } |
|
| 1841 | 1918 | |
| 1842 | 1919 | // Load the required file. |
| 1843 | 1920 | require_once($sourcedir . '/Subs-Package.php'); |
@@ -1853,18 +1930,19 @@ discard block |
||
| 1853 | 1930 | { |
| 1854 | 1931 | $context['extracted_files'] = read_tgz_file($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1855 | 1932 | |
| 1856 | - if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
| 1857 | - foreach ($context['extracted_files'] as $file) |
|
| 1933 | + if ($context['extracted_files'] && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
| 1934 | + foreach ($context['extracted_files'] as $file) |
|
| 1858 | 1935 | if (basename($file['filename']) == 'package-info.xml') |
| 1859 | 1936 | { |
| 1860 | 1937 | $context['base_path'] = dirname($file['filename']) . '/'; |
| 1938 | + } |
|
| 1861 | 1939 | break; |
| 1862 | 1940 | } |
| 1863 | 1941 | |
| 1864 | - if (!isset($context['base_path'])) |
|
| 1865 | - $context['base_path'] = ''; |
|
| 1866 | - } |
|
| 1867 | - elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1942 | + if (!isset($context['base_path'])) { |
|
| 1943 | + $context['base_path'] = ''; |
|
| 1944 | + } |
|
| 1945 | + } elseif (is_dir($packagesdir . '/' . $context['filename'])) |
|
| 1868 | 1946 | { |
| 1869 | 1947 | copytree($packagesdir . '/' . $context['filename'], $packagesdir . '/temp'); |
| 1870 | 1948 | $context['extracted_files'] = listtree($packagesdir . '/temp'); |
@@ -1885,8 +1963,9 @@ discard block |
||
| 1885 | 1963 | ) |
| 1886 | 1964 | ); |
| 1887 | 1965 | $theme_paths = array(); |
| 1888 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1889 | - $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1966 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1967 | + $theme_paths[$row['id_theme']][$row['variable']] = $row['value']; |
|
| 1968 | + } |
|
| 1890 | 1969 | $smcFunc['db_free_result']($request); |
| 1891 | 1970 | |
| 1892 | 1971 | // If we're viewing uninstall operations, only consider themes that |
@@ -1911,19 +1990,21 @@ discard block |
||
| 1911 | 1990 | list ($old_themes) = $smcFunc['db_fetch_row']($request); |
| 1912 | 1991 | $old_themes = explode(',', $old_themes); |
| 1913 | 1992 | |
| 1914 | - foreach ($theme_paths as $id => $data) |
|
| 1915 | - if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1993 | + foreach ($theme_paths as $id => $data) { |
|
| 1994 | + if ($id != 1 && !in_array($id, $old_themes)) |
|
| 1916 | 1995 | unset($theme_paths[$id]); |
| 1996 | + } |
|
| 1917 | 1997 | } |
| 1918 | 1998 | $smcFunc['db_free_result']($request); |
| 1919 | 1999 | } |
| 1920 | 2000 | } |
| 1921 | 2001 | |
| 1922 | 2002 | // Boardmod? |
| 1923 | - if (isset($_REQUEST['boardmod'])) |
|
| 1924 | - $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 1925 | - else |
|
| 1926 | - $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2003 | + if (isset($_REQUEST['boardmod'])) { |
|
| 2004 | + $mod_actions = parseBoardMod(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2005 | + } else { |
|
| 2006 | + $mod_actions = parseModification(@file_get_contents($packagesdir . '/temp/' . $context['base_path'] . $_REQUEST['filename']), true, $reverse, $theme_paths); |
|
| 2007 | + } |
|
| 1927 | 2008 | |
| 1928 | 2009 | // Ok lets get the content of the file. |
| 1929 | 2010 | $context['operations'] = array( |
@@ -1979,9 +2060,9 @@ discard block |
||
| 1979 | 2060 | 'path' => $detect_path, |
| 1980 | 2061 | 'form_elements_only' => true, |
| 1981 | 2062 | ); |
| 2063 | + } else { |
|
| 2064 | + $context['ftp_connected'] = true; |
|
| 1982 | 2065 | } |
| 1983 | - else |
|
| 1984 | - $context['ftp_connected'] = true; |
|
| 1985 | 2066 | |
| 1986 | 2067 | // Define the template. |
| 1987 | 2068 | $context['page_title'] = $txt['package_file_perms']; |
@@ -2094,18 +2175,19 @@ discard block |
||
| 2094 | 2175 | { |
| 2095 | 2176 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2096 | 2177 | |
| 2097 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
| 2098 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 2178 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
| 2179 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
| 2180 | + } |
|
| 2099 | 2181 | |
| 2100 | 2182 | // @todo Should we suggest non-current directories be read only? |
| 2101 | - foreach ($modSettings['attachmentUploadDir'] as $dir) |
|
| 2102 | - $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2183 | + foreach ($modSettings['attachmentUploadDir'] as $dir) { |
|
| 2184 | + $context['file_tree'][strtr($dir, array('\\' => '/'))] = array( |
|
| 2103 | 2185 | 'type' => 'dir', |
| 2104 | 2186 | 'writable_on' => 'restrictive', |
| 2105 | 2187 | ); |
| 2188 | + } |
|
| 2106 | 2189 | |
| 2107 | - } |
|
| 2108 | - elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2190 | + } elseif (substr($modSettings['attachmentUploadDir'], 0, strlen($boarddir)) != $boarddir) |
|
| 2109 | 2191 | { |
| 2110 | 2192 | unset($context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['attachments']); |
| 2111 | 2193 | $context['file_tree'][strtr($modSettings['attachmentUploadDir'], array('\\' => '/'))] = array( |
@@ -2155,8 +2237,8 @@ discard block |
||
| 2155 | 2237 | ); |
| 2156 | 2238 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2157 | 2239 | { |
| 2158 | - if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) |
|
| 2159 | - $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2240 | + if (substr(strtolower(strtr($row['value'], array('\\' => '/'))), 0, strlen($boarddir) + 7) == strtolower(strtr($boarddir, array('\\' => '/')) . '/Themes')) { |
|
| 2241 | + $context['file_tree'][strtr($boarddir, array('\\' => '/'))]['contents']['Themes']['contents'][substr($row['value'], strlen($boarddir) + 8)] = array( |
|
| 2160 | 2242 | 'type' => 'dir_recursive', |
| 2161 | 2243 | 'list_contents' => true, |
| 2162 | 2244 | 'contents' => array( |
@@ -2166,7 +2248,7 @@ discard block |
||
| 2166 | 2248 | ), |
| 2167 | 2249 | ), |
| 2168 | 2250 | ); |
| 2169 | - else |
|
| 2251 | + } else |
|
| 2170 | 2252 | { |
| 2171 | 2253 | $context['file_tree'][strtr($row['value'], array('\\' => '/'))] = array( |
| 2172 | 2254 | 'type' => 'dir_recursive', |
@@ -2183,28 +2265,33 @@ discard block |
||
| 2183 | 2265 | $smcFunc['db_free_result']($request); |
| 2184 | 2266 | |
| 2185 | 2267 | // If we're submitting then let's move on to another function to keep things cleaner.. |
| 2186 | - if (isset($_POST['action_changes'])) |
|
| 2187 | - return PackagePermissionsAction(); |
|
| 2268 | + if (isset($_POST['action_changes'])) { |
|
| 2269 | + return PackagePermissionsAction(); |
|
| 2270 | + } |
|
| 2188 | 2271 | |
| 2189 | 2272 | $context['look_for'] = array(); |
| 2190 | 2273 | // Are we looking for a particular tree - normally an expansion? |
| 2191 | - if (!empty($_REQUEST['find'])) |
|
| 2192 | - $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2274 | + if (!empty($_REQUEST['find'])) { |
|
| 2275 | + $context['look_for'][] = base64_decode($_REQUEST['find']); |
|
| 2276 | + } |
|
| 2193 | 2277 | // Only that tree? |
| 2194 | 2278 | $context['only_find'] = isset($_GET['xml']) && !empty($_REQUEST['onlyfind']) ? $_REQUEST['onlyfind'] : ''; |
| 2195 | - if ($context['only_find']) |
|
| 2196 | - $context['look_for'][] = $context['only_find']; |
|
| 2279 | + if ($context['only_find']) { |
|
| 2280 | + $context['look_for'][] = $context['only_find']; |
|
| 2281 | + } |
|
| 2197 | 2282 | |
| 2198 | 2283 | // Have we got a load of back-catalogue trees to expand from a submit etc? |
| 2199 | 2284 | if (!empty($_GET['back_look'])) |
| 2200 | 2285 | { |
| 2201 | 2286 | $potententialTrees = smf_json_decode(base64_decode($_GET['back_look']), true); |
| 2202 | - foreach ($potententialTrees as $tree) |
|
| 2203 | - $context['look_for'][] = $tree; |
|
| 2287 | + foreach ($potententialTrees as $tree) { |
|
| 2288 | + $context['look_for'][] = $tree; |
|
| 2289 | + } |
|
| 2204 | 2290 | } |
| 2205 | 2291 | // ... maybe posted? |
| 2206 | - if (!empty($_POST['back_look'])) |
|
| 2207 | - $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2292 | + if (!empty($_POST['back_look'])) { |
|
| 2293 | + $context['only_find'] = array_merge($context['only_find'], $_POST['back_look']); |
|
| 2294 | + } |
|
| 2208 | 2295 | |
| 2209 | 2296 | $context['back_look_data'] = base64_encode(json_encode(array_slice($context['look_for'], 0, 15))); |
| 2210 | 2297 | |
@@ -2243,9 +2330,9 @@ discard block |
||
| 2243 | 2330 | 'chmod' => @is_writable($path), |
| 2244 | 2331 | 'perms' => @fileperms($path), |
| 2245 | 2332 | ); |
| 2333 | + } else { |
|
| 2334 | + unset($context['file_tree'][$path]); |
|
| 2246 | 2335 | } |
| 2247 | - else |
|
| 2248 | - unset($context['file_tree'][$path]); |
|
| 2249 | 2336 | } |
| 2250 | 2337 | |
| 2251 | 2338 | // Is this actually xml? |
@@ -2269,22 +2356,25 @@ discard block |
||
| 2269 | 2356 | global $context; |
| 2270 | 2357 | |
| 2271 | 2358 | $isLikelyPath = false; |
| 2272 | - foreach ($context['look_for'] as $possiblePath) |
|
| 2273 | - if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2359 | + foreach ($context['look_for'] as $possiblePath) { |
|
| 2360 | + if (substr($possiblePath, 0, strlen($path)) == $path) |
|
| 2274 | 2361 | $isLikelyPath = true; |
| 2362 | + } |
|
| 2275 | 2363 | |
| 2276 | 2364 | // Is this where we stop? |
| 2277 | - if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) |
|
| 2278 | - return; |
|
| 2279 | - elseif ($level > $context['default_level'] && !$isLikelyPath) |
|
| 2280 | - return; |
|
| 2365 | + if (isset($_GET['xml']) && !empty($context['look_for']) && !$isLikelyPath) { |
|
| 2366 | + return; |
|
| 2367 | + } elseif ($level > $context['default_level'] && !$isLikelyPath) { |
|
| 2368 | + return; |
|
| 2369 | + } |
|
| 2281 | 2370 | |
| 2282 | 2371 | // Are we actually interested in saving this data? |
| 2283 | 2372 | $save_data = empty($context['only_find']) || $context['only_find'] == $path; |
| 2284 | 2373 | |
| 2285 | 2374 | // @todo Shouldn't happen - but better error message? |
| 2286 | - if (!is_dir($path)) |
|
| 2287 | - fatal_lang_error('no_access', false); |
|
| 2375 | + if (!is_dir($path)) { |
|
| 2376 | + fatal_lang_error('no_access', false); |
|
| 2377 | + } |
|
| 2288 | 2378 | |
| 2289 | 2379 | // This is where we put stuff we've found for sorting. |
| 2290 | 2380 | $foundData = array( |
@@ -2299,11 +2389,13 @@ discard block |
||
| 2299 | 2389 | if (is_file($path . '/' . $entry)) |
| 2300 | 2390 | { |
| 2301 | 2391 | // Are we listing PHP files in this directory? |
| 2302 | - if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') |
|
| 2303 | - $foundData['files'][$entry] = true; |
|
| 2392 | + if ($save_data && !empty($data['list_contents']) && substr($entry, -4) == '.php') { |
|
| 2393 | + $foundData['files'][$entry] = true; |
|
| 2394 | + } |
|
| 2304 | 2395 | // A file we were looking for. |
| 2305 | - elseif ($save_data && isset($data['contents'][$entry])) |
|
| 2306 | - $foundData['files'][$entry] = true; |
|
| 2396 | + elseif ($save_data && isset($data['contents'][$entry])) { |
|
| 2397 | + $foundData['files'][$entry] = true; |
|
| 2398 | + } |
|
| 2307 | 2399 | } |
| 2308 | 2400 | // It's a directory - we're interested one way or another, probably... |
| 2309 | 2401 | elseif ($entry != '.' && $entry != '..') |
@@ -2311,32 +2403,36 @@ discard block |
||
| 2311 | 2403 | // Going further? |
| 2312 | 2404 | if ((!empty($data['type']) && $data['type'] == 'dir_recursive') || (isset($data['contents'][$entry]) && (!empty($data['contents'][$entry]['list_contents']) || (!empty($data['contents'][$entry]['type']) && $data['contents'][$entry]['type'] == 'dir_recursive')))) |
| 2313 | 2405 | { |
| 2314 | - if (!isset($data['contents'][$entry])) |
|
| 2315 | - $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2316 | - else |
|
| 2317 | - $foundData['folders'][$entry] = true; |
|
| 2406 | + if (!isset($data['contents'][$entry])) { |
|
| 2407 | + $foundData['folders'][$entry] = 'dir_recursive'; |
|
| 2408 | + } else { |
|
| 2409 | + $foundData['folders'][$entry] = true; |
|
| 2410 | + } |
|
| 2318 | 2411 | |
| 2319 | 2412 | // If this wasn't expected inherit the recusiveness... |
| 2320 | - if (!isset($data['contents'][$entry])) |
|
| 2321 | - // We need to do this as we will be going all recursive. |
|
| 2413 | + if (!isset($data['contents'][$entry])) { |
|
| 2414 | + // We need to do this as we will be going all recursive. |
|
| 2322 | 2415 | $data['contents'][$entry] = array( |
| 2323 | 2416 | 'type' => 'dir_recursive', |
| 2324 | 2417 | ); |
| 2418 | + } |
|
| 2325 | 2419 | |
| 2326 | 2420 | // Actually do the recursive stuff... |
| 2327 | 2421 | fetchPerms__recursive($path . '/' . $entry, $data['contents'][$entry], $level + 1); |
| 2328 | 2422 | } |
| 2329 | 2423 | // Maybe it is a folder we are not descending into. |
| 2330 | - elseif (isset($data['contents'][$entry])) |
|
| 2331 | - $foundData['folders'][$entry] = true; |
|
| 2424 | + elseif (isset($data['contents'][$entry])) { |
|
| 2425 | + $foundData['folders'][$entry] = true; |
|
| 2426 | + } |
|
| 2332 | 2427 | // Otherwise we stop here. |
| 2333 | 2428 | } |
| 2334 | 2429 | } |
| 2335 | 2430 | closedir($dh); |
| 2336 | 2431 | |
| 2337 | 2432 | // Nothing to see here? |
| 2338 | - if (!$save_data) |
|
| 2339 | - return; |
|
| 2433 | + if (!$save_data) { |
|
| 2434 | + return; |
|
| 2435 | + } |
|
| 2340 | 2436 | |
| 2341 | 2437 | // Now actually add the data, starting with the folders. |
| 2342 | 2438 | ksort($foundData['folders']); |
@@ -2348,8 +2444,9 @@ discard block |
||
| 2348 | 2444 | 'perms' => @fileperms($path . '/' . $folder), |
| 2349 | 2445 | ), |
| 2350 | 2446 | ); |
| 2351 | - if ($type !== true) |
|
| 2352 | - $additional_data['type'] = $type; |
|
| 2447 | + if ($type !== true) { |
|
| 2448 | + $additional_data['type'] = $type; |
|
| 2449 | + } |
|
| 2353 | 2450 | |
| 2354 | 2451 | // If there's an offset ignore any folders in XML mode. |
| 2355 | 2452 | if (isset($_GET['xml']) && $context['file_offset'] == 0) |
@@ -2368,13 +2465,13 @@ discard block |
||
| 2368 | 2465 | ), |
| 2369 | 2466 | 'value' => $folder, |
| 2370 | 2467 | ); |
| 2371 | - } |
|
| 2372 | - elseif (!isset($_GET['xml'])) |
|
| 2468 | + } elseif (!isset($_GET['xml'])) |
|
| 2373 | 2469 | { |
| 2374 | - if (isset($data['contents'][$folder])) |
|
| 2375 | - $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2376 | - else |
|
| 2377 | - $data['contents'][$folder] = $additional_data; |
|
| 2470 | + if (isset($data['contents'][$folder])) { |
|
| 2471 | + $data['contents'][$folder] = array_merge($data['contents'][$folder], $additional_data); |
|
| 2472 | + } else { |
|
| 2473 | + $data['contents'][$folder] = $additional_data; |
|
| 2474 | + } |
|
| 2378 | 2475 | } |
| 2379 | 2476 | } |
| 2380 | 2477 | |
@@ -2386,11 +2483,13 @@ discard block |
||
| 2386 | 2483 | $counter++; |
| 2387 | 2484 | |
| 2388 | 2485 | // Have we reached our offset? |
| 2389 | - if ($context['file_offset'] > $counter) |
|
| 2390 | - continue; |
|
| 2486 | + if ($context['file_offset'] > $counter) { |
|
| 2487 | + continue; |
|
| 2488 | + } |
|
| 2391 | 2489 | // Gone too far? |
| 2392 | - if ($counter > ($context['file_offset'] + $context['file_limit'])) |
|
| 2393 | - continue; |
|
| 2490 | + if ($counter > ($context['file_offset'] + $context['file_limit'])) { |
|
| 2491 | + continue; |
|
| 2492 | + } |
|
| 2394 | 2493 | |
| 2395 | 2494 | $additional_data = array( |
| 2396 | 2495 | 'perms' => array( |
@@ -2416,13 +2515,13 @@ discard block |
||
| 2416 | 2515 | ), |
| 2417 | 2516 | 'value' => $file, |
| 2418 | 2517 | ); |
| 2419 | - } |
|
| 2420 | - elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2518 | + } elseif ($counter != ($context['file_offset'] + $context['file_limit'])) |
|
| 2421 | 2519 | { |
| 2422 | - if (isset($data['contents'][$file])) |
|
| 2423 | - $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2424 | - else |
|
| 2425 | - $data['contents'][$file] = $additional_data; |
|
| 2520 | + if (isset($data['contents'][$file])) { |
|
| 2521 | + $data['contents'][$file] = array_merge($data['contents'][$file], $additional_data); |
|
| 2522 | + } else { |
|
| 2523 | + $data['contents'][$file] = $additional_data; |
|
| 2524 | + } |
|
| 2426 | 2525 | } |
| 2427 | 2526 | } |
| 2428 | 2527 | } |
@@ -2444,8 +2543,9 @@ discard block |
||
| 2444 | 2543 | $context['back_look_data'] = isset($_POST['back_look']) ? $_POST['back_look'] : array(); |
| 2445 | 2544 | |
| 2446 | 2545 | // Skipping use of FTP? |
| 2447 | - if (empty($package_ftp)) |
|
| 2448 | - $context['skip_ftp'] = true; |
|
| 2546 | + if (empty($package_ftp)) { |
|
| 2547 | + $context['skip_ftp'] = true; |
|
| 2548 | + } |
|
| 2449 | 2549 | |
| 2450 | 2550 | // We'll start off in a good place, security. Make sure that if we're dealing with individual files that they seem in the right place. |
| 2451 | 2551 | if ($context['method'] == 'individual') |
@@ -2455,8 +2555,9 @@ discard block |
||
| 2455 | 2555 | $context['custom_value'] = (int) $_POST['custom_value']; |
| 2456 | 2556 | |
| 2457 | 2557 | // Continuing? |
| 2458 | - if (isset($_POST['toProcess'])) |
|
| 2459 | - $_POST['permStatus'] = smf_json_decode(base64_decode($_POST['toProcess']), true); |
|
| 2558 | + if (isset($_POST['toProcess'])) { |
|
| 2559 | + $_POST['permStatus'] = smf_json_decode(base64_decode($_POST['toProcess']), true); |
|
| 2560 | + } |
|
| 2460 | 2561 | |
| 2461 | 2562 | if (isset($_POST['permStatus'])) |
| 2462 | 2563 | { |
@@ -2465,22 +2566,27 @@ discard block |
||
| 2465 | 2566 | foreach ($_POST['permStatus'] as $path => $status) |
| 2466 | 2567 | { |
| 2467 | 2568 | // Nothing to see here? |
| 2468 | - if ($status == 'no_change') |
|
| 2469 | - continue; |
|
| 2569 | + if ($status == 'no_change') { |
|
| 2570 | + continue; |
|
| 2571 | + } |
|
| 2470 | 2572 | $legal = false; |
| 2471 | - foreach ($legal_roots as $root) |
|
| 2472 | - if (substr($path, 0, strlen($root)) == $root) |
|
| 2573 | + foreach ($legal_roots as $root) { |
|
| 2574 | + if (substr($path, 0, strlen($root)) == $root) |
|
| 2473 | 2575 | $legal = true; |
| 2576 | + } |
|
| 2474 | 2577 | |
| 2475 | - if (!$legal) |
|
| 2476 | - continue; |
|
| 2578 | + if (!$legal) { |
|
| 2579 | + continue; |
|
| 2580 | + } |
|
| 2477 | 2581 | |
| 2478 | 2582 | // Check it exists. |
| 2479 | - if (!file_exists($path)) |
|
| 2480 | - continue; |
|
| 2583 | + if (!file_exists($path)) { |
|
| 2584 | + continue; |
|
| 2585 | + } |
|
| 2481 | 2586 | |
| 2482 | - if ($status == 'custom') |
|
| 2483 | - $validate_custom = true; |
|
| 2587 | + if ($status == 'custom') { |
|
| 2588 | + $validate_custom = true; |
|
| 2589 | + } |
|
| 2484 | 2590 | |
| 2485 | 2591 | // Now add it. |
| 2486 | 2592 | $context['to_process'][$path] = $status; |
@@ -2490,17 +2596,20 @@ discard block |
||
| 2490 | 2596 | // Make sure the chmod status is valid? |
| 2491 | 2597 | if ($validate_custom) |
| 2492 | 2598 | { |
| 2493 | - if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) |
|
| 2494 | - fatal_error($txt['chmod_value_invalid']); |
|
| 2599 | + if (preg_match('~^[4567][4567][4567]$~', $context['custom_value']) == false) { |
|
| 2600 | + fatal_error($txt['chmod_value_invalid']); |
|
| 2601 | + } |
|
| 2495 | 2602 | } |
| 2496 | 2603 | |
| 2497 | 2604 | // Nothing to do? |
| 2498 | - if (empty($context['to_process'])) |
|
| 2499 | - redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode(json_encode($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2605 | + if (empty($context['to_process'])) { |
|
| 2606 | + redirectexit('action=admin;area=packages;sa=perms' . (!empty($context['back_look_data']) ? ';back_look=' . base64_encode(json_encode($context['back_look_data'])) : '') . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 2607 | + } |
|
| 2500 | 2608 | } |
| 2501 | 2609 | // Should never get here, |
| 2502 | - else |
|
| 2503 | - fatal_lang_error('no_access', false); |
|
| 2610 | + else { |
|
| 2611 | + fatal_lang_error('no_access', false); |
|
| 2612 | + } |
|
| 2504 | 2613 | |
| 2505 | 2614 | // Setup the custom value. |
| 2506 | 2615 | $custom_value = octdec('0' . $context['custom_value']); |
@@ -2508,26 +2617,27 @@ discard block |
||
| 2508 | 2617 | // Start processing items. |
| 2509 | 2618 | foreach ($context['to_process'] as $path => $status) |
| 2510 | 2619 | { |
| 2511 | - if (in_array($status, array('execute', 'writable', 'read'))) |
|
| 2512 | - package_chmod($path, $status); |
|
| 2513 | - elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2620 | + if (in_array($status, array('execute', 'writable', 'read'))) { |
|
| 2621 | + package_chmod($path, $status); |
|
| 2622 | + } elseif ($status == 'custom' && !empty($custom_value)) |
|
| 2514 | 2623 | { |
| 2515 | 2624 | // Use FTP if we have it. |
| 2516 | 2625 | if (!empty($package_ftp) && !empty($_SESSION['pack_ftp'])) |
| 2517 | 2626 | { |
| 2518 | 2627 | $ftp_file = strtr($path, array($_SESSION['pack_ftp']['root'] => '')); |
| 2519 | 2628 | $package_ftp->chmod($ftp_file, $custom_value); |
| 2629 | + } else { |
|
| 2630 | + smf_chmod($path, $custom_value); |
|
| 2520 | 2631 | } |
| 2521 | - else |
|
| 2522 | - smf_chmod($path, $custom_value); |
|
| 2523 | 2632 | } |
| 2524 | 2633 | |
| 2525 | 2634 | // This fish is fried... |
| 2526 | 2635 | unset($context['to_process'][$path]); |
| 2527 | 2636 | |
| 2528 | 2637 | // See if we're out of time? |
| 2529 | - if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) |
|
| 2530 | - return false; |
|
| 2638 | + if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) { |
|
| 2639 | + return false; |
|
| 2640 | + } |
|
| 2531 | 2641 | } |
| 2532 | 2642 | } |
| 2533 | 2643 | // If predefined this is a little different. |
@@ -2595,23 +2705,27 @@ discard block |
||
| 2595 | 2705 | { |
| 2596 | 2706 | global $context; |
| 2597 | 2707 | |
| 2598 | - if (!empty($data['writable_on'])) |
|
| 2599 | - if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2708 | + if (!empty($data['writable_on'])) { |
|
| 2709 | + if ($context['predefined_type'] == 'standard' || $data['writable_on'] == 'restrictive') |
|
| 2600 | 2710 | $context['special_files'][$path] = 1; |
| 2711 | + } |
|
| 2601 | 2712 | |
| 2602 | - if (!empty($data['contents'])) |
|
| 2603 | - foreach ($data['contents'] as $name => $contents) |
|
| 2713 | + if (!empty($data['contents'])) { |
|
| 2714 | + foreach ($data['contents'] as $name => $contents) |
|
| 2604 | 2715 | build_special_files__recursive($path . '/' . $name, $contents); |
| 2716 | + } |
|
| 2605 | 2717 | } |
| 2606 | 2718 | |
| 2607 | - foreach ($context['file_tree'] as $path => $data) |
|
| 2608 | - build_special_files__recursive($path, $data); |
|
| 2719 | + foreach ($context['file_tree'] as $path => $data) { |
|
| 2720 | + build_special_files__recursive($path, $data); |
|
| 2721 | + } |
|
| 2609 | 2722 | } |
| 2610 | 2723 | // Free doesn't need special files. |
| 2611 | - elseif ($context['predefined_type'] == 'free') |
|
| 2612 | - $context['special_files'] = array(); |
|
| 2613 | - else |
|
| 2614 | - $context['special_files'] = smf_json_decode(base64_decode($_POST['specialFiles']), true); |
|
| 2724 | + elseif ($context['predefined_type'] == 'free') { |
|
| 2725 | + $context['special_files'] = array(); |
|
| 2726 | + } else { |
|
| 2727 | + $context['special_files'] = smf_json_decode(base64_decode($_POST['specialFiles']), true); |
|
| 2728 | + } |
|
| 2615 | 2729 | |
| 2616 | 2730 | // Now we definitely know where we are, we need to go through again doing the chmod! |
| 2617 | 2731 | foreach ($context['directory_list'] as $path => $dummy) |
@@ -2656,8 +2770,9 @@ discard block |
||
| 2656 | 2770 | unset($context['directory_list'][$path]); |
| 2657 | 2771 | |
| 2658 | 2772 | // See if we're out of time? |
| 2659 | - if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) |
|
| 2660 | - return false; |
|
| 2773 | + if (time() - array_sum(explode(' ', $time_start)) > $timeout_limit) { |
|
| 2774 | + return false; |
|
| 2775 | + } |
|
| 2661 | 2776 | } |
| 2662 | 2777 | } |
| 2663 | 2778 | |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
| 257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
| 258 | 271 | $txt['starter'] = $txt['started_by']; |
| 259 | 272 | |
| 260 | - foreach ($sort_methods as $key => $val) |
|
| 261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 273 | + foreach ($sort_methods as $key => $val) { |
|
| 274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 275 | + } |
|
| 262 | 276 | |
| 263 | 277 | // Calculate the fastest way to get the topics. |
| 264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
| 268 | 282 | $fake_ascending = true; |
| 269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
| 270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
| 285 | + } else { |
|
| 286 | + $fake_ascending = false; |
|
| 271 | 287 | } |
| 272 | - else |
|
| 273 | - $fake_ascending = false; |
|
| 274 | 288 | |
| 275 | 289 | // Setup the default topic icons... |
| 276 | 290 | $context['icon_sources'] = array(); |
| 277 | - foreach ($context['stable_icons'] as $icon) |
|
| 278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 291 | + foreach ($context['stable_icons'] as $icon) { |
|
| 292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 293 | + } |
|
| 279 | 294 | |
| 280 | 295 | $topic_ids = array(); |
| 281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
| 306 | 321 | ) |
| 307 | 322 | ); |
| 308 | 323 | $topic_ids = array(); |
| 309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 310 | - $topic_ids[] = $row['id_topic']; |
|
| 324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 325 | + $topic_ids[] = $row['id_topic']; |
|
| 326 | + } |
|
| 311 | 327 | } |
| 312 | 328 | |
| 313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
| 363 | 379 | // Begin 'printing' the message index for current board. |
| 364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 381 | { |
| 366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 367 | - continue; |
|
| 382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 368 | 385 | |
| 369 | - if (!$pre_query) |
|
| 370 | - $topic_ids[] = $row['id_topic']; |
|
| 386 | + if (!$pre_query) { |
|
| 387 | + $topic_ids[] = $row['id_topic']; |
|
| 388 | + } |
|
| 371 | 389 | |
| 372 | 390 | // Reference the main color class. |
| 373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
| 377 | 395 | { |
| 378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
| 379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 400 | + } |
|
| 382 | 401 | |
| 383 | 402 | // Censor the subject and message preview. |
| 384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
| 389 | 408 | { |
| 390 | 409 | $row['last_subject'] = $row['first_subject']; |
| 391 | 410 | $row['last_body'] = $row['first_body']; |
| 392 | - } |
|
| 393 | - else |
|
| 411 | + } else |
|
| 394 | 412 | { |
| 395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 416 | + } |
|
| 398 | 417 | |
| 399 | 418 | censorText($row['last_subject']); |
| 400 | 419 | censorText($row['last_body']); |
| 401 | 420 | } |
| 402 | - } |
|
| 403 | - else |
|
| 421 | + } else |
|
| 404 | 422 | { |
| 405 | 423 | $row['first_body'] = ''; |
| 406 | 424 | $row['last_body'] = ''; |
| 407 | 425 | censorText($row['first_subject']); |
| 408 | 426 | |
| 409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 410 | - $row['last_subject'] = $row['first_subject']; |
|
| 411 | - else |
|
| 412 | - censorText($row['last_subject']); |
|
| 427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 428 | + $row['last_subject'] = $row['first_subject']; |
|
| 429 | + } else { |
|
| 430 | + censorText($row['last_subject']); |
|
| 431 | + } |
|
| 413 | 432 | } |
| 414 | 433 | |
| 415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
| 420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 421 | 440 | |
| 422 | 441 | // If we can use all, show all. |
| 423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 444 | + } |
|
| 445 | + } else { |
|
| 446 | + $pages = ''; |
|
| 425 | 447 | } |
| 426 | - else |
|
| 427 | - $pages = ''; |
|
| 428 | 448 | |
| 429 | 449 | // We need to check the topic icons exist... |
| 430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 431 | 451 | { |
| 432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 436 | - } |
|
| 437 | - else |
|
| 452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 454 | + } |
|
| 455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 457 | + } |
|
| 458 | + } else |
|
| 438 | 459 | { |
| 439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 462 | + } |
|
| 463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 465 | + } |
|
| 443 | 466 | } |
| 444 | 467 | |
| 445 | - if (!empty($board_info['recycle'])) |
|
| 446 | - $row['first_icon'] = 'recycled'; |
|
| 468 | + if (!empty($board_info['recycle'])) { |
|
| 469 | + $row['first_icon'] = 'recycled'; |
|
| 470 | + } |
|
| 447 | 471 | |
| 448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
| 449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 475 | + } |
|
| 451 | 476 | |
| 452 | 477 | // Sticky topics should get a different color, too. |
| 453 | - if ($row['is_sticky']) |
|
| 454 | - $colorClass .= ' sticky'; |
|
| 478 | + if ($row['is_sticky']) { |
|
| 479 | + $colorClass .= ' sticky'; |
|
| 480 | + } |
|
| 455 | 481 | |
| 456 | 482 | // Locked topics get special treatment as well. |
| 457 | - if ($row['locked']) |
|
| 458 | - $colorClass .= ' locked'; |
|
| 483 | + if ($row['locked']) { |
|
| 484 | + $colorClass .= ' locked'; |
|
| 485 | + } |
|
| 459 | 486 | |
| 460 | 487 | // 'Print' the topic info. |
| 461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
| 536 | 563 | $smcFunc['db_free_result']($result); |
| 537 | 564 | |
| 538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 539 | - if ($fake_ascending) |
|
| 540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 566 | + if ($fake_ascending) { |
|
| 567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 568 | + } |
|
| 541 | 569 | |
| 542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
| 554 | 582 | 'limit' => count($topic_ids), |
| 555 | 583 | ) |
| 556 | 584 | ); |
| 557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 587 | + } |
|
| 559 | 588 | $smcFunc['db_free_result']($result); |
| 560 | 589 | } |
| 561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
| 580 | 609 | // Can we restore topics? |
| 581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 582 | 611 | |
| 583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 584 | - $context['can_move_any'] = true; |
|
| 585 | - else |
|
| 612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 613 | + $context['can_move_any'] = true; |
|
| 614 | + } else |
|
| 586 | 615 | { |
| 587 | 616 | // We'll use this in a minute |
| 588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
| 609 | 638 | } |
| 610 | 639 | |
| 611 | 640 | // Can we use quick moderation checkboxes? |
| 612 | - if ($options['display_quick_mod'] == 1) |
|
| 613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 641 | + if ($options['display_quick_mod'] == 1) { |
|
| 642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 643 | + } |
|
| 614 | 644 | // Or the icons? |
| 615 | - else |
|
| 616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 645 | + else { |
|
| 646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 647 | + } |
|
| 617 | 648 | } |
| 618 | 649 | |
| 619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
| 647 | 678 | ); |
| 648 | 679 | |
| 649 | 680 | // We've seen all these boards now! |
| 650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
| 684 | + } |
|
| 653 | 685 | } |
| 654 | 686 | |
| 655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 689 | + } |
|
| 657 | 690 | |
| 658 | 691 | $request = $smcFunc['db_query']('', ' |
| 659 | 692 | SELECT id_topic, id_board, sent |
@@ -675,8 +708,9 @@ discard block |
||
| 675 | 708 | $context['is_marked_notify'] = true; |
| 676 | 709 | $board_sent = $row['sent']; |
| 677 | 710 | } |
| 678 | - if (!empty($row['id_topic'])) |
|
| 679 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 711 | + if (!empty($row['id_topic'])) { |
|
| 712 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 713 | + } |
|
| 680 | 714 | } |
| 681 | 715 | $smcFunc['db_free_result']($request); |
| 682 | 716 | |
@@ -700,8 +734,7 @@ discard block |
||
| 700 | 734 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 701 | 735 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 702 | 736 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 703 | - } |
|
| 704 | - else |
|
| 737 | + } else |
|
| 705 | 738 | { |
| 706 | 739 | $context['is_marked_notify'] = false; |
| 707 | 740 | $context['board_notification_mode'] = 1; |
@@ -714,23 +747,27 @@ discard block |
||
| 714 | 747 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 715 | 748 | |
| 716 | 749 | // Don't want to show this forever... |
| 717 | - if ($context['becomesUnapproved']) |
|
| 718 | - unset($_SESSION['becomesUnapproved']); |
|
| 750 | + if ($context['becomesUnapproved']) { |
|
| 751 | + unset($_SESSION['becomesUnapproved']); |
|
| 752 | + } |
|
| 719 | 753 | |
| 720 | 754 | // Build the message index button array. |
| 721 | 755 | $context['normal_buttons'] = array(); |
| 722 | 756 | |
| 723 | - if ($context['can_post_new']) |
|
| 724 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 757 | + if ($context['can_post_new']) { |
|
| 758 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 759 | + } |
|
| 725 | 760 | |
| 726 | - if ($context['can_post_poll']) |
|
| 727 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 761 | + if ($context['can_post_poll']) { |
|
| 762 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 763 | + } |
|
| 728 | 764 | |
| 729 | - if (!$context['user']['is_logged']) |
|
| 730 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 765 | + if (!$context['user']['is_logged']) { |
|
| 766 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 767 | + } |
|
| 731 | 768 | |
| 732 | - if ($context['can_mark_notify']) |
|
| 733 | - $context['normal_buttons']['notify'] = array( |
|
| 769 | + if ($context['can_mark_notify']) { |
|
| 770 | + $context['normal_buttons']['notify'] = array( |
|
| 734 | 771 | 'lang' => true, |
| 735 | 772 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 736 | 773 | 'sub_buttons' => array( |
@@ -748,6 +785,7 @@ discard block |
||
| 748 | 785 | ), |
| 749 | 786 | ), |
| 750 | 787 | ); |
| 788 | + } |
|
| 751 | 789 | |
| 752 | 790 | // Javascript for inline editing. |
| 753 | 791 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -769,18 +807,21 @@ discard block |
||
| 769 | 807 | checkSession('request'); |
| 770 | 808 | |
| 771 | 809 | // Lets go straight to the restore area. |
| 772 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 773 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 810 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 811 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 812 | + } |
|
| 774 | 813 | |
| 775 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 776 | - $_SESSION['topicseen_cache'] = array(); |
|
| 814 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 815 | + $_SESSION['topicseen_cache'] = array(); |
|
| 816 | + } |
|
| 777 | 817 | |
| 778 | 818 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 779 | 819 | require_once($sourcedir . '/Subs-Post.php'); |
| 780 | 820 | |
| 781 | 821 | // Remember the last board they moved things to. |
| 782 | - if (isset($_REQUEST['move_to'])) |
|
| 783 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 822 | + if (isset($_REQUEST['move_to'])) { |
|
| 823 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 824 | + } |
|
| 784 | 825 | |
| 785 | 826 | // Only a few possible actions. |
| 786 | 827 | $possibleActions = array(); |
@@ -800,8 +841,7 @@ discard block |
||
| 800 | 841 | ); |
| 801 | 842 | |
| 802 | 843 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 803 | - } |
|
| 804 | - else |
|
| 844 | + } else |
|
| 805 | 845 | { |
| 806 | 846 | /** |
| 807 | 847 | * @todo Ugly. There's no getting around this, is there? |
@@ -819,8 +859,7 @@ discard block |
||
| 819 | 859 | if (!empty($board)) |
| 820 | 860 | { |
| 821 | 861 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 822 | - } |
|
| 823 | - else |
|
| 862 | + } else |
|
| 824 | 863 | { |
| 825 | 864 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 826 | 865 | } |
@@ -831,55 +870,67 @@ discard block |
||
| 831 | 870 | } |
| 832 | 871 | } |
| 833 | 872 | |
| 834 | - if (!$user_info['is_guest']) |
|
| 835 | - $possibleActions[] = 'markread'; |
|
| 836 | - if (!empty($boards_can['make_sticky'])) |
|
| 837 | - $possibleActions[] = 'sticky'; |
|
| 838 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 839 | - $possibleActions[] = 'move'; |
|
| 840 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 841 | - $possibleActions[] = 'remove'; |
|
| 842 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 843 | - $possibleActions[] = 'lock'; |
|
| 844 | - if (!empty($boards_can['merge_any'])) |
|
| 845 | - $possibleActions[] = 'merge'; |
|
| 846 | - if (!empty($boards_can['approve_posts'])) |
|
| 847 | - $possibleActions[] = 'approve'; |
|
| 873 | + if (!$user_info['is_guest']) { |
|
| 874 | + $possibleActions[] = 'markread'; |
|
| 875 | + } |
|
| 876 | + if (!empty($boards_can['make_sticky'])) { |
|
| 877 | + $possibleActions[] = 'sticky'; |
|
| 878 | + } |
|
| 879 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 880 | + $possibleActions[] = 'move'; |
|
| 881 | + } |
|
| 882 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 883 | + $possibleActions[] = 'remove'; |
|
| 884 | + } |
|
| 885 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 886 | + $possibleActions[] = 'lock'; |
|
| 887 | + } |
|
| 888 | + if (!empty($boards_can['merge_any'])) { |
|
| 889 | + $possibleActions[] = 'merge'; |
|
| 890 | + } |
|
| 891 | + if (!empty($boards_can['approve_posts'])) { |
|
| 892 | + $possibleActions[] = 'approve'; |
|
| 893 | + } |
|
| 848 | 894 | |
| 849 | 895 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 850 | 896 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 851 | 897 | if (!empty($_REQUEST['topics'])) |
| 852 | 898 | { |
| 853 | 899 | // If the action isn't valid, just quit now. |
| 854 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 855 | - redirectexit($redirect_url); |
|
| 900 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 901 | + redirectexit($redirect_url); |
|
| 902 | + } |
|
| 856 | 903 | |
| 857 | 904 | // Merge requires all topics as one parameter and can be done at once. |
| 858 | 905 | if ($_REQUEST['qaction'] == 'merge') |
| 859 | 906 | { |
| 860 | 907 | // Merge requires at least two topics. |
| 861 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 862 | - redirectexit($redirect_url); |
|
| 908 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 909 | + redirectexit($redirect_url); |
|
| 910 | + } |
|
| 863 | 911 | |
| 864 | 912 | require_once($sourcedir . '/SplitTopics.php'); |
| 865 | 913 | return MergeExecute($_REQUEST['topics']); |
| 866 | 914 | } |
| 867 | 915 | |
| 868 | 916 | // Just convert to the other method, to make it easier. |
| 869 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 870 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 917 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 918 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 919 | + } |
|
| 871 | 920 | } |
| 872 | 921 | |
| 873 | 922 | // Weird... how'd you get here? |
| 874 | - if (empty($_REQUEST['actions'])) |
|
| 875 | - redirectexit($redirect_url); |
|
| 923 | + if (empty($_REQUEST['actions'])) { |
|
| 924 | + redirectexit($redirect_url); |
|
| 925 | + } |
|
| 876 | 926 | |
| 877 | 927 | // Validate each action. |
| 878 | 928 | $temp = array(); |
| 879 | 929 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 880 | 930 | { |
| 881 | - if (in_array($action, $possibleActions)) |
|
| 882 | - $temp[(int) $topic] = $action; |
|
| 931 | + if (in_array($action, $possibleActions)) { |
|
| 932 | + $temp[(int) $topic] = $action; |
|
| 933 | + } |
|
| 883 | 934 | } |
| 884 | 935 | $_REQUEST['actions'] = $temp; |
| 885 | 936 | |
@@ -900,27 +951,31 @@ discard block |
||
| 900 | 951 | { |
| 901 | 952 | if (!empty($board)) |
| 902 | 953 | { |
| 903 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 904 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 905 | - } |
|
| 906 | - else |
|
| 954 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 955 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 956 | + } |
|
| 957 | + } else |
|
| 907 | 958 | { |
| 908 | 959 | // Don't allow them to act on unapproved posts they can't see... |
| 909 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 910 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 960 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 961 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 962 | + } |
|
| 911 | 963 | // Goodness, this is fun. We need to validate the action. |
| 912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 916 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 917 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 964 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 968 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 969 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 970 | + } |
|
| 918 | 971 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 919 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 920 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 972 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 973 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 974 | + } |
|
| 921 | 975 | // If the topic is approved then you need permission to approve the posts within. |
| 922 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 923 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 976 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 977 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 978 | + } |
|
| 924 | 979 | } |
| 925 | 980 | } |
| 926 | 981 | $smcFunc['db_free_result']($request); |
@@ -938,11 +993,11 @@ discard block |
||
| 938 | 993 | { |
| 939 | 994 | $topic = (int) $topic; |
| 940 | 995 | |
| 941 | - if ($action == 'markread') |
|
| 942 | - $markCache[] = $topic; |
|
| 943 | - elseif ($action == 'sticky') |
|
| 944 | - $stickyCache[] = $topic; |
|
| 945 | - elseif ($action == 'move') |
|
| 996 | + if ($action == 'markread') { |
|
| 997 | + $markCache[] = $topic; |
|
| 998 | + } elseif ($action == 'sticky') { |
|
| 999 | + $stickyCache[] = $topic; |
|
| 1000 | + } elseif ($action == 'move') |
|
| 946 | 1001 | { |
| 947 | 1002 | require_once($sourcedir . '/MoveTopic.php'); |
| 948 | 1003 | moveTopicConcurrence(); |
@@ -950,23 +1005,25 @@ discard block |
||
| 950 | 1005 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 951 | 1006 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 952 | 1007 | |
| 953 | - if (empty($moveCache[1][$topic])) |
|
| 954 | - continue; |
|
| 1008 | + if (empty($moveCache[1][$topic])) { |
|
| 1009 | + continue; |
|
| 1010 | + } |
|
| 955 | 1011 | |
| 956 | 1012 | $moveCache[0][] = $topic; |
| 1013 | + } elseif ($action == 'remove') { |
|
| 1014 | + $removeCache[] = $topic; |
|
| 1015 | + } elseif ($action == 'lock') { |
|
| 1016 | + $lockCache[] = $topic; |
|
| 1017 | + } elseif ($action == 'approve') { |
|
| 1018 | + $approveCache[] = $topic; |
|
| 957 | 1019 | } |
| 958 | - elseif ($action == 'remove') |
|
| 959 | - $removeCache[] = $topic; |
|
| 960 | - elseif ($action == 'lock') |
|
| 961 | - $lockCache[] = $topic; |
|
| 962 | - elseif ($action == 'approve') |
|
| 963 | - $approveCache[] = $topic; |
|
| 964 | 1020 | } |
| 965 | 1021 | |
| 966 | - if (empty($board)) |
|
| 967 | - $affectedBoards = array(); |
|
| 968 | - else |
|
| 969 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1022 | + if (empty($board)) { |
|
| 1023 | + $affectedBoards = array(); |
|
| 1024 | + } else { |
|
| 1025 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1026 | + } |
|
| 970 | 1027 | |
| 971 | 1028 | // Do all the stickies... |
| 972 | 1029 | if (!empty($stickyCache)) |
@@ -1026,14 +1083,16 @@ discard block |
||
| 1026 | 1083 | { |
| 1027 | 1084 | $to = $moveCache[1][$row['id_topic']]; |
| 1028 | 1085 | |
| 1029 | - if (empty($to)) |
|
| 1030 | - continue; |
|
| 1086 | + if (empty($to)) { |
|
| 1087 | + continue; |
|
| 1088 | + } |
|
| 1031 | 1089 | |
| 1032 | 1090 | // Does this topic's board count the posts or not? |
| 1033 | 1091 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1034 | 1092 | |
| 1035 | - if (!isset($moveTos[$to])) |
|
| 1036 | - $moveTos[$to] = array(); |
|
| 1093 | + if (!isset($moveTos[$to])) { |
|
| 1094 | + $moveTos[$to] = array(); |
|
| 1095 | + } |
|
| 1037 | 1096 | |
| 1038 | 1097 | $moveTos[$to][] = $row['id_topic']; |
| 1039 | 1098 | |
@@ -1047,8 +1106,9 @@ discard block |
||
| 1047 | 1106 | require_once($sourcedir . '/MoveTopic.php'); |
| 1048 | 1107 | |
| 1049 | 1108 | // Do the actual moves... |
| 1050 | - foreach ($moveTos as $to => $topics) |
|
| 1051 | - moveTopics($topics, $to); |
|
| 1109 | + foreach ($moveTos as $to => $topics) { |
|
| 1110 | + moveTopics($topics, $to); |
|
| 1111 | + } |
|
| 1052 | 1112 | |
| 1053 | 1113 | // Does the post counts need to be updated? |
| 1054 | 1114 | if (!empty($moveTos)) |
@@ -1097,20 +1157,23 @@ discard block |
||
| 1097 | 1157 | |
| 1098 | 1158 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1099 | 1159 | { |
| 1100 | - if (!isset($members[$row['id_member']])) |
|
| 1101 | - $members[$row['id_member']] = 0; |
|
| 1160 | + if (!isset($members[$row['id_member']])) { |
|
| 1161 | + $members[$row['id_member']] = 0; |
|
| 1162 | + } |
|
| 1102 | 1163 | |
| 1103 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1104 | - $members[$row['id_member']] += 1; |
|
| 1105 | - else |
|
| 1106 | - $members[$row['id_member']] -= 1; |
|
| 1164 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1165 | + $members[$row['id_member']] += 1; |
|
| 1166 | + } else { |
|
| 1167 | + $members[$row['id_member']] -= 1; |
|
| 1168 | + } |
|
| 1107 | 1169 | } |
| 1108 | 1170 | |
| 1109 | 1171 | $smcFunc['db_free_result']($request); |
| 1110 | 1172 | |
| 1111 | 1173 | // And now update them member's post counts |
| 1112 | - foreach ($members as $id_member => $post_adj) |
|
| 1113 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1174 | + foreach ($members as $id_member => $post_adj) { |
|
| 1175 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1176 | + } |
|
| 1114 | 1177 | |
| 1115 | 1178 | } |
| 1116 | 1179 | } |
@@ -1190,8 +1253,9 @@ discard block |
||
| 1190 | 1253 | approveTopics($approveCache); |
| 1191 | 1254 | |
| 1192 | 1255 | // Time for some logging! |
| 1193 | - foreach ($approveCache as $topic) |
|
| 1194 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1256 | + foreach ($approveCache as $topic) { |
|
| 1257 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1258 | + } |
|
| 1195 | 1259 | } |
| 1196 | 1260 | } |
| 1197 | 1261 | |
@@ -1226,8 +1290,7 @@ discard block |
||
| 1226 | 1290 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1227 | 1291 | } |
| 1228 | 1292 | $smcFunc['db_free_result']($result); |
| 1229 | - } |
|
| 1230 | - else |
|
| 1293 | + } else |
|
| 1231 | 1294 | { |
| 1232 | 1295 | $result = $smcFunc['db_query']('', ' |
| 1233 | 1296 | SELECT id_topic, locked, id_board |
@@ -1277,13 +1340,15 @@ discard block |
||
| 1277 | 1340 | ) |
| 1278 | 1341 | ); |
| 1279 | 1342 | $logged_topics = array(); |
| 1280 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1281 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1343 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1344 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1345 | + } |
|
| 1282 | 1346 | $smcFunc['db_free_result']($request); |
| 1283 | 1347 | |
| 1284 | 1348 | $markArray = array(); |
| 1285 | - foreach ($markCache as $topic) |
|
| 1286 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1349 | + foreach ($markCache as $topic) { |
|
| 1350 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1351 | + } |
|
| 1287 | 1352 | |
| 1288 | 1353 | $smcFunc['db_insert']('replace', |
| 1289 | 1354 | '{db_prefix}log_topics', |
@@ -1296,8 +1361,9 @@ discard block |
||
| 1296 | 1361 | foreach ($moveCache as $topic) |
| 1297 | 1362 | { |
| 1298 | 1363 | // Didn't actually move anything! |
| 1299 | - if (!isset($topic[0])) |
|
| 1300 | - break; |
|
| 1364 | + if (!isset($topic[0])) { |
|
| 1365 | + break; |
|
| 1366 | + } |
|
| 1301 | 1367 | |
| 1302 | 1368 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1303 | 1369 | sendNotifications($topic[0], 'move'); |
@@ -1319,8 +1385,9 @@ discard block |
||
| 1319 | 1385 | 'calendar_updated' => time(), |
| 1320 | 1386 | )); |
| 1321 | 1387 | |
| 1322 | - if (!empty($affectedBoards)) |
|
| 1323 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1388 | + if (!empty($affectedBoards)) { |
|
| 1389 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1390 | + } |
|
| 1324 | 1391 | |
| 1325 | 1392 | redirectexit($redirect_url); |
| 1326 | 1393 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 3 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * 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, $board, $topic, $scripturl, $sourcedir, $modSettings, $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 |
@@ -17,8 +17,9 @@ discard block |
||
| 17 | 17 | * @version 2.1 Beta 3 |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | -if (!defined('SMF')) |
|
| 20 | +if (!defined('SMF')) { |
|
| 21 | 21 | die('No direct access...'); |
| 22 | +} |
|
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | { |
| 39 | 40 | $parsed_url = parse_url($boardurl); |
| 40 | 41 | |
| 41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
| 42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
| 43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | // @todo Set the session cookie path? |
| 45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
| 47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
| 48 | 50 | { |
| 49 | 51 | // Attempt to end the already-started session. |
| 50 | - if (ini_get('session.auto_start') == 1) |
|
| 51 | - session_write_close(); |
|
| 52 | + if (ini_get('session.auto_start') == 1) { |
|
| 53 | + session_write_close(); |
|
| 54 | + } |
|
| 52 | 55 | |
| 53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
| 54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
| 65 | 68 | @ini_set('session.serialize_handler', 'php'); |
| 66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
| 67 | 70 | @ini_set('session.gc_probability', '1'); |
| 71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
| 72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 68 | 73 | } |
| 69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
| 70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
| 71 | 74 | |
| 72 | 75 | // Use cache setting sessions? |
| 73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
| 74 | - call_integration_hook('integrate_session_handlers'); |
|
| 76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
| 77 | + call_integration_hook('integrate_session_handlers'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | session_start(); |
| 77 | 81 | |
| 78 | 82 | // Change it so the cache settings are a little looser than default. |
| 79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
| 80 | - header('Cache-Control: private'); |
|
| 83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
| 84 | + header('Cache-Control: private'); |
|
| 85 | + } |
|
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
| 123 | 128 | { |
| 124 | 129 | global $smcFunc; |
| 125 | 130 | |
| 126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 127 | - return ''; |
|
| 131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 132 | + return ''; |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | // Look for it in the database. |
| 130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | global $smcFunc; |
| 155 | 161 | |
| 156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 157 | - return false; |
|
| 162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 163 | + return false; |
|
| 164 | + } |
|
| 158 | 165 | |
| 159 | 166 | // First try to update an existing row... |
| 160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
| 169 | 176 | ); |
| 170 | 177 | |
| 171 | 178 | // If that didn't work, try inserting a new one. |
| 172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
| 173 | - $smcFunc['db_insert']('ignore', |
|
| 179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
| 180 | + $smcFunc['db_insert']('ignore', |
|
| 174 | 181 | '{db_prefix}sessions', |
| 175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
| 176 | 183 | array($session_id, $data, time()), |
| 177 | 184 | array('session_id') |
| 178 | 185 | ); |
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
| 181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
| 190 | 198 | { |
| 191 | 199 | global $smcFunc; |
| 192 | 200 | |
| 193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
| 194 | - return false; |
|
| 201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
| 202 | + return false; |
|
| 203 | + } |
|
| 195 | 204 | |
| 196 | 205 | // Just delete the row... |
| 197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
| 217 | 226 | global $modSettings, $smcFunc; |
| 218 | 227 | |
| 219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
| 220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
| 221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
| 230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
| 231 | + } |
|
| 222 | 232 | |
| 223 | 233 | // Clean up after yerself ;). |
| 224 | 234 | $smcFunc['db_query']('', ' |