@@ -96,14 +96,15 @@ |
||
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // Insert the alerts if any |
| 99 | - if (!empty($alert_rows)) |
|
| 100 | - $smcFunc['db_insert']('', |
|
| 99 | + if (!empty($alert_rows)) { |
|
| 100 | + $smcFunc['db_insert']('', |
|
| 101 | 101 | '{db_prefix}user_alerts', |
| 102 | 102 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
| 103 | 103 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
| 104 | 104 | $alert_rows, |
| 105 | 105 | array() |
| 106 | 106 | ); |
| 107 | + } |
|
| 107 | 108 | |
| 108 | 109 | return true; |
| 109 | 110 | } |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | ) |
| 38 | 38 | ); |
| 39 | 39 | $moderators = array(); |
| 40 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 41 | - $moderators[] = $row['id_member']; |
|
| 40 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 41 | + $moderators[] = $row['id_member']; |
|
| 42 | + } |
|
| 42 | 43 | $smcFunc['db_free_result']($request); |
| 43 | 44 | |
| 44 | 45 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -59,11 +60,13 @@ discard block |
||
| 59 | 60 | { |
| 60 | 61 | if (!empty($prefs[$mod]['request_group'])) |
| 61 | 62 | { |
| 62 | - if ($prefs[$mod]['request_group'] & 0x01) |
|
| 63 | - $data['alert'][] = $mod; |
|
| 63 | + if ($prefs[$mod]['request_group'] & 0x01) { |
|
| 64 | + $data['alert'][] = $mod; |
|
| 65 | + } |
|
| 64 | 66 | |
| 65 | - if ($prefs[$mod]['request_group'] & 0x02) |
|
| 66 | - $data['email'][] = $mod; |
|
| 67 | + if ($prefs[$mod]['request_group'] & 0x02) { |
|
| 68 | + $data['email'][] = $mod; |
|
| 69 | + } |
|
| 67 | 70 | } |
| 68 | 71 | } |
| 69 | 72 | |
@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 3 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Our Cache API class |
@@ -46,8 +47,9 @@ discard block |
||
| 46 | 47 | |
| 47 | 48 | $supported = function_exists('xcache_get') && function_exists('xcache_set') && ini_get('xcache.var_size') > 0; |
| 48 | 49 | |
| 49 | - if ($test) |
|
| 50 | - return $supported; |
|
| 50 | + if ($test) { |
|
| 51 | + return $supported; |
|
| 52 | + } |
|
| 51 | 53 | return parent::isSupported() && $supported; |
| 52 | 54 | } |
| 53 | 55 | |
@@ -68,10 +70,11 @@ discard block |
||
| 68 | 70 | { |
| 69 | 71 | $key = $this->prefix . strtr($key, ':/', '-_'); |
| 70 | 72 | |
| 71 | - if ($value === null) |
|
| 72 | - return xcache_unset($key); |
|
| 73 | - else |
|
| 74 | - return xcache_set($key, $value, $ttl); |
|
| 73 | + if ($value === null) { |
|
| 74 | + return xcache_unset($key); |
|
| 75 | + } else { |
|
| 76 | + return xcache_set($key, $value, $ttl); |
|
| 77 | + } |
|
| 75 | 78 | } |
| 76 | 79 | |
| 77 | 80 | /** |
@@ -90,10 +93,12 @@ discard block |
||
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | // if passed a type, clear that type out |
| 93 | - if ($type === '' || $type === 'user') |
|
| 94 | - xcache_clear_cache(XC_TYPE_VAR, 0); |
|
| 95 | - if ($type === '' || $type === 'data') |
|
| 96 | - xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 96 | + if ($type === '' || $type === 'user') { |
|
| 97 | + xcache_clear_cache(XC_TYPE_VAR, 0); |
|
| 98 | + } |
|
| 99 | + if ($type === '' || $type === 'data') { |
|
| 100 | + xcache_clear_cache(XC_TYPE_PHP, 0); |
|
| 101 | + } |
|
| 97 | 102 | |
| 98 | 103 | $this->invalidateCache(); |
| 99 | 104 | return true; |
@@ -112,8 +117,9 @@ discard block |
||
| 112 | 117 | // While we could md5 this when saving, this could be tricky to be sure it doesn't get corrupted on additional saves. |
| 113 | 118 | $config_vars[] = array('xcache_adminpass', $txt['cache_xcache_adminpass'], 'db', 'text', 0); |
| 114 | 119 | |
| 115 | - if (!isset($context['settings_post_javascript'])) |
|
| 116 | - $context['settings_post_javascript'] = ''; |
|
| 120 | + if (!isset($context['settings_post_javascript'])) { |
|
| 121 | + $context['settings_post_javascript'] = ''; |
|
| 122 | + } |
|
| 117 | 123 | |
| 118 | 124 | $context['settings_post_javascript'] .= ' |
| 119 | 125 | $("#cache_accelerator").change(function (e) { |
@@ -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 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
| 48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
| 49 | 50 | |
| 50 | 51 | // If we are doing approval, update the stats for the member just in case. |
| 51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
| 52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
| 53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
| 54 | + } |
|
| 53 | 55 | |
| 54 | 56 | // Make sure we update the stats too. |
| 55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
| 76 | 78 | $issueErrors = array(); |
| 77 | 79 | |
| 78 | 80 | // Doesn't hurt to be overly cautious. |
| 79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
| 80 | - fatal_lang_error('no_access', false); |
|
| 81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
| 82 | + fatal_lang_error('no_access', false); |
|
| 83 | + } |
|
| 81 | 84 | |
| 82 | 85 | // Get the base (errors related) stuff done. |
| 83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
| 135 | 138 | |
| 136 | 139 | // This cannot be empty! |
| 137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
| 138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
| 139 | - $issueErrors[] = 'warning_no_reason'; |
|
| 141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
| 142 | + $issueErrors[] = 'warning_no_reason'; |
|
| 143 | + } |
|
| 140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
| 141 | 145 | |
| 142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
| 143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
| 144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
| 145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
| 146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
| 147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
| 148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
| 149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
| 150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
| 151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
| 152 | + } |
|
| 148 | 153 | |
| 149 | 154 | // Do we actually have to issue them with a PM? |
| 150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
| 152 | 157 | { |
| 153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
| 154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
| 155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 156 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 161 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 162 | + } |
|
| 157 | 163 | // Send the PM? |
| 158 | 164 | else |
| 159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
| 190 | 196 | if (empty($issueErrors)) |
| 191 | 197 | { |
| 192 | 198 | // Log what we've done! |
| 193 | - if (!$context['user']['is_owner']) |
|
| 194 | - $smcFunc['db_insert']('', |
|
| 199 | + if (!$context['user']['is_owner']) { |
|
| 200 | + $smcFunc['db_insert']('', |
|
| 195 | 201 | '{db_prefix}log_comments', |
| 196 | 202 | array( |
| 197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
| 203 | 209 | ), |
| 204 | 210 | array('id_comment') |
| 205 | 211 | ); |
| 212 | + } |
|
| 206 | 213 | |
| 207 | 214 | // Make the change. |
| 208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
| 209 | 216 | |
| 210 | 217 | // Leave a lovely message. |
| 211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
| 212 | - } |
|
| 213 | - else |
|
| 219 | + } else |
|
| 214 | 220 | { |
| 215 | 221 | // Try to remember some bits. |
| 216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
| 229 | 235 | { |
| 230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
| 231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
| 232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
| 233 | - $issueErrors[] = 'warning_notify_blank'; |
|
| 238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
| 239 | + $issueErrors[] = 'warning_notify_blank'; |
|
| 240 | + } |
|
| 234 | 241 | |
| 235 | 242 | if (!empty($_POST['warn_body'])) |
| 236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
| 254 | 261 | { |
| 255 | 262 | // Fill in the suite of errors. |
| 256 | 263 | $context['post_errors'] = array(); |
| 257 | - foreach ($issueErrors as $error) |
|
| 258 | - $context['post_errors'][] = $txt[$error]; |
|
| 264 | + foreach ($issueErrors as $error) { |
|
| 265 | + $context['post_errors'][] = $txt[$error]; |
|
| 266 | + } |
|
| 259 | 267 | } |
| 260 | 268 | |
| 261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
| 272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
| 273 | 281 | ); |
| 274 | 282 | $context['current_level'] = 0; |
| 275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 276 | - if ($context['member']['warning'] >= $limit) |
|
| 283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 284 | + if ($context['member']['warning'] >= $limit) |
|
| 277 | 285 | $context['current_level'] = $limit; |
| 286 | + } |
|
| 278 | 287 | |
| 279 | 288 | $listOptions = array( |
| 280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
| 337 | 346 | ' . $warning['reason'] . ' |
| 338 | 347 | </div>'; |
| 339 | 348 | |
| 340 | - if (!empty($warning['id_notice'])) |
|
| 341 | - $ret .= ' |
|
| 349 | + if (!empty($warning['id_notice'])) { |
|
| 350 | + $ret .= ' |
|
| 342 | 351 | <div class="floatright"> |
| 343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
| 344 | 353 | </div>'; |
| 354 | + } |
|
| 345 | 355 | |
| 346 | 356 | return $ret; |
| 347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
| 413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 414 | 424 | { |
| 415 | 425 | // If we're not warning for a message skip any that are. |
| 416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
| 417 | - continue; |
|
| 426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
| 427 | + continue; |
|
| 428 | + } |
|
| 418 | 429 | |
| 419 | 430 | $context['notification_templates'][] = array( |
| 420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
| 424 | 435 | $smcFunc['db_free_result']($request); |
| 425 | 436 | |
| 426 | 437 | // Setup the "default" templates. |
| 427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
| 428 | - $context['notification_templates'][] = array( |
|
| 438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
| 439 | + $context['notification_templates'][] = array( |
|
| 429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
| 430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
| 431 | 442 | ); |
| 443 | + } |
|
| 432 | 444 | |
| 433 | 445 | // Replace all the common variables in the templates. |
| 434 | - foreach ($context['notification_templates'] as $k => $name) |
|
| 435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 436 | -} |
|
| 446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
| 447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
| 448 | + } |
|
| 449 | + } |
|
| 437 | 450 | |
| 438 | 451 | /** |
| 439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
| 517 | 530 | { |
| 518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
| 519 | 532 | |
| 520 | - if (!$context['user']['is_owner']) |
|
| 521 | - isAllowedTo('profile_remove_any'); |
|
| 522 | - elseif (!allowedTo('profile_remove_any')) |
|
| 523 | - isAllowedTo('profile_remove_own'); |
|
| 533 | + if (!$context['user']['is_owner']) { |
|
| 534 | + isAllowedTo('profile_remove_any'); |
|
| 535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 536 | + isAllowedTo('profile_remove_own'); |
|
| 537 | + } |
|
| 524 | 538 | |
| 525 | 539 | // Permissions for removing stuff... |
| 526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
| 547 | 561 | |
| 548 | 562 | // @todo Add a way to delete pms as well? |
| 549 | 563 | |
| 550 | - if (!$context['user']['is_owner']) |
|
| 551 | - isAllowedTo('profile_remove_any'); |
|
| 552 | - elseif (!allowedTo('profile_remove_any')) |
|
| 553 | - isAllowedTo('profile_remove_own'); |
|
| 564 | + if (!$context['user']['is_owner']) { |
|
| 565 | + isAllowedTo('profile_remove_any'); |
|
| 566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
| 567 | + isAllowedTo('profile_remove_own'); |
|
| 568 | + } |
|
| 554 | 569 | |
| 555 | 570 | checkSession(); |
| 556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
| 576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
| 577 | 592 | $smcFunc['db_free_result']($request); |
| 578 | 593 | |
| 579 | - if (empty($another)) |
|
| 580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 594 | + if (empty($another)) { |
|
| 595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
| 596 | + } |
|
| 581 | 597 | } |
| 582 | 598 | |
| 583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
| 656 | 672 | ) |
| 657 | 673 | ); |
| 658 | 674 | $topicIDs = array(); |
| 659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 660 | - $topicIDs[] = $row['id_topic']; |
|
| 675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 676 | + $topicIDs[] = $row['id_topic']; |
|
| 677 | + } |
|
| 661 | 678 | $smcFunc['db_free_result']($request); |
| 662 | 679 | |
| 663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
| 680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
| 681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 682 | 699 | { |
| 683 | - if (function_exists('apache_reset_timeout')) |
|
| 684 | - @apache_reset_timeout(); |
|
| 700 | + if (function_exists('apache_reset_timeout')) { |
|
| 701 | + @apache_reset_timeout(); |
|
| 702 | + } |
|
| 685 | 703 | |
| 686 | 704 | removeMessage($row['id_msg']); |
| 687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
| 689 | 707 | } |
| 690 | 708 | |
| 691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
| 692 | - if (isset($_POST['deleteAccount'])) |
|
| 693 | - deleteMembers($memID); |
|
| 710 | + if (isset($_POST['deleteAccount'])) { |
|
| 711 | + deleteMembers($memID); |
|
| 712 | + } |
|
| 694 | 713 | } |
| 695 | 714 | // Do they need approval to delete? |
| 696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
| 741 | 760 | { |
| 742 | 761 | foreach ($costs as $duration => $cost) |
| 743 | 762 | { |
| 744 | - if ($cost != 0) |
|
| 745 | - $cost_array[$duration] = $cost; |
|
| 763 | + if ($cost != 0) { |
|
| 764 | + $cost_array[$duration] = $cost; |
|
| 765 | + } |
|
| 746 | 766 | } |
| 747 | - } |
|
| 748 | - else |
|
| 767 | + } else |
|
| 749 | 768 | { |
| 750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
| 751 | 770 | } |
| 752 | 771 | |
| 753 | - if (empty($cost_array)) |
|
| 754 | - unset($context['subscriptions'][$id]); |
|
| 755 | - else |
|
| 772 | + if (empty($cost_array)) { |
|
| 773 | + unset($context['subscriptions'][$id]); |
|
| 774 | + } else |
|
| 756 | 775 | { |
| 757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
| 758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
| 765 | 784 | foreach ($gateways as $id => $gateway) |
| 766 | 785 | { |
| 767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
| 768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
| 769 | - unset($gateways[$id]); |
|
| 787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
| 788 | + unset($gateways[$id]); |
|
| 789 | + } |
|
| 770 | 790 | } |
| 771 | 791 | |
| 772 | 792 | // No gateways yet? |
| 773 | - if (empty($gateways)) |
|
| 774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 793 | + if (empty($gateways)) { |
|
| 794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 795 | + } |
|
| 775 | 796 | |
| 776 | 797 | // Get the current subscriptions. |
| 777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
| 786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 787 | 808 | { |
| 788 | 809 | // The subscription must exist! |
| 789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
| 790 | - continue; |
|
| 810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
| 811 | + continue; |
|
| 812 | + } |
|
| 791 | 813 | |
| 792 | 814 | $context['current'][$row['id_subscribe']] = array( |
| 793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
| 801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
| 802 | 824 | ); |
| 803 | 825 | |
| 804 | - if ($row['status'] == 1) |
|
| 805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 826 | + if ($row['status'] == 1) { |
|
| 827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
| 828 | + } |
|
| 806 | 829 | } |
| 807 | 830 | $smcFunc['db_free_result']($request); |
| 808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
| 853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
| 854 | 877 | { |
| 855 | 878 | // Hopefully just one. |
| 856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
| 857 | - $ID_SUB = (int) $k; |
|
| 879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
| 880 | + $ID_SUB = (int) $k; |
|
| 881 | + } |
|
| 858 | 882 | |
| 859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
| 860 | - fatal_lang_error('paid_sub_not_active'); |
|
| 883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
| 884 | + fatal_lang_error('paid_sub_not_active'); |
|
| 885 | + } |
|
| 861 | 886 | |
| 862 | 887 | // Simplify... |
| 863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
| 864 | 889 | $period = 'xx'; |
| 865 | - if ($context['sub']['flexible']) |
|
| 866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 890 | + if ($context['sub']['flexible']) { |
|
| 891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
| 892 | + } |
|
| 867 | 893 | |
| 868 | 894 | // Check we have a valid cost. |
| 869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
| 870 | - fatal_lang_error('paid_sub_not_active'); |
|
| 895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
| 896 | + fatal_lang_error('paid_sub_not_active'); |
|
| 897 | + } |
|
| 871 | 898 | |
| 872 | 899 | // Sort out the cost/currency. |
| 873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
| 880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
| 881 | 908 | // The period value for paypal. |
| 882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
| 883 | - } |
|
| 884 | - else |
|
| 910 | + } else |
|
| 885 | 911 | { |
| 886 | 912 | // Real cost... |
| 887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
| 898 | 924 | foreach ($gateways as $id => $gateway) |
| 899 | 925 | { |
| 900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
| 901 | - if (!empty($fields['form'])) |
|
| 902 | - $context['gateways'][] = $fields; |
|
| 927 | + if (!empty($fields['form'])) { |
|
| 928 | + $context['gateways'][] = $fields; |
|
| 929 | + } |
|
| 903 | 930 | } |
| 904 | 931 | |
| 905 | 932 | // Bugger?! |
| 906 | - if (empty($context['gateways'])) |
|
| 907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 933 | + if (empty($context['gateways'])) { |
|
| 934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
| 935 | + } |
|
| 908 | 936 | |
| 909 | 937 | // Now we are going to assume they want to take this out ;) |
| 910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
| 912 | 940 | { |
| 913 | 941 | // What are the details like? |
| 914 | 942 | $current_pending = array(); |
| 915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
| 916 | - $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
| 944 | + $current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true); |
|
| 945 | + } |
|
| 917 | 946 | // Don't get silly. |
| 918 | - if (count($current_pending) > 9) |
|
| 919 | - $current_pending = array(); |
|
| 947 | + if (count($current_pending) > 9) { |
|
| 948 | + $current_pending = array(); |
|
| 949 | + } |
|
| 920 | 950 | $pending_count = 0; |
| 921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
| 922 | - foreach ($current_pending as $pending) |
|
| 923 | - if ($pending[3] == 'payback') |
|
| 952 | + foreach ($current_pending as $pending) { |
|
| 953 | + if ($pending[3] == 'payback') |
|
| 924 | 954 | $pending_count++; |
| 955 | + } |
|
| 925 | 956 | |
| 926 | 957 | if (!in_array($new_data, $current_pending)) |
| 927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
| 966 | 997 | |
| 967 | 998 | // Quit. |
| 968 | 999 | return; |
| 1000 | + } else { |
|
| 1001 | + $context['sub_template'] = 'user_subscription'; |
|
| 1002 | + } |
|
| 969 | 1003 | } |
| 970 | - else |
|
| 971 | - $context['sub_template'] = 'user_subscription'; |
|
| 972 | -} |
|
| 973 | 1004 | |
| 974 | 1005 | ?> |
| 975 | 1006 | \ No newline at end of file |
@@ -16,8 +16,9 @@ discard block |
||
| 16 | 16 | * @version 2.1 Beta 3 |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -if (!defined('SMF')) |
|
| 19 | +if (!defined('SMF')) { |
|
| 20 | 20 | die('No direct access...'); |
| 21 | +} |
|
| 21 | 22 | |
| 22 | 23 | |
| 23 | 24 | /** |
@@ -28,14 +29,16 @@ discard block |
||
| 28 | 29 | function sha1_smf($str) |
| 29 | 30 | { |
| 30 | 31 | // If we have mhash loaded in, use it instead! |
| 31 | - if (function_exists('mhash') && defined('MHASH_SHA1')) |
|
| 32 | - return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 32 | + if (function_exists('mhash') && defined('MHASH_SHA1')) { |
|
| 33 | + return bin2hex(mhash(MHASH_SHA1, $str)); |
|
| 34 | + } |
|
| 33 | 35 | |
| 34 | 36 | $nblk = (strlen($str) + 8 >> 6) + 1; |
| 35 | 37 | $blks = array_pad(array(), $nblk * 16, 0); |
| 36 | 38 | |
| 37 | - for ($i = 0; $i < strlen($str); $i++) |
|
| 38 | - $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 39 | + for ($i = 0; $i < strlen($str); $i++) { |
|
| 40 | + $blks[$i >> 2] |= ord($str{$i}) << (24 - ($i % 4) * 8); |
|
| 41 | + } |
|
| 39 | 42 | |
| 40 | 43 | $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); |
| 41 | 44 | |
@@ -70,10 +73,11 @@ discard block |
||
| 70 | 73 | |
| 71 | 74 | for ($j = 0; $j < 80; $j++) |
| 72 | 75 | { |
| 73 | - if ($j < 16) |
|
| 74 | - $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 75 | - else |
|
| 76 | - $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 76 | + if ($j < 16) { |
|
| 77 | + $w[$j] = isset($x[$i + $j]) ? $x[$i + $j] : 0; |
|
| 78 | + } else { |
|
| 79 | + $w[$j] = sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); |
|
| 80 | + } |
|
| 77 | 81 | |
| 78 | 82 | $t = sha1_rol($a, 5) + sha1_ft($j, $b, $c, $d) + $e + $w[$j] + sha1_kt($j); |
| 79 | 83 | $e = $d; |
@@ -103,12 +107,15 @@ discard block |
||
| 103 | 107 | */ |
| 104 | 108 | function sha1_ft($t, $b, $c, $d) |
| 105 | 109 | { |
| 106 | - if ($t < 20) |
|
| 107 | - return ($b & $c) | ((~$b) & $d); |
|
| 108 | - if ($t < 40) |
|
| 109 | - return $b ^ $c ^ $d; |
|
| 110 | - if ($t < 60) |
|
| 111 | - return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 110 | + if ($t < 20) { |
|
| 111 | + return ($b & $c) | ((~$b) & $d); |
|
| 112 | + } |
|
| 113 | + if ($t < 40) { |
|
| 114 | + return $b ^ $c ^ $d; |
|
| 115 | + } |
|
| 116 | + if ($t < 60) { |
|
| 117 | + return ($b & $c) | ($b & $d) | ($c & $d); |
|
| 118 | + } |
|
| 112 | 119 | |
| 113 | 120 | return $b ^ $c ^ $d; |
| 114 | 121 | } |
@@ -132,10 +139,11 @@ discard block |
||
| 132 | 139 | function sha1_rol($num, $cnt) |
| 133 | 140 | { |
| 134 | 141 | // Unfortunately, PHP uses unsigned 32-bit longs only. So we have to kludge it a bit. |
| 135 | - if ($num & 0x80000000) |
|
| 136 | - $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 137 | - else |
|
| 138 | - $a = $num >> (32 - $cnt); |
|
| 142 | + if ($num & 0x80000000) { |
|
| 143 | + $a = ($num >> 1 & 0x7fffffff) >> (31 - $cnt); |
|
| 144 | + } else { |
|
| 145 | + $a = $num >> (32 - $cnt); |
|
| 146 | + } |
|
| 139 | 147 | |
| 140 | 148 | return ($num << $cnt) | $a; |
| 141 | 149 | } |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | // Get everything started up... |
| 27 | 27 | define('SMF', 1); |
| 28 | -if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) |
|
| 28 | +if (function_exists('set_magic_quotes_runtime') && strnatcmp(phpversion(), '5.3.0') < 0) { |
|
| 29 | 29 | @set_magic_quotes_runtime(0); |
| 30 | +} |
|
| 30 | 31 | error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL); |
| 31 | 32 | $time_start = microtime(); |
| 32 | 33 | |
@@ -34,16 +35,18 @@ discard block |
||
| 34 | 35 | ob_start(); |
| 35 | 36 | |
| 36 | 37 | // Do some cleaning, just in case. |
| 37 | -foreach (array('db_character_set', 'cachedir') as $variable) |
|
| 38 | +foreach (array('db_character_set', 'cachedir') as $variable) { |
|
| 38 | 39 | if (isset($GLOBALS[$variable])) |
| 39 | 40 | unset($GLOBALS[$variable], $GLOBALS[$variable]); |
| 41 | +} |
|
| 40 | 42 | |
| 41 | 43 | // Load the settings... |
| 42 | 44 | require_once(dirname(__FILE__) . '/Settings.php'); |
| 43 | 45 | |
| 44 | 46 | // Make absolutely sure the cache directory is defined. |
| 45 | -if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
| 47 | +if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
| 46 | 48 | $cachedir = $boarddir . '/cache'; |
| 49 | +} |
|
| 47 | 50 | |
| 48 | 51 | // Without those we can't go anywhere |
| 49 | 52 | require_once($sourcedir . '/QueryString.php'); |
@@ -53,8 +56,9 @@ discard block |
||
| 53 | 56 | require_once($sourcedir . '/Load.php'); |
| 54 | 57 | |
| 55 | 58 | // If $maintenance is set specifically to 2, then we're upgrading or something. |
| 56 | -if (!empty($maintenance) && $maintenance == 2) |
|
| 59 | +if (!empty($maintenance) && $maintenance == 2) { |
|
| 57 | 60 | display_maintenance_message(); |
| 61 | +} |
|
| 58 | 62 | |
| 59 | 63 | // Create a variable to store some SMF specific functions in. |
| 60 | 64 | $smcFunc = array(); |
@@ -69,8 +73,9 @@ discard block |
||
| 69 | 73 | cleanRequest(); |
| 70 | 74 | |
| 71 | 75 | // Seed the random generator. |
| 72 | -if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) |
|
| 76 | +if (empty($modSettings['rand_seed']) || mt_rand(1, 250) == 69) { |
|
| 73 | 77 | smf_seed_generator(); |
| 78 | +} |
|
| 74 | 79 | |
| 75 | 80 | // Before we get carried away, are we doing a scheduled task? If so save CPU cycles by jumping out! |
| 76 | 81 | if (isset($_GET['scheduled'])) |
@@ -90,9 +95,9 @@ discard block |
||
| 90 | 95 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent()) |
| 91 | 96 | { |
| 92 | 97 | // If zlib is being used, turn off output compression. |
| 93 | - if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') |
|
| 94 | - $modSettings['enableCompressedOutput'] = '0'; |
|
| 95 | - else |
|
| 98 | + if (ini_get('zlib.output_compression') >= 1 || ini_get('output_handler') == 'ob_gzhandler') { |
|
| 99 | + $modSettings['enableCompressedOutput'] = '0'; |
|
| 100 | + } else |
|
| 96 | 101 | { |
| 97 | 102 | ob_end_clean(); |
| 98 | 103 | ob_start('ob_gzhandler'); |
@@ -141,18 +146,21 @@ discard block |
||
| 141 | 146 | loadPermissions(); |
| 142 | 147 | |
| 143 | 148 | // Attachments don't require the entire theme to be loaded. |
| 144 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') |
|
| 145 | - detectBrowser(); |
|
| 149 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach') { |
|
| 150 | + detectBrowser(); |
|
| 151 | + } |
|
| 146 | 152 | // Load the current theme. (note that ?theme=1 will also work, may be used for guest theming.) |
| 147 | - else |
|
| 148 | - loadTheme(); |
|
| 153 | + else { |
|
| 154 | + loadTheme(); |
|
| 155 | + } |
|
| 149 | 156 | |
| 150 | 157 | // Check if the user should be disallowed access. |
| 151 | 158 | is_not_banned(); |
| 152 | 159 | |
| 153 | 160 | // If we are in a topic and don't have permission to approve it then duck out now. |
| 154 | - if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) |
|
| 155 | - fatal_lang_error('not_a_topic', false); |
|
| 161 | + if (!empty($topic) && empty($board_info['cur_topic_approved']) && !allowedTo('approve_posts') && ($user_info['id'] != $board_info['cur_topic_starter'] || $user_info['is_guest'])) { |
|
| 162 | + fatal_lang_error('not_a_topic', false); |
|
| 163 | + } |
|
| 156 | 164 | |
| 157 | 165 | $no_stat_actions = array('clock', 'dlattach', 'findmember', 'jsoption', 'likes', 'loadeditorlocale', 'modifycat', 'requestmembers', 'smstats', 'suggest', 'about:unknown', '.xml', 'xmlhttp', 'verificationcode', 'viewquery', 'viewsmfile'); |
| 158 | 166 | call_integration_hook('integrate_pre_log_stats', array(&$no_stat_actions)); |
@@ -163,8 +171,9 @@ discard block |
||
| 163 | 171 | writeLog(); |
| 164 | 172 | |
| 165 | 173 | // Track forum statistics and hits...? |
| 166 | - if (!empty($modSettings['hitStats'])) |
|
| 167 | - trackStats(array('hits' => '+')); |
|
| 174 | + if (!empty($modSettings['hitStats'])) { |
|
| 175 | + trackStats(array('hits' => '+')); |
|
| 176 | + } |
|
| 168 | 177 | } |
| 169 | 178 | unset($no_stat_actions); |
| 170 | 179 | |
@@ -178,13 +187,14 @@ discard block |
||
| 178 | 187 | return ($_REQUEST['action'] == 'login2' ? 'Login2' : ($_REQUEST['action'] == 'logintfa' ? 'LoginTFA' : 'Logout')); |
| 179 | 188 | } |
| 180 | 189 | // Don't even try it, sonny. |
| 181 | - else |
|
| 182 | - return 'InMaintenance'; |
|
| 190 | + else { |
|
| 191 | + return 'InMaintenance'; |
|
| 192 | + } |
|
| 183 | 193 | } |
| 184 | 194 | // If guest access is off, a guest can only do one of the very few following actions. |
| 185 | - elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) |
|
| 186 | - return 'KickGuest'; |
|
| 187 | - elseif (empty($_REQUEST['action'])) |
|
| 195 | + elseif (empty($modSettings['allow_guestAccess']) && $user_info['is_guest'] && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('coppa', 'login', 'login2', 'logintfa', 'reminder', 'activate', 'help', 'helpadmin', 'smstats', 'verificationcode', 'signup', 'signup2')))) { |
|
| 196 | + return 'KickGuest'; |
|
| 197 | + } elseif (empty($_REQUEST['action'])) |
|
| 188 | 198 | { |
| 189 | 199 | // Action and board are both empty... BoardIndex! Unless someone else wants to do something different. |
| 190 | 200 | if (empty($board) && empty($topic)) |
@@ -200,8 +210,9 @@ discard block |
||
| 200 | 210 | |
| 201 | 211 | $call = call_helper($defaultAction, true); |
| 202 | 212 | |
| 203 | - if (!empty($call)) |
|
| 204 | - return $call; |
|
| 213 | + if (!empty($call)) { |
|
| 214 | + return $call; |
|
| 215 | + } |
|
| 205 | 216 | } |
| 206 | 217 | |
| 207 | 218 | // No default action huh? then go to our good old BoardIndex. |
@@ -331,8 +342,9 @@ discard block |
||
| 331 | 342 | |
| 332 | 343 | $call = call_helper($fallbackAction, true); |
| 333 | 344 | |
| 334 | - if (!empty($call)) |
|
| 335 | - return $call; |
|
| 345 | + if (!empty($call)) { |
|
| 346 | + return $call; |
|
| 347 | + } |
|
| 336 | 348 | } |
| 337 | 349 | |
| 338 | 350 | // No fallback action, huh? |
@@ -89,8 +89,9 @@ discard block |
||
| 89 | 89 | foreach ($section['areas'] as $i => $area) |
| 90 | 90 | { |
| 91 | 91 | // Not supposed to be printed? |
| 92 | - if (empty($area['label'])) |
|
| 93 | - continue; |
|
| 92 | + if (empty($area['label'])) { |
|
| 93 | + continue; |
|
| 94 | + } |
|
| 94 | 95 | |
| 95 | 96 | echo ' |
| 96 | 97 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>'; |
@@ -99,8 +100,9 @@ discard block |
||
| 99 | 100 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>'; |
| 100 | 101 | |
| 101 | 102 | // Is this the current area, or just some area? |
| 102 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
| 103 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 103 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
| 104 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
| 105 | + } |
|
| 104 | 106 | |
| 105 | 107 | // Are there any subsections? |
| 106 | 108 | if (!empty($area['subsections'])) |
@@ -110,8 +112,9 @@ discard block |
||
| 110 | 112 | |
| 111 | 113 | foreach ($area['subsections'] as $sa => $sub) |
| 112 | 114 | { |
| 113 | - if (!empty($sub['disabled'])) |
|
| 114 | - continue; |
|
| 115 | + if (!empty($sub['disabled'])) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
| 117 | 120 | |
@@ -158,8 +161,9 @@ discard block |
||
| 158 | 161 | <h3 class="catbg">'; |
| 159 | 162 | |
| 160 | 163 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
| 161 | - if (function_exists('template_admin_quick_search')) |
|
| 162 | - template_admin_quick_search(); |
|
| 164 | + if (function_exists('template_admin_quick_search')) { |
|
| 165 | + template_admin_quick_search(); |
|
| 166 | + } |
|
| 163 | 167 | |
| 164 | 168 | // Exactly how many tabs do we have? |
| 165 | 169 | if (!empty($context['tabs'])) |
@@ -174,30 +178,36 @@ discard block |
||
| 174 | 178 | } |
| 175 | 179 | |
| 176 | 180 | // Did this not even exist - or do we not have a label? |
| 177 | - if (!isset($tab_context['tabs'][$id])) |
|
| 178 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 179 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
| 180 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 181 | + if (!isset($tab_context['tabs'][$id])) { |
|
| 182 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
| 183 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
| 184 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
| 185 | + } |
|
| 181 | 186 | |
| 182 | 187 | // Has a custom URL defined in the main admin structure? |
| 183 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
| 184 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 188 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
| 189 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
| 190 | + } |
|
| 185 | 191 | |
| 186 | 192 | // Any additional paramaters for the url? |
| 187 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
| 188 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 193 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
| 194 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
| 195 | + } |
|
| 189 | 196 | |
| 190 | 197 | // Has it been deemed selected? |
| 191 | - if (!empty($tab['is_selected'])) |
|
| 192 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 198 | + if (!empty($tab['is_selected'])) { |
|
| 199 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
| 200 | + } |
|
| 193 | 201 | |
| 194 | 202 | // Does it have its own help? |
| 195 | - if (!empty($tab['help'])) |
|
| 196 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 203 | + if (!empty($tab['help'])) { |
|
| 204 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | // Is this the last one? |
| 199 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
| 200 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
| 208 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
| 209 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
| 210 | + } |
|
| 201 | 211 | } |
| 202 | 212 | |
| 203 | 213 | // Find the selected tab |
@@ -214,17 +224,18 @@ discard block |
||
| 214 | 224 | // Show an icon and/or a help item? |
| 215 | 225 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
| 216 | 226 | { |
| 217 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
| 218 | - echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
| 219 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
| 220 | - echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
| 227 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
| 228 | + echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
| 229 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
| 230 | + echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
| 231 | + } |
|
| 221 | 232 | |
| 222 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
| 223 | - echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
| 233 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
| 234 | + echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
| 235 | + } |
|
| 224 | 236 | |
| 225 | 237 | echo $tab_context['title']; |
| 226 | - } |
|
| 227 | - else |
|
| 238 | + } else |
|
| 228 | 239 | { |
| 229 | 240 | echo ' |
| 230 | 241 | ', $tab_context['title']; |
@@ -237,11 +248,12 @@ discard block |
||
| 237 | 248 | } |
| 238 | 249 | |
| 239 | 250 | // Shall we use the tabs? Yes, it's the only known way! |
| 240 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
| 241 | - echo ' |
|
| 251 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
| 252 | + echo ' |
|
| 242 | 253 | <p class="information"> |
| 243 | 254 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
| 244 | 255 | </p>'; |
| 256 | + } |
|
| 245 | 257 | |
| 246 | 258 | // Print out all the items in this tab (if any). |
| 247 | 259 | if (!empty($context['tabs'])) |
@@ -253,8 +265,9 @@ discard block |
||
| 253 | 265 | |
| 254 | 266 | foreach ($tab_context['tabs'] as $sa => $tab) |
| 255 | 267 | { |
| 256 | - if (!empty($tab['disabled'])) |
|
| 257 | - continue; |
|
| 268 | + if (!empty($tab['disabled'])) { |
|
| 269 | + continue; |
|
| 270 | + } |
|
| 258 | 271 | |
| 259 | 272 | if (!empty($tab['is_selected'])) |
| 260 | 273 | { |
@@ -262,12 +275,12 @@ discard block |
||
| 262 | 275 | <li> |
| 263 | 276 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 264 | 277 | </li>'; |
| 265 | - } |
|
| 266 | - else |
|
| 267 | - echo ' |
|
| 278 | + } else { |
|
| 279 | + echo ' |
|
| 268 | 280 | <li> |
| 269 | 281 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
| 270 | 282 | </li>'; |
| 283 | + } |
|
| 271 | 284 | } |
| 272 | 285 | |
| 273 | 286 | // the end of tabs |
@@ -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( |
@@ -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)); |