@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
| 60 | 61 | 'max_year' => $year_high, |
| 61 | 62 | ) |
| 62 | 63 | ); |
| 63 | - } |
|
| 64 | - else |
|
| 64 | + } else |
|
| 65 | 65 | { |
| 66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
| 67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
| 91 | 91 | $bday = array(); |
| 92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 93 | 93 | { |
| 94 | - if ($year_low != $year_high) |
|
| 95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | - else |
|
| 97 | - $age_year = $year_low; |
|
| 94 | + if ($year_low != $year_high) { |
|
| 95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
| 96 | + } else { |
|
| 97 | + $age_year = $year_low; |
|
| 98 | + } |
|
| 98 | 99 | |
| 99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
| 100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
| 108 | 109 | ksort($bday); |
| 109 | 110 | |
| 110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
| 111 | - foreach ($bday as $mday => $array) |
|
| 112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 112 | + foreach ($bday as $mday => $array) { |
|
| 113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
| 114 | + } |
|
| 113 | 115 | |
| 114 | 116 | return $bday; |
| 115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
| 133 | 135 | static $timezone_array = array(); |
| 134 | 136 | require_once($sourcedir . '/Subs.php'); |
| 135 | 137 | |
| 136 | - if (empty($timezone_array['default'])) |
|
| 137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 138 | + if (empty($timezone_array['default'])) { |
|
| 139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
| 140 | + } |
|
| 138 | 141 | |
| 139 | 142 | $low_object = date_create($low_date); |
| 140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
| 161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 162 | 165 | { |
| 163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 165 | - continue; |
|
| 167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 168 | + continue; |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | // Force a censor of the title - as often these are used by others. |
| 168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
| 170 | 174 | // Get the various time and date properties for this event |
| 171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 172 | 176 | |
| 173 | - if (empty($timezone_array[$tz])) |
|
| 174 | - $timezone_array[$tz] = timezone_open($tz); |
|
| 177 | + if (empty($timezone_array[$tz])) { |
|
| 178 | + $timezone_array[$tz] = timezone_open($tz); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | // Sanity check |
| 177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 178 | - continue; |
|
| 182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 183 | + continue; |
|
| 184 | + } |
|
| 179 | 185 | |
| 180 | 186 | // Get set up for the loop |
| 181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
| 239 | 245 | ); |
| 240 | 246 | |
| 241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 242 | - if ($use_permissions) |
|
| 243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 248 | + if ($use_permissions) { |
|
| 249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
| 248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 250 | 256 | )); |
| 257 | + } |
|
| 251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 252 | - else |
|
| 253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 259 | + else { |
|
| 260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
| 260 | 267 | 'poster' => $row['id_member'], |
| 261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 262 | 269 | )); |
| 270 | + } |
|
| 263 | 271 | |
| 264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
| 269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 270 | 278 | if ($use_permissions) |
| 271 | 279 | { |
| 272 | - foreach ($events as $mday => $array) |
|
| 273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 280 | + foreach ($events as $mday => $array) { |
|
| 281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 282 | + } |
|
| 274 | 283 | } |
| 275 | 284 | |
| 276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
| 290 | 299 | global $smcFunc; |
| 291 | 300 | |
| 292 | 301 | // Get the lowest and highest dates for "all years". |
| 293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 296 | - else |
|
| 297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 305 | + } else { |
|
| 306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 307 | + } |
|
| 298 | 308 | |
| 299 | 309 | // Find some holidays... ;). |
| 300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
| 314 | 324 | $holidays = array(); |
| 315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 316 | 326 | { |
| 317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 319 | - else |
|
| 320 | - $event_year = substr($low_date, 0, 4); |
|
| 327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 329 | + } else { |
|
| 330 | + $event_year = substr($low_date, 0, 4); |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
| 343 | 354 | isAllowedTo('calendar_post'); |
| 344 | 355 | |
| 345 | 356 | // No board? No topic?!? |
| 346 | - if (empty($board)) |
|
| 347 | - fatal_lang_error('missing_board_id', false); |
|
| 348 | - if (empty($topic)) |
|
| 349 | - fatal_lang_error('missing_topic_id', false); |
|
| 357 | + if (empty($board)) { |
|
| 358 | + fatal_lang_error('missing_board_id', false); |
|
| 359 | + } |
|
| 360 | + if (empty($topic)) { |
|
| 361 | + fatal_lang_error('missing_topic_id', false); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Administrator, Moderator, or owner. Period. |
| 352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
| 364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 365 | 378 | { |
| 366 | 379 | // Not the owner of the topic. |
| 367 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 368 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 381 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 382 | + } |
|
| 369 | 383 | } |
| 370 | 384 | // Topic/Board doesn't exist..... |
| 371 | - else |
|
| 372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 385 | + else { |
|
| 386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 387 | + } |
|
| 373 | 388 | $smcFunc['db_free_result']($result); |
| 374 | 389 | } |
| 375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
| 457 | 472 | if (!empty($calendarOptions['start_day'])) |
| 458 | 473 | { |
| 459 | 474 | $nShift -= $calendarOptions['start_day']; |
| 460 | - if ($nShift < 0) |
|
| 461 | - $nShift = 7 + $nShift; |
|
| 475 | + if ($nShift < 0) { |
|
| 476 | + $nShift = 7 + $nShift; |
|
| 477 | + } |
|
| 462 | 478 | } |
| 463 | 479 | |
| 464 | 480 | // Number of rows required to fit the month. |
| 465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 467 | - $nRows++; |
|
| 482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 483 | + $nRows++; |
|
| 484 | + } |
|
| 468 | 485 | |
| 469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
| 477 | 494 | { |
| 478 | 495 | $calendarGrid['week_days'][] = $count; |
| 479 | 496 | $count++; |
| 480 | - if ($count == 7) |
|
| 481 | - $count = 0; |
|
| 497 | + if ($count == 7) { |
|
| 498 | + $count = 0; |
|
| 499 | + } |
|
| 482 | 500 | } |
| 483 | 501 | |
| 484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
| 495 | 513 | { |
| 496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 497 | 515 | |
| 498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 499 | - $nDay = 0; |
|
| 516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 517 | + $nDay = 0; |
|
| 518 | + } |
|
| 500 | 519 | |
| 501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
| 514 | 533 | } |
| 515 | 534 | |
| 516 | 535 | // What is the last day of the month? |
| 517 | - if ($is_previous === true) |
|
| 518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 536 | + if ($is_previous === true) { |
|
| 537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 538 | + } |
|
| 519 | 539 | |
| 520 | 540 | // We'll use the shift in the template. |
| 521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
| 549 | 569 | { |
| 550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
| 551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 552 | - if ($date_diff < 0) |
|
| 553 | - $date_diff += 7; |
|
| 572 | + if ($date_diff < 0) { |
|
| 573 | + $date_diff += 7; |
|
| 574 | + } |
|
| 554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
| 556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
| 680 | 701 | { |
| 681 | 702 | foreach ($date_events as $event_key => $event_val) |
| 682 | 703 | { |
| 683 | - if (in_array($event_val['id'], $temp)) |
|
| 684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 685 | - else |
|
| 686 | - $temp[] = $event_val['id']; |
|
| 704 | + if (in_array($event_val['id'], $temp)) { |
|
| 705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 706 | + } else { |
|
| 707 | + $temp[] = $event_val['id']; |
|
| 708 | + } |
|
| 687 | 709 | } |
| 688 | 710 | } |
| 689 | 711 | |
| 690 | 712 | // Give birthdays and holidays a friendly format, without the year |
| 691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 692 | - $date_format = '%b %d'; |
|
| 693 | - else |
|
| 694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 714 | + $date_format = '%b %d'; |
|
| 715 | + } else { |
|
| 716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 717 | + } |
|
| 695 | 718 | |
| 696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
| 697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
| 790 | 813 | // Holidays between now and now + days. |
| 791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 792 | 815 | { |
| 793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 818 | + } |
|
| 795 | 819 | } |
| 796 | 820 | } |
| 797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
| 803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
| 804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
| 805 | 829 | { |
| 806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 832 | + } |
|
| 808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 809 | 834 | } |
| 810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
| 819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
| 820 | 845 | |
| 821 | 846 | // No events today? Check the next day. |
| 822 | - if (empty($cached_data['events'][$loop_date])) |
|
| 823 | - continue; |
|
| 847 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 848 | + continue; |
|
| 849 | + } |
|
| 824 | 850 | |
| 825 | 851 | // Loop through all events to add a few last-minute values. |
| 826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
| 833 | 859 | { |
| 834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
| 835 | 861 | continue; |
| 862 | + } else { |
|
| 863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 836 | 864 | } |
| 837 | - else |
|
| 838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 839 | 865 | |
| 840 | 866 | // Might be set to true afterwards, depending on the permissions. |
| 841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
| 843 | 869 | $this_event['date'] = $loop_date; |
| 844 | 870 | } |
| 845 | 871 | |
| 846 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 874 | + } |
|
| 848 | 875 | } |
| 849 | 876 | } |
| 850 | 877 | |
| 851 | 878 | // Mark the last item so that a list separator can be used in the template. |
| 852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 881 | + } |
|
| 882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 884 | + } |
|
| 856 | 885 | |
| 857 | 886 | return array( |
| 858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
| 900 | 929 | if (isset($_POST['start_date'])) |
| 901 | 930 | { |
| 902 | 931 | $d = date_parse($_POST['start_date']); |
| 903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 904 | - fatal_lang_error('invalid_date', false); |
|
| 905 | - if (empty($d['year'])) |
|
| 906 | - fatal_lang_error('event_year_missing', false); |
|
| 907 | - if (empty($d['month'])) |
|
| 908 | - fatal_lang_error('event_month_missing', false); |
|
| 909 | - } |
|
| 910 | - elseif (isset($_POST['start_datetime'])) |
|
| 932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 933 | + fatal_lang_error('invalid_date', false); |
|
| 934 | + } |
|
| 935 | + if (empty($d['year'])) { |
|
| 936 | + fatal_lang_error('event_year_missing', false); |
|
| 937 | + } |
|
| 938 | + if (empty($d['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + } elseif (isset($_POST['start_datetime'])) |
|
| 911 | 942 | { |
| 912 | 943 | $d = date_parse($_POST['start_datetime']); |
| 913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 914 | - fatal_lang_error('invalid_date', false); |
|
| 915 | - if (empty($d['year'])) |
|
| 916 | - fatal_lang_error('event_year_missing', false); |
|
| 917 | - if (empty($d['month'])) |
|
| 918 | - fatal_lang_error('event_month_missing', false); |
|
| 944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 945 | + fatal_lang_error('invalid_date', false); |
|
| 946 | + } |
|
| 947 | + if (empty($d['year'])) { |
|
| 948 | + fatal_lang_error('event_year_missing', false); |
|
| 949 | + } |
|
| 950 | + if (empty($d['month'])) { |
|
| 951 | + fatal_lang_error('event_month_missing', false); |
|
| 952 | + } |
|
| 919 | 953 | } |
| 920 | 954 | // The 2.0 way |
| 921 | 955 | else |
| 922 | 956 | { |
| 923 | 957 | // No month? No year? |
| 924 | - if (!isset($_POST['month'])) |
|
| 925 | - fatal_lang_error('event_month_missing', false); |
|
| 926 | - if (!isset($_POST['year'])) |
|
| 927 | - fatal_lang_error('event_year_missing', false); |
|
| 958 | + if (!isset($_POST['month'])) { |
|
| 959 | + fatal_lang_error('event_month_missing', false); |
|
| 960 | + } |
|
| 961 | + if (!isset($_POST['year'])) { |
|
| 962 | + fatal_lang_error('event_year_missing', false); |
|
| 963 | + } |
|
| 928 | 964 | |
| 929 | 965 | // Check the month and year... |
| 930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 931 | - fatal_lang_error('invalid_month', false); |
|
| 932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 933 | - fatal_lang_error('invalid_year', false); |
|
| 966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 967 | + fatal_lang_error('invalid_month', false); |
|
| 968 | + } |
|
| 969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 970 | + fatal_lang_error('invalid_year', false); |
|
| 971 | + } |
|
| 934 | 972 | } |
| 935 | 973 | } |
| 936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
| 940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 941 | 979 | if (isset($_POST['span'])) |
| 942 | 980 | { |
| 943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 944 | - fatal_lang_error('invalid_days_numb', false); |
|
| 981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 982 | + fatal_lang_error('invalid_days_numb', false); |
|
| 983 | + } |
|
| 945 | 984 | } |
| 946 | 985 | |
| 947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
| 951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 952 | 991 | { |
| 953 | 992 | // No day? |
| 954 | - if (!isset($_POST['day'])) |
|
| 955 | - fatal_lang_error('event_day_missing', false); |
|
| 993 | + if (!isset($_POST['day'])) { |
|
| 994 | + fatal_lang_error('event_day_missing', false); |
|
| 995 | + } |
|
| 956 | 996 | |
| 957 | 997 | // Bad day? |
| 958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 959 | - fatal_lang_error('invalid_date', false); |
|
| 998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 999 | + fatal_lang_error('invalid_date', false); |
|
| 1000 | + } |
|
| 960 | 1001 | } |
| 961 | 1002 | |
| 962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 963 | - fatal_lang_error('event_title_missing', false); |
|
| 964 | - elseif (!isset($_POST['evtitle'])) |
|
| 965 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 1004 | + fatal_lang_error('event_title_missing', false); |
|
| 1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 1007 | + } |
|
| 966 | 1008 | |
| 967 | 1009 | // No title? |
| 968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 969 | - fatal_lang_error('no_event_title', false); |
|
| 970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 1011 | + fatal_lang_error('no_event_title', false); |
|
| 1012 | + } |
|
| 1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 1015 | + } |
|
| 972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 973 | 1017 | } |
| 974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
| 995 | 1039 | ); |
| 996 | 1040 | |
| 997 | 1041 | // No results, return false. |
| 998 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 999 | - return false; |
|
| 1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1043 | + return false; |
|
| 1044 | + } |
|
| 1000 | 1045 | |
| 1001 | 1046 | // Grab the results and return. |
| 1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
| 1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1131 | 1176 | |
| 1132 | 1177 | $column_clauses = array(); |
| 1133 | - foreach ($event_columns as $col => $crit) |
|
| 1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1178 | + foreach ($event_columns as $col => $crit) { |
|
| 1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1180 | + } |
|
| 1135 | 1181 | |
| 1136 | 1182 | $smcFunc['db_query']('', ' |
| 1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
| 1216 | 1262 | ); |
| 1217 | 1263 | |
| 1218 | 1264 | // If nothing returned, we are in poo, poo. |
| 1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1220 | - return false; |
|
| 1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1266 | + return false; |
|
| 1267 | + } |
|
| 1221 | 1268 | |
| 1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
| 1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1226 | 1273 | |
| 1227 | 1274 | // Sanity check |
| 1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1229 | - return false; |
|
| 1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1276 | + return false; |
|
| 1277 | + } |
|
| 1230 | 1278 | |
| 1231 | 1279 | $return_value = array( |
| 1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
| 1363 | 1411 | |
| 1364 | 1412 | // Set $span, in case we need it |
| 1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1366 | - if ($span > 0) |
|
| 1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1414 | + if ($span > 0) { |
|
| 1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1416 | + } |
|
| 1368 | 1417 | |
| 1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
| 1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1371 | - $tz = $eventOptions['tz']; |
|
| 1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1373 | - $tz = $_POST['tz']; |
|
| 1374 | - else |
|
| 1375 | - $tz = getUserTimezone(); |
|
| 1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1420 | + $tz = $eventOptions['tz']; |
|
| 1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1422 | + $tz = $_POST['tz']; |
|
| 1423 | + } else { |
|
| 1424 | + $tz = getUserTimezone(); |
|
| 1425 | + } |
|
| 1376 | 1426 | |
| 1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1378 | - if (isset($eventOptions['allday'])) |
|
| 1379 | - $allday = $eventOptions['allday']; |
|
| 1380 | - elseif (empty($_POST['allday'])) |
|
| 1381 | - $allday = false; |
|
| 1382 | - else |
|
| 1383 | - $allday = true; |
|
| 1428 | + if (isset($eventOptions['allday'])) { |
|
| 1429 | + $allday = $eventOptions['allday']; |
|
| 1430 | + } elseif (empty($_POST['allday'])) { |
|
| 1431 | + $allday = false; |
|
| 1432 | + } else { |
|
| 1433 | + $allday = true; |
|
| 1434 | + } |
|
| 1384 | 1435 | |
| 1385 | 1436 | // Input might come as individual parameters... |
| 1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
| 1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1408 | 1459 | |
| 1409 | 1460 | // If the date and time were given in separate strings, combine them |
| 1410 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1412 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1463 | + } |
|
| 1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1466 | + } |
|
| 1414 | 1467 | |
| 1415 | 1468 | // If some form of string input was given, override individually defined options with it |
| 1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
| 1501 | 1554 | if ($start_object >= $end_object) |
| 1502 | 1555 | { |
| 1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1504 | - if ($span > 0) |
|
| 1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1506 | - else |
|
| 1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1557 | + if ($span > 0) { |
|
| 1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1559 | + } else { |
|
| 1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1561 | + } |
|
| 1508 | 1562 | } |
| 1509 | 1563 | |
| 1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
| 1517 | 1571 | { |
| 1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1574 | + } else { |
|
| 1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1520 | 1576 | } |
| 1521 | - else |
|
| 1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1523 | 1577 | } |
| 1524 | 1578 | } |
| 1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
| 1532 | 1586 | $start_time = null; |
| 1533 | 1587 | $end_time = null; |
| 1534 | 1588 | $tz = null; |
| 1535 | - } |
|
| 1536 | - else |
|
| 1589 | + } else |
|
| 1537 | 1590 | { |
| 1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
| 1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
| 1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
| 1560 | 1613 | if (empty($date_format)) |
| 1561 | 1614 | { |
| 1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1563 | - $date_format = '%F'; |
|
| 1564 | - else |
|
| 1565 | - $date_format = $matches[0]; |
|
| 1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1616 | + $date_format = '%F'; |
|
| 1617 | + } else { |
|
| 1618 | + $date_format = $matches[0]; |
|
| 1619 | + } |
|
| 1566 | 1620 | } |
| 1567 | 1621 | |
| 1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1569 | 1623 | if (empty($time_format)) |
| 1570 | 1624 | { |
| 1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1572 | - $time_format = '%k:%M'; |
|
| 1573 | - else |
|
| 1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1626 | + $time_format = '%k:%M'; |
|
| 1627 | + } else { |
|
| 1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1629 | + } |
|
| 1575 | 1630 | } |
| 1576 | 1631 | |
| 1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
| 1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1582 | 1637 | |
| 1583 | 1638 | // We need to have a defined timezone in the steps below |
| 1584 | - if (empty($row['timezone'])) |
|
| 1585 | - $row['timezone'] = getUserTimezone(); |
|
| 1639 | + if (empty($row['timezone'])) { |
|
| 1640 | + $row['timezone'] = getUserTimezone(); |
|
| 1641 | + } |
|
| 1586 | 1642 | |
| 1587 | - if (empty($timezone_array[$row['timezone']])) |
|
| 1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
| 1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
| 1645 | + } |
|
| 1589 | 1646 | |
| 1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
| 1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
| 1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1634 | 1691 | static $member_cache = array(); |
| 1635 | 1692 | |
| 1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1637 | - $id_member = $context['user']['id']; |
|
| 1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1694 | + $id_member = $context['user']['id']; |
|
| 1695 | + } |
|
| 1638 | 1696 | |
| 1639 | 1697 | //check if the cache got the data |
| 1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
| 1663 | 1721 | $smcFunc['db_free_result']($request); |
| 1664 | 1722 | } |
| 1665 | 1723 | |
| 1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1726 | + } |
|
| 1668 | 1727 | |
| 1669 | - if (isset($id_member)) |
|
| 1670 | - $member_cache[$id_member] = $timezone; |
|
| 1728 | + if (isset($id_member)) { |
|
| 1729 | + $member_cache[$id_member] = $timezone; |
|
| 1730 | + } |
|
| 1671 | 1731 | |
| 1672 | 1732 | return $timezone; |
| 1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
| 1696 | 1756 | ) |
| 1697 | 1757 | ); |
| 1698 | 1758 | $holidays = array(); |
| 1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1700 | - $holidays[] = $row; |
|
| 1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1760 | + $holidays[] = $row; |
|
| 1761 | + } |
|
| 1701 | 1762 | $smcFunc['db_free_result']($request); |
| 1702 | 1763 | |
| 1703 | 1764 | return $holidays; |
@@ -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 | |
@@ -242,16 +250,18 @@ discard block |
||
| 242 | 250 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
| 243 | 251 | $alerts[$id_alert] = $row; |
| 244 | 252 | |
| 245 | - if (!empty($row['sender_id'])) |
|
| 246 | - $senders[] = $row['sender_id']; |
|
| 253 | + if (!empty($row['sender_id'])) { |
|
| 254 | + $senders[] = $row['sender_id']; |
|
| 255 | + } |
|
| 247 | 256 | } |
| 248 | 257 | $smcFunc['db_free_result']($request); |
| 249 | 258 | |
| 250 | 259 | if($withSender) |
| 251 | 260 | { |
| 252 | 261 | $senders = loadMemberData($senders); |
| 253 | - foreach ($senders as $member) |
|
| 254 | - loadMemberContext($member); |
|
| 262 | + foreach ($senders as $member) { |
|
| 263 | + loadMemberContext($member); |
|
| 264 | + } |
|
| 255 | 265 | } |
| 256 | 266 | |
| 257 | 267 | // Now go through and actually make with the text. |
@@ -266,12 +276,15 @@ discard block |
||
| 266 | 276 | $msgs = array(); |
| 267 | 277 | foreach ($alerts as $id_alert => $alert) |
| 268 | 278 | { |
| 269 | - if (isset($alert['extra']['board'])) |
|
| 270 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 271 | - if (isset($alert['extra']['topic'])) |
|
| 272 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 273 | - if ($alert['content_type'] == 'msg') |
|
| 274 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 279 | + if (isset($alert['extra']['board'])) { |
|
| 280 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
| 281 | + } |
|
| 282 | + if (isset($alert['extra']['topic'])) { |
|
| 283 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
| 284 | + } |
|
| 285 | + if ($alert['content_type'] == 'msg') { |
|
| 286 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
| 287 | + } |
|
| 275 | 288 | } |
| 276 | 289 | |
| 277 | 290 | // 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. |
@@ -286,8 +299,9 @@ discard block |
||
| 286 | 299 | 'boards' => array_keys($boards), |
| 287 | 300 | ) |
| 288 | 301 | ); |
| 289 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 290 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 303 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 304 | + } |
|
| 291 | 305 | } |
| 292 | 306 | if (!empty($topics)) |
| 293 | 307 | { |
@@ -302,8 +316,9 @@ discard block |
||
| 302 | 316 | 'topics' => array_keys($topics), |
| 303 | 317 | ) |
| 304 | 318 | ); |
| 305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 306 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 319 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 320 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
| 321 | + } |
|
| 307 | 322 | } |
| 308 | 323 | if (!empty($msgs)) |
| 309 | 324 | { |
@@ -318,44 +333,51 @@ discard block |
||
| 318 | 333 | 'msgs' => array_keys($msgs), |
| 319 | 334 | ) |
| 320 | 335 | ); |
| 321 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 322 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 336 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 337 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 338 | + } |
|
| 323 | 339 | } |
| 324 | 340 | |
| 325 | 341 | // 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) |
| 326 | 342 | foreach ($alerts as $id_alert => $alert) |
| 327 | 343 | { |
| 328 | - if (!empty($alert['text'])) |
|
| 329 | - continue; |
|
| 330 | - if (isset($alert['extra']['board'])) |
|
| 331 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 344 | + if (!empty($alert['text'])) { |
|
| 345 | + continue; |
|
| 346 | + } |
|
| 347 | + if (isset($alert['extra']['board'])) { |
|
| 348 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
| 332 | 349 | { |
| 333 | 350 | unset($alerts[$id_alert]); |
| 351 | + } |
|
| 334 | 352 | continue; |
| 353 | + } else { |
|
| 354 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 335 | 355 | } |
| 336 | - else |
|
| 337 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
| 338 | - if (isset($alert['extra']['topic'])) |
|
| 339 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 356 | + if (isset($alert['extra']['topic'])) { |
|
| 357 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
| 340 | 358 | { |
| 341 | 359 | unset($alerts[$id_alert]); |
| 360 | + } |
|
| 342 | 361 | continue; |
| 362 | + } else { |
|
| 363 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 343 | 364 | } |
| 344 | - else |
|
| 345 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
| 346 | - if ($alert['content_type'] == 'msg') |
|
| 347 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 365 | + if ($alert['content_type'] == 'msg') { |
|
| 366 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
| 348 | 367 | { |
| 349 | 368 | unset($alerts[$id_alert]); |
| 369 | + } |
|
| 350 | 370 | continue; |
| 351 | - } |
|
| 352 | - else |
|
| 353 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 354 | - if ($alert['content_type'] == 'profile') |
|
| 355 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 371 | + } else { |
|
| 372 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
| 373 | + } |
|
| 374 | + if ($alert['content_type'] == 'profile') { |
|
| 375 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
| 376 | + } |
|
| 356 | 377 | |
| 357 | - if (!empty($memberContext[$alert['sender_id']])) |
|
| 358 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 378 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
| 379 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
| 380 | + } |
|
| 359 | 381 | |
| 360 | 382 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
| 361 | 383 | if (isset($txt[$string])) |
@@ -443,11 +465,11 @@ discard block |
||
| 443 | 465 | checkSession('request'); |
| 444 | 466 | |
| 445 | 467 | // Call it! |
| 446 | - if ($action == 'remove') |
|
| 447 | - alert_delete($toMark, $memID); |
|
| 448 | - |
|
| 449 | - else |
|
| 450 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 468 | + if ($action == 'remove') { |
|
| 469 | + alert_delete($toMark, $memID); |
|
| 470 | + } else { |
|
| 471 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
| 472 | + } |
|
| 451 | 473 | |
| 452 | 474 | // Set a nice update message. |
| 453 | 475 | $_SESSION['update_message'] = true; |
@@ -497,23 +519,27 @@ discard block |
||
| 497 | 519 | ); |
| 498 | 520 | |
| 499 | 521 | // Set the page title |
| 500 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
| 501 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 502 | - else |
|
| 503 | - $context['page_title'] = $txt['showPosts']; |
|
| 522 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
| 523 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
| 524 | + } else { |
|
| 525 | + $context['page_title'] = $txt['showPosts']; |
|
| 526 | + } |
|
| 504 | 527 | |
| 505 | 528 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
| 506 | 529 | |
| 507 | 530 | // Is the load average too high to allow searching just now? |
| 508 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
| 509 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 531 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
| 532 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
| 533 | + } |
|
| 510 | 534 | |
| 511 | 535 | // If we're specifically dealing with attachments use that function! |
| 512 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
| 513 | - return showAttachments($memID); |
|
| 536 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
| 537 | + return showAttachments($memID); |
|
| 538 | + } |
|
| 514 | 539 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
| 515 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
| 516 | - return showUnwatched($memID); |
|
| 540 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
| 541 | + return showUnwatched($memID); |
|
| 542 | + } |
|
| 517 | 543 | |
| 518 | 544 | // Are we just viewing topics? |
| 519 | 545 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -536,27 +562,30 @@ discard block |
||
| 536 | 562 | $smcFunc['db_free_result']($request); |
| 537 | 563 | |
| 538 | 564 | // Trying to remove a message that doesn't exist. |
| 539 | - if (empty($info)) |
|
| 540 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 565 | + if (empty($info)) { |
|
| 566 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
| 567 | + } |
|
| 541 | 568 | |
| 542 | 569 | // We can be lazy, since removeMessage() will check the permissions for us. |
| 543 | 570 | require_once($sourcedir . '/RemoveTopic.php'); |
| 544 | 571 | removeMessage((int) $_GET['delete']); |
| 545 | 572 | |
| 546 | 573 | // Add it to the mod log. |
| 547 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
| 548 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 574 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
| 575 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
| 576 | + } |
|
| 549 | 577 | |
| 550 | 578 | // Back to... where we are now ;). |
| 551 | 579 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
| 552 | 580 | } |
| 553 | 581 | |
| 554 | 582 | // Default to 10. |
| 555 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
| 556 | - $_REQUEST['viewscount'] = '10'; |
|
| 583 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
| 584 | + $_REQUEST['viewscount'] = '10'; |
|
| 585 | + } |
|
| 557 | 586 | |
| 558 | - if ($context['is_topics']) |
|
| 559 | - $request = $smcFunc['db_query']('', ' |
|
| 587 | + if ($context['is_topics']) { |
|
| 588 | + $request = $smcFunc['db_query']('', ' |
|
| 560 | 589 | SELECT COUNT(*) |
| 561 | 590 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 562 | 591 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -569,8 +598,8 @@ discard block |
||
| 569 | 598 | 'board' => $board, |
| 570 | 599 | ) |
| 571 | 600 | ); |
| 572 | - else |
|
| 573 | - $request = $smcFunc['db_query']('', ' |
|
| 601 | + } else { |
|
| 602 | + $request = $smcFunc['db_query']('', ' |
|
| 574 | 603 | SELECT COUNT(*) |
| 575 | 604 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
| 576 | 605 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -583,6 +612,7 @@ discard block |
||
| 583 | 612 | 'board' => $board, |
| 584 | 613 | ) |
| 585 | 614 | ); |
| 615 | + } |
|
| 586 | 616 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
| 587 | 617 | $smcFunc['db_free_result']($request); |
| 588 | 618 | |
@@ -603,10 +633,11 @@ discard block |
||
| 603 | 633 | |
| 604 | 634 | $range_limit = ''; |
| 605 | 635 | |
| 606 | - if ($context['is_topics']) |
|
| 607 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 608 | - else |
|
| 609 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 636 | + if ($context['is_topics']) { |
|
| 637 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
| 638 | + } else { |
|
| 639 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 640 | + } |
|
| 610 | 641 | |
| 611 | 642 | $maxIndex = $maxPerPage; |
| 612 | 643 | |
@@ -632,9 +663,9 @@ discard block |
||
| 632 | 663 | { |
| 633 | 664 | $margin *= 5; |
| 634 | 665 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
| 666 | + } else { |
|
| 667 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 635 | 668 | } |
| 636 | - else |
|
| 637 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
| 638 | 669 | } |
| 639 | 670 | |
| 640 | 671 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -666,8 +697,7 @@ discard block |
||
| 666 | 697 | 'max' => $maxIndex, |
| 667 | 698 | ) |
| 668 | 699 | ); |
| 669 | - } |
|
| 670 | - else |
|
| 700 | + } else |
|
| 671 | 701 | { |
| 672 | 702 | $request = $smcFunc['db_query']('', ' |
| 673 | 703 | SELECT |
@@ -696,8 +726,9 @@ discard block |
||
| 696 | 726 | } |
| 697 | 727 | |
| 698 | 728 | // Make sure we quit this loop. |
| 699 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
| 700 | - break; |
|
| 729 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
| 730 | + break; |
|
| 731 | + } |
|
| 701 | 732 | $looped = true; |
| 702 | 733 | $range_limit = ''; |
| 703 | 734 | } |
@@ -741,19 +772,21 @@ discard block |
||
| 741 | 772 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
| 742 | 773 | ); |
| 743 | 774 | |
| 744 | - if ($user_info['id'] == $row['id_member_started']) |
|
| 745 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
| 775 | + if ($user_info['id'] == $row['id_member_started']) { |
|
| 776 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
| 777 | + } |
|
| 746 | 778 | $board_ids['any'][$row['id_board']][] = $counter; |
| 747 | 779 | } |
| 748 | 780 | $smcFunc['db_free_result']($request); |
| 749 | 781 | |
| 750 | 782 | // All posts were retrieved in reverse order, get them right again. |
| 751 | - if ($reverse) |
|
| 752 | - $context['posts'] = array_reverse($context['posts'], true); |
|
| 783 | + if ($reverse) { |
|
| 784 | + $context['posts'] = array_reverse($context['posts'], true); |
|
| 785 | + } |
|
| 753 | 786 | |
| 754 | 787 | // These are all the permissions that are different from board to board.. |
| 755 | - if ($context['is_topics']) |
|
| 756 | - $permissions = array( |
|
| 788 | + if ($context['is_topics']) { |
|
| 789 | + $permissions = array( |
|
| 757 | 790 | 'own' => array( |
| 758 | 791 | 'post_reply_own' => 'can_reply', |
| 759 | 792 | ), |
@@ -761,8 +794,8 @@ discard block |
||
| 761 | 794 | 'post_reply_any' => 'can_reply', |
| 762 | 795 | ) |
| 763 | 796 | ); |
| 764 | - else |
|
| 765 | - $permissions = array( |
|
| 797 | + } else { |
|
| 798 | + $permissions = array( |
|
| 766 | 799 | 'own' => array( |
| 767 | 800 | 'post_reply_own' => 'can_reply', |
| 768 | 801 | 'delete_own' => 'can_delete', |
@@ -772,6 +805,7 @@ discard block |
||
| 772 | 805 | 'delete_any' => 'can_delete', |
| 773 | 806 | ) |
| 774 | 807 | ); |
| 808 | + } |
|
| 775 | 809 | |
| 776 | 810 | // For every permission in the own/any lists... |
| 777 | 811 | foreach ($permissions as $type => $list) |
@@ -782,19 +816,22 @@ discard block |
||
| 782 | 816 | $boards = boardsAllowedTo($permission); |
| 783 | 817 | |
| 784 | 818 | // Hmm, they can do it on all boards, can they? |
| 785 | - if (!empty($boards) && $boards[0] == 0) |
|
| 786 | - $boards = array_keys($board_ids[$type]); |
|
| 819 | + if (!empty($boards) && $boards[0] == 0) { |
|
| 820 | + $boards = array_keys($board_ids[$type]); |
|
| 821 | + } |
|
| 787 | 822 | |
| 788 | 823 | // Now go through each board they can do the permission on. |
| 789 | 824 | foreach ($boards as $board_id) |
| 790 | 825 | { |
| 791 | 826 | // There aren't any posts displayed from this board. |
| 792 | - if (!isset($board_ids[$type][$board_id])) |
|
| 793 | - continue; |
|
| 827 | + if (!isset($board_ids[$type][$board_id])) { |
|
| 828 | + continue; |
|
| 829 | + } |
|
| 794 | 830 | |
| 795 | 831 | // Set the permission to true ;). |
| 796 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
| 797 | - $context['posts'][$counter][$allowed] = true; |
|
| 832 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
| 833 | + $context['posts'][$counter][$allowed] = true; |
|
| 834 | + } |
|
| 798 | 835 | } |
| 799 | 836 | } |
| 800 | 837 | } |
@@ -825,8 +862,9 @@ discard block |
||
| 825 | 862 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
| 826 | 863 | |
| 827 | 864 | // Make sure we can't actually see anything... |
| 828 | - if (empty($boardsAllowed)) |
|
| 829 | - $boardsAllowed = array(-1); |
|
| 865 | + if (empty($boardsAllowed)) { |
|
| 866 | + $boardsAllowed = array(-1); |
|
| 867 | + } |
|
| 830 | 868 | |
| 831 | 869 | require_once($sourcedir . '/Subs-List.php'); |
| 832 | 870 | |
@@ -977,8 +1015,8 @@ discard block |
||
| 977 | 1015 | ) |
| 978 | 1016 | ); |
| 979 | 1017 | $attachments = array(); |
| 980 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 981 | - $attachments[] = array( |
|
| 1018 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1019 | + $attachments[] = array( |
|
| 982 | 1020 | 'id' => $row['id_attach'], |
| 983 | 1021 | 'filename' => $row['filename'], |
| 984 | 1022 | 'downloads' => $row['downloads'], |
@@ -990,6 +1028,7 @@ discard block |
||
| 990 | 1028 | 'board_name' => $row['name'], |
| 991 | 1029 | 'approved' => $row['approved'], |
| 992 | 1030 | ); |
| 1031 | + } |
|
| 993 | 1032 | |
| 994 | 1033 | $smcFunc['db_free_result']($request); |
| 995 | 1034 | |
@@ -1044,8 +1083,9 @@ discard block |
||
| 1044 | 1083 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
| 1045 | 1084 | |
| 1046 | 1085 | // Only the owner can see the list (if the function is enabled of course) |
| 1047 | - if ($user_info['id'] != $memID) |
|
| 1048 | - return; |
|
| 1086 | + if ($user_info['id'] != $memID) { |
|
| 1087 | + return; |
|
| 1088 | + } |
|
| 1049 | 1089 | |
| 1050 | 1090 | require_once($sourcedir . '/Subs-List.php'); |
| 1051 | 1091 | |
@@ -1191,8 +1231,9 @@ discard block |
||
| 1191 | 1231 | ); |
| 1192 | 1232 | |
| 1193 | 1233 | $topics = array(); |
| 1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1195 | - $topics[] = $row['id_topic']; |
|
| 1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1235 | + $topics[] = $row['id_topic']; |
|
| 1236 | + } |
|
| 1196 | 1237 | |
| 1197 | 1238 | $smcFunc['db_free_result']($request); |
| 1198 | 1239 | |
@@ -1212,8 +1253,9 @@ discard block |
||
| 1212 | 1253 | 'topics' => $topics, |
| 1213 | 1254 | ) |
| 1214 | 1255 | ); |
| 1215 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1216 | - $topicsInfo[] = $row; |
|
| 1256 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1257 | + $topicsInfo[] = $row; |
|
| 1258 | + } |
|
| 1217 | 1259 | $smcFunc['db_free_result']($request); |
| 1218 | 1260 | } |
| 1219 | 1261 | |
@@ -1261,8 +1303,9 @@ discard block |
||
| 1261 | 1303 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
| 1262 | 1304 | |
| 1263 | 1305 | // Is the load average too high to allow searching just now? |
| 1264 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
| 1265 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1306 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
| 1307 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
| 1308 | + } |
|
| 1266 | 1309 | |
| 1267 | 1310 | // General user statistics. |
| 1268 | 1311 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1405,11 +1448,13 @@ discard block |
||
| 1405 | 1448 | } |
| 1406 | 1449 | $smcFunc['db_free_result']($result); |
| 1407 | 1450 | |
| 1408 | - if ($maxPosts > 0) |
|
| 1409 | - for ($hour = 0; $hour < 24; $hour++) |
|
| 1451 | + if ($maxPosts > 0) { |
|
| 1452 | + for ($hour = 0; |
|
| 1453 | + } |
|
| 1454 | + $hour < 24; $hour++) |
|
| 1410 | 1455 | { |
| 1411 | - if (!isset($context['posts_by_time'][$hour])) |
|
| 1412 | - $context['posts_by_time'][$hour] = array( |
|
| 1456 | + if (!isset($context['posts_by_time'][$hour])) { |
|
| 1457 | + $context['posts_by_time'][$hour] = array( |
|
| 1413 | 1458 | 'hour' => $hour, |
| 1414 | 1459 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
| 1415 | 1460 | 'posts' => 0, |
@@ -1417,7 +1462,7 @@ discard block |
||
| 1417 | 1462 | 'relative_percent' => 0, |
| 1418 | 1463 | 'is_last' => $hour == 23, |
| 1419 | 1464 | ); |
| 1420 | - else |
|
| 1465 | + } else |
|
| 1421 | 1466 | { |
| 1422 | 1467 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
| 1423 | 1468 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1450,8 +1495,9 @@ discard block |
||
| 1450 | 1495 | |
| 1451 | 1496 | foreach ($subActions as $sa => $action) |
| 1452 | 1497 | { |
| 1453 | - if (!allowedTo($action[2])) |
|
| 1454 | - unset($subActions[$sa]); |
|
| 1498 | + if (!allowedTo($action[2])) { |
|
| 1499 | + unset($subActions[$sa]); |
|
| 1500 | + } |
|
| 1455 | 1501 | } |
| 1456 | 1502 | |
| 1457 | 1503 | // Create the tabs for the template. |
@@ -1469,15 +1515,18 @@ discard block |
||
| 1469 | 1515 | ); |
| 1470 | 1516 | |
| 1471 | 1517 | // Moderation must be on to track edits. |
| 1472 | - if (empty($modSettings['userlog_enabled'])) |
|
| 1473 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1518 | + if (empty($modSettings['userlog_enabled'])) { |
|
| 1519 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
| 1520 | + } |
|
| 1474 | 1521 | |
| 1475 | 1522 | // Group requests must be active to show it... |
| 1476 | - if (empty($modSettings['show_group_membership'])) |
|
| 1477 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1523 | + if (empty($modSettings['show_group_membership'])) { |
|
| 1524 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
| 1525 | + } |
|
| 1478 | 1526 | |
| 1479 | - if (empty($subActions)) |
|
| 1480 | - fatal_lang_error('no_access', false); |
|
| 1527 | + if (empty($subActions)) { |
|
| 1528 | + fatal_lang_error('no_access', false); |
|
| 1529 | + } |
|
| 1481 | 1530 | |
| 1482 | 1531 | $keys = array_keys($subActions); |
| 1483 | 1532 | $default = array_shift($keys); |
@@ -1490,9 +1539,10 @@ discard block |
||
| 1490 | 1539 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
| 1491 | 1540 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
| 1492 | 1541 | |
| 1493 | - if (!empty($call)) |
|
| 1494 | - call_user_func($call, $memID); |
|
| 1495 | -} |
|
| 1542 | + if (!empty($call)) { |
|
| 1543 | + call_user_func($call, $memID); |
|
| 1544 | + } |
|
| 1545 | + } |
|
| 1496 | 1546 | |
| 1497 | 1547 | /** |
| 1498 | 1548 | * Handles tracking a user's activity |
@@ -1508,8 +1558,9 @@ discard block |
||
| 1508 | 1558 | isAllowedTo('moderate_forum'); |
| 1509 | 1559 | |
| 1510 | 1560 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
| 1511 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
| 1512 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1561 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
| 1562 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
| 1563 | + } |
|
| 1513 | 1564 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
| 1514 | 1565 | |
| 1515 | 1566 | // Set the options for the list component. |
@@ -1675,8 +1726,9 @@ discard block |
||
| 1675 | 1726 | ) |
| 1676 | 1727 | ); |
| 1677 | 1728 | $message_members = array(); |
| 1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1679 | - $message_members[] = $row['id_member']; |
|
| 1729 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1730 | + $message_members[] = $row['id_member']; |
|
| 1731 | + } |
|
| 1680 | 1732 | $smcFunc['db_free_result']($request); |
| 1681 | 1733 | |
| 1682 | 1734 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1691,8 +1743,9 @@ discard block |
||
| 1691 | 1743 | 'ip_list' => $ips, |
| 1692 | 1744 | ) |
| 1693 | 1745 | ); |
| 1694 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1695 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1746 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1747 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1748 | + } |
|
| 1696 | 1749 | $smcFunc['db_free_result']($request); |
| 1697 | 1750 | } |
| 1698 | 1751 | |
@@ -1706,8 +1759,9 @@ discard block |
||
| 1706 | 1759 | 'ip_list' => $ips, |
| 1707 | 1760 | ) |
| 1708 | 1761 | ); |
| 1709 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1710 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1762 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1763 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 1764 | + } |
|
| 1711 | 1765 | $smcFunc['db_free_result']($request); |
| 1712 | 1766 | } |
| 1713 | 1767 | } |
@@ -1767,8 +1821,8 @@ discard block |
||
| 1767 | 1821 | )) |
| 1768 | 1822 | ); |
| 1769 | 1823 | $error_messages = array(); |
| 1770 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1771 | - $error_messages[] = array( |
|
| 1824 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1825 | + $error_messages[] = array( |
|
| 1772 | 1826 | 'ip' => inet_dtop($row['ip']), |
| 1773 | 1827 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
| 1774 | 1828 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1776,6 +1830,7 @@ discard block |
||
| 1776 | 1830 | 'time' => timeformat($row['log_time']), |
| 1777 | 1831 | 'timestamp' => forum_time(true, $row['log_time']), |
| 1778 | 1832 | ); |
| 1833 | + } |
|
| 1779 | 1834 | $smcFunc['db_free_result']($request); |
| 1780 | 1835 | |
| 1781 | 1836 | return $error_messages; |
@@ -1838,8 +1893,8 @@ discard block |
||
| 1838 | 1893 | )) |
| 1839 | 1894 | ); |
| 1840 | 1895 | $messages = array(); |
| 1841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1842 | - $messages[] = array( |
|
| 1896 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1897 | + $messages[] = array( |
|
| 1843 | 1898 | 'ip' => inet_dtop($row['poster_ip']), |
| 1844 | 1899 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
| 1845 | 1900 | 'board' => array( |
@@ -1852,6 +1907,7 @@ discard block |
||
| 1852 | 1907 | 'time' => timeformat($row['poster_time']), |
| 1853 | 1908 | 'timestamp' => forum_time(true, $row['poster_time']) |
| 1854 | 1909 | ); |
| 1910 | + } |
|
| 1855 | 1911 | $smcFunc['db_free_result']($request); |
| 1856 | 1912 | |
| 1857 | 1913 | return $messages; |
@@ -1878,19 +1934,20 @@ discard block |
||
| 1878 | 1934 | $context['sub_template'] = 'trackIP'; |
| 1879 | 1935 | $context['page_title'] = $txt['profile']; |
| 1880 | 1936 | $context['base_url'] = $scripturl . '?action=trackip'; |
| 1881 | - } |
|
| 1882 | - else |
|
| 1937 | + } else |
|
| 1883 | 1938 | { |
| 1884 | 1939 | $context['ip'] = $user_profile[$memID]['member_ip']; |
| 1885 | 1940 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
| 1886 | 1941 | } |
| 1887 | 1942 | |
| 1888 | 1943 | // Searching? |
| 1889 | - if (isset($_REQUEST['searchip'])) |
|
| 1890 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1944 | + if (isset($_REQUEST['searchip'])) { |
|
| 1945 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
| 1946 | + } |
|
| 1891 | 1947 | |
| 1892 | - if (isValidIP($context['ip']) === false) |
|
| 1893 | - fatal_lang_error('invalid_tracking_ip', false); |
|
| 1948 | + if (isValidIP($context['ip']) === false) { |
|
| 1949 | + fatal_lang_error('invalid_tracking_ip', false); |
|
| 1950 | + } |
|
| 1894 | 1951 | |
| 1895 | 1952 | //mysql didn't support like search with varbinary |
| 1896 | 1953 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1898,8 +1955,9 @@ discard block |
||
| 1898 | 1955 | $ip_var = $context['ip']; |
| 1899 | 1956 | $ip_string = '= {inet:ip_address}'; |
| 1900 | 1957 | |
| 1901 | - if (empty($context['tracking_area'])) |
|
| 1902 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1958 | + if (empty($context['tracking_area'])) { |
|
| 1959 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
| 1960 | + } |
|
| 1903 | 1961 | |
| 1904 | 1962 | $request = $smcFunc['db_query']('', ' |
| 1905 | 1963 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1910,8 +1968,9 @@ discard block |
||
| 1910 | 1968 | ) |
| 1911 | 1969 | ); |
| 1912 | 1970 | $context['ips'] = array(); |
| 1913 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1914 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1971 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1972 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
| 1973 | + } |
|
| 1915 | 1974 | $smcFunc['db_free_result']($request); |
| 1916 | 1975 | |
| 1917 | 1976 | ksort($context['ips']); |
@@ -2140,8 +2199,9 @@ discard block |
||
| 2140 | 2199 | foreach ($context['whois_servers'] as $whois) |
| 2141 | 2200 | { |
| 2142 | 2201 | // Strip off the "decimal point" and anything following... |
| 2143 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
| 2144 | - $context['auto_whois_server'] = $whois; |
|
| 2202 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
| 2203 | + $context['auto_whois_server'] = $whois; |
|
| 2204 | + } |
|
| 2145 | 2205 | } |
| 2146 | 2206 | } |
| 2147 | 2207 | } |
@@ -2158,10 +2218,11 @@ discard block |
||
| 2158 | 2218 | // Gonna want this for the list. |
| 2159 | 2219 | require_once($sourcedir . '/Subs-List.php'); |
| 2160 | 2220 | |
| 2161 | - if ($memID == 0) |
|
| 2162 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2163 | - else |
|
| 2164 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2221 | + if ($memID == 0) { |
|
| 2222 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
| 2223 | + } else { |
|
| 2224 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
| 2225 | + } |
|
| 2165 | 2226 | |
| 2166 | 2227 | // Start with the user messages. |
| 2167 | 2228 | $listOptions = array( |
@@ -2271,12 +2332,13 @@ discard block |
||
| 2271 | 2332 | ) |
| 2272 | 2333 | ); |
| 2273 | 2334 | $logins = array(); |
| 2274 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2275 | - $logins[] = array( |
|
| 2335 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2336 | + $logins[] = array( |
|
| 2276 | 2337 | 'time' => timeformat($row['time']), |
| 2277 | 2338 | 'ip' => inet_dtop($row['ip']), |
| 2278 | 2339 | 'ip2' => inet_dtop($row['ip2']), |
| 2279 | 2340 | ); |
| 2341 | + } |
|
| 2280 | 2342 | $smcFunc['db_free_result']($request); |
| 2281 | 2343 | |
| 2282 | 2344 | return $logins; |
@@ -2301,11 +2363,12 @@ discard block |
||
| 2301 | 2363 | ) |
| 2302 | 2364 | ); |
| 2303 | 2365 | $context['custom_field_titles'] = array(); |
| 2304 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2305 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2366 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2367 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
| 2306 | 2368 | 'title' => $row['field_name'], |
| 2307 | 2369 | 'parse_bbc' => $row['bbc'], |
| 2308 | 2370 | ); |
| 2371 | + } |
|
| 2309 | 2372 | $smcFunc['db_free_result']($request); |
| 2310 | 2373 | |
| 2311 | 2374 | // Set the options for the error lists. |
@@ -2444,19 +2507,22 @@ discard block |
||
| 2444 | 2507 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2445 | 2508 | { |
| 2446 | 2509 | $extra = $smcFunc['json_decode']($row['extra'], true); |
| 2447 | - if (!empty($extra['applicator'])) |
|
| 2448 | - $members[] = $extra['applicator']; |
|
| 2510 | + if (!empty($extra['applicator'])) { |
|
| 2511 | + $members[] = $extra['applicator']; |
|
| 2512 | + } |
|
| 2449 | 2513 | |
| 2450 | 2514 | // Work out what the name of the action is. |
| 2451 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
| 2452 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2453 | - elseif (isset($txt[$row['action']])) |
|
| 2454 | - $action_text = $txt[$row['action']]; |
|
| 2515 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
| 2516 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
| 2517 | + } elseif (isset($txt[$row['action']])) { |
|
| 2518 | + $action_text = $txt[$row['action']]; |
|
| 2519 | + } |
|
| 2455 | 2520 | // Custom field? |
| 2456 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
| 2457 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2458 | - else |
|
| 2459 | - $action_text = $row['action']; |
|
| 2521 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
| 2522 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
| 2523 | + } else { |
|
| 2524 | + $action_text = $row['action']; |
|
| 2525 | + } |
|
| 2460 | 2526 | |
| 2461 | 2527 | // Parse BBC? |
| 2462 | 2528 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2488,13 +2554,15 @@ discard block |
||
| 2488 | 2554 | ) |
| 2489 | 2555 | ); |
| 2490 | 2556 | $members = array(); |
| 2491 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 2492 | - $members[$row['id_member']] = $row['real_name']; |
|
| 2557 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 2558 | + $members[$row['id_member']] = $row['real_name']; |
|
| 2559 | + } |
|
| 2493 | 2560 | $smcFunc['db_free_result']($request); |
| 2494 | 2561 | |
| 2495 | - foreach ($edits as $key => $value) |
|
| 2496 | - if (isset($members[$value['id_member']])) |
|
| 2562 | + foreach ($edits as $key => $value) { |
|
| 2563 | + if (isset($members[$value['id_member']])) |
|
| 2497 | 2564 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
| 2565 | + } |
|
| 2498 | 2566 | } |
| 2499 | 2567 | |
| 2500 | 2568 | return $edits; |
@@ -2695,10 +2763,11 @@ discard block |
||
| 2695 | 2763 | $context['board'] = $board; |
| 2696 | 2764 | |
| 2697 | 2765 | // Determine which groups this user is in. |
| 2698 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
| 2699 | - $curGroups = array(); |
|
| 2700 | - else |
|
| 2701 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2766 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
| 2767 | + $curGroups = array(); |
|
| 2768 | + } else { |
|
| 2769 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
| 2770 | + } |
|
| 2702 | 2771 | $curGroups[] = $user_profile[$memID]['id_group']; |
| 2703 | 2772 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
| 2704 | 2773 | |
@@ -2718,28 +2787,30 @@ discard block |
||
| 2718 | 2787 | $context['no_access_boards'] = array(); |
| 2719 | 2788 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2720 | 2789 | { |
| 2721 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
| 2722 | - $context['no_access_boards'][] = array( |
|
| 2790 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
| 2791 | + $context['no_access_boards'][] = array( |
|
| 2723 | 2792 | 'id' => $row['id_board'], |
| 2724 | 2793 | 'name' => $row['name'], |
| 2725 | 2794 | 'is_last' => false, |
| 2726 | 2795 | ); |
| 2727 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
| 2728 | - $context['boards'][$row['id_board']] = array( |
|
| 2796 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
| 2797 | + $context['boards'][$row['id_board']] = array( |
|
| 2729 | 2798 | 'id' => $row['id_board'], |
| 2730 | 2799 | 'name' => $row['name'], |
| 2731 | 2800 | 'selected' => $board == $row['id_board'], |
| 2732 | 2801 | 'profile' => $row['id_profile'], |
| 2733 | 2802 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
| 2734 | 2803 | ); |
| 2804 | + } |
|
| 2735 | 2805 | } |
| 2736 | 2806 | $smcFunc['db_free_result']($request); |
| 2737 | 2807 | |
| 2738 | 2808 | require_once($sourcedir . '/Subs-Boards.php'); |
| 2739 | 2809 | sortBoards($context['boards']); |
| 2740 | 2810 | |
| 2741 | - if (!empty($context['no_access_boards'])) |
|
| 2742 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2811 | + if (!empty($context['no_access_boards'])) { |
|
| 2812 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
| 2813 | + } |
|
| 2743 | 2814 | |
| 2744 | 2815 | $context['member']['permissions'] = array( |
| 2745 | 2816 | 'general' => array(), |
@@ -2748,8 +2819,9 @@ discard block |
||
| 2748 | 2819 | |
| 2749 | 2820 | // If you're an admin we know you can do everything, we might as well leave. |
| 2750 | 2821 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
| 2751 | - if ($context['member']['has_all_permissions']) |
|
| 2752 | - return; |
|
| 2822 | + if ($context['member']['has_all_permissions']) { |
|
| 2823 | + return; |
|
| 2824 | + } |
|
| 2753 | 2825 | |
| 2754 | 2826 | $denied = array(); |
| 2755 | 2827 | |
@@ -2768,21 +2840,24 @@ discard block |
||
| 2768 | 2840 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 2769 | 2841 | { |
| 2770 | 2842 | // We don't know about this permission, it doesn't exist :P. |
| 2771 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2772 | - continue; |
|
| 2843 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2844 | + continue; |
|
| 2845 | + } |
|
| 2773 | 2846 | |
| 2774 | - if (empty($row['add_deny'])) |
|
| 2775 | - $denied[] = $row['permission']; |
|
| 2847 | + if (empty($row['add_deny'])) { |
|
| 2848 | + $denied[] = $row['permission']; |
|
| 2849 | + } |
|
| 2776 | 2850 | |
| 2777 | 2851 | // Permissions that end with _own or _any consist of two parts. |
| 2778 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2779 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2780 | - else |
|
| 2781 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2852 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2853 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2854 | + } else { |
|
| 2855 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2856 | + } |
|
| 2782 | 2857 | |
| 2783 | 2858 | // Add this permission if it doesn't exist yet. |
| 2784 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
| 2785 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2859 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
| 2860 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
| 2786 | 2861 | 'id' => $row['permission'], |
| 2787 | 2862 | 'groups' => array( |
| 2788 | 2863 | 'allowed' => array(), |
@@ -2792,6 +2867,7 @@ discard block |
||
| 2792 | 2867 | 'is_denied' => false, |
| 2793 | 2868 | 'is_global' => true, |
| 2794 | 2869 | ); |
| 2870 | + } |
|
| 2795 | 2871 | |
| 2796 | 2872 | // Add the membergroup to either the denied or the allowed groups. |
| 2797 | 2873 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2825,18 +2901,20 @@ discard block |
||
| 2825 | 2901 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 2826 | 2902 | { |
| 2827 | 2903 | // We don't know about this permission, it doesn't exist :P. |
| 2828 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
| 2829 | - continue; |
|
| 2904 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
| 2905 | + continue; |
|
| 2906 | + } |
|
| 2830 | 2907 | |
| 2831 | 2908 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
| 2832 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
| 2833 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2834 | - else |
|
| 2835 | - $name = $txt['permissionname_' . $row['permission']]; |
|
| 2909 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
| 2910 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
| 2911 | + } else { |
|
| 2912 | + $name = $txt['permissionname_' . $row['permission']]; |
|
| 2913 | + } |
|
| 2836 | 2914 | |
| 2837 | 2915 | // Create the structure for this permission. |
| 2838 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
| 2839 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2916 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
| 2917 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
| 2840 | 2918 | 'id' => $row['permission'], |
| 2841 | 2919 | 'groups' => array( |
| 2842 | 2920 | 'allowed' => array(), |
@@ -2846,6 +2924,7 @@ discard block |
||
| 2846 | 2924 | 'is_denied' => false, |
| 2847 | 2925 | 'is_global' => empty($board), |
| 2848 | 2926 | ); |
| 2927 | + } |
|
| 2849 | 2928 | |
| 2850 | 2929 | $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']; |
| 2851 | 2930 | |
@@ -2864,8 +2943,9 @@ discard block |
||
| 2864 | 2943 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
| 2865 | 2944 | |
| 2866 | 2945 | // Firstly, can we actually even be here? |
| 2867 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
| 2868 | - fatal_lang_error('no_access', false); |
|
| 2946 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
| 2947 | + fatal_lang_error('no_access', false); |
|
| 2948 | + } |
|
| 2869 | 2949 | |
| 2870 | 2950 | // Make sure things which are disabled stay disabled. |
| 2871 | 2951 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2952,9 +3032,10 @@ discard block |
||
| 2952 | 3032 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
| 2953 | 3033 | ); |
| 2954 | 3034 | $context['current_level'] = 0; |
| 2955 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
| 2956 | - if ($context['member']['warning'] >= $limit) |
|
| 3035 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
| 3036 | + if ($context['member']['warning'] >= $limit) |
|
| 2957 | 3037 | $context['current_level'] = $limit; |
| 2958 | -} |
|
| 3038 | + } |
|
| 3039 | + } |
|
| 2959 | 3040 | |
| 2960 | 3041 | ?> |
| 2961 | 3042 | \ No newline at end of file |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
| 182 | 183 | { |
| 183 | 184 | global $cache_enable; |
| 184 | 185 | |
| 185 | - if ($test) |
|
| 186 | - return true; |
|
| 186 | + if ($test) { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 187 | 189 | return !empty($cache_enable); |
| 188 | 190 | } |
| 189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
| 202 | 204 | global $boardurl, $cachedir; |
| 203 | 205 | |
| 204 | 206 | // Find a valid good file to do mtime checks on. |
| 205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
| 206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
| 207 | - elseif (is_dir($cachedir . '/')) |
|
| 208 | - $filemtime = $cachedir . '/'; |
|
| 209 | - else |
|
| 210 | - $filemtime = $boardurl . '/index.php'; |
|
| 207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
| 208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
| 209 | + } elseif (is_dir($cachedir . '/')) { |
|
| 210 | + $filemtime = $cachedir . '/'; |
|
| 211 | + } else { |
|
| 212 | + $filemtime = $boardurl . '/index.php'; |
|
| 213 | + } |
|
| 211 | 214 | |
| 212 | 215 | // Set the default if no prefix was specified. |
| 213 | - if (empty($prefix)) |
|
| 214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 215 | - else |
|
| 216 | - $this->prefix = $prefix; |
|
| 216 | + if (empty($prefix)) { |
|
| 217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
| 218 | + } else { |
|
| 219 | + $this->prefix = $prefix; |
|
| 220 | + } |
|
| 217 | 221 | |
| 218 | 222 | return true; |
| 219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
| 276 | 280 | |
| 277 | 281 | // Invalidate cache, to be sure! |
| 278 | 282 | // ... as long as index.php can be modified, anyway. |
| 279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
| 280 | - @touch($cachedir . '/' . 'index.php'); |
|
| 283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
| 284 | + @touch($cachedir . '/' . 'index.php'); |
|
| 285 | + } |
|
| 281 | 286 | |
| 282 | 287 | return true; |
| 283 | 288 | } |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * SQLite Cache API class |
@@ -68,8 +69,9 @@ discard block |
||
| 68 | 69 | { |
| 69 | 70 | $supported = class_exists("SQLite3") && is_writable($this->cachedir); |
| 70 | 71 | |
| 71 | - if ($test) |
|
| 72 | - return $supported; |
|
| 72 | + if ($test) { |
|
| 73 | + return $supported; |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | return parent::isSupported() && $supported; |
| 75 | 77 | } |
@@ -84,8 +86,9 @@ discard block |
||
| 84 | 86 | $result = $this->cacheDB->query($query); |
| 85 | 87 | |
| 86 | 88 | $value = null; |
| 87 | - while ($res = $result->fetchArray(SQLITE3_ASSOC)) |
|
| 88 | - $value = $res['value']; |
|
| 89 | + while ($res = $result->fetchArray(SQLITE3_ASSOC)) { |
|
| 90 | + $value = $res['value']; |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | return !empty($value) ? $value : null; |
| 91 | 94 | } |
@@ -125,8 +128,9 @@ discard block |
||
| 125 | 128 | $config_vars[] = $txt['cache_sqlite_settings']; |
| 126 | 129 | $config_vars[] = array('cachedir_sqlite', $txt['cachedir_sqlite'], 'file', 'text', 36, 'cache_sqlite_cachedir'); |
| 127 | 130 | |
| 128 | - if (!isset($context['settings_post_javascript'])) |
|
| 129 | - $context['settings_post_javascript'] = ''; |
|
| 131 | + if (!isset($context['settings_post_javascript'])) { |
|
| 132 | + $context['settings_post_javascript'] = ''; |
|
| 133 | + } |
|
| 130 | 134 | |
| 131 | 135 | $context['settings_post_javascript'] .= ' |
| 132 | 136 | $("#cache_accelerator").change(function (e) { |
@@ -149,10 +153,11 @@ discard block |
||
| 149 | 153 | global $cachedir_sqlite; |
| 150 | 154 | |
| 151 | 155 | // If its invalid, use SMF's. |
| 152 | - if (is_null($dir) || !is_writable($dir)) |
|
| 153 | - $this->cachedir = $cachedir_sqlite; |
|
| 154 | - else |
|
| 155 | - $this->cachedir = $dir; |
|
| 156 | + if (is_null($dir) || !is_writable($dir)) { |
|
| 157 | + $this->cachedir = $cachedir_sqlite; |
|
| 158 | + } else { |
|
| 159 | + $this->cachedir = $dir; |
|
| 160 | + } |
|
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | /** |
@@ -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('Hacking attempt...'); |
| 16 | +} |
|
| 16 | 17 | |
| 17 | 18 | /** |
| 18 | 19 | * PostgreSQL Cache API class |
@@ -49,8 +50,9 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | $result = pg_execute($db_connection, '', array('public', $db_prefix . 'cache')); |
| 51 | 52 | |
| 52 | - if (pg_affected_rows($result) === 0) |
|
| 53 | - pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 53 | + if (pg_affected_rows($result) === 0) { |
|
| 54 | + pg_query($db_connection, 'CREATE UNLOGGED TABLE {db_prefix}cache (key text, value text, ttl bigint, PRIMARY KEY (key))'); |
|
| 55 | + } |
|
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | /** |
@@ -60,14 +62,16 @@ discard block |
||
| 60 | 62 | { |
| 61 | 63 | global $smcFunc, $db_connection; |
| 62 | 64 | |
| 63 | - if ($smcFunc['db_title'] !== 'PostgreSQL') |
|
| 64 | - return false; |
|
| 65 | + if ($smcFunc['db_title'] !== 'PostgreSQL') { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 65 | 68 | |
| 66 | 69 | $result = pg_query($db_connection, 'SHOW server_version_num'); |
| 67 | 70 | $res = pg_fetch_assoc($result); |
| 68 | 71 | |
| 69 | - if ($res['server_version_num'] < 90500) |
|
| 70 | - return false; |
|
| 72 | + if ($res['server_version_num'] < 90500) { |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 71 | 75 | |
| 72 | 76 | return $test ? true : parent::isSupported(); |
| 73 | 77 | } |
@@ -81,13 +85,15 @@ discard block |
||
| 81 | 85 | |
| 82 | 86 | $ttl = time() - $ttl; |
| 83 | 87 | |
| 84 | - if (empty($this->pg_get_data_prep)) |
|
| 85 | - $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 88 | + if (empty($this->pg_get_data_prep)) { |
|
| 89 | + $this->pg_get_data_prep = pg_prepare($db_connection, 'smf_cache_get_data', 'SELECT value FROM ' . $db_prefix . 'cache WHERE key = $1 AND ttl >= $2 LIMIT 1'); |
|
| 90 | + } |
|
| 86 | 91 | |
| 87 | 92 | $result = pg_execute($db_connection, 'smf_cache_get_data', array($key, $ttl)); |
| 88 | 93 | |
| 89 | - if (pg_affected_rows($result) === 0) |
|
| 90 | - return null; |
|
| 94 | + if (pg_affected_rows($result) === 0) { |
|
| 95 | + return null; |
|
| 96 | + } |
|
| 91 | 97 | |
| 92 | 98 | $res = pg_fetch_assoc($result); |
| 93 | 99 | |
@@ -101,23 +107,26 @@ discard block |
||
| 101 | 107 | { |
| 102 | 108 | global $db_prefix, $db_connection; |
| 103 | 109 | |
| 104 | - if (!isset($value)) |
|
| 105 | - $value = ''; |
|
| 110 | + if (!isset($value)) { |
|
| 111 | + $value = ''; |
|
| 112 | + } |
|
| 106 | 113 | |
| 107 | 114 | $ttl = time() + $ttl; |
| 108 | 115 | |
| 109 | - if (empty($this->pg_put_data_prep)) |
|
| 110 | - $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 116 | + if (empty($this->pg_put_data_prep)) { |
|
| 117 | + $this->pg_put_data_prep = pg_prepare($db_connection, 'smf_cache_put_data', |
|
| 111 | 118 | 'INSERT INTO ' . $db_prefix . 'cache(key,value,ttl) VALUES($1,$2,$3) |
| 112 | 119 | ON CONFLICT(key) DO UPDATE SET value = excluded.value, ttl = excluded.ttl' |
| 113 | 120 | ); |
| 121 | + } |
|
| 114 | 122 | |
| 115 | 123 | $result = pg_execute($db_connection, 'smf_cache_put_data', array($key, $value, $ttl)); |
| 116 | 124 | |
| 117 | - if (pg_affected_rows($result) > 0) |
|
| 118 | - return true; |
|
| 119 | - else |
|
| 120 | - return false; |
|
| 125 | + if (pg_affected_rows($result) > 0) { |
|
| 126 | + return true; |
|
| 127 | + } else { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | /** |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
| 32 | 33 | |
| 33 | 34 | // Are we looking at the moderation log or the administration log. |
| 34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
| 35 | - if ($context['log_type'] == 3) |
|
| 36 | - isAllowedTo('admin_forum'); |
|
| 36 | + if ($context['log_type'] == 3) { |
|
| 37 | + isAllowedTo('admin_forum'); |
|
| 38 | + } |
|
| 37 | 39 | |
| 38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
| 39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
| 40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 41 | - else |
|
| 42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
| 42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
| 43 | + } else { |
|
| 44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
| 45 | + } |
|
| 43 | 46 | |
| 44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
| 45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
| 67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
| 68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
| 69 | 72 | |
| 70 | - } |
|
| 71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
| 72 | 74 | { |
| 73 | 75 | checkSession(); |
| 74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
| 114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
| 115 | 117 | ); |
| 116 | 118 | |
| 117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
| 118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 119 | - else |
|
| 120 | - $search_params_string = $search_params['string']; |
|
| 119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
| 120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
| 121 | + } else { |
|
| 122 | + $search_params_string = $search_params['string']; |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
| 123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 124 | - else |
|
| 125 | - $search_params_type = $search_params['type']; |
|
| 125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
| 126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
| 127 | + } else { |
|
| 128 | + $search_params_type = $search_params['type']; |
|
| 129 | + } |
|
| 126 | 130 | |
| 127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
| 128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
| 301 | 305 | $context['default_list'] = 'moderation_log_list'; |
| 302 | 306 | |
| 303 | 307 | // If a hook has changed this, respect it. |
| 304 | - if (!empty($moderation_menu_name)) |
|
| 305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 306 | - elseif (isset($context['moderation_menu_name'])) |
|
| 307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | + if (!empty($moderation_menu_name)) { |
|
| 309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
| 310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
| 311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
| 308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
| 309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
| 310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
| 311 | 315 | ); |
| 312 | -} |
|
| 316 | + } |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | /** |
| 315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
| 413 | 418 | // Add on some of the column stuff info |
| 414 | 419 | if (!empty($row['id_board'])) |
| 415 | 420 | { |
| 416 | - if ($row['action'] == 'move') |
|
| 417 | - $row['extra']['board_to'] = $row['id_board']; |
|
| 418 | - else |
|
| 419 | - $row['extra']['board'] = $row['id_board']; |
|
| 421 | + if ($row['action'] == 'move') { |
|
| 422 | + $row['extra']['board_to'] = $row['id_board']; |
|
| 423 | + } else { |
|
| 424 | + $row['extra']['board'] = $row['id_board']; |
|
| 425 | + } |
|
| 420 | 426 | } |
| 421 | 427 | |
| 422 | - if (!empty($row['id_topic'])) |
|
| 423 | - $row['extra']['topic'] = $row['id_topic']; |
|
| 424 | - if (!empty($row['id_msg'])) |
|
| 425 | - $row['extra']['message'] = $row['id_msg']; |
|
| 428 | + if (!empty($row['id_topic'])) { |
|
| 429 | + $row['extra']['topic'] = $row['id_topic']; |
|
| 430 | + } |
|
| 431 | + if (!empty($row['id_msg'])) { |
|
| 432 | + $row['extra']['message'] = $row['id_msg']; |
|
| 433 | + } |
|
| 426 | 434 | |
| 427 | 435 | // Is this associated with a topic? |
| 428 | - if (isset($row['extra']['topic'])) |
|
| 429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 430 | - if (isset($row['extra']['new_topic'])) |
|
| 431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 436 | + if (isset($row['extra']['topic'])) { |
|
| 437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
| 438 | + } |
|
| 439 | + if (isset($row['extra']['new_topic'])) { |
|
| 440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
| 441 | + } |
|
| 432 | 442 | |
| 433 | 443 | // How about a member? |
| 434 | 444 | if (isset($row['extra']['member'])) |
| 435 | 445 | { |
| 436 | 446 | // Guests don't have names! |
| 437 | - if (empty($row['extra']['member'])) |
|
| 438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 439 | - else |
|
| 447 | + if (empty($row['extra']['member'])) { |
|
| 448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
| 449 | + } else |
|
| 440 | 450 | { |
| 441 | 451 | // Try to find it... |
| 442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
| 444 | 454 | } |
| 445 | 455 | |
| 446 | 456 | // Associated with a board? |
| 447 | - if (isset($row['extra']['board_to'])) |
|
| 448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 449 | - if (isset($row['extra']['board_from'])) |
|
| 450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 451 | - if (isset($row['extra']['board'])) |
|
| 452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 457 | + if (isset($row['extra']['board_to'])) { |
|
| 458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
| 459 | + } |
|
| 460 | + if (isset($row['extra']['board_from'])) { |
|
| 461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
| 462 | + } |
|
| 463 | + if (isset($row['extra']['board'])) { |
|
| 464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
| 465 | + } |
|
| 453 | 466 | |
| 454 | 467 | // A message? |
| 455 | - if (isset($row['extra']['message'])) |
|
| 456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 468 | + if (isset($row['extra']['message'])) { |
|
| 469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
| 470 | + } |
|
| 457 | 471 | |
| 458 | 472 | // IP Info? |
| 459 | - if (isset($row['extra']['ip_range'])) |
|
| 460 | - if ($seeIP) |
|
| 473 | + if (isset($row['extra']['ip_range'])) { |
|
| 474 | + if ($seeIP) |
|
| 461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
| 462 | - else |
|
| 463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
| 476 | + } else { |
|
| 477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
| 478 | + } |
|
| 464 | 479 | |
| 465 | 480 | // Email? |
| 466 | - if (isset($row['extra']['email'])) |
|
| 467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 481 | + if (isset($row['extra']['email'])) { |
|
| 482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
| 483 | + } |
|
| 468 | 484 | |
| 469 | 485 | // Bans are complex. |
| 470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
| 471 | 487 | { |
| 472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
| 473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
| 474 | - if (isset($row['extra'][$type])) |
|
| 489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
| 490 | + if (isset($row['extra'][$type])) |
|
| 475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
| 492 | + } |
|
| 476 | 493 | } |
| 477 | 494 | |
| 478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
| 508 | 525 | foreach ($boards[$row['id_board']] as $action) |
| 509 | 526 | { |
| 510 | 527 | // Make the board number into a link - dealing with moving too. |
| 511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
| 512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
| 514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
| 516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
| 529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
| 531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
| 533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
| 534 | + } |
|
| 517 | 535 | } |
| 518 | 536 | } |
| 519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
| 547 | 565 | ); |
| 548 | 566 | |
| 549 | 567 | // Make the topic number into a link - dealing with splitting too. |
| 550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
| 551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
| 553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
| 569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
| 571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
| 572 | + } |
|
| 554 | 573 | } |
| 555 | 574 | } |
| 556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
| 583 | 602 | ); |
| 584 | 603 | |
| 585 | 604 | // Make the message number into a link. |
| 586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
| 587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
| 606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
| 607 | + } |
|
| 588 | 608 | } |
| 589 | 609 | } |
| 590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
| 624 | 644 | foreach ($entries as $k => $entry) |
| 625 | 645 | { |
| 626 | 646 | // Make any message info links so its easier to go find that message. |
| 627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
| 628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
| 648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
| 649 | + } |
|
| 629 | 650 | |
| 630 | 651 | // Mark up any deleted members, topics and boards. |
| 631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
| 632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
| 653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
| 633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
| 655 | + } |
|
| 634 | 656 | |
| 635 | 657 | if (isset($entry['extra']['report'])) |
| 636 | 658 | { |
| 637 | 659 | // Member profile reports go in a different area |
| 638 | - if (stristr($entry['action'], 'user_report')) |
|
| 639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 640 | - else |
|
| 641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 660 | + if (stristr($entry['action'], 'user_report')) { |
|
| 661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 662 | + } else { |
|
| 663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
| 664 | + } |
|
| 642 | 665 | } |
| 643 | 666 | |
| 644 | - if (empty($entries[$k]['action_text'])) |
|
| 645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 667 | + if (empty($entries[$k]['action_text'])) { |
|
| 668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
| 669 | + } |
|
| 646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
| 647 | 671 | function ($matches) use ($entries, $k) |
| 648 | 672 | { |
@@ -13,8 +13,9 @@ discard block |
||
| 13 | 13 | * @version 2.1 Beta 4 |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | -if (!defined('SMF')) |
|
| 16 | +if (!defined('SMF')) { |
|
| 17 | 17 | die('No direct access...'); |
| 18 | +} |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | // Not allowed sort method? Bang! Error! |
| 48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
| 49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
| 50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Initialize the array that'll be returned later on. |
| 52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
| 63 | 65 | // Get any spiders if enabled. |
| 64 | 66 | $spiders = array(); |
| 65 | 67 | $spider_finds = array(); |
| 66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
| 67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
| 69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
| 70 | + } |
|
| 68 | 71 | |
| 69 | 72 | // Load the users online right now. |
| 70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
| 92 | 95 | $membersOnlineStats['num_guests']++; |
| 93 | 96 | |
| 94 | 97 | continue; |
| 95 | - } |
|
| 96 | - |
|
| 97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
| 98 | 99 | { |
| 99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
| 100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // Some basic color coding... |
| 105 | - if (!empty($row['online_color'])) |
|
| 106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 107 | - else |
|
| 108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 106 | + if (!empty($row['online_color'])) { |
|
| 107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 108 | + } else { |
|
| 109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 110 | + } |
|
| 109 | 111 | |
| 110 | 112 | // Buddies get counted and highlighted. |
| 111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
| 132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
| 133 | 135 | |
| 134 | 136 | // Store all distinct (primary) membergroups that are shown. |
| 135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
| 136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
| 138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
| 137 | 139 | 'id' => $row['id_group'], |
| 138 | 140 | 'name' => $row['group_name'], |
| 139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
| 141 | 143 | 'type' => $row['group_type'], |
| 142 | 144 | 'parent' => $row['id_parent'], |
| 143 | 145 | ); |
| 146 | + } |
|
| 144 | 147 | } |
| 145 | 148 | $smcFunc['db_free_result']($request); |
| 146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
| 201 | 204 | $settingsToUpdate = array(); |
| 202 | 205 | |
| 203 | 206 | // More members on now than ever were? Update it! |
| 204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
| 205 | - $settingsToUpdate = array( |
|
| 207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
| 208 | + $settingsToUpdate = array( |
|
| 206 | 209 | 'mostOnline' => $total_users_online, |
| 207 | 210 | 'mostDate' => time() |
| 208 | 211 | ); |
| 212 | + } |
|
| 209 | 213 | |
| 210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
| 211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
| 237 | 241 | { |
| 238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
| 239 | 243 | |
| 240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
| 241 | - trackStats(array('most_on' => $total_users_online)); |
|
| 244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
| 245 | + trackStats(array('most_on' => $total_users_online)); |
|
| 246 | + } |
|
| 242 | 247 | |
| 243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
| 244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
| 255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
| 256 | 261 | } |
| 257 | 262 | |
| 258 | - if (!empty($settingsToUpdate)) |
|
| 259 | - updateSettings($settingsToUpdate); |
|
| 260 | -} |
|
| 263 | + if (!empty($settingsToUpdate)) { |
|
| 264 | + updateSettings($settingsToUpdate); |
|
| 265 | + } |
|
| 266 | + } |
|
| 261 | 267 | |
| 262 | 268 | ?> |
| 263 | 269 | \ No newline at end of file |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | * @version 2.1 Beta 4 |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (!defined('SMF')) |
|
| 17 | +if (!defined('SMF')) { |
|
| 18 | 18 | die('No direct access...'); |
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
| 56 | 57 | |
| 57 | 58 | $context['name'] = $board_info['name']; |
| 58 | 59 | $context['description'] = $board_info['description']; |
| 59 | - if (!empty($board_info['description'])) |
|
| 60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
| 60 | + if (!empty($board_info['description'])) { |
|
| 61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | // How many topics do we have in total? |
| 63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
| 73 | 75 | $session_name = session_name(); |
| 74 | 76 | foreach ($_GET as $k => $v) |
| 75 | 77 | { |
| 76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
| 77 | - $context['robot_no_index'] = true; |
|
| 78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
| 79 | + $context['robot_no_index'] = true; |
|
| 80 | + } |
|
| 78 | 81 | } |
| 79 | 82 | } |
| 80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
| 81 | - $context['robot_no_index'] = true; |
|
| 83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
| 84 | + $context['robot_no_index'] = true; |
|
| 85 | + } |
|
| 82 | 86 | |
| 83 | 87 | // If we can view unapproved messages and there are some build up a list. |
| 84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 95 | // We only know these. |
| 92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
| 93 | - $_REQUEST['sort'] = 'last_post'; |
|
| 96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
| 97 | + $_REQUEST['sort'] = 'last_post'; |
|
| 98 | + } |
|
| 94 | 99 | |
| 95 | 100 | // Make sure the starting place makes sense and construct the page index. |
| 96 | - if (isset($_REQUEST['sort'])) |
|
| 97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 98 | - else |
|
| 99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 101 | + if (isset($_REQUEST['sort'])) { |
|
| 102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 103 | + } else { |
|
| 104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
| 105 | + } |
|
| 100 | 106 | $context['start'] = &$_REQUEST['start']; |
| 101 | 107 | |
| 102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
| 132 | 138 | $context['link_moderators'] = array(); |
| 133 | 139 | if (!empty($board_info['moderators'])) |
| 134 | 140 | { |
| 135 | - foreach ($board_info['moderators'] as $mod) |
|
| 136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 141 | + foreach ($board_info['moderators'] as $mod) { |
|
| 142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
| 143 | + } |
|
| 137 | 144 | } |
| 138 | 145 | if (!empty($board_info['moderator_groups'])) |
| 139 | 146 | { |
| 140 | 147 | // By default just tack the moderator groups onto the end of the members |
| 141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
| 142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
| 149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
| 150 | + } |
|
| 143 | 151 | } |
| 144 | 152 | |
| 145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
| 191 | 199 | ); |
| 192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 193 | 201 | { |
| 194 | - if (empty($row['id_member'])) |
|
| 195 | - continue; |
|
| 202 | + if (empty($row['id_member'])) { |
|
| 203 | + continue; |
|
| 204 | + } |
|
| 196 | 205 | |
| 197 | - if (!empty($row['online_color'])) |
|
| 198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 199 | - else |
|
| 200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 206 | + if (!empty($row['online_color'])) { |
|
| 207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
| 208 | + } else { |
|
| 209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
| 203 | - if ($is_buddy) |
|
| 204 | - $link = '<strong>' . $link . '</strong>'; |
|
| 213 | + if ($is_buddy) { |
|
| 214 | + $link = '<strong>' . $link . '</strong>'; |
|
| 215 | + } |
|
| 205 | 216 | |
| 206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
| 207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
| 218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
| 219 | + } |
|
| 208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
| 209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
| 210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
| 217 | 229 | 'hidden' => empty($row['show_online']), |
| 218 | 230 | ); |
| 219 | 231 | |
| 220 | - if (empty($row['show_online'])) |
|
| 221 | - $context['view_num_hidden']++; |
|
| 232 | + if (empty($row['show_online'])) { |
|
| 233 | + $context['view_num_hidden']++; |
|
| 234 | + } |
|
| 222 | 235 | } |
| 223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
| 224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
| 260 | 273 | // Bring in any changes we want to make before the query. |
| 261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
| 262 | 275 | |
| 263 | - foreach ($sort_methods as $key => $val) |
|
| 264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 276 | + foreach ($sort_methods as $key => $val) { |
|
| 277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
| 278 | + } |
|
| 265 | 279 | |
| 266 | 280 | // Calculate the fastest way to get the topics. |
| 267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
| 271 | 285 | $fake_ascending = true; |
| 272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
| 273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
| 288 | + } else { |
|
| 289 | + $fake_ascending = false; |
|
| 274 | 290 | } |
| 275 | - else |
|
| 276 | - $fake_ascending = false; |
|
| 277 | 291 | |
| 278 | 292 | // Setup the default topic icons... |
| 279 | 293 | $context['icon_sources'] = array(); |
| 280 | - foreach ($context['stable_icons'] as $icon) |
|
| 281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
| 294 | + foreach ($context['stable_icons'] as $icon) { |
|
| 295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
| 296 | + } |
|
| 282 | 297 | |
| 283 | 298 | $topic_ids = array(); |
| 284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
| 316 | 331 | $message_pre_index_parameters |
| 317 | 332 | ); |
| 318 | 333 | $topic_ids = array(); |
| 319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 320 | - $topic_ids[] = $row['id_topic']; |
|
| 334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 335 | + $topic_ids[] = $row['id_topic']; |
|
| 336 | + } |
|
| 321 | 337 | } |
| 322 | 338 | |
| 323 | 339 | // Grab the appropriate topic information... |
@@ -375,11 +391,13 @@ discard block |
||
| 375 | 391 | // Begin 'printing' the message index for current board. |
| 376 | 392 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 377 | 393 | { |
| 378 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
| 379 | - continue; |
|
| 394 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
| 395 | + continue; |
|
| 396 | + } |
|
| 380 | 397 | |
| 381 | - if (!$pre_query) |
|
| 382 | - $topic_ids[] = $row['id_topic']; |
|
| 398 | + if (!$pre_query) { |
|
| 399 | + $topic_ids[] = $row['id_topic']; |
|
| 400 | + } |
|
| 383 | 401 | |
| 384 | 402 | // Reference the main color class. |
| 385 | 403 | $colorClass = 'windowbg'; |
@@ -389,8 +407,9 @@ discard block |
||
| 389 | 407 | { |
| 390 | 408 | // Limit them to $modSettings['preview_characters'] characters |
| 391 | 409 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
| 392 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
| 393 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 410 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
| 411 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 412 | + } |
|
| 394 | 413 | |
| 395 | 414 | // Censor the subject and message preview. |
| 396 | 415 | censorText($row['first_subject']); |
@@ -401,27 +420,27 @@ discard block |
||
| 401 | 420 | { |
| 402 | 421 | $row['last_subject'] = $row['first_subject']; |
| 403 | 422 | $row['last_body'] = $row['first_body']; |
| 404 | - } |
|
| 405 | - else |
|
| 423 | + } else |
|
| 406 | 424 | { |
| 407 | 425 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
| 408 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
| 409 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 426 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
| 427 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
| 428 | + } |
|
| 410 | 429 | |
| 411 | 430 | censorText($row['last_subject']); |
| 412 | 431 | censorText($row['last_body']); |
| 413 | 432 | } |
| 414 | - } |
|
| 415 | - else |
|
| 433 | + } else |
|
| 416 | 434 | { |
| 417 | 435 | $row['first_body'] = ''; |
| 418 | 436 | $row['last_body'] = ''; |
| 419 | 437 | censorText($row['first_subject']); |
| 420 | 438 | |
| 421 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
| 422 | - $row['last_subject'] = $row['first_subject']; |
|
| 423 | - else |
|
| 424 | - censorText($row['last_subject']); |
|
| 439 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
| 440 | + $row['last_subject'] = $row['first_subject']; |
|
| 441 | + } else { |
|
| 442 | + censorText($row['last_subject']); |
|
| 443 | + } |
|
| 425 | 444 | } |
| 426 | 445 | |
| 427 | 446 | // Decide how many pages the topic should have. |
@@ -432,42 +451,50 @@ discard block |
||
| 432 | 451 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
| 433 | 452 | |
| 434 | 453 | // If we can use all, show all. |
| 435 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
| 436 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 454 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
| 455 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
| 456 | + } |
|
| 457 | + } else { |
|
| 458 | + $pages = ''; |
|
| 437 | 459 | } |
| 438 | - else |
|
| 439 | - $pages = ''; |
|
| 440 | 460 | |
| 441 | 461 | // We need to check the topic icons exist... |
| 442 | 462 | if (!empty($modSettings['messageIconChecks_enable'])) |
| 443 | 463 | { |
| 444 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 445 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 446 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 447 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 448 | - } |
|
| 449 | - else |
|
| 464 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 465 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 466 | + } |
|
| 467 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 468 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
| 469 | + } |
|
| 470 | + } else |
|
| 450 | 471 | { |
| 451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
| 452 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
| 454 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
| 473 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
| 474 | + } |
|
| 475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
| 476 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
| 477 | + } |
|
| 455 | 478 | } |
| 456 | 479 | |
| 457 | - if (!empty($board_info['recycle'])) |
|
| 458 | - $row['first_icon'] = 'recycled'; |
|
| 480 | + if (!empty($board_info['recycle'])) { |
|
| 481 | + $row['first_icon'] = 'recycled'; |
|
| 482 | + } |
|
| 459 | 483 | |
| 460 | 484 | // Is this topic pending approval, or does it have any posts pending approval? |
| 461 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
| 462 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 485 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
| 486 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
| 487 | + } |
|
| 463 | 488 | |
| 464 | 489 | // Sticky topics should get a different color, too. |
| 465 | - if ($row['is_sticky']) |
|
| 466 | - $colorClass .= ' sticky'; |
|
| 490 | + if ($row['is_sticky']) { |
|
| 491 | + $colorClass .= ' sticky'; |
|
| 492 | + } |
|
| 467 | 493 | |
| 468 | 494 | // Locked topics get special treatment as well. |
| 469 | - if ($row['locked']) |
|
| 470 | - $colorClass .= ' locked'; |
|
| 495 | + if ($row['locked']) { |
|
| 496 | + $colorClass .= ' locked'; |
|
| 497 | + } |
|
| 471 | 498 | |
| 472 | 499 | // 'Print' the topic info. |
| 473 | 500 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -548,8 +575,9 @@ discard block |
||
| 548 | 575 | $smcFunc['db_free_result']($result); |
| 549 | 576 | |
| 550 | 577 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
| 551 | - if ($fake_ascending) |
|
| 552 | - $context['topics'] = array_reverse($context['topics'], true); |
|
| 578 | + if ($fake_ascending) { |
|
| 579 | + $context['topics'] = array_reverse($context['topics'], true); |
|
| 580 | + } |
|
| 553 | 581 | |
| 554 | 582 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
| 555 | 583 | { |
@@ -566,8 +594,9 @@ discard block |
||
| 566 | 594 | 'limit' => count($topic_ids), |
| 567 | 595 | ) |
| 568 | 596 | ); |
| 569 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
| 570 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 597 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
| 598 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
| 599 | + } |
|
| 571 | 600 | $smcFunc['db_free_result']($result); |
| 572 | 601 | } |
| 573 | 602 | } |
@@ -592,9 +621,9 @@ discard block |
||
| 592 | 621 | // Can we restore topics? |
| 593 | 622 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
| 594 | 623 | |
| 595 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
| 596 | - $context['can_move_any'] = true; |
|
| 597 | - else |
|
| 624 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
| 625 | + $context['can_move_any'] = true; |
|
| 626 | + } else |
|
| 598 | 627 | { |
| 599 | 628 | // We'll use this in a minute |
| 600 | 629 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -621,11 +650,13 @@ discard block |
||
| 621 | 650 | } |
| 622 | 651 | |
| 623 | 652 | // Can we use quick moderation checkboxes? |
| 624 | - if ($options['display_quick_mod'] == 1) |
|
| 625 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 653 | + if ($options['display_quick_mod'] == 1) { |
|
| 654 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
| 655 | + } |
|
| 626 | 656 | // Or the icons? |
| 627 | - else |
|
| 628 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 657 | + else { |
|
| 658 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
| 659 | + } |
|
| 629 | 660 | } |
| 630 | 661 | |
| 631 | 662 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -659,13 +690,15 @@ discard block |
||
| 659 | 690 | ); |
| 660 | 691 | |
| 661 | 692 | // We've seen all these boards now! |
| 662 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
| 663 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 693 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
| 694 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
| 664 | 695 | unset($_SESSION['topicseen_cache'][$k]); |
| 696 | + } |
|
| 665 | 697 | } |
| 666 | 698 | |
| 667 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
| 668 | - unset($_SESSION['topicseen_cache'][$board]); |
|
| 699 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
| 700 | + unset($_SESSION['topicseen_cache'][$board]); |
|
| 701 | + } |
|
| 669 | 702 | |
| 670 | 703 | $request = $smcFunc['db_query']('', ' |
| 671 | 704 | SELECT id_topic, id_board, sent |
@@ -686,8 +719,9 @@ discard block |
||
| 686 | 719 | $context['is_marked_notify'] = true; |
| 687 | 720 | $board_sent = $row['sent']; |
| 688 | 721 | } |
| 689 | - if (!empty($row['id_topic'])) |
|
| 690 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 722 | + if (!empty($row['id_topic'])) { |
|
| 723 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
| 724 | + } |
|
| 691 | 725 | } |
| 692 | 726 | $smcFunc['db_free_result']($request); |
| 693 | 727 | |
@@ -711,8 +745,7 @@ discard block |
||
| 711 | 745 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
| 712 | 746 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
| 713 | 747 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
| 714 | - } |
|
| 715 | - else |
|
| 748 | + } else |
|
| 716 | 749 | { |
| 717 | 750 | $context['is_marked_notify'] = false; |
| 718 | 751 | $context['board_notification_mode'] = 1; |
@@ -725,23 +758,27 @@ discard block |
||
| 725 | 758 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
| 726 | 759 | |
| 727 | 760 | // Don't want to show this forever... |
| 728 | - if ($context['becomesUnapproved']) |
|
| 729 | - unset($_SESSION['becomesUnapproved']); |
|
| 761 | + if ($context['becomesUnapproved']) { |
|
| 762 | + unset($_SESSION['becomesUnapproved']); |
|
| 763 | + } |
|
| 730 | 764 | |
| 731 | 765 | // Build the message index button array. |
| 732 | 766 | $context['normal_buttons'] = array(); |
| 733 | 767 | |
| 734 | - if ($context['can_post_new']) |
|
| 735 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 768 | + if ($context['can_post_new']) { |
|
| 769 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
| 770 | + } |
|
| 736 | 771 | |
| 737 | - if ($context['can_post_poll']) |
|
| 738 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 772 | + if ($context['can_post_poll']) { |
|
| 773 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
| 774 | + } |
|
| 739 | 775 | |
| 740 | - if (!$context['user']['is_logged']) |
|
| 741 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 776 | + if (!$context['user']['is_logged']) { |
|
| 777 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
| 778 | + } |
|
| 742 | 779 | |
| 743 | - if ($context['can_mark_notify']) |
|
| 744 | - $context['normal_buttons']['notify'] = array( |
|
| 780 | + if ($context['can_mark_notify']) { |
|
| 781 | + $context['normal_buttons']['notify'] = array( |
|
| 745 | 782 | 'lang' => true, |
| 746 | 783 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
| 747 | 784 | 'sub_buttons' => array( |
@@ -759,6 +796,7 @@ discard block |
||
| 759 | 796 | ), |
| 760 | 797 | ), |
| 761 | 798 | ); |
| 799 | + } |
|
| 762 | 800 | |
| 763 | 801 | // Javascript for inline editing. |
| 764 | 802 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -780,18 +818,21 @@ discard block |
||
| 780 | 818 | checkSession('request'); |
| 781 | 819 | |
| 782 | 820 | // Lets go straight to the restore area. |
| 783 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
| 784 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 821 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
| 822 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
| 823 | + } |
|
| 785 | 824 | |
| 786 | - if (isset($_SESSION['topicseen_cache'])) |
|
| 787 | - $_SESSION['topicseen_cache'] = array(); |
|
| 825 | + if (isset($_SESSION['topicseen_cache'])) { |
|
| 826 | + $_SESSION['topicseen_cache'] = array(); |
|
| 827 | + } |
|
| 788 | 828 | |
| 789 | 829 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
| 790 | 830 | require_once($sourcedir . '/Subs-Post.php'); |
| 791 | 831 | |
| 792 | 832 | // Remember the last board they moved things to. |
| 793 | - if (isset($_REQUEST['move_to'])) |
|
| 794 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 833 | + if (isset($_REQUEST['move_to'])) { |
|
| 834 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
| 835 | + } |
|
| 795 | 836 | |
| 796 | 837 | // Only a few possible actions. |
| 797 | 838 | $possibleActions = array(); |
@@ -811,8 +852,7 @@ discard block |
||
| 811 | 852 | ); |
| 812 | 853 | |
| 813 | 854 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
| 814 | - } |
|
| 815 | - else |
|
| 855 | + } else |
|
| 816 | 856 | { |
| 817 | 857 | /** |
| 818 | 858 | * @todo Ugly. There's no getting around this, is there? |
@@ -830,8 +870,7 @@ discard block |
||
| 830 | 870 | if (!empty($board)) |
| 831 | 871 | { |
| 832 | 872 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
| 833 | - } |
|
| 834 | - else |
|
| 873 | + } else |
|
| 835 | 874 | { |
| 836 | 875 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
| 837 | 876 | } |
@@ -842,55 +881,67 @@ discard block |
||
| 842 | 881 | } |
| 843 | 882 | } |
| 844 | 883 | |
| 845 | - if (!$user_info['is_guest']) |
|
| 846 | - $possibleActions[] = 'markread'; |
|
| 847 | - if (!empty($boards_can['make_sticky'])) |
|
| 848 | - $possibleActions[] = 'sticky'; |
|
| 849 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
| 850 | - $possibleActions[] = 'move'; |
|
| 851 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
| 852 | - $possibleActions[] = 'remove'; |
|
| 853 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
| 854 | - $possibleActions[] = 'lock'; |
|
| 855 | - if (!empty($boards_can['merge_any'])) |
|
| 856 | - $possibleActions[] = 'merge'; |
|
| 857 | - if (!empty($boards_can['approve_posts'])) |
|
| 858 | - $possibleActions[] = 'approve'; |
|
| 884 | + if (!$user_info['is_guest']) { |
|
| 885 | + $possibleActions[] = 'markread'; |
|
| 886 | + } |
|
| 887 | + if (!empty($boards_can['make_sticky'])) { |
|
| 888 | + $possibleActions[] = 'sticky'; |
|
| 889 | + } |
|
| 890 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
| 891 | + $possibleActions[] = 'move'; |
|
| 892 | + } |
|
| 893 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
| 894 | + $possibleActions[] = 'remove'; |
|
| 895 | + } |
|
| 896 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
| 897 | + $possibleActions[] = 'lock'; |
|
| 898 | + } |
|
| 899 | + if (!empty($boards_can['merge_any'])) { |
|
| 900 | + $possibleActions[] = 'merge'; |
|
| 901 | + } |
|
| 902 | + if (!empty($boards_can['approve_posts'])) { |
|
| 903 | + $possibleActions[] = 'approve'; |
|
| 904 | + } |
|
| 859 | 905 | |
| 860 | 906 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
| 861 | 907 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
| 862 | 908 | if (!empty($_REQUEST['topics'])) |
| 863 | 909 | { |
| 864 | 910 | // If the action isn't valid, just quit now. |
| 865 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
| 866 | - redirectexit($redirect_url); |
|
| 911 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
| 912 | + redirectexit($redirect_url); |
|
| 913 | + } |
|
| 867 | 914 | |
| 868 | 915 | // Merge requires all topics as one parameter and can be done at once. |
| 869 | 916 | if ($_REQUEST['qaction'] == 'merge') |
| 870 | 917 | { |
| 871 | 918 | // Merge requires at least two topics. |
| 872 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
| 873 | - redirectexit($redirect_url); |
|
| 919 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
| 920 | + redirectexit($redirect_url); |
|
| 921 | + } |
|
| 874 | 922 | |
| 875 | 923 | require_once($sourcedir . '/SplitTopics.php'); |
| 876 | 924 | return MergeExecute($_REQUEST['topics']); |
| 877 | 925 | } |
| 878 | 926 | |
| 879 | 927 | // Just convert to the other method, to make it easier. |
| 880 | - foreach ($_REQUEST['topics'] as $topic) |
|
| 881 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 928 | + foreach ($_REQUEST['topics'] as $topic) { |
|
| 929 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
| 930 | + } |
|
| 882 | 931 | } |
| 883 | 932 | |
| 884 | 933 | // Weird... how'd you get here? |
| 885 | - if (empty($_REQUEST['actions'])) |
|
| 886 | - redirectexit($redirect_url); |
|
| 934 | + if (empty($_REQUEST['actions'])) { |
|
| 935 | + redirectexit($redirect_url); |
|
| 936 | + } |
|
| 887 | 937 | |
| 888 | 938 | // Validate each action. |
| 889 | 939 | $temp = array(); |
| 890 | 940 | foreach ($_REQUEST['actions'] as $topic => $action) |
| 891 | 941 | { |
| 892 | - if (in_array($action, $possibleActions)) |
|
| 893 | - $temp[(int) $topic] = $action; |
|
| 942 | + if (in_array($action, $possibleActions)) { |
|
| 943 | + $temp[(int) $topic] = $action; |
|
| 944 | + } |
|
| 894 | 945 | } |
| 895 | 946 | $_REQUEST['actions'] = $temp; |
| 896 | 947 | |
@@ -911,27 +962,31 @@ discard block |
||
| 911 | 962 | { |
| 912 | 963 | if (!empty($board)) |
| 913 | 964 | { |
| 914 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
| 915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 916 | - } |
|
| 917 | - else |
|
| 965 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
| 966 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 967 | + } |
|
| 968 | + } else |
|
| 918 | 969 | { |
| 919 | 970 | // Don't allow them to act on unapproved posts they can't see... |
| 920 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
| 921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 971 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
| 972 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 973 | + } |
|
| 922 | 974 | // Goodness, this is fun. We need to validate the action. |
| 923 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
| 924 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 925 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
| 926 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 927 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
| 928 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 975 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
| 976 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 977 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
| 978 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 979 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
| 980 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 981 | + } |
|
| 929 | 982 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
| 930 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
| 931 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 983 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
| 984 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 985 | + } |
|
| 932 | 986 | // If the topic is approved then you need permission to approve the posts within. |
| 933 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
| 934 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 987 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
| 988 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
| 989 | + } |
|
| 935 | 990 | } |
| 936 | 991 | } |
| 937 | 992 | $smcFunc['db_free_result']($request); |
@@ -949,11 +1004,11 @@ discard block |
||
| 949 | 1004 | { |
| 950 | 1005 | $topic = (int) $topic; |
| 951 | 1006 | |
| 952 | - if ($action == 'markread') |
|
| 953 | - $markCache[] = $topic; |
|
| 954 | - elseif ($action == 'sticky') |
|
| 955 | - $stickyCache[] = $topic; |
|
| 956 | - elseif ($action == 'move') |
|
| 1007 | + if ($action == 'markread') { |
|
| 1008 | + $markCache[] = $topic; |
|
| 1009 | + } elseif ($action == 'sticky') { |
|
| 1010 | + $stickyCache[] = $topic; |
|
| 1011 | + } elseif ($action == 'move') |
|
| 957 | 1012 | { |
| 958 | 1013 | require_once($sourcedir . '/MoveTopic.php'); |
| 959 | 1014 | moveTopicConcurrence(); |
@@ -961,23 +1016,25 @@ discard block |
||
| 961 | 1016 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
| 962 | 1017 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
| 963 | 1018 | |
| 964 | - if (empty($moveCache[1][$topic])) |
|
| 965 | - continue; |
|
| 1019 | + if (empty($moveCache[1][$topic])) { |
|
| 1020 | + continue; |
|
| 1021 | + } |
|
| 966 | 1022 | |
| 967 | 1023 | $moveCache[0][] = $topic; |
| 1024 | + } elseif ($action == 'remove') { |
|
| 1025 | + $removeCache[] = $topic; |
|
| 1026 | + } elseif ($action == 'lock') { |
|
| 1027 | + $lockCache[] = $topic; |
|
| 1028 | + } elseif ($action == 'approve') { |
|
| 1029 | + $approveCache[] = $topic; |
|
| 968 | 1030 | } |
| 969 | - elseif ($action == 'remove') |
|
| 970 | - $removeCache[] = $topic; |
|
| 971 | - elseif ($action == 'lock') |
|
| 972 | - $lockCache[] = $topic; |
|
| 973 | - elseif ($action == 'approve') |
|
| 974 | - $approveCache[] = $topic; |
|
| 975 | 1031 | } |
| 976 | 1032 | |
| 977 | - if (empty($board)) |
|
| 978 | - $affectedBoards = array(); |
|
| 979 | - else |
|
| 980 | - $affectedBoards = array($board => array(0, 0)); |
|
| 1033 | + if (empty($board)) { |
|
| 1034 | + $affectedBoards = array(); |
|
| 1035 | + } else { |
|
| 1036 | + $affectedBoards = array($board => array(0, 0)); |
|
| 1037 | + } |
|
| 981 | 1038 | |
| 982 | 1039 | // Do all the stickies... |
| 983 | 1040 | if (!empty($stickyCache)) |
@@ -1037,14 +1094,16 @@ discard block |
||
| 1037 | 1094 | { |
| 1038 | 1095 | $to = $moveCache[1][$row['id_topic']]; |
| 1039 | 1096 | |
| 1040 | - if (empty($to)) |
|
| 1041 | - continue; |
|
| 1097 | + if (empty($to)) { |
|
| 1098 | + continue; |
|
| 1099 | + } |
|
| 1042 | 1100 | |
| 1043 | 1101 | // Does this topic's board count the posts or not? |
| 1044 | 1102 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
| 1045 | 1103 | |
| 1046 | - if (!isset($moveTos[$to])) |
|
| 1047 | - $moveTos[$to] = array(); |
|
| 1104 | + if (!isset($moveTos[$to])) { |
|
| 1105 | + $moveTos[$to] = array(); |
|
| 1106 | + } |
|
| 1048 | 1107 | |
| 1049 | 1108 | $moveTos[$to][] = $row['id_topic']; |
| 1050 | 1109 | |
@@ -1058,8 +1117,9 @@ discard block |
||
| 1058 | 1117 | require_once($sourcedir . '/MoveTopic.php'); |
| 1059 | 1118 | |
| 1060 | 1119 | // Do the actual moves... |
| 1061 | - foreach ($moveTos as $to => $topics) |
|
| 1062 | - moveTopics($topics, $to); |
|
| 1120 | + foreach ($moveTos as $to => $topics) { |
|
| 1121 | + moveTopics($topics, $to); |
|
| 1122 | + } |
|
| 1063 | 1123 | |
| 1064 | 1124 | // Does the post counts need to be updated? |
| 1065 | 1125 | if (!empty($moveTos)) |
@@ -1108,20 +1168,23 @@ discard block |
||
| 1108 | 1168 | |
| 1109 | 1169 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 1110 | 1170 | { |
| 1111 | - if (!isset($members[$row['id_member']])) |
|
| 1112 | - $members[$row['id_member']] = 0; |
|
| 1171 | + if (!isset($members[$row['id_member']])) { |
|
| 1172 | + $members[$row['id_member']] = 0; |
|
| 1173 | + } |
|
| 1113 | 1174 | |
| 1114 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
| 1115 | - $members[$row['id_member']] += 1; |
|
| 1116 | - else |
|
| 1117 | - $members[$row['id_member']] -= 1; |
|
| 1175 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
| 1176 | + $members[$row['id_member']] += 1; |
|
| 1177 | + } else { |
|
| 1178 | + $members[$row['id_member']] -= 1; |
|
| 1179 | + } |
|
| 1118 | 1180 | } |
| 1119 | 1181 | |
| 1120 | 1182 | $smcFunc['db_free_result']($request); |
| 1121 | 1183 | |
| 1122 | 1184 | // And now update them member's post counts |
| 1123 | - foreach ($members as $id_member => $post_adj) |
|
| 1124 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1185 | + foreach ($members as $id_member => $post_adj) { |
|
| 1186 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
| 1187 | + } |
|
| 1125 | 1188 | |
| 1126 | 1189 | } |
| 1127 | 1190 | } |
@@ -1201,8 +1264,9 @@ discard block |
||
| 1201 | 1264 | approveTopics($approveCache); |
| 1202 | 1265 | |
| 1203 | 1266 | // Time for some logging! |
| 1204 | - foreach ($approveCache as $topic) |
|
| 1205 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1267 | + foreach ($approveCache as $topic) { |
|
| 1268 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
| 1269 | + } |
|
| 1206 | 1270 | } |
| 1207 | 1271 | } |
| 1208 | 1272 | |
@@ -1237,8 +1301,7 @@ discard block |
||
| 1237 | 1301 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
| 1238 | 1302 | } |
| 1239 | 1303 | $smcFunc['db_free_result']($result); |
| 1240 | - } |
|
| 1241 | - else |
|
| 1304 | + } else |
|
| 1242 | 1305 | { |
| 1243 | 1306 | $result = $smcFunc['db_query']('', ' |
| 1244 | 1307 | SELECT id_topic, locked, id_board |
@@ -1288,13 +1351,15 @@ discard block |
||
| 1288 | 1351 | ) |
| 1289 | 1352 | ); |
| 1290 | 1353 | $logged_topics = array(); |
| 1291 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1292 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1354 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1355 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
| 1356 | + } |
|
| 1293 | 1357 | $smcFunc['db_free_result']($request); |
| 1294 | 1358 | |
| 1295 | 1359 | $markArray = array(); |
| 1296 | - foreach ($markCache as $topic) |
|
| 1297 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1360 | + foreach ($markCache as $topic) { |
|
| 1361 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
| 1362 | + } |
|
| 1298 | 1363 | |
| 1299 | 1364 | $smcFunc['db_insert']('replace', |
| 1300 | 1365 | '{db_prefix}log_topics', |
@@ -1307,8 +1372,9 @@ discard block |
||
| 1307 | 1372 | foreach ($moveCache as $topic) |
| 1308 | 1373 | { |
| 1309 | 1374 | // Didn't actually move anything! |
| 1310 | - if (!isset($topic[0])) |
|
| 1311 | - break; |
|
| 1375 | + if (!isset($topic[0])) { |
|
| 1376 | + break; |
|
| 1377 | + } |
|
| 1312 | 1378 | |
| 1313 | 1379 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
| 1314 | 1380 | sendNotifications($topic[0], 'move'); |
@@ -1330,8 +1396,9 @@ discard block |
||
| 1330 | 1396 | 'calendar_updated' => time(), |
| 1331 | 1397 | )); |
| 1332 | 1398 | |
| 1333 | - if (!empty($affectedBoards)) |
|
| 1334 | - updateLastMessages(array_keys($affectedBoards)); |
|
| 1399 | + if (!empty($affectedBoards)) { |
|
| 1400 | + updateLastMessages(array_keys($affectedBoards)); |
|
| 1401 | + } |
|
| 1335 | 1402 | |
| 1336 | 1403 | redirectexit($redirect_url); |
| 1337 | 1404 | } |
@@ -15,8 +15,9 @@ discard block |
||
| 15 | 15 | * @version 2.1 Beta 4 |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | -if (!defined('SMF')) |
|
| 18 | +if (!defined('SMF')) { |
|
| 19 | 19 | die('No direct access...'); |
| 20 | +} |
|
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
| 245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 246 | 247 | { |
| 247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
| 248 | - if (!empty($row['private'])) |
|
| 249 | - $row['subject'] = $txt['personal_message']; |
|
| 249 | + if (!empty($row['private'])) { |
|
| 250 | + $row['subject'] = $txt['personal_message']; |
|
| 251 | + } |
|
| 250 | 252 | |
| 251 | 253 | $mails[] = $row; |
| 252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
| 300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
| 301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
| 302 | 304 | } |
| 303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
| 304 | - $emails[$index] = $index; |
|
| 305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
| 306 | + $emails[$index] = $index; |
|
| 307 | + } |
|
| 305 | 308 | |
| 306 | 309 | $config_vars = array( |
| 307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
| 322 | 325 | |
| 323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
| 324 | 327 | |
| 325 | - if ($return_config) |
|
| 326 | - return $config_vars; |
|
| 328 | + if ($return_config) { |
|
| 329 | + return $config_vars; |
|
| 330 | + } |
|
| 327 | 331 | |
| 328 | 332 | // Saving? |
| 329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
| 398 | 402 | ); |
| 399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
| 400 | 404 | $smcFunc['db_free_result']($request); |
| 405 | + } else { |
|
| 406 | + $_GET['te'] = (int) $_GET['te']; |
|
| 401 | 407 | } |
| 402 | - else |
|
| 403 | - $_GET['te'] = (int) $_GET['te']; |
|
| 404 | 408 | |
| 405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
| 406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
| 424 | 428 | |
| 425 | 429 | // Try get more time... |
| 426 | 430 | @set_time_limit(600); |
| 427 | - if (function_exists('apache_reset_timeout')) |
|
| 428 | - @apache_reset_timeout(); |
|
| 431 | + if (function_exists('apache_reset_timeout')) { |
|
| 432 | + @apache_reset_timeout(); |
|
| 433 | + } |
|
| 429 | 434 | |
| 430 | 435 | // Have we already used our maximum time? |
| 431 | - if ((time() - $time_start) < 5) |
|
| 432 | - return; |
|
| 436 | + if ((time() - $time_start) < 5) { |
|
| 437 | + return; |
|
| 438 | + } |
|
| 433 | 439 | |
| 434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
| 435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
| 459 | 465 | { |
| 460 | 466 | global $txt; |
| 461 | 467 | |
| 462 | - if ($time_diff < 0) |
|
| 463 | - $time_diff = 0; |
|
| 468 | + if ($time_diff < 0) { |
|
| 469 | + $time_diff = 0; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | // Just do a bit of an if fest... |
| 466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
| 481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
| 482 | 489 | } |
| 483 | 490 | // Otherwise must be second |
| 484 | - else |
|
| 485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 486 | -} |
|
| 491 | + else { |
|
| 492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
| 493 | + } |
|
| 494 | + } |
|
| 487 | 495 | |
| 488 | 496 | ?> |
| 489 | 497 | \ No newline at end of file |