@@ -11,8 +11,9 @@ discard block |
||
| 11 | 11 | * @version 2.1 Beta 4 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if (!defined('SMF')) |
|
| 14 | +if (!defined('SMF')) { |
|
| 15 | 15 | die('No direct access...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
| 23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
| 24 | 25 | |
| 25 | 26 | // Attempt to load the member's profile data. |
| 26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
| 27 | - fatal_lang_error('not_a_user', false, 404); |
|
| 27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
| 28 | + fatal_lang_error('not_a_user', false, 404); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | // Set up the stuff and load the user. |
| 30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
| 49 | 51 | |
| 50 | 52 | // See if they have broken any warning levels... |
| 51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
| 52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
| 53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
| 55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
| 57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
| 55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
| 56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
| 57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
| 58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
| 59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | // They haven't even been registered for a full day!? |
| 60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
| 61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
| 62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 63 | - else |
|
| 64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
| 65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
| 66 | + } else { |
|
| 67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
| 68 | + } |
|
| 65 | 69 | |
| 66 | 70 | // Set the age... |
| 67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
| 70 | 74 | 'age' => $txt['not_applicable'], |
| 71 | 75 | 'today_is_birthday' => false |
| 72 | 76 | ); |
| 73 | - } |
|
| 74 | - else |
|
| 77 | + } else |
|
| 75 | 78 | { |
| 76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
| 77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
| 84 | 87 | if (allowedTo('moderate_forum')) |
| 85 | 88 | { |
| 86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
| 87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
| 88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 89 | - else |
|
| 90 | - $context['member']['hostname'] = ''; |
|
| 90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
| 91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
| 92 | + } else { |
|
| 93 | + $context['member']['hostname'] = ''; |
|
| 94 | + } |
|
| 91 | 95 | |
| 92 | 96 | $context['can_see_ip'] = true; |
| 97 | + } else { |
|
| 98 | + $context['can_see_ip'] = false; |
|
| 93 | 99 | } |
| 94 | - else |
|
| 95 | - $context['can_see_ip'] = false; |
|
| 96 | 100 | |
| 97 | 101 | // Are they hidden? |
| 98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | include_once($sourcedir . '/Who.php'); |
| 104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
| 105 | 109 | |
| 106 | - if ($action !== false) |
|
| 107 | - $context['member']['action'] = $action; |
|
| 110 | + if ($action !== false) { |
|
| 111 | + $context['member']['action'] = $action; |
|
| 112 | + } |
|
| 108 | 113 | } |
| 109 | 114 | |
| 110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
| 167 | 172 | { |
| 168 | 173 | // Work out what restrictions we actually have. |
| 169 | 174 | $ban_restrictions = array(); |
| 170 | - foreach (array('access', 'login', 'post') as $type) |
|
| 171 | - if ($row['cannot_' . $type]) |
|
| 175 | + foreach (array('access', 'login', 'post') as $type) { |
|
| 176 | + if ($row['cannot_' . $type]) |
|
| 172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // No actual ban in place? |
| 175 | - if (empty($ban_restrictions)) |
|
| 176 | - continue; |
|
| 181 | + if (empty($ban_restrictions)) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 177 | 184 | |
| 178 | 185 | // Prepare the link for context. |
| 179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
| 195 | 202 | $context['print_custom_fields'] = array(); |
| 196 | 203 | |
| 197 | 204 | // Any custom profile fields? |
| 198 | - if (!empty($context['custom_fields'])) |
|
| 199 | - foreach ($context['custom_fields'] as $custom) |
|
| 205 | + if (!empty($context['custom_fields'])) { |
|
| 206 | + foreach ($context['custom_fields'] as $custom) |
|
| 200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
| 208 | + } |
|
| 201 | 209 | |
| 202 | 210 | } |
| 203 | 211 | |
@@ -245,16 +253,18 @@ discard block |
||
| 245 | 253 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
| 246 | 254 | $alerts[$id_alert] = $row; |
| 247 | 255 | |
| 248 | - if (!empty($row['sender_id'])) |
|
| 249 | - $senders[] = $row['sender_id']; |
|
| 256 | + if (!empty($row['sender_id'])) { |
|
| 257 | + $senders[] = $row['sender_id']; |
|
| 258 | + } |
|
| 250 | 259 | } |
| 251 | 260 | $smcFunc['db_free_result']($request); |
| 252 | 261 | |
| 253 | 262 | if($withSender) |
| 254 | 263 | { |
| 255 | 264 | $senders = loadMemberData($senders); |
| 256 | - foreach ($senders as $member) |
|
| 257 | - loadMemberContext($member); |
|
| 265 | + foreach ($senders as $member) { |
|
| 266 | + loadMemberContext($member); |
|
| 267 | + } |
|
| 258 | 268 | } |
| 259 | 269 | |
| 260 | 270 | // Now go through and actually make with the text. |
@@ -269,12 +279,15 @@ discard block |
||
| 269 | 279 | $msgs = array(); |
| 270 | 280 | foreach ($alerts as $id_alert => $alert) |
| 271 | 281 | { |
| 272 | - if (isset($alert['extra']['board'])) |
|
| 273 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 274 | - if (isset($alert['extra']['topic'])) |
|
| 275 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 276 | - if ($alert['content_type'] == 'msg') |
|
| 277 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 282 | + if (isset($alert['extra']['board'])) { |
|
| 283 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 284 | + } |
|
| 285 | + if (isset($alert['extra']['topic'])) { |
|
| 286 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 287 | + } |
|
| 288 | + if ($alert['content_type'] == 'msg') { |
|
| 289 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 290 | + } |
|
| 278 | 291 | } |
| 279 | 292 | |
| 280 | 293 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -289,8 +302,9 @@ discard block |
||
| 289 | 302 | 'boards' => array_keys($boards), |
| 290 | 303 | ) |
| 291 | 304 | ); |
| 292 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 293 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 305 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 306 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 307 | + } |
|
| 294 | 308 | } |
| 295 | 309 | if (!empty($topics)) |
| 296 | 310 | { |
@@ -305,8 +319,9 @@ discard block |
||
| 305 | 319 | 'topics' => array_keys($topics), |
| 306 | 320 | ) |
| 307 | 321 | ); |
| 308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 309 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 323 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 324 | + } |
|
| 310 | 325 | } |
| 311 | 326 | if (!empty($msgs)) |
| 312 | 327 | { |
@@ -321,44 +336,51 @@ discard block |
||
| 321 | 336 | 'msgs' => array_keys($msgs), |
| 322 | 337 | ) |
| 323 | 338 | ); |
| 324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 325 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 340 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 341 | + } |
|
| 326 | 342 | } |
| 327 | 343 | |
| 328 | 344 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
| 329 | 345 | foreach ($alerts as $id_alert => $alert) |
| 330 | 346 | { |
| 331 | - if (!empty($alert['text'])) |
|
| 332 | - continue; |
|
| 333 | - if (isset($alert['extra']['board'])) |
|
| 334 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 347 | + if (!empty($alert['text'])) { |
|
| 348 | + continue; |
|
| 349 | + } |
|
| 350 | + if (isset($alert['extra']['board'])) { |
|
| 351 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 335 | 352 | { |
| 336 | 353 | unset($alerts[$id_alert]); |
| 354 | + } |
|
| 337 | 355 | continue; |
| 356 | + } else { |
|
| 357 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 338 | 358 | } |
| 339 | - else |
|
| 340 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 341 | - if (isset($alert['extra']['topic'])) |
|
| 342 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 359 | + if (isset($alert['extra']['topic'])) { |
|
| 360 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 343 | 361 | { |
| 344 | 362 | unset($alerts[$id_alert]); |
| 363 | + } |
|
| 345 | 364 | continue; |
| 365 | + } else { |
|
| 366 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 346 | 367 | } |
| 347 | - else |
|
| 348 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 349 | - if ($alert['content_type'] == 'msg') |
|
| 350 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 368 | + if ($alert['content_type'] == 'msg') { |
|
| 369 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 351 | 370 | { |
| 352 | 371 | unset($alerts[$id_alert]); |
| 372 | + } |
|
| 353 | 373 | continue; |
| 374 | + } else { |
|
| 375 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 354 | 376 | } |
| 355 | - else |
|
| 356 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 357 | - if ($alert['content_type'] == 'profile') |
|
| 358 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 377 | + if ($alert['content_type'] == 'profile') { |
|
| 378 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 379 | + } |
|
| 359 | 380 | |
| 360 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 361 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 381 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 382 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 383 | + } |
|
| 362 | 384 | |
| 363 | 385 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 364 | 386 | if (isset($txt[$string])) |
@@ -406,8 +428,8 @@ discard block |
||
| 406 | 428 | $context['pagination'] = constructPageIndex($scripturl . '?action=profile;area=showalerts;u=' . $memID, $start, $count, $maxIndex, false); |
| 407 | 429 | |
| 408 | 430 | // Set some JavaScript for checking all alerts at once. |
| 409 | - if ($context['showCheckboxes']) |
|
| 410 | - addInlineJavaScript(' |
|
| 431 | + if ($context['showCheckboxes']) { |
|
| 432 | + addInlineJavaScript(' |
|
| 411 | 433 | $(function(){ |
| 412 | 434 | $(\'#select_all\').on(\'change\', function() { |
| 413 | 435 | var checkboxes = $(\'ul.quickbuttons\').find(\':checkbox\'); |
@@ -419,6 +441,7 @@ discard block |
||
| 419 | 441 | } |
| 420 | 442 | }); |
| 421 | 443 | });', true); |
| 444 | + } |
|
| 422 | 445 | |
| 423 | 446 | // Set a nice message. |
| 424 | 447 | if (!empty($_SESSION['update_message'])) |
@@ -450,11 +473,11 @@ discard block |
||
| 450 | 473 | checkSession('request'); |
| 451 | 474 | |
| 452 | 475 | // Call it! |
| 453 | - if ($action == 'remove') |
|
| 454 | - alert_delete($toMark, $memID); |
|
| 455 | - |
|
| 456 | - else |
|
| 457 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 476 | + if ($action == 'remove') { |
|
| 477 | + alert_delete($toMark, $memID); |
|
| 478 | + } else { |
|
| 479 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 480 | + } |
|
| 458 | 481 | |
| 459 | 482 | // Set a nice update message. |
| 460 | 483 | $_SESSION['update_message'] = true; |
@@ -504,23 +527,27 @@ discard block |
||
| 504 | 527 | ); |
| 505 | 528 | |
| 506 | 529 | // Set the page title |
| 507 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 508 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 509 | - else |
|
| 510 | - $context['page_title'] = $txt['showPosts']; |
|
| 530 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 531 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 532 | + } else { |
|
| 533 | + $context['page_title'] = $txt['showPosts']; |
|
| 534 | + } |
|
| 511 | 535 | |
| 512 | 536 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 513 | 537 | |
| 514 | 538 | // Is the load average too high to allow searching just now? |
| 515 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 516 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 539 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 540 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 541 | + } |
|
| 517 | 542 | |
| 518 | 543 | // If we're specifically dealing with attachments use that function! |
| 519 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 520 | - return showAttachments($memID); |
|
| 544 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 545 | + return showAttachments($memID); |
|
| 546 | + } |
|
| 521 | 547 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 522 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 523 | - return showUnwatched($memID); |
|
| 548 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 549 | + return showUnwatched($memID); |
|
| 550 | + } |
|
| 524 | 551 | |
| 525 | 552 | // Are we just viewing topics? |
| 526 | 553 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -543,27 +570,30 @@ discard block |
||
| 543 | 570 | $smcFunc['db_free_result']($request); |
| 544 | 571 | |
| 545 | 572 | // Trying to remove a message that doesn't exist. |
| 546 | - if (empty($info)) |
|
| 547 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 573 | + if (empty($info)) { |
|
| 574 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 575 | + } |
|
| 548 | 576 | |
| 549 | 577 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 550 | 578 | require_once($sourcedir . '/RemoveTopic.php'); |
| 551 | 579 | removeMessage((int) $_GET['delete']); |
| 552 | 580 | |
| 553 | 581 | // Add it to the mod log. |
| 554 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 555 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 582 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 583 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 584 | + } |
|
| 556 | 585 | |
| 557 | 586 | // Back to... where we are now ;). |
| 558 | 587 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 559 | 588 | } |
| 560 | 589 | |
| 561 | 590 | // Default to 10. |
| 562 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 563 | - $_REQUEST['viewscount'] = '10'; |
|
| 591 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 592 | + $_REQUEST['viewscount'] = '10'; |
|
| 593 | + } |
|
| 564 | 594 | |
| 565 | - if ($context['is_topics']) |
|
| 566 | - $request = $smcFunc['db_query']('', ' |
|
| 595 | + if ($context['is_topics']) { |
|
| 596 | + $request = $smcFunc['db_query']('', ' |
|
| 567 | 597 | SELECT COUNT(*) |
| 568 | 598 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 569 | 599 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -576,8 +606,8 @@ discard block |
||
| 576 | 606 | 'board' => $board, |
| 577 | 607 | ) |
| 578 | 608 | ); |
| 579 | - else |
|
| 580 | - $request = $smcFunc['db_query']('', ' |
|
| 609 | + } else { |
|
| 610 | + $request = $smcFunc['db_query']('', ' |
|
| 581 | 611 | SELECT COUNT(*) |
| 582 | 612 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 583 | 613 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -590,6 +620,7 @@ discard block |
||
| 590 | 620 | 'board' => $board, |
| 591 | 621 | ) |
| 592 | 622 | ); |
| 623 | + } |
|
| 593 | 624 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 594 | 625 | $smcFunc['db_free_result']($request); |
| 595 | 626 | |
@@ -610,10 +641,11 @@ discard block |
||
| 610 | 641 | |
| 611 | 642 | $range_limit = ''; |
| 612 | 643 | |
| 613 | - if ($context['is_topics']) |
|
| 614 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 615 | - else |
|
| 616 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 644 | + if ($context['is_topics']) { |
|
| 645 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 646 | + } else { |
|
| 647 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 648 | + } |
|
| 617 | 649 | |
| 618 | 650 | $maxIndex = $maxPerPage; |
| 619 | 651 | |
@@ -639,9 +671,9 @@ discard block |
||
| 639 | 671 | { |
| 640 | 672 | $margin *= 5; |
| 641 | 673 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 674 | + } else { |
|
| 675 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 642 | 676 | } |
| 643 | - else |
|
| 644 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 645 | 677 | } |
| 646 | 678 | |
| 647 | 679 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -673,8 +705,7 @@ discard block |
||
| 673 | 705 | 'max' => $maxIndex, |
| 674 | 706 | ) |
| 675 | 707 | ); |
| 676 | - } |
|
| 677 | - else |
|
| 708 | + } else |
|
| 678 | 709 | { |
| 679 | 710 | $request = $smcFunc['db_query']('', ' |
| 680 | 711 | SELECT |
@@ -703,8 +734,9 @@ discard block |
||
| 703 | 734 | } |
| 704 | 735 | |
| 705 | 736 | // Make sure we quit this loop. |
| 706 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') |
|
| 707 | - break; |
|
| 737 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') { |
|
| 738 | + break; |
|
| 739 | + } |
|
| 708 | 740 | $looped = true; |
| 709 | 741 | $range_limit = ''; |
| 710 | 742 | } |
@@ -748,19 +780,21 @@ discard block |
||
| 748 | 780 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 749 | 781 | ); |
| 750 | 782 | |
| 751 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 752 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 783 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 784 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 785 | + } |
|
| 753 | 786 | $board_ids['any'][$row['id_board']][] = $counter; |
| 754 | 787 | } |
| 755 | 788 | $smcFunc['db_free_result']($request); |
| 756 | 789 | |
| 757 | 790 | // All posts were retrieved in reverse order, get them right again. |
| 758 | - if ($reverse) |
|
| 759 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 791 | + if ($reverse) { |
|
| 792 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 793 | + } |
|
| 760 | 794 | |
| 761 | 795 | // These are all the permissions that are different from board to board.. |
| 762 | - if ($context['is_topics']) |
|
| 763 | - $permissions = array( |
|
| 796 | + if ($context['is_topics']) { |
|
| 797 | + $permissions = array( |
|
| 764 | 798 | 'own' => array( |
| 765 | 799 | 'post_reply_own' => 'can_reply', |
| 766 | 800 | ), |
@@ -768,8 +802,8 @@ discard block |
||
| 768 | 802 | 'post_reply_any' => 'can_reply', |
| 769 | 803 | ) |
| 770 | 804 | ); |
| 771 | - else |
|
| 772 | - $permissions = array( |
|
| 805 | + } else { |
|
| 806 | + $permissions = array( |
|
| 773 | 807 | 'own' => array( |
| 774 | 808 | 'post_reply_own' => 'can_reply', |
| 775 | 809 | 'delete_own' => 'can_delete', |
@@ -779,6 +813,7 @@ discard block |
||
| 779 | 813 | 'delete_any' => 'can_delete', |
| 780 | 814 | ) |
| 781 | 815 | ); |
| 816 | + } |
|
| 782 | 817 | |
| 783 | 818 | // For every permission in the own/any lists... |
| 784 | 819 | foreach ($permissions as $type => $list) |
@@ -789,19 +824,22 @@ discard block |
||
| 789 | 824 | $boards = boardsAllowedTo($permission); |
| 790 | 825 | |
| 791 | 826 | // Hmm, they can do it on all boards, can they? |
| 792 | - if (!empty($boards) && $boards[0] == 0) |
|
| 793 | - $boards = array_keys($board_ids[$type]); |
|
| 827 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 828 | + $boards = array_keys($board_ids[$type]); |
|
| 829 | + } |
|
| 794 | 830 | |
| 795 | 831 | // Now go through each board they can do the permission on. |
| 796 | 832 | foreach ($boards as $board_id) |
| 797 | 833 | { |
| 798 | 834 | // There aren't any posts displayed from this board. |
| 799 | - if (!isset($board_ids[$type][$board_id])) |
|
| 800 | - continue; |
|
| 835 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 836 | + continue; |
|
| 837 | + } |
|
| 801 | 838 | |
| 802 | 839 | // Set the permission to true ;). |
| 803 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 804 | - $context['posts'][$counter][$allowed] = true; |
|
| 840 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 841 | + $context['posts'][$counter][$allowed] = true; |
|
| 842 | + } |
|
| 805 | 843 | } |
| 806 | 844 | } |
| 807 | 845 | } |
@@ -832,8 +870,9 @@ discard block |
||
| 832 | 870 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 833 | 871 | |
| 834 | 872 | // Make sure we can't actually see anything... |
| 835 | - if (empty($boardsAllowed)) |
|
| 836 | - $boardsAllowed = array(-1); |
|
| 873 | + if (empty($boardsAllowed)) { |
|
| 874 | + $boardsAllowed = array(-1); |
|
| 875 | + } |
|
| 837 | 876 | |
| 838 | 877 | require_once($sourcedir . '/Subs-List.php'); |
| 839 | 878 | |
@@ -984,8 +1023,8 @@ discard block |
||
| 984 | 1023 | ) |
| 985 | 1024 | ); |
| 986 | 1025 | $attachments = array(); |
| 987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 988 | - $attachments[] = array( |
|
| 1026 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1027 | + $attachments[] = array( |
|
| 989 | 1028 | 'id' => $row['id_attach'], |
| 990 | 1029 | 'filename' => $row['filename'], |
| 991 | 1030 | 'downloads' => $row['downloads'], |
@@ -997,6 +1036,7 @@ discard block |
||
| 997 | 1036 | 'board_name' => $row['name'], |
| 998 | 1037 | 'approved' => $row['approved'], |
| 999 | 1038 | ); |
| 1039 | + } |
|
| 1000 | 1040 | |
| 1001 | 1041 | $smcFunc['db_free_result']($request); |
| 1002 | 1042 | |
@@ -1051,8 +1091,9 @@ discard block |
||
| 1051 | 1091 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1052 | 1092 | |
| 1053 | 1093 | // Only the owner can see the list (if the function is enabled of course) |
| 1054 | - if ($user_info['id'] != $memID) |
|
| 1055 | - return; |
|
| 1094 | + if ($user_info['id'] != $memID) { |
|
| 1095 | + return; |
|
| 1096 | + } |
|
| 1056 | 1097 | |
| 1057 | 1098 | require_once($sourcedir . '/Subs-List.php'); |
| 1058 | 1099 | |
@@ -1198,8 +1239,9 @@ discard block |
||
| 1198 | 1239 | ); |
| 1199 | 1240 | |
| 1200 | 1241 | $topics = array(); |
| 1201 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1202 | - $topics[] = $row['id_topic']; |
|
| 1242 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1243 | + $topics[] = $row['id_topic']; |
|
| 1244 | + } |
|
| 1203 | 1245 | |
| 1204 | 1246 | $smcFunc['db_free_result']($request); |
| 1205 | 1247 | |
@@ -1219,8 +1261,9 @@ discard block |
||
| 1219 | 1261 | 'topics' => $topics, |
| 1220 | 1262 | ) |
| 1221 | 1263 | ); |
| 1222 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1223 | - $topicsInfo[] = $row; |
|
| 1264 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1265 | + $topicsInfo[] = $row; |
|
| 1266 | + } |
|
| 1224 | 1267 | $smcFunc['db_free_result']($request); |
| 1225 | 1268 | } |
| 1226 | 1269 | |
@@ -1268,8 +1311,9 @@ discard block |
||
| 1268 | 1311 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1269 | 1312 | |
| 1270 | 1313 | // Is the load average too high to allow searching just now? |
| 1271 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1272 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1314 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1315 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1316 | + } |
|
| 1273 | 1317 | |
| 1274 | 1318 | // General user statistics. |
| 1275 | 1319 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1412,11 +1456,13 @@ discard block |
||
| 1412 | 1456 | } |
| 1413 | 1457 | $smcFunc['db_free_result']($result); |
| 1414 | 1458 | |
| 1415 | - if ($maxPosts > 0) |
|
| 1416 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1459 | + if ($maxPosts > 0) { |
|
| 1460 | + for ($hour = 0; |
|
| 1461 | + } |
|
| 1462 | + $hour < 24; $hour++) |
|
| 1417 | 1463 | { |
| 1418 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1419 | - $context['posts_by_time'][$hour] = array( |
|
| 1464 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1465 | + $context['posts_by_time'][$hour] = array( |
|
| 1420 | 1466 | 'hour' => $hour, |
| 1421 | 1467 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1422 | 1468 | 'posts' => 0, |
@@ -1424,7 +1470,7 @@ discard block |
||
| 1424 | 1470 | 'relative_percent' => 0, |
| 1425 | 1471 | 'is_last' => $hour == 23, |
| 1426 | 1472 | ); |
| 1427 | - else |
|
| 1473 | + } else |
|
| 1428 | 1474 | { |
| 1429 | 1475 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1430 | 1476 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1457,8 +1503,9 @@ discard block |
||
| 1457 | 1503 | |
| 1458 | 1504 | foreach ($subActions as $sa => $action) |
| 1459 | 1505 | { |
| 1460 | - if (!allowedTo($action[2])) |
|
| 1461 | - unset($subActions[$sa]); |
|
| 1506 | + if (!allowedTo($action[2])) { |
|
| 1507 | + unset($subActions[$sa]); |
|
| 1508 | + } |
|
| 1462 | 1509 | } |
| 1463 | 1510 | |
| 1464 | 1511 | // Create the tabs for the template. |
@@ -1476,15 +1523,18 @@ discard block |
||
| 1476 | 1523 | ); |
| 1477 | 1524 | |
| 1478 | 1525 | // Moderation must be on to track edits. |
| 1479 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1480 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1526 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1527 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1528 | + } |
|
| 1481 | 1529 | |
| 1482 | 1530 | // Group requests must be active to show it... |
| 1483 | - if (empty($modSettings['show_group_membership'])) |
|
| 1484 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1531 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1532 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1533 | + } |
|
| 1485 | 1534 | |
| 1486 | - if (empty($subActions)) |
|
| 1487 | - fatal_lang_error('no_access', false); |
|
| 1535 | + if (empty($subActions)) { |
|
| 1536 | + fatal_lang_error('no_access', false); |
|
| 1537 | + } |
|
| 1488 | 1538 | |
| 1489 | 1539 | $keys = array_keys($subActions); |
| 1490 | 1540 | $default = array_shift($keys); |
@@ -1497,9 +1547,10 @@ discard block |
||
| 1497 | 1547 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1498 | 1548 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1499 | 1549 | |
| 1500 | - if (!empty($call)) |
|
| 1501 | - call_user_func($call, $memID); |
|
| 1502 | -} |
|
| 1550 | + if (!empty($call)) { |
|
| 1551 | + call_user_func($call, $memID); |
|
| 1552 | + } |
|
| 1553 | + } |
|
| 1503 | 1554 | |
| 1504 | 1555 | /** |
| 1505 | 1556 | * Handles tracking a user's activity |
@@ -1515,8 +1566,9 @@ discard block |
||
| 1515 | 1566 | isAllowedTo('moderate_forum'); |
| 1516 | 1567 | |
| 1517 | 1568 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1518 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1519 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1569 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1570 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1571 | + } |
|
| 1520 | 1572 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1521 | 1573 | |
| 1522 | 1574 | // Set the options for the list component. |
@@ -1683,8 +1735,9 @@ discard block |
||
| 1683 | 1735 | ) |
| 1684 | 1736 | ); |
| 1685 | 1737 | $message_members = array(); |
| 1686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1687 | - $message_members[] = $row['id_member']; |
|
| 1738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1739 | + $message_members[] = $row['id_member']; |
|
| 1740 | + } |
|
| 1688 | 1741 | $smcFunc['db_free_result']($request); |
| 1689 | 1742 | |
| 1690 | 1743 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1699,8 +1752,9 @@ discard block |
||
| 1699 | 1752 | 'ip_list' => $ips, |
| 1700 | 1753 | ) |
| 1701 | 1754 | ); |
| 1702 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1703 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1755 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1756 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1757 | + } |
|
| 1704 | 1758 | $smcFunc['db_free_result']($request); |
| 1705 | 1759 | } |
| 1706 | 1760 | |
@@ -1714,8 +1768,9 @@ discard block |
||
| 1714 | 1768 | 'ip_list' => $ips, |
| 1715 | 1769 | ) |
| 1716 | 1770 | ); |
| 1717 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1718 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1771 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1772 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1773 | + } |
|
| 1719 | 1774 | $smcFunc['db_free_result']($request); |
| 1720 | 1775 | } |
| 1721 | 1776 | } |
@@ -1775,8 +1830,8 @@ discard block |
||
| 1775 | 1830 | )) |
| 1776 | 1831 | ); |
| 1777 | 1832 | $error_messages = array(); |
| 1778 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1779 | - $error_messages[] = array( |
|
| 1833 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1834 | + $error_messages[] = array( |
|
| 1780 | 1835 | 'ip' => inet_dtop($row['ip']), |
| 1781 | 1836 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1782 | 1837 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1784,6 +1839,7 @@ discard block |
||
| 1784 | 1839 | 'time' => timeformat($row['log_time']), |
| 1785 | 1840 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1786 | 1841 | ); |
| 1842 | + } |
|
| 1787 | 1843 | $smcFunc['db_free_result']($request); |
| 1788 | 1844 | |
| 1789 | 1845 | return $error_messages; |
@@ -1846,8 +1902,8 @@ discard block |
||
| 1846 | 1902 | )) |
| 1847 | 1903 | ); |
| 1848 | 1904 | $messages = array(); |
| 1849 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1850 | - $messages[] = array( |
|
| 1905 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1906 | + $messages[] = array( |
|
| 1851 | 1907 | 'ip' => inet_dtop($row['poster_ip']), |
| 1852 | 1908 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1853 | 1909 | 'board' => array( |
@@ -1860,6 +1916,7 @@ discard block |
||
| 1860 | 1916 | 'time' => timeformat($row['poster_time']), |
| 1861 | 1917 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1862 | 1918 | ); |
| 1919 | + } |
|
| 1863 | 1920 | $smcFunc['db_free_result']($request); |
| 1864 | 1921 | |
| 1865 | 1922 | return $messages; |
@@ -1886,19 +1943,20 @@ discard block |
||
| 1886 | 1943 | $context['sub_template'] = 'trackIP'; |
| 1887 | 1944 | $context['page_title'] = $txt['profile']; |
| 1888 | 1945 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1889 | - } |
|
| 1890 | - else |
|
| 1946 | + } else |
|
| 1891 | 1947 | { |
| 1892 | 1948 | $context['ip'] = ip2range($user_profile[$memID]['member_ip']); |
| 1893 | 1949 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1894 | 1950 | } |
| 1895 | 1951 | |
| 1896 | 1952 | // Searching? |
| 1897 | - if (isset($_REQUEST['searchip'])) |
|
| 1898 | - $context['ip'] = ip2range(trim($_REQUEST['searchip'])); |
|
| 1953 | + if (isset($_REQUEST['searchip'])) { |
|
| 1954 | + $context['ip'] = ip2range(trim($_REQUEST['searchip'])); |
|
| 1955 | + } |
|
| 1899 | 1956 | |
| 1900 | - if (count($context['ip']) !== 2) |
|
| 1901 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1957 | + if (count($context['ip']) !== 2) { |
|
| 1958 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1959 | + } |
|
| 1902 | 1960 | |
| 1903 | 1961 | $ip_string = array('{inet:ip_address_low}','{inet:ip_address_high}'); |
| 1904 | 1962 | $fields = array( |
@@ -1908,13 +1966,15 @@ discard block |
||
| 1908 | 1966 | |
| 1909 | 1967 | $ip_var = $context['ip']; |
| 1910 | 1968 | |
| 1911 | - if ($context['ip']['low'] !== $context['ip']['high']) |
|
| 1912 | - $context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high']; |
|
| 1913 | - else |
|
| 1914 | - $context['ip'] = $context['ip']['low']; |
|
| 1969 | + if ($context['ip']['low'] !== $context['ip']['high']) { |
|
| 1970 | + $context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high']; |
|
| 1971 | + } else { |
|
| 1972 | + $context['ip'] = $context['ip']['low']; |
|
| 1973 | + } |
|
| 1915 | 1974 | |
| 1916 | - if (empty($context['tracking_area'])) |
|
| 1917 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1975 | + if (empty($context['tracking_area'])) { |
|
| 1976 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1977 | + } |
|
| 1918 | 1978 | |
| 1919 | 1979 | $request = $smcFunc['db_query']('', ' |
| 1920 | 1980 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1923,8 +1983,9 @@ discard block |
||
| 1923 | 1983 | $fields |
| 1924 | 1984 | ); |
| 1925 | 1985 | $context['ips'] = array(); |
| 1926 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1927 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1986 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1987 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1988 | + } |
|
| 1928 | 1989 | $smcFunc['db_free_result']($request); |
| 1929 | 1990 | |
| 1930 | 1991 | ksort($context['ips']); |
@@ -2154,10 +2215,11 @@ discard block |
||
| 2154 | 2215 | // Gonna want this for the list. |
| 2155 | 2216 | require_once($sourcedir . '/Subs-List.php'); |
| 2156 | 2217 | |
| 2157 | - if ($memID == 0) |
|
| 2158 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2159 | - else |
|
| 2160 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2218 | + if ($memID == 0) { |
|
| 2219 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2220 | + } else { |
|
| 2221 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2222 | + } |
|
| 2161 | 2223 | |
| 2162 | 2224 | // Start with the user messages. |
| 2163 | 2225 | $listOptions = array( |
@@ -2267,12 +2329,13 @@ discard block |
||
| 2267 | 2329 | ) |
| 2268 | 2330 | ); |
| 2269 | 2331 | $logins = array(); |
| 2270 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2271 | - $logins[] = array( |
|
| 2332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2333 | + $logins[] = array( |
|
| 2272 | 2334 | 'time' => timeformat($row['time']), |
| 2273 | 2335 | 'ip' => inet_dtop($row['ip']), |
| 2274 | 2336 | 'ip2' => inet_dtop($row['ip2']), |
| 2275 | 2337 | ); |
| 2338 | + } |
|
| 2276 | 2339 | $smcFunc['db_free_result']($request); |
| 2277 | 2340 | |
| 2278 | 2341 | return $logins; |
@@ -2297,11 +2360,12 @@ discard block |
||
| 2297 | 2360 | ) |
| 2298 | 2361 | ); |
| 2299 | 2362 | $context['custom_field_titles'] = array(); |
| 2300 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2301 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2363 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2364 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2302 | 2365 | 'title' => $row['field_name'], |
| 2303 | 2366 | 'parse_bbc' => $row['bbc'], |
| 2304 | 2367 | ); |
| 2368 | + } |
|
| 2305 | 2369 | $smcFunc['db_free_result']($request); |
| 2306 | 2370 | |
| 2307 | 2371 | // Set the options for the error lists. |
@@ -2440,19 +2504,22 @@ discard block |
||
| 2440 | 2504 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2441 | 2505 | { |
| 2442 | 2506 | $extra = $smcFunc['json_decode']($row['extra'], true); |
| 2443 | - if (!empty($extra['applicator'])) |
|
| 2444 | - $members[] = $extra['applicator']; |
|
| 2507 | + if (!empty($extra['applicator'])) { |
|
| 2508 | + $members[] = $extra['applicator']; |
|
| 2509 | + } |
|
| 2445 | 2510 | |
| 2446 | 2511 | // Work out what the name of the action is. |
| 2447 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2448 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2449 | - elseif (isset($txt[$row['action']])) |
|
| 2450 | - $action_text = $txt[$row['action']]; |
|
| 2512 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2513 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2514 | + } elseif (isset($txt[$row['action']])) { |
|
| 2515 | + $action_text = $txt[$row['action']]; |
|
| 2516 | + } |
|
| 2451 | 2517 | // Custom field? |
| 2452 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2453 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2454 | - else |
|
| 2455 | - $action_text = $row['action']; |
|
| 2518 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2519 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2520 | + } else { |
|
| 2521 | + $action_text = $row['action']; |
|
| 2522 | + } |
|
| 2456 | 2523 | |
| 2457 | 2524 | // Parse BBC? |
| 2458 | 2525 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2484,13 +2551,15 @@ discard block |
||
| 2484 | 2551 | ) |
| 2485 | 2552 | ); |
| 2486 | 2553 | $members = array(); |
| 2487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2488 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2554 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2555 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2556 | + } |
|
| 2489 | 2557 | $smcFunc['db_free_result']($request); |
| 2490 | 2558 | |
| 2491 | - foreach ($edits as $key => $value) |
|
| 2492 | - if (isset($members[$value['id_member']])) |
|
| 2559 | + foreach ($edits as $key => $value) { |
|
| 2560 | + if (isset($members[$value['id_member']])) |
|
| 2493 | 2561 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2562 | + } |
|
| 2494 | 2563 | } |
| 2495 | 2564 | |
| 2496 | 2565 | return $edits; |
@@ -2691,10 +2760,11 @@ discard block |
||
| 2691 | 2760 | $context['board'] = $board; |
| 2692 | 2761 | |
| 2693 | 2762 | // Determine which groups this user is in. |
| 2694 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2695 | - $curGroups = array(); |
|
| 2696 | - else |
|
| 2697 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2763 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2764 | + $curGroups = array(); |
|
| 2765 | + } else { |
|
| 2766 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2767 | + } |
|
| 2698 | 2768 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2699 | 2769 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2700 | 2770 | |
@@ -2714,28 +2784,30 @@ discard block |
||
| 2714 | 2784 | $context['no_access_boards'] = array(); |
| 2715 | 2785 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2716 | 2786 | { |
| 2717 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2718 | - $context['no_access_boards'][] = array( |
|
| 2787 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2788 | + $context['no_access_boards'][] = array( |
|
| 2719 | 2789 | 'id' => $row['id_board'], |
| 2720 | 2790 | 'name' => $row['name'], |
| 2721 | 2791 | 'is_last' => false, |
| 2722 | 2792 | ); |
| 2723 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2724 | - $context['boards'][$row['id_board']] = array( |
|
| 2793 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2794 | + $context['boards'][$row['id_board']] = array( |
|
| 2725 | 2795 | 'id' => $row['id_board'], |
| 2726 | 2796 | 'name' => $row['name'], |
| 2727 | 2797 | 'selected' => $board == $row['id_board'], |
| 2728 | 2798 | 'profile' => $row['id_profile'], |
| 2729 | 2799 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2730 | 2800 | ); |
| 2801 | + } |
|
| 2731 | 2802 | } |
| 2732 | 2803 | $smcFunc['db_free_result']($request); |
| 2733 | 2804 | |
| 2734 | 2805 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2735 | 2806 | sortBoards($context['boards']); |
| 2736 | 2807 | |
| 2737 | - if (!empty($context['no_access_boards'])) |
|
| 2738 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2808 | + if (!empty($context['no_access_boards'])) { |
|
| 2809 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2810 | + } |
|
| 2739 | 2811 | |
| 2740 | 2812 | $context['member']['permissions'] = array( |
| 2741 | 2813 | 'general' => array(), |
@@ -2744,8 +2816,9 @@ discard block |
||
| 2744 | 2816 | |
| 2745 | 2817 | // If you're an admin we know you can do everything, we might as well leave. |
| 2746 | 2818 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2747 | - if ($context['member']['has_all_permissions']) |
|
| 2748 | - return; |
|
| 2819 | + if ($context['member']['has_all_permissions']) { |
|
| 2820 | + return; |
|
| 2821 | + } |
|
| 2749 | 2822 | |
| 2750 | 2823 | $denied = array(); |
| 2751 | 2824 | |
@@ -2764,21 +2837,24 @@ discard block |
||
| 2764 | 2837 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2765 | 2838 | { |
| 2766 | 2839 | // We don't know about this permission, it doesn't exist :P. |
| 2767 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2768 | - continue; |
|
| 2840 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2841 | + continue; |
|
| 2842 | + } |
|
| 2769 | 2843 | |
| 2770 | - if (empty($row['add_deny'])) |
|
| 2771 | - $denied[] = $row['permission']; |
|
| 2844 | + if (empty($row['add_deny'])) { |
|
| 2845 | + $denied[] = $row['permission']; |
|
| 2846 | + } |
|
| 2772 | 2847 | |
| 2773 | 2848 | // Permissions that end with _own or _any consist of two parts. |
| 2774 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2775 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2776 | - else |
|
| 2777 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2849 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2850 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2851 | + } else { |
|
| 2852 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2853 | + } |
|
| 2778 | 2854 | |
| 2779 | 2855 | // Add this permission if it doesn't exist yet. |
| 2780 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2781 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2856 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2857 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2782 | 2858 | 'id' => $row['permission'], |
| 2783 | 2859 | 'groups' => array( |
| 2784 | 2860 | 'allowed' => array(), |
@@ -2788,6 +2864,7 @@ discard block |
||
| 2788 | 2864 | 'is_denied' => false, |
| 2789 | 2865 | 'is_global' => true, |
| 2790 | 2866 | ); |
| 2867 | + } |
|
| 2791 | 2868 | |
| 2792 | 2869 | // Add the membergroup to either the denied or the allowed groups. |
| 2793 | 2870 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2821,18 +2898,20 @@ discard block |
||
| 2821 | 2898 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2822 | 2899 | { |
| 2823 | 2900 | // We don't know about this permission, it doesn't exist :P. |
| 2824 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2825 | - continue; |
|
| 2901 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2902 | + continue; |
|
| 2903 | + } |
|
| 2826 | 2904 | |
| 2827 | 2905 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2828 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2829 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2830 | - else |
|
| 2831 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2906 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2907 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2908 | + } else { |
|
| 2909 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2910 | + } |
|
| 2832 | 2911 | |
| 2833 | 2912 | // Create the structure for this permission. |
| 2834 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2835 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2913 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2914 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2836 | 2915 | 'id' => $row['permission'], |
| 2837 | 2916 | 'groups' => array( |
| 2838 | 2917 | 'allowed' => array(), |
@@ -2842,6 +2921,7 @@ discard block |
||
| 2842 | 2921 | 'is_denied' => false, |
| 2843 | 2922 | 'is_global' => empty($board), |
| 2844 | 2923 | ); |
| 2924 | + } |
|
| 2845 | 2925 | |
| 2846 | 2926 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
| 2847 | 2927 | |
@@ -2860,8 +2940,9 @@ discard block |
||
| 2860 | 2940 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2861 | 2941 | |
| 2862 | 2942 | // Firstly, can we actually even be here? |
| 2863 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2864 | - fatal_lang_error('no_access', false); |
|
| 2943 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2944 | + fatal_lang_error('no_access', false); |
|
| 2945 | + } |
|
| 2865 | 2946 | |
| 2866 | 2947 | // Make sure things which are disabled stay disabled. |
| 2867 | 2948 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2948,9 +3029,10 @@ discard block |
||
| 2948 | 3029 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2949 | 3030 | ); |
| 2950 | 3031 | $context['current_level'] = 0; |
| 2951 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2952 | - if ($context['member']['warning'] >= $limit) |
|
| 3032 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3033 | + if ($context['member']['warning'] >= $limit) |
|
| 2953 | 3034 | $context['current_level'] = $limit; |
| 2954 | -} |
|
| 3035 | + } |
|
| 3036 | + } |
|
| 2955 | 3037 | |
| 2956 | 3038 | ?> |
| 2957 | 3039 | \ No newline at end of file |