@@ -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 | } |
@@ -157,8 +159,9 @@ discard block |
||
| 157 | 159 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 158 | 160 | { |
| 159 | 161 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
| 160 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
| 161 | - continue; |
|
| 162 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
| 163 | + continue; |
|
| 164 | + } |
|
| 162 | 165 | |
| 163 | 166 | // Force a censor of the title - as often these are used by others. |
| 164 | 167 | censorText($row['title'], $use_permissions ? false : true); |
@@ -167,8 +170,9 @@ discard block |
||
| 167 | 170 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 168 | 171 | |
| 169 | 172 | // Sanity check |
| 170 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 171 | - continue; |
|
| 173 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 174 | + continue; |
|
| 175 | + } |
|
| 172 | 176 | |
| 173 | 177 | // Get set up for the loop |
| 174 | 178 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz)); |
@@ -232,8 +236,8 @@ discard block |
||
| 232 | 236 | ); |
| 233 | 237 | |
| 234 | 238 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
| 235 | - if ($use_permissions) |
|
| 236 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 239 | + if ($use_permissions) { |
|
| 240 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 237 | 241 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 238 | 242 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 239 | 243 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -241,9 +245,10 @@ discard block |
||
| 241 | 245 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
| 242 | 246 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
| 243 | 247 | )); |
| 248 | + } |
|
| 244 | 249 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
| 245 | - else |
|
| 246 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 250 | + else { |
|
| 251 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
| 247 | 252 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
| 248 | 253 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
| 249 | 254 | 'can_edit' => false, |
@@ -253,6 +258,7 @@ discard block |
||
| 253 | 258 | 'poster' => $row['id_member'], |
| 254 | 259 | 'allowed_groups' => explode(',', $row['member_groups']), |
| 255 | 260 | )); |
| 261 | + } |
|
| 256 | 262 | |
| 257 | 263 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
| 258 | 264 | } |
@@ -262,8 +268,9 @@ discard block |
||
| 262 | 268 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
| 263 | 269 | if ($use_permissions) |
| 264 | 270 | { |
| 265 | - foreach ($events as $mday => $array) |
|
| 266 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 271 | + foreach ($events as $mday => $array) { |
|
| 272 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
| 273 | + } |
|
| 267 | 274 | } |
| 268 | 275 | |
| 269 | 276 | ksort($events); |
@@ -283,11 +290,12 @@ discard block |
||
| 283 | 290 | global $smcFunc; |
| 284 | 291 | |
| 285 | 292 | // Get the lowest and highest dates for "all years". |
| 286 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 287 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
| 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} |
|
| 288 | 295 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
| 289 | - else |
|
| 290 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 296 | + } else { |
|
| 297 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
| 298 | + } |
|
| 291 | 299 | |
| 292 | 300 | // Find some holidays... ;). |
| 293 | 301 | $result = $smcFunc['db_query']('', ' |
@@ -307,10 +315,11 @@ discard block |
||
| 307 | 315 | $holidays = array(); |
| 308 | 316 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
| 309 | 317 | { |
| 310 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
| 311 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 312 | - else |
|
| 313 | - $event_year = substr($low_date, 0, 4); |
|
| 318 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
| 319 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
| 320 | + } else { |
|
| 321 | + $event_year = substr($low_date, 0, 4); |
|
| 322 | + } |
|
| 314 | 323 | |
| 315 | 324 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
| 316 | 325 | } |
@@ -336,10 +345,12 @@ discard block |
||
| 336 | 345 | isAllowedTo('calendar_post'); |
| 337 | 346 | |
| 338 | 347 | // No board? No topic?!? |
| 339 | - if (empty($board)) |
|
| 340 | - fatal_lang_error('missing_board_id', false); |
|
| 341 | - if (empty($topic)) |
|
| 342 | - fatal_lang_error('missing_topic_id', false); |
|
| 348 | + if (empty($board)) { |
|
| 349 | + fatal_lang_error('missing_board_id', false); |
|
| 350 | + } |
|
| 351 | + if (empty($topic)) { |
|
| 352 | + fatal_lang_error('missing_topic_id', false); |
|
| 353 | + } |
|
| 343 | 354 | |
| 344 | 355 | // Administrator, Moderator, or owner. Period. |
| 345 | 356 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -357,12 +368,14 @@ discard block |
||
| 357 | 368 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
| 358 | 369 | { |
| 359 | 370 | // Not the owner of the topic. |
| 360 | - if ($row['id_member_started'] != $user_info['id']) |
|
| 361 | - fatal_lang_error('not_your_topic', 'user'); |
|
| 371 | + if ($row['id_member_started'] != $user_info['id']) { |
|
| 372 | + fatal_lang_error('not_your_topic', 'user'); |
|
| 373 | + } |
|
| 362 | 374 | } |
| 363 | 375 | // Topic/Board doesn't exist..... |
| 364 | - else |
|
| 365 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
| 376 | + else { |
|
| 377 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
| 378 | + } |
|
| 366 | 379 | $smcFunc['db_free_result']($result); |
| 367 | 380 | } |
| 368 | 381 | } |
@@ -450,14 +463,16 @@ discard block |
||
| 450 | 463 | if (!empty($calendarOptions['start_day'])) |
| 451 | 464 | { |
| 452 | 465 | $nShift -= $calendarOptions['start_day']; |
| 453 | - if ($nShift < 0) |
|
| 454 | - $nShift = 7 + $nShift; |
|
| 466 | + if ($nShift < 0) { |
|
| 467 | + $nShift = 7 + $nShift; |
|
| 468 | + } |
|
| 455 | 469 | } |
| 456 | 470 | |
| 457 | 471 | // Number of rows required to fit the month. |
| 458 | 472 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
| 459 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
| 460 | - $nRows++; |
|
| 473 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
| 474 | + $nRows++; |
|
| 475 | + } |
|
| 461 | 476 | |
| 462 | 477 | // Fetch the arrays for birthdays, posted events, and holidays. |
| 463 | 478 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -470,8 +485,9 @@ discard block |
||
| 470 | 485 | { |
| 471 | 486 | $calendarGrid['week_days'][] = $count; |
| 472 | 487 | $count++; |
| 473 | - if ($count == 7) |
|
| 474 | - $count = 0; |
|
| 488 | + if ($count == 7) { |
|
| 489 | + $count = 0; |
|
| 490 | + } |
|
| 475 | 491 | } |
| 476 | 492 | |
| 477 | 493 | // Iterate through each week. |
@@ -488,8 +504,9 @@ discard block |
||
| 488 | 504 | { |
| 489 | 505 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
| 490 | 506 | |
| 491 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
| 492 | - $nDay = 0; |
|
| 507 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
| 508 | + $nDay = 0; |
|
| 509 | + } |
|
| 493 | 510 | |
| 494 | 511 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
| 495 | 512 | |
@@ -507,8 +524,9 @@ discard block |
||
| 507 | 524 | } |
| 508 | 525 | |
| 509 | 526 | // What is the last day of the month? |
| 510 | - if ($is_previous === true) |
|
| 511 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 527 | + if ($is_previous === true) { |
|
| 528 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
| 529 | + } |
|
| 512 | 530 | |
| 513 | 531 | // We'll use the shift in the template. |
| 514 | 532 | $calendarGrid['shift'] = $nShift; |
@@ -542,8 +560,9 @@ discard block |
||
| 542 | 560 | { |
| 543 | 561 | // Here we offset accordingly to get things to the real start of a week. |
| 544 | 562 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
| 545 | - if ($date_diff < 0) |
|
| 546 | - $date_diff += 7; |
|
| 563 | + if ($date_diff < 0) { |
|
| 564 | + $date_diff += 7; |
|
| 565 | + } |
|
| 547 | 566 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
| 548 | 567 | $day = (int) strftime('%d', $new_timestamp); |
| 549 | 568 | $month = (int) strftime('%m', $new_timestamp); |
@@ -673,18 +692,20 @@ discard block |
||
| 673 | 692 | { |
| 674 | 693 | foreach ($date_events as $event_key => $event_val) |
| 675 | 694 | { |
| 676 | - if (in_array($event_val['id'], $temp)) |
|
| 677 | - unset($calendarGrid['events'][$date][$event_key]); |
|
| 678 | - else |
|
| 679 | - $temp[] = $event_val['id']; |
|
| 695 | + if (in_array($event_val['id'], $temp)) { |
|
| 696 | + unset($calendarGrid['events'][$date][$event_key]); |
|
| 697 | + } else { |
|
| 698 | + $temp[] = $event_val['id']; |
|
| 699 | + } |
|
| 680 | 700 | } |
| 681 | 701 | } |
| 682 | 702 | |
| 683 | 703 | // Give birthdays and holidays a friendly format, without the year |
| 684 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 685 | - $date_format = '%b %d'; |
|
| 686 | - else |
|
| 687 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 704 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 705 | + $date_format = '%b %d'; |
|
| 706 | + } else { |
|
| 707 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
| 708 | + } |
|
| 688 | 709 | |
| 689 | 710 | foreach (array('birthdays', 'holidays') as $type) |
| 690 | 711 | { |
@@ -779,8 +800,9 @@ discard block |
||
| 779 | 800 | // Holidays between now and now + days. |
| 780 | 801 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
| 781 | 802 | { |
| 782 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
| 783 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 803 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
| 804 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
| 805 | + } |
|
| 784 | 806 | } |
| 785 | 807 | |
| 786 | 808 | // Happy Birthday, guys and gals! |
@@ -789,8 +811,9 @@ discard block |
||
| 789 | 811 | $loop_date = strftime('%Y-%m-%d', $i); |
| 790 | 812 | if (isset($cached_data['birthdays'][$loop_date])) |
| 791 | 813 | { |
| 792 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
| 793 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 814 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
| 815 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
| 816 | + } |
|
| 794 | 817 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
| 795 | 818 | } |
| 796 | 819 | } |
@@ -802,8 +825,9 @@ discard block |
||
| 802 | 825 | $loop_date = strftime('%Y-%m-%d', $i); |
| 803 | 826 | |
| 804 | 827 | // No events today? Check the next day. |
| 805 | - if (empty($cached_data['events'][$loop_date])) |
|
| 806 | - continue; |
|
| 828 | + if (empty($cached_data['events'][$loop_date])) { |
|
| 829 | + continue; |
|
| 830 | + } |
|
| 807 | 831 | |
| 808 | 832 | // Loop through all events to add a few last-minute values. |
| 809 | 833 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -816,9 +840,9 @@ discard block |
||
| 816 | 840 | { |
| 817 | 841 | unset($cached_data['events'][$loop_date][$ev]); |
| 818 | 842 | continue; |
| 843 | + } else { |
|
| 844 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 819 | 845 | } |
| 820 | - else |
|
| 821 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
| 822 | 846 | |
| 823 | 847 | // Might be set to true afterwards, depending on the permissions. |
| 824 | 848 | $this_event['can_edit'] = false; |
@@ -826,15 +850,18 @@ discard block |
||
| 826 | 850 | $this_event['date'] = $loop_date; |
| 827 | 851 | } |
| 828 | 852 | |
| 829 | - if (!empty($cached_data['events'][$loop_date])) |
|
| 830 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 853 | + if (!empty($cached_data['events'][$loop_date])) { |
|
| 854 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
| 855 | + } |
|
| 831 | 856 | } |
| 832 | 857 | |
| 833 | 858 | // Mark the last item so that a list separator can be used in the template. |
| 834 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
| 835 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 836 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
| 837 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 859 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
| 860 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
| 861 | + } |
|
| 862 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
| 863 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
| 864 | + } |
|
| 838 | 865 | |
| 839 | 866 | return array( |
| 840 | 867 | 'data' => $return_data, |
@@ -882,37 +909,46 @@ discard block |
||
| 882 | 909 | if (isset($_POST['start_date'])) |
| 883 | 910 | { |
| 884 | 911 | $d = date_parse($_POST['start_date']); |
| 885 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 886 | - fatal_lang_error('invalid_date', false); |
|
| 887 | - if (empty($d['year'])) |
|
| 888 | - fatal_lang_error('event_year_missing', false); |
|
| 889 | - if (empty($d['month'])) |
|
| 890 | - fatal_lang_error('event_month_missing', false); |
|
| 891 | - } |
|
| 892 | - elseif (isset($_POST['start_datetime'])) |
|
| 912 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 913 | + fatal_lang_error('invalid_date', false); |
|
| 914 | + } |
|
| 915 | + if (empty($d['year'])) { |
|
| 916 | + fatal_lang_error('event_year_missing', false); |
|
| 917 | + } |
|
| 918 | + if (empty($d['month'])) { |
|
| 919 | + fatal_lang_error('event_month_missing', false); |
|
| 920 | + } |
|
| 921 | + } elseif (isset($_POST['start_datetime'])) |
|
| 893 | 922 | { |
| 894 | 923 | $d = date_parse($_POST['start_datetime']); |
| 895 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
| 896 | - fatal_lang_error('invalid_date', false); |
|
| 897 | - if (empty($d['year'])) |
|
| 898 | - fatal_lang_error('event_year_missing', false); |
|
| 899 | - if (empty($d['month'])) |
|
| 900 | - fatal_lang_error('event_month_missing', false); |
|
| 924 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
| 925 | + fatal_lang_error('invalid_date', false); |
|
| 926 | + } |
|
| 927 | + if (empty($d['year'])) { |
|
| 928 | + fatal_lang_error('event_year_missing', false); |
|
| 929 | + } |
|
| 930 | + if (empty($d['month'])) { |
|
| 931 | + fatal_lang_error('event_month_missing', false); |
|
| 932 | + } |
|
| 901 | 933 | } |
| 902 | 934 | // The 2.0 way |
| 903 | 935 | else |
| 904 | 936 | { |
| 905 | 937 | // No month? No year? |
| 906 | - if (!isset($_POST['month'])) |
|
| 907 | - fatal_lang_error('event_month_missing', false); |
|
| 908 | - if (!isset($_POST['year'])) |
|
| 909 | - fatal_lang_error('event_year_missing', false); |
|
| 938 | + if (!isset($_POST['month'])) { |
|
| 939 | + fatal_lang_error('event_month_missing', false); |
|
| 940 | + } |
|
| 941 | + if (!isset($_POST['year'])) { |
|
| 942 | + fatal_lang_error('event_year_missing', false); |
|
| 943 | + } |
|
| 910 | 944 | |
| 911 | 945 | // Check the month and year... |
| 912 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
| 913 | - fatal_lang_error('invalid_month', false); |
|
| 914 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
| 915 | - fatal_lang_error('invalid_year', false); |
|
| 946 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
| 947 | + fatal_lang_error('invalid_month', false); |
|
| 948 | + } |
|
| 949 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
| 950 | + fatal_lang_error('invalid_year', false); |
|
| 951 | + } |
|
| 916 | 952 | } |
| 917 | 953 | } |
| 918 | 954 | |
@@ -922,8 +958,9 @@ discard block |
||
| 922 | 958 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
| 923 | 959 | if (isset($_POST['span'])) |
| 924 | 960 | { |
| 925 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
| 926 | - fatal_lang_error('invalid_days_numb', false); |
|
| 961 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
| 962 | + fatal_lang_error('invalid_days_numb', false); |
|
| 963 | + } |
|
| 927 | 964 | } |
| 928 | 965 | |
| 929 | 966 | // There is no need to validate the following values if we are just deleting the event. |
@@ -933,24 +970,29 @@ discard block |
||
| 933 | 970 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
| 934 | 971 | { |
| 935 | 972 | // No day? |
| 936 | - if (!isset($_POST['day'])) |
|
| 937 | - fatal_lang_error('event_day_missing', false); |
|
| 973 | + if (!isset($_POST['day'])) { |
|
| 974 | + fatal_lang_error('event_day_missing', false); |
|
| 975 | + } |
|
| 938 | 976 | |
| 939 | 977 | // Bad day? |
| 940 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
| 941 | - fatal_lang_error('invalid_date', false); |
|
| 978 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
| 979 | + fatal_lang_error('invalid_date', false); |
|
| 980 | + } |
|
| 942 | 981 | } |
| 943 | 982 | |
| 944 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
| 945 | - fatal_lang_error('event_title_missing', false); |
|
| 946 | - elseif (!isset($_POST['evtitle'])) |
|
| 947 | - $_POST['evtitle'] = $_POST['subject']; |
|
| 983 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
| 984 | + fatal_lang_error('event_title_missing', false); |
|
| 985 | + } elseif (!isset($_POST['evtitle'])) { |
|
| 986 | + $_POST['evtitle'] = $_POST['subject']; |
|
| 987 | + } |
|
| 948 | 988 | |
| 949 | 989 | // No title? |
| 950 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
| 951 | - fatal_lang_error('no_event_title', false); |
|
| 952 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
| 953 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 990 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
| 991 | + fatal_lang_error('no_event_title', false); |
|
| 992 | + } |
|
| 993 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
| 994 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
| 995 | + } |
|
| 954 | 996 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
| 955 | 997 | } |
| 956 | 998 | } |
@@ -977,8 +1019,9 @@ discard block |
||
| 977 | 1019 | ); |
| 978 | 1020 | |
| 979 | 1021 | // No results, return false. |
| 980 | - if ($smcFunc['db_num_rows'] === 0) |
|
| 981 | - return false; |
|
| 1022 | + if ($smcFunc['db_num_rows'] === 0) { |
|
| 1023 | + return false; |
|
| 1024 | + } |
|
| 982 | 1025 | |
| 983 | 1026 | // Grab the results and return. |
| 984 | 1027 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1112,8 +1155,9 @@ discard block |
||
| 1112 | 1155 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
| 1113 | 1156 | |
| 1114 | 1157 | $column_clauses = array(); |
| 1115 | - foreach ($event_columns as $col => $crit) |
|
| 1116 | - $column_clauses[] = $col . ' = ' . $crit; |
|
| 1158 | + foreach ($event_columns as $col => $crit) { |
|
| 1159 | + $column_clauses[] = $col . ' = ' . $crit; |
|
| 1160 | + } |
|
| 1117 | 1161 | |
| 1118 | 1162 | $smcFunc['db_query']('', ' |
| 1119 | 1163 | UPDATE {db_prefix}calendar |
@@ -1198,8 +1242,9 @@ discard block |
||
| 1198 | 1242 | ); |
| 1199 | 1243 | |
| 1200 | 1244 | // If nothing returned, we are in poo, poo. |
| 1201 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
| 1202 | - return false; |
|
| 1245 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
| 1246 | + return false; |
|
| 1247 | + } |
|
| 1203 | 1248 | |
| 1204 | 1249 | $row = $smcFunc['db_fetch_assoc']($request); |
| 1205 | 1250 | $smcFunc['db_free_result']($request); |
@@ -1207,8 +1252,9 @@ discard block |
||
| 1207 | 1252 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
| 1208 | 1253 | |
| 1209 | 1254 | // Sanity check |
| 1210 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
| 1211 | - return false; |
|
| 1255 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
| 1256 | + return false; |
|
| 1257 | + } |
|
| 1212 | 1258 | |
| 1213 | 1259 | $return_value = array( |
| 1214 | 1260 | 'boards' => array(), |
@@ -1345,24 +1391,27 @@ discard block |
||
| 1345 | 1391 | |
| 1346 | 1392 | // Set $span, in case we need it |
| 1347 | 1393 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
| 1348 | - if ($span > 0) |
|
| 1349 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1394 | + if ($span > 0) { |
|
| 1395 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
| 1396 | + } |
|
| 1350 | 1397 | |
| 1351 | 1398 | // Define the timezone for this event, falling back to the default if not provided |
| 1352 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1353 | - $tz = $eventOptions['tz']; |
|
| 1354 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1355 | - $tz = $_POST['tz']; |
|
| 1356 | - else |
|
| 1357 | - $tz = getUserTimezone(); |
|
| 1399 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1400 | + $tz = $eventOptions['tz']; |
|
| 1401 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1402 | + $tz = $_POST['tz']; |
|
| 1403 | + } else { |
|
| 1404 | + $tz = getUserTimezone(); |
|
| 1405 | + } |
|
| 1358 | 1406 | |
| 1359 | 1407 | // Is this supposed to be an all day event, or should it have specific start and end times? |
| 1360 | - if (isset($eventOptions['allday'])) |
|
| 1361 | - $allday = $eventOptions['allday']; |
|
| 1362 | - elseif (empty($_POST['allday'])) |
|
| 1363 | - $allday = false; |
|
| 1364 | - else |
|
| 1365 | - $allday = true; |
|
| 1408 | + if (isset($eventOptions['allday'])) { |
|
| 1409 | + $allday = $eventOptions['allday']; |
|
| 1410 | + } elseif (empty($_POST['allday'])) { |
|
| 1411 | + $allday = false; |
|
| 1412 | + } else { |
|
| 1413 | + $allday = true; |
|
| 1414 | + } |
|
| 1366 | 1415 | |
| 1367 | 1416 | // Input might come as individual parameters... |
| 1368 | 1417 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1389,10 +1438,12 @@ discard block |
||
| 1389 | 1438 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
| 1390 | 1439 | |
| 1391 | 1440 | // If the date and time were given in separate strings, combine them |
| 1392 | - if (empty($start_string) && isset($start_date_string)) |
|
| 1393 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1394 | - if (empty($end_string) && isset($end_date_string)) |
|
| 1395 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1441 | + if (empty($start_string) && isset($start_date_string)) { |
|
| 1442 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
| 1443 | + } |
|
| 1444 | + if (empty($end_string) && isset($end_date_string)) { |
|
| 1445 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
| 1446 | + } |
|
| 1396 | 1447 | |
| 1397 | 1448 | // If some form of string input was given, override individually defined options with it |
| 1398 | 1449 | if (isset($start_string)) |
@@ -1483,10 +1534,11 @@ discard block |
||
| 1483 | 1534 | if ($start_object >= $end_object) |
| 1484 | 1535 | { |
| 1485 | 1536 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1486 | - if ($span > 0) |
|
| 1487 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1488 | - else |
|
| 1489 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1537 | + if ($span > 0) { |
|
| 1538 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
| 1539 | + } else { |
|
| 1540 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
| 1541 | + } |
|
| 1490 | 1542 | } |
| 1491 | 1543 | |
| 1492 | 1544 | // Is $end_object too late? |
@@ -1499,9 +1551,9 @@ discard block |
||
| 1499 | 1551 | { |
| 1500 | 1552 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
| 1501 | 1553 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
| 1554 | + } else { |
|
| 1555 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1502 | 1556 | } |
| 1503 | - else |
|
| 1504 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
| 1505 | 1557 | } |
| 1506 | 1558 | } |
| 1507 | 1559 | |
@@ -1514,8 +1566,7 @@ discard block |
||
| 1514 | 1566 | $start_time = null; |
| 1515 | 1567 | $end_time = null; |
| 1516 | 1568 | $tz = null; |
| 1517 | - } |
|
| 1518 | - else |
|
| 1569 | + } else |
|
| 1519 | 1570 | { |
| 1520 | 1571 | $start_time = date_format($start_object, 'H:i:s'); |
| 1521 | 1572 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1536,16 +1587,18 @@ discard block |
||
| 1536 | 1587 | require_once($sourcedir . '/Subs.php'); |
| 1537 | 1588 | |
| 1538 | 1589 | // First, try to create a better date format, ignoring the "time" elements. |
| 1539 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1540 | - $date_format = '%F'; |
|
| 1541 | - else |
|
| 1542 | - $date_format = $matches[0]; |
|
| 1590 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1591 | + $date_format = '%F'; |
|
| 1592 | + } else { |
|
| 1593 | + $date_format = $matches[0]; |
|
| 1594 | + } |
|
| 1543 | 1595 | |
| 1544 | 1596 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
| 1545 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
| 1546 | - $time_format = '%k:%M'; |
|
| 1547 | - else |
|
| 1548 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1597 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
| 1598 | + $time_format = '%k:%M'; |
|
| 1599 | + } else { |
|
| 1600 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
| 1601 | + } |
|
| 1549 | 1602 | |
| 1550 | 1603 | // Should this be an all day event? |
| 1551 | 1604 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
@@ -1554,8 +1607,9 @@ discard block |
||
| 1554 | 1607 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
| 1555 | 1608 | |
| 1556 | 1609 | // We need to have a defined timezone in the steps below |
| 1557 | - if (empty($row['timezone'])) |
|
| 1558 | - $row['timezone'] = getUserTimezone(); |
|
| 1610 | + if (empty($row['timezone'])) { |
|
| 1611 | + $row['timezone'] = getUserTimezone(); |
|
| 1612 | + } |
|
| 1559 | 1613 | |
| 1560 | 1614 | // Get most of the standard date information for the start and end datetimes |
| 1561 | 1615 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1607,8 +1661,9 @@ discard block |
||
| 1607 | 1661 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
| 1608 | 1662 | static $member_cache = array(); |
| 1609 | 1663 | |
| 1610 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
| 1611 | - $id_member = $context['user']['id']; |
|
| 1664 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
| 1665 | + $id_member = $context['user']['id']; |
|
| 1666 | + } |
|
| 1612 | 1667 | |
| 1613 | 1668 | //check if the cache got the data |
| 1614 | 1669 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1637,11 +1692,13 @@ discard block |
||
| 1637 | 1692 | $smcFunc['db_free_result']($request); |
| 1638 | 1693 | } |
| 1639 | 1694 | |
| 1640 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
| 1641 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1695 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
| 1696 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
| 1697 | + } |
|
| 1642 | 1698 | |
| 1643 | - if (isset($id_member)) |
|
| 1644 | - $member_cache[$id_member] = $timezone; |
|
| 1699 | + if (isset($id_member)) { |
|
| 1700 | + $member_cache[$id_member] = $timezone; |
|
| 1701 | + } |
|
| 1645 | 1702 | |
| 1646 | 1703 | return $timezone; |
| 1647 | 1704 | } |
@@ -1670,8 +1727,9 @@ discard block |
||
| 1670 | 1727 | ) |
| 1671 | 1728 | ); |
| 1672 | 1729 | $holidays = array(); |
| 1673 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 1674 | - $holidays[] = $row; |
|
| 1730 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 1731 | + $holidays[] = $row; |
|
| 1732 | + } |
|
| 1675 | 1733 | $smcFunc['db_free_result']($request); |
| 1676 | 1734 | |
| 1677 | 1735 | return $holidays; |
@@ -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 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
| 29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
| 30 | 31 | |
| 31 | 32 | // Is this an incoming AJAX check? |
| 32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
| 33 | - return RegisterCheckUsername(); |
|
| 33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
| 34 | + return RegisterCheckUsername(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // Check if the administrator has it disabled. |
| 36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
| 37 | - fatal_lang_error('registration_disabled', false); |
|
| 38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
| 39 | + fatal_lang_error('registration_disabled', false); |
|
| 40 | + } |
|
| 38 | 41 | |
| 39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
| 40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
| 41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
| 44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
| 45 | + } |
|
| 42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
| 43 | - elseif (empty($user_info['is_guest'])) |
|
| 44 | - redirectexit(); |
|
| 47 | + elseif (empty($user_info['is_guest'])) { |
|
| 48 | + redirectexit(); |
|
| 49 | + } |
|
| 45 | 50 | |
| 46 | 51 | loadLanguage('Login'); |
| 47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
| 82 | 87 | } |
| 83 | 88 | } |
| 84 | 89 | // Make sure they don't squeeze through without agreeing. |
| 85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
| 86 | - $current_step = 1; |
|
| 90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
| 91 | + $current_step = 1; |
|
| 92 | + } |
|
| 87 | 93 | |
| 88 | 94 | // Show the user the right form. |
| 89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
| 90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
| 91 | 97 | |
| 92 | 98 | // Kinda need this. |
| 93 | - if ($context['sub_template'] == 'registration_form') |
|
| 94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 99 | + if ($context['sub_template'] == 'registration_form') { |
|
| 100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
| 101 | + } |
|
| 95 | 102 | |
| 96 | 103 | // Add the register chain to the link tree. |
| 97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
| 100 | 107 | ); |
| 101 | 108 | |
| 102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
| 103 | - if (!isset($_SESSION['register'])) |
|
| 104 | - $_SESSION['register'] = array( |
|
| 110 | + if (!isset($_SESSION['register'])) { |
|
| 111 | + $_SESSION['register'] = array( |
|
| 105 | 112 | 'timenow' => time(), |
| 106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
| 107 | 114 | ); |
| 108 | - else |
|
| 109 | - $_SESSION['register']['timenow'] = time(); |
|
| 115 | + } else { |
|
| 116 | + $_SESSION['register']['timenow'] = time(); |
|
| 117 | + } |
|
| 110 | 118 | |
| 111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
| 112 | 120 | if ($context['require_agreement']) |
| 113 | 121 | { |
| 114 | 122 | // Have we got a localized one? |
| 115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
| 116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
| 118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 119 | - else |
|
| 120 | - $context['agreement'] = ''; |
|
| 123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
| 124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
| 125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
| 126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
| 127 | + } else { |
|
| 128 | + $context['agreement'] = ''; |
|
| 129 | + } |
|
| 121 | 130 | |
| 122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
| 123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
| 133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
| 134 | 143 | |
| 135 | 144 | // Do we have any languages? |
| 136 | - if (empty($context['languages'])) |
|
| 137 | - getLanguages(); |
|
| 145 | + if (empty($context['languages'])) { |
|
| 146 | + getLanguages(); |
|
| 147 | + } |
|
| 138 | 148 | |
| 139 | 149 | // Try to find our selected language. |
| 140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
| 142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
| 143 | 153 | |
| 144 | 154 | // Found it! |
| 145 | - if ($selectedLanguage == $lang['filename']) |
|
| 146 | - $context['languages'][$key]['selected'] = true; |
|
| 155 | + if ($selectedLanguage == $lang['filename']) { |
|
| 156 | + $context['languages'][$key]['selected'] = true; |
|
| 157 | + } |
|
| 147 | 158 | } |
| 148 | 159 | } |
| 149 | 160 | |
@@ -167,9 +178,10 @@ discard block |
||
| 167 | 178 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 168 | 179 | |
| 169 | 180 | // We might have had some submissions on this front - go check. |
| 170 | - foreach ($reg_fields as $field) |
|
| 171 | - if (isset($_POST[$field])) |
|
| 181 | + foreach ($reg_fields as $field) { |
|
| 182 | + if (isset($_POST[$field])) |
|
| 172 | 183 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
| 184 | + } |
|
| 173 | 185 | |
| 174 | 186 | // Load all the fields in question. |
| 175 | 187 | setupProfileContext($reg_fields); |
@@ -186,8 +198,9 @@ discard block |
||
| 186 | 198 | $context['visual_verification_id'] = $verificationOptions['id']; |
| 187 | 199 | } |
| 188 | 200 | // Otherwise we have nothing to show. |
| 189 | - else |
|
| 190 | - $context['visual_verification'] = false; |
|
| 201 | + else { |
|
| 202 | + $context['visual_verification'] = false; |
|
| 203 | + } |
|
| 191 | 204 | |
| 192 | 205 | |
| 193 | 206 | $context += array( |
@@ -198,8 +211,9 @@ discard block |
||
| 198 | 211 | |
| 199 | 212 | // Were there any errors? |
| 200 | 213 | $context['registration_errors'] = array(); |
| 201 | - if (!empty($reg_errors)) |
|
| 202 | - $context['registration_errors'] = $reg_errors; |
|
| 214 | + if (!empty($reg_errors)) { |
|
| 215 | + $context['registration_errors'] = $reg_errors; |
|
| 216 | + } |
|
| 203 | 217 | |
| 204 | 218 | createToken('register'); |
| 205 | 219 | } |
@@ -216,27 +230,32 @@ discard block |
||
| 216 | 230 | validateToken('register'); |
| 217 | 231 | |
| 218 | 232 | // Check to ensure we're forcing SSL for authentication |
| 219 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 220 | - fatal_lang_error('register_ssl_required'); |
|
| 233 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 234 | + fatal_lang_error('register_ssl_required'); |
|
| 235 | + } |
|
| 221 | 236 | |
| 222 | 237 | // Start collecting together any errors. |
| 223 | 238 | $reg_errors = array(); |
| 224 | 239 | |
| 225 | 240 | // You can't register if it's disabled. |
| 226 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
| 227 | - fatal_lang_error('registration_disabled', false); |
|
| 241 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
| 242 | + fatal_lang_error('registration_disabled', false); |
|
| 243 | + } |
|
| 228 | 244 | |
| 229 | 245 | // Well, if you don't agree, you can't register. |
| 230 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
| 231 | - redirectexit(); |
|
| 246 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
| 247 | + redirectexit(); |
|
| 248 | + } |
|
| 232 | 249 | |
| 233 | 250 | // Make sure they came from *somewhere*, have a session. |
| 234 | - if (!isset($_SESSION['old_url'])) |
|
| 235 | - redirectexit('action=signup'); |
|
| 251 | + if (!isset($_SESSION['old_url'])) { |
|
| 252 | + redirectexit('action=signup'); |
|
| 253 | + } |
|
| 236 | 254 | |
| 237 | 255 | // If we don't require an agreement, we need a extra check for coppa. |
| 238 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
| 239 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 256 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
| 257 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
| 258 | + } |
|
| 240 | 259 | // Are they under age, and under age users are banned? |
| 241 | 260 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
| 242 | 261 | { |
@@ -245,8 +264,9 @@ discard block |
||
| 245 | 264 | } |
| 246 | 265 | |
| 247 | 266 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
| 248 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
| 249 | - redirectexit('action=signup'); |
|
| 267 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
| 268 | + redirectexit('action=signup'); |
|
| 269 | + } |
|
| 250 | 270 | // Failing that, check the time on it. |
| 251 | 271 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
| 252 | 272 | { |
@@ -266,15 +286,17 @@ discard block |
||
| 266 | 286 | if (is_array($context['visual_verification'])) |
| 267 | 287 | { |
| 268 | 288 | loadLanguage('Errors'); |
| 269 | - foreach ($context['visual_verification'] as $error) |
|
| 270 | - $reg_errors[] = $txt['error_' . $error]; |
|
| 289 | + foreach ($context['visual_verification'] as $error) { |
|
| 290 | + $reg_errors[] = $txt['error_' . $error]; |
|
| 291 | + } |
|
| 271 | 292 | } |
| 272 | 293 | } |
| 273 | 294 | |
| 274 | 295 | foreach ($_POST as $key => $value) |
| 275 | 296 | { |
| 276 | - if (!is_array($_POST[$key])) |
|
| 277 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 297 | + if (!is_array($_POST[$key])) { |
|
| 298 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
| 299 | + } |
|
| 278 | 300 | } |
| 279 | 301 | |
| 280 | 302 | // Collect all extra registration fields someone might have filled in. |
@@ -304,12 +326,14 @@ discard block |
||
| 304 | 326 | $reg_fields = explode(',', $modSettings['registration_fields']); |
| 305 | 327 | |
| 306 | 328 | // Website is a little different |
| 307 | - if (in_array('website', $reg_fields)) |
|
| 308 | - $possible_strings += array('website_url', 'website_title'); |
|
| 329 | + if (in_array('website', $reg_fields)) { |
|
| 330 | + $possible_strings += array('website_url', 'website_title'); |
|
| 331 | + } |
|
| 309 | 332 | } |
| 310 | 333 | |
| 311 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
| 312 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 334 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
| 335 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
| 336 | + } |
|
| 313 | 337 | |
| 314 | 338 | // Needed for isReservedName() and registerMember(). |
| 315 | 339 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -318,8 +342,9 @@ discard block |
||
| 318 | 342 | if (isset($_POST['real_name'])) |
| 319 | 343 | { |
| 320 | 344 | // Are you already allowed to edit the displayed name? |
| 321 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
| 322 | - $canEditDisplayName = true; |
|
| 345 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
| 346 | + $canEditDisplayName = true; |
|
| 347 | + } |
|
| 323 | 348 | |
| 324 | 349 | // If you are a guest, will you be allowed to once you register? |
| 325 | 350 | else |
@@ -343,33 +368,38 @@ discard block |
||
| 343 | 368 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
| 344 | 369 | |
| 345 | 370 | // Only set it if we are sure it is good |
| 346 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
| 347 | - $possible_strings[] = 'real_name'; |
|
| 371 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
| 372 | + $possible_strings[] = 'real_name'; |
|
| 373 | + } |
|
| 348 | 374 | } |
| 349 | 375 | } |
| 350 | 376 | |
| 351 | 377 | // Handle a string as a birthdate... |
| 352 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
| 353 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 378 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
| 379 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
| 380 | + } |
|
| 354 | 381 | // Or birthdate parts... |
| 355 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
| 356 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 382 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
| 383 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
| 384 | + } |
|
| 357 | 385 | |
| 358 | 386 | // Validate the passed language file. |
| 359 | 387 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
| 360 | 388 | { |
| 361 | 389 | // Do we have any languages? |
| 362 | - if (empty($context['languages'])) |
|
| 363 | - getLanguages(); |
|
| 390 | + if (empty($context['languages'])) { |
|
| 391 | + getLanguages(); |
|
| 392 | + } |
|
| 364 | 393 | |
| 365 | 394 | // Did we find it? |
| 366 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
| 367 | - $_SESSION['language'] = $_POST['lngfile']; |
|
| 368 | - else |
|
| 395 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
| 396 | + $_SESSION['language'] = $_POST['lngfile']; |
|
| 397 | + } else { |
|
| 398 | + unset($_POST['lngfile']); |
|
| 399 | + } |
|
| 400 | + } else { |
|
| 369 | 401 | unset($_POST['lngfile']); |
| 370 | 402 | } |
| 371 | - else |
|
| 372 | - unset($_POST['lngfile']); |
|
| 373 | 403 | |
| 374 | 404 | // Set the options needed for registration. |
| 375 | 405 | $regOptions = array( |
@@ -389,22 +419,27 @@ discard block |
||
| 389 | 419 | ); |
| 390 | 420 | |
| 391 | 421 | // Include the additional options that might have been filled in. |
| 392 | - foreach ($possible_strings as $var) |
|
| 393 | - if (isset($_POST[$var])) |
|
| 422 | + foreach ($possible_strings as $var) { |
|
| 423 | + if (isset($_POST[$var])) |
|
| 394 | 424 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
| 395 | - foreach ($possible_ints as $var) |
|
| 396 | - if (isset($_POST[$var])) |
|
| 425 | + } |
|
| 426 | + foreach ($possible_ints as $var) { |
|
| 427 | + if (isset($_POST[$var])) |
|
| 397 | 428 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
| 398 | - foreach ($possible_floats as $var) |
|
| 399 | - if (isset($_POST[$var])) |
|
| 429 | + } |
|
| 430 | + foreach ($possible_floats as $var) { |
|
| 431 | + if (isset($_POST[$var])) |
|
| 400 | 432 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
| 401 | - foreach ($possible_bools as $var) |
|
| 402 | - if (isset($_POST[$var])) |
|
| 433 | + } |
|
| 434 | + foreach ($possible_bools as $var) { |
|
| 435 | + if (isset($_POST[$var])) |
|
| 403 | 436 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
| 437 | + } |
|
| 404 | 438 | |
| 405 | 439 | // Registration options are always default options... |
| 406 | - if (isset($_POST['default_options'])) |
|
| 407 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 440 | + if (isset($_POST['default_options'])) { |
|
| 441 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
| 442 | + } |
|
| 408 | 443 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
| 409 | 444 | |
| 410 | 445 | // Make sure they are clean, dammit! |
@@ -424,12 +459,14 @@ discard block |
||
| 424 | 459 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 425 | 460 | { |
| 426 | 461 | // Don't allow overriding of the theme variables. |
| 427 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
| 428 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 462 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
| 463 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
| 464 | + } |
|
| 429 | 465 | |
| 430 | 466 | // Not actually showing it then? |
| 431 | - if (!$row['show_reg']) |
|
| 432 | - continue; |
|
| 467 | + if (!$row['show_reg']) { |
|
| 468 | + continue; |
|
| 469 | + } |
|
| 433 | 470 | |
| 434 | 471 | // Prepare the value! |
| 435 | 472 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -438,24 +475,27 @@ discard block |
||
| 438 | 475 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
| 439 | 476 | { |
| 440 | 477 | // Is it too long? |
| 441 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
| 442 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 478 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
| 479 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
| 480 | + } |
|
| 443 | 481 | |
| 444 | 482 | // Any masks to apply? |
| 445 | 483 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
| 446 | 484 | { |
| 447 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
| 448 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 449 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
| 450 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 451 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
| 452 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 485 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
| 486 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
| 487 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
| 488 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
| 489 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
| 490 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
| 491 | + } |
|
| 453 | 492 | } |
| 454 | 493 | } |
| 455 | 494 | |
| 456 | 495 | // Is this required but not there? |
| 457 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
| 458 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 496 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
| 497 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
| 498 | + } |
|
| 459 | 499 | } |
| 460 | 500 | $smcFunc['db_free_result']($request); |
| 461 | 501 | |
@@ -463,8 +503,9 @@ discard block |
||
| 463 | 503 | if (!empty($custom_field_errors)) |
| 464 | 504 | { |
| 465 | 505 | loadLanguage('Errors'); |
| 466 | - foreach ($custom_field_errors as $error) |
|
| 467 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 506 | + foreach ($custom_field_errors as $error) { |
|
| 507 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
| 508 | + } |
|
| 468 | 509 | } |
| 469 | 510 | |
| 470 | 511 | // Lets check for other errors before trying to register the member. |
@@ -509,8 +550,9 @@ discard block |
||
| 509 | 550 | } |
| 510 | 551 | |
| 511 | 552 | // If COPPA has been selected then things get complicated, setup the template. |
| 512 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
| 513 | - redirectexit('action=coppa;member=' . $memberID); |
|
| 553 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
| 554 | + redirectexit('action=coppa;member=' . $memberID); |
|
| 555 | + } |
|
| 514 | 556 | // Basic template variable setup. |
| 515 | 557 | elseif (!empty($modSettings['registration_method'])) |
| 516 | 558 | { |
@@ -522,8 +564,7 @@ discard block |
||
| 522 | 564 | 'sub_template' => 'after', |
| 523 | 565 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
| 524 | 566 | ); |
| 525 | - } |
|
| 526 | - else |
|
| 567 | + } else |
|
| 527 | 568 | { |
| 528 | 569 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
| 529 | 570 | |
@@ -543,16 +584,18 @@ discard block |
||
| 543 | 584 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
| 544 | 585 | |
| 545 | 586 | // Logged in users should not bother to activate their accounts |
| 546 | - if (!empty($user_info['id'])) |
|
| 547 | - redirectexit(); |
|
| 587 | + if (!empty($user_info['id'])) { |
|
| 588 | + redirectexit(); |
|
| 589 | + } |
|
| 548 | 590 | |
| 549 | 591 | loadLanguage('Login'); |
| 550 | 592 | loadTemplate('Login'); |
| 551 | 593 | |
| 552 | 594 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
| 553 | 595 | { |
| 554 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
| 555 | - fatal_lang_error('no_access', false); |
|
| 596 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
| 597 | + fatal_lang_error('no_access', false); |
|
| 598 | + } |
|
| 556 | 599 | |
| 557 | 600 | $context['member_id'] = 0; |
| 558 | 601 | $context['sub_template'] = 'resend'; |
@@ -592,11 +635,13 @@ discard block |
||
| 592 | 635 | // Change their email address? (they probably tried a fake one first :P.) |
| 593 | 636 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
| 594 | 637 | { |
| 595 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
| 596 | - fatal_lang_error('no_access', false); |
|
| 638 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
| 639 | + fatal_lang_error('no_access', false); |
|
| 640 | + } |
|
| 597 | 641 | |
| 598 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
| 599 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 642 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
| 643 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
| 644 | + } |
|
| 600 | 645 | |
| 601 | 646 | // Make sure their email isn't banned. |
| 602 | 647 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -612,8 +657,9 @@ discard block |
||
| 612 | 657 | ) |
| 613 | 658 | ); |
| 614 | 659 | |
| 615 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
| 616 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 660 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
| 661 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
| 662 | + } |
|
| 617 | 663 | $smcFunc['db_free_result']($request); |
| 618 | 664 | |
| 619 | 665 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -651,9 +697,9 @@ discard block |
||
| 651 | 697 | // Quit if this code is not right. |
| 652 | 698 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
| 653 | 699 | { |
| 654 | - if (!empty($row['is_activated'])) |
|
| 655 | - fatal_lang_error('already_activated', false); |
|
| 656 | - elseif ($row['validation_code'] == '') |
|
| 700 | + if (!empty($row['is_activated'])) { |
|
| 701 | + fatal_lang_error('already_activated', false); |
|
| 702 | + } elseif ($row['validation_code'] == '') |
|
| 657 | 703 | { |
| 658 | 704 | loadLanguage('Profile'); |
| 659 | 705 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -703,8 +749,9 @@ discard block |
||
| 703 | 749 | loadTemplate('Register'); |
| 704 | 750 | |
| 705 | 751 | // No User ID?? |
| 706 | - if (!isset($_GET['member'])) |
|
| 707 | - fatal_lang_error('no_access', false); |
|
| 752 | + if (!isset($_GET['member'])) { |
|
| 753 | + fatal_lang_error('no_access', false); |
|
| 754 | + } |
|
| 708 | 755 | |
| 709 | 756 | // Get the user details... |
| 710 | 757 | $request = $smcFunc['db_query']('', ' |
@@ -717,8 +764,9 @@ discard block |
||
| 717 | 764 | 'is_coppa' => 5, |
| 718 | 765 | ) |
| 719 | 766 | ); |
| 720 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
| 721 | - fatal_lang_error('no_access', false); |
|
| 767 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
| 768 | + fatal_lang_error('no_access', false); |
|
| 769 | + } |
|
| 722 | 770 | list ($username) = $smcFunc['db_fetch_row']($request); |
| 723 | 771 | $smcFunc['db_free_result']($request); |
| 724 | 772 | |
@@ -756,8 +804,7 @@ discard block |
||
| 756 | 804 | echo $data; |
| 757 | 805 | obExit(false); |
| 758 | 806 | } |
| 759 | - } |
|
| 760 | - else |
|
| 807 | + } else |
|
| 761 | 808 | { |
| 762 | 809 | $context += array( |
| 763 | 810 | 'page_title' => $txt['coppa_title'], |
@@ -810,8 +857,9 @@ discard block |
||
| 810 | 857 | { |
| 811 | 858 | require_once($sourcedir . '/Subs-Graphics.php'); |
| 812 | 859 | |
| 813 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
| 814 | - header('HTTP/1.1 400 Bad Request'); |
|
| 860 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
| 861 | + header('HTTP/1.1 400 Bad Request'); |
|
| 862 | + } |
|
| 815 | 863 | |
| 816 | 864 | // Otherwise just show a pre-defined letter. |
| 817 | 865 | elseif (isset($_REQUEST['letter'])) |
@@ -829,14 +877,13 @@ discard block |
||
| 829 | 877 | header('Content-Type: image/gif'); |
| 830 | 878 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
| 831 | 879 | } |
| 832 | - } |
|
| 833 | - |
|
| 834 | - elseif ($_REQUEST['format'] === '.wav') |
|
| 880 | + } elseif ($_REQUEST['format'] === '.wav') |
|
| 835 | 881 | { |
| 836 | 882 | require_once($sourcedir . '/Subs-Sound.php'); |
| 837 | 883 | |
| 838 | - if (!createWaveFile($code)) |
|
| 839 | - header('HTTP/1.1 400 Bad Request'); |
|
| 884 | + if (!createWaveFile($code)) { |
|
| 885 | + header('HTTP/1.1 400 Bad Request'); |
|
| 886 | + } |
|
| 840 | 887 | } |
| 841 | 888 | |
| 842 | 889 | // We all die one day... |
@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
| 107 | 108 | // Perhaps the search method wants to add some settings? |
| 108 | 109 | require_once($sourcedir . '/Search.php'); |
| 109 | 110 | $searchAPI = findSearchAPI(); |
| 110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
| 111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
| 112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
| 113 | + } |
|
| 112 | 114 | |
| 113 | - if ($return_config) |
|
| 114 | - return $config_vars; |
|
| 115 | + if ($return_config) { |
|
| 116 | + return $config_vars; |
|
| 117 | + } |
|
| 115 | 118 | |
| 116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
| 117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | |
| 127 | 130 | call_integration_hook('integrate_save_search_settings'); |
| 128 | 131 | |
| 129 | - if (empty($_POST['search_results_per_page'])) |
|
| 130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 132 | + if (empty($_POST['search_results_per_page'])) { |
|
| 133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
| 134 | + } |
|
| 131 | 135 | saveDBSettings($config_vars); |
| 132 | 136 | $_SESSION['adm-save'] = true; |
| 133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
| 177 | 181 | call_integration_hook('integrate_save_search_weights'); |
| 178 | 182 | |
| 179 | 183 | $changes = array(); |
| 180 | - foreach ($factors as $factor) |
|
| 181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
| 184 | + foreach ($factors as $factor) { |
|
| 185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
| 186 | + } |
|
| 182 | 187 | updateSettings($changes); |
| 183 | 188 | } |
| 184 | 189 | |
| 185 | 190 | $context['relative_weights'] = array('total' => 0); |
| 186 | - foreach ($factors as $factor) |
|
| 187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 191 | + foreach ($factors as $factor) { |
|
| 192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
| 193 | + } |
|
| 188 | 194 | |
| 189 | - foreach ($factors as $factor) |
|
| 190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 195 | + foreach ($factors as $factor) { |
|
| 196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
| 197 | + } |
|
| 191 | 198 | |
| 192 | 199 | createToken('admin-msw'); |
| 193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
| 215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
| 216 | 223 | |
| 217 | 224 | // Detect whether a fulltext index is set. |
| 218 | - if ($context['supports_fulltext']) |
|
| 219 | - detectFulltextIndex(); |
|
| 225 | + if ($context['supports_fulltext']) { |
|
| 226 | + detectFulltextIndex(); |
|
| 227 | + } |
|
| 220 | 228 | |
| 221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
| 222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
| 240 | 248 | 'language' => $language_ftx |
| 241 | 249 | ) |
| 242 | 250 | ); |
| 243 | - } |
|
| 244 | - else |
|
| 251 | + } else |
|
| 245 | 252 | { |
| 246 | 253 | // Make sure it's gone before creating it. |
| 247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
| 259 | 266 | ) |
| 260 | 267 | ); |
| 261 | 268 | } |
| 262 | - } |
|
| 263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
| 264 | 270 | { |
| 265 | 271 | checkSession('get'); |
| 266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
| 277 | 283 | $context['fulltext_index'] = array(); |
| 278 | 284 | |
| 279 | 285 | // Go back to the default search method. |
| 280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
| 281 | - updateSettings(array( |
|
| 286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
| 287 | + updateSettings(array( |
|
| 282 | 288 | 'search_index' => '', |
| 283 | 289 | )); |
| 284 | - } |
|
| 285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 290 | + } |
|
| 291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
| 286 | 292 | { |
| 287 | 293 | checkSession('get'); |
| 288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
| 304 | 310 | )); |
| 305 | 311 | |
| 306 | 312 | // Go back to the default search method. |
| 307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 308 | - updateSettings(array( |
|
| 313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 314 | + updateSettings(array( |
|
| 309 | 315 | 'search_index' => '', |
| 310 | 316 | )); |
| 311 | - } |
|
| 312 | - elseif (isset($_POST['save'])) |
|
| 317 | + } |
|
| 318 | + } elseif (isset($_POST['save'])) |
|
| 313 | 319 | { |
| 314 | 320 | checkSession(); |
| 315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
| 331 | 337 | // Get some info about the messages table, to show its size and index size. |
| 332 | 338 | if ($db_type == 'mysql') |
| 333 | 339 | { |
| 334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 335 | - $request = $smcFunc['db_query']('', ' |
|
| 340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 341 | + $request = $smcFunc['db_query']('', ' |
|
| 336 | 342 | SHOW TABLE STATUS |
| 337 | 343 | FROM {string:database_name} |
| 338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
| 341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 342 | 348 | ) |
| 343 | 349 | ); |
| 344 | - else |
|
| 345 | - $request = $smcFunc['db_query']('', ' |
|
| 350 | + } else { |
|
| 351 | + $request = $smcFunc['db_query']('', ' |
|
| 346 | 352 | SHOW TABLE STATUS |
| 347 | 353 | LIKE {string:table_name}', |
| 348 | 354 | array( |
| 349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 350 | 356 | ) |
| 351 | 357 | ); |
| 358 | + } |
|
| 352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 353 | 360 | { |
| 354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
| 360 | 367 | } |
| 361 | 368 | |
| 362 | 369 | // Now check the custom index table, if it exists at all. |
| 363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 364 | - $request = $smcFunc['db_query']('', ' |
|
| 370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 371 | + $request = $smcFunc['db_query']('', ' |
|
| 365 | 372 | SHOW TABLE STATUS |
| 366 | 373 | FROM {string:database_name} |
| 367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
| 370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
| 371 | 378 | ) |
| 372 | 379 | ); |
| 373 | - else |
|
| 374 | - $request = $smcFunc['db_query']('', ' |
|
| 380 | + } else { |
|
| 381 | + $request = $smcFunc['db_query']('', ' |
|
| 375 | 382 | SHOW TABLE STATUS |
| 376 | 383 | LIKE {string:table_name}', |
| 377 | 384 | array( |
| 378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
| 379 | 386 | ) |
| 380 | 387 | ); |
| 388 | + } |
|
| 381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
| 382 | 390 | { |
| 383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
| 386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
| 387 | 395 | $smcFunc['db_free_result']($request); |
| 388 | 396 | } |
| 389 | - } |
|
| 390 | - elseif ($db_type == 'postgresql') |
|
| 397 | + } elseif ($db_type == 'postgresql') |
|
| 391 | 398 | { |
| 392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
| 393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
| 429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
| 430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
| 432 | - } |
|
| 433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
| 434 | 440 | { |
| 435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
| 436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
| 437 | 443 | } |
| 438 | 444 | } |
| 439 | 445 | $smcFunc['db_free_result']($request); |
| 440 | - } |
|
| 441 | - else |
|
| 442 | - // Didn't work for some reason... |
|
| 446 | + } else { |
|
| 447 | + // Didn't work for some reason... |
|
| 443 | 448 | $context['table_info'] = array( |
| 444 | 449 | 'data_length' => $txt['not_applicable'], |
| 445 | 450 | 'index_length' => $txt['not_applicable'], |
| 446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
| 447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
| 448 | 453 | ); |
| 449 | - } |
|
| 450 | - else |
|
| 451 | - $context['table_info'] = array( |
|
| 454 | + } |
|
| 455 | + } else { |
|
| 456 | + $context['table_info'] = array( |
|
| 452 | 457 | 'data_length' => $txt['not_applicable'], |
| 453 | 458 | 'index_length' => $txt['not_applicable'], |
| 454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
| 455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
| 456 | 461 | ); |
| 462 | + } |
|
| 457 | 463 | |
| 458 | 464 | // Format the data and index length in kilobytes. |
| 459 | 465 | foreach ($context['table_info'] as $type => $size) |
| 460 | 466 | { |
| 461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
| 462 | - if (!is_numeric($size)) |
|
| 463 | - break; |
|
| 468 | + if (!is_numeric($size)) { |
|
| 469 | + break; |
|
| 470 | + } |
|
| 464 | 471 | |
| 465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
| 466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
| 489 | 496 | |
| 490 | 497 | // Scotty, we need more time... |
| 491 | 498 | @set_time_limit(600); |
| 492 | - if (function_exists('apache_reset_timeout')) |
|
| 493 | - @apache_reset_timeout(); |
|
| 499 | + if (function_exists('apache_reset_timeout')) { |
|
| 500 | + @apache_reset_timeout(); |
|
| 501 | + } |
|
| 494 | 502 | |
| 495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
| 496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
| 520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
| 521 | 529 | unset($context['index_settings']['resume_at']); |
| 522 | 530 | $context['step'] = 1; |
| 523 | - } |
|
| 524 | - else |
|
| 531 | + } else |
|
| 525 | 532 | { |
| 526 | 533 | $context['index_settings'] = array( |
| 527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
| 530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
| 531 | 538 | |
| 532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
| 533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
| 534 | - $_SESSION['admin_time'] = time(); |
|
| 540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
| 541 | + $_SESSION['admin_time'] = time(); |
|
| 542 | + } |
|
| 535 | 543 | } |
| 536 | 544 | |
| 537 | - if ($context['step'] !== 0) |
|
| 538 | - checkSession('request'); |
|
| 545 | + if ($context['step'] !== 0) { |
|
| 546 | + checkSession('request'); |
|
| 547 | + } |
|
| 539 | 548 | |
| 540 | 549 | // Step 0: let the user determine how they like their index. |
| 541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
| 564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
| 565 | 574 | |
| 566 | 575 | // Temporarily switch back to not using a search index. |
| 567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
| 568 | - updateSettings(array('search_index' => '')); |
|
| 576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
| 577 | + updateSettings(array('search_index' => '')); |
|
| 578 | + } |
|
| 569 | 579 | |
| 570 | 580 | // Don't let simultanious processes be updating the search index. |
| 571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
| 572 | - updateSettings(array('search_custom_index_config' => '')); |
|
| 581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
| 582 | + updateSettings(array('search_custom_index_config' => '')); |
|
| 583 | + } |
|
| 573 | 584 | } |
| 574 | 585 | |
| 575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
| 585 | 596 | 'starting_id' => $context['start'], |
| 586 | 597 | ) |
| 587 | 598 | ); |
| 588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
| 601 | + } |
|
| 590 | 602 | |
| 591 | 603 | if (empty($num_messages['todo'])) |
| 592 | 604 | { |
| 593 | 605 | $context['step'] = 2; |
| 594 | 606 | $context['percentage'] = 80; |
| 595 | 607 | $context['start'] = 0; |
| 596 | - } |
|
| 597 | - else |
|
| 608 | + } else |
|
| 598 | 609 | { |
| 599 | 610 | // Number of seconds before the next step. |
| 600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
| 635 | 646 | |
| 636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
| 637 | 648 | |
| 638 | - if (!empty($inserts)) |
|
| 639 | - $smcFunc['db_insert']('ignore', |
|
| 649 | + if (!empty($inserts)) { |
|
| 650 | + $smcFunc['db_insert']('ignore', |
|
| 640 | 651 | '{db_prefix}log_search_words', |
| 641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
| 642 | 653 | $inserts, |
| 643 | 654 | array('id_word', 'id_msg') |
| 644 | 655 | ); |
| 656 | + } |
|
| 645 | 657 | if ($num_messages['todo'] === 0) |
| 646 | 658 | { |
| 647 | 659 | $context['step'] = 2; |
| 648 | 660 | $context['start'] = 0; |
| 649 | 661 | break; |
| 662 | + } else { |
|
| 663 | + updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 650 | 664 | } |
| 651 | - else |
|
| 652 | - updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
| 653 | 665 | } |
| 654 | 666 | |
| 655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
| 660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
| 661 | 673 | elseif ($context['step'] === 2) |
| 662 | 674 | { |
| 663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
| 664 | - $context['step'] = 3; |
|
| 665 | - else |
|
| 675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
| 676 | + $context['step'] = 3; |
|
| 677 | + } else |
|
| 666 | 678 | { |
| 667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
| 668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
| 683 | 695 | 'minimum_messages' => $max_messages, |
| 684 | 696 | ) |
| 685 | 697 | ); |
| 686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 687 | - $stop_words[] = $row['id_word']; |
|
| 698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 699 | + $stop_words[] = $row['id_word']; |
|
| 700 | + } |
|
| 688 | 701 | $smcFunc['db_free_result']($request); |
| 689 | 702 | |
| 690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
| 691 | 704 | |
| 692 | - if (!empty($stop_words)) |
|
| 693 | - $smcFunc['db_query']('', ' |
|
| 705 | + if (!empty($stop_words)) { |
|
| 706 | + $smcFunc['db_query']('', ' |
|
| 694 | 707 | DELETE FROM {db_prefix}log_search_words |
| 695 | 708 | WHERE id_word in ({array_int:stop_words})', |
| 696 | 709 | array( |
| 697 | 710 | 'stop_words' => $stop_words, |
| 698 | 711 | ) |
| 699 | 712 | ); |
| 713 | + } |
|
| 700 | 714 | |
| 701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
| 702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
| 757 | 771 | $searchAPI = new $search_class_name(); |
| 758 | 772 | |
| 759 | 773 | // No Support? NEXT! |
| 760 | - if (!$searchAPI->is_supported) |
|
| 761 | - continue; |
|
| 774 | + if (!$searchAPI->is_supported) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 762 | 777 | |
| 763 | 778 | $apis[$index_name] = array( |
| 764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
| 805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
| 806 | 821 | ) |
| 807 | 822 | ); |
| 808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 809 | - $context['fulltext_index'][] = $row['indexname']; |
|
| 810 | - } |
|
| 811 | - else |
|
| 823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 824 | + $context['fulltext_index'][] = $row['indexname']; |
|
| 825 | + } |
|
| 826 | + } else |
|
| 812 | 827 | { |
| 813 | 828 | $request = $smcFunc['db_query']('', ' |
| 814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
| 819 | 834 | $context['fulltext_index'] = array(); |
| 820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
| 821 | 836 | { |
| 822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
| 824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
| 840 | + } |
|
| 825 | 841 | $smcFunc['db_free_result']($request); |
| 826 | 842 | |
| 827 | - if (is_array($context['fulltext_index'])) |
|
| 828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 843 | + if (is_array($context['fulltext_index'])) { |
|
| 844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
| 845 | + } |
|
| 829 | 846 | } |
| 830 | 847 | |
| 831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
| 832 | - $request = $smcFunc['db_query']('', ' |
|
| 848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
| 849 | + $request = $smcFunc['db_query']('', ' |
|
| 833 | 850 | SHOW TABLE STATUS |
| 834 | 851 | FROM {string:database_name} |
| 835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
| 838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
| 839 | 856 | ) |
| 840 | 857 | ); |
| 841 | - else |
|
| 842 | - $request = $smcFunc['db_query']('', ' |
|
| 858 | + } else { |
|
| 859 | + $request = $smcFunc['db_query']('', ' |
|
| 843 | 860 | SHOW TABLE STATUS |
| 844 | 861 | LIKE {string:table_name}', |
| 845 | 862 | array( |
| 846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
| 847 | 864 | ) |
| 848 | 865 | ); |
| 866 | + } |
|
| 849 | 867 | |
| 850 | 868 | if ($request !== false) |
| 851 | 869 | { |
| 852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
| 870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
| 854 | 872 | $context['cannot_create_fulltext'] = true; |
| 873 | + } |
|
| 855 | 874 | $smcFunc['db_free_result']($request); |
| 856 | 875 | } |
| 857 | 876 | } |
@@ -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 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
| 29 | 30 | global $txt, $context, $scripturl, $user_info; |
| 30 | 31 | |
| 31 | 32 | // You are already logged in, go take a tour of the boards |
| 32 | - if (!empty($user_info['id'])) |
|
| 33 | - redirectexit(); |
|
| 33 | + if (!empty($user_info['id'])) { |
|
| 34 | + redirectexit(); |
|
| 35 | + } |
|
| 34 | 36 | |
| 35 | 37 | // We need to load the Login template/language file. |
| 36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
| 57 | 59 | ); |
| 58 | 60 | |
| 59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
| 60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
| 61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
| 63 | - unset($_SESSION['login_url']); |
|
| 62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
| 63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
| 65 | + unset($_SESSION['login_url']); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // Create a one time token. |
| 66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
| 83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
| 84 | 87 | |
| 85 | 88 | // Check to ensure we're forcing SSL for authentication |
| 86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 87 | - fatal_lang_error('login_ssl_required'); |
|
| 89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 90 | + fatal_lang_error('login_ssl_required'); |
|
| 91 | + } |
|
| 88 | 92 | |
| 89 | 93 | // Load cookie authentication stuff. |
| 90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
| 102 | 106 | list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true); |
| 103 | 107 | |
| 104 | 108 | // That didn't work... Maybe it's using serialize? |
| 105 | - if (is_null($timeout)) |
|
| 106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 107 | - } |
|
| 108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | + if (is_null($timeout)) { |
|
| 110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
| 111 | + } |
|
| 112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
| 109 | 113 | { |
| 110 | 114 | list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]); |
| 111 | 115 | |
| 112 | 116 | // Try for old format |
| 113 | - if (is_null($timeout)) |
|
| 114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 117 | + if (is_null($timeout)) { |
|
| 118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 115 | 122 | } |
| 116 | - else |
|
| 117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
| 118 | 123 | |
| 119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
| 120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -125,16 +130,18 @@ discard block |
||
| 125 | 130 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
| 126 | 131 | |
| 127 | 132 | // If that didn't work, try unserialize instead... |
| 128 | - if (is_null($tfadata)) |
|
| 129 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 133 | + if (is_null($tfadata)) { |
|
| 134 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
| 135 | + } |
|
| 130 | 136 | |
| 131 | 137 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 132 | 138 | |
| 133 | 139 | // If we're preserving the cookie, reset it with updated salt |
| 134 | - if ($preserve && time() < $exp) |
|
| 135 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 136 | - else |
|
| 137 | - setTFACookie(-3600, 0, ''); |
|
| 140 | + if ($preserve && time() < $exp) { |
|
| 141 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
| 142 | + } else { |
|
| 143 | + setTFACookie(-3600, 0, ''); |
|
| 144 | + } |
|
| 138 | 145 | } |
| 139 | 146 | |
| 140 | 147 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -145,20 +152,20 @@ discard block |
||
| 145 | 152 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
| 146 | 153 | { |
| 147 | 154 | // Strike! You're outta there! |
| 148 | - if ($_GET['member'] != $user_info['id']) |
|
| 149 | - fatal_lang_error('login_cookie_error', false); |
|
| 155 | + if ($_GET['member'] != $user_info['id']) { |
|
| 156 | + fatal_lang_error('login_cookie_error', false); |
|
| 157 | + } |
|
| 150 | 158 | |
| 151 | 159 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
| 152 | 160 | |
| 153 | 161 | // Some whitelisting for login_url... |
| 154 | - if (empty($_SESSION['login_url'])) |
|
| 155 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 156 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 162 | + if (empty($_SESSION['login_url'])) { |
|
| 163 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
| 164 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
| 157 | 165 | { |
| 158 | 166 | unset ($_SESSION['login_url']); |
| 159 | 167 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
| 160 | - } |
|
| 161 | - else |
|
| 168 | + } else |
|
| 162 | 169 | { |
| 163 | 170 | // Best not to clutter the session data too much... |
| 164 | 171 | $temp = $_SESSION['login_url']; |
@@ -169,8 +176,9 @@ discard block |
||
| 169 | 176 | } |
| 170 | 177 | |
| 171 | 178 | // Beyond this point you are assumed to be a guest trying to login. |
| 172 | - if (!$user_info['is_guest']) |
|
| 173 | - redirectexit(); |
|
| 179 | + if (!$user_info['is_guest']) { |
|
| 180 | + redirectexit(); |
|
| 181 | + } |
|
| 174 | 182 | |
| 175 | 183 | // Are you guessing with a script? |
| 176 | 184 | checkSession(); |
@@ -178,18 +186,21 @@ discard block |
||
| 178 | 186 | spamProtection('login'); |
| 179 | 187 | |
| 180 | 188 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
| 181 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
| 182 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 189 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
| 190 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
| 191 | + } |
|
| 183 | 192 | |
| 184 | 193 | // Been guessing a lot, haven't we? |
| 185 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
| 186 | - fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 194 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
| 195 | + fatal_lang_error('login_threshold_fail', 'critical'); |
|
| 196 | + } |
|
| 187 | 197 | |
| 188 | 198 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
| 189 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
| 190 | - $modSettings['cookieTime'] = 3153600; |
|
| 191 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
| 192 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 199 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
| 200 | + $modSettings['cookieTime'] = 3153600; |
|
| 201 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
| 202 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
| 203 | + } |
|
| 193 | 204 | |
| 194 | 205 | loadLanguage('Login'); |
| 195 | 206 | // Load the template stuff. |
@@ -309,8 +320,9 @@ discard block |
||
| 309 | 320 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
| 310 | 321 | |
| 311 | 322 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
| 312 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
| 313 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 323 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
| 324 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
| 325 | + } |
|
| 314 | 326 | |
| 315 | 327 | // phpBB3 users new hashing. We now support it as well ;). |
| 316 | 328 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -330,27 +342,29 @@ discard block |
||
| 330 | 342 | // Some common md5 ones. |
| 331 | 343 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
| 332 | 344 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
| 333 | - } |
|
| 334 | - elseif (strlen($user_settings['passwd']) == 40) |
|
| 345 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
| 335 | 346 | { |
| 336 | 347 | // Maybe they are using a hash from before the password fix. |
| 337 | 348 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
| 338 | 349 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
| 339 | 350 | |
| 340 | 351 | // BurningBoard3 style of hashing. |
| 341 | - if (!empty($modSettings['enable_password_conversion'])) |
|
| 342 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 352 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
| 353 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
| 354 | + } |
|
| 343 | 355 | |
| 344 | 356 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
| 345 | 357 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
| 346 | 358 | { |
| 347 | 359 | // Try iconv first, for no particular reason. |
| 348 | - if (function_exists('iconv')) |
|
| 349 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 360 | + if (function_exists('iconv')) { |
|
| 361 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
| 362 | + } |
|
| 350 | 363 | |
| 351 | 364 | // Say it aint so, iconv failed! |
| 352 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
| 353 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 365 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
| 366 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
| 367 | + } |
|
| 354 | 368 | } |
| 355 | 369 | } |
| 356 | 370 | |
@@ -380,8 +394,9 @@ discard block |
||
| 380 | 394 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
| 381 | 395 | |
| 382 | 396 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
| 383 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
| 384 | - redirectexit('action=reminder'); |
|
| 397 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
| 398 | + redirectexit('action=reminder'); |
|
| 399 | + } |
|
| 385 | 400 | // We'll give you another chance... |
| 386 | 401 | else |
| 387 | 402 | { |
@@ -392,8 +407,7 @@ discard block |
||
| 392 | 407 | return; |
| 393 | 408 | } |
| 394 | 409 | } |
| 395 | - } |
|
| 396 | - elseif (!empty($user_settings['passwd_flood'])) |
|
| 410 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
| 397 | 411 | { |
| 398 | 412 | // Let's be sure they weren't a little hacker. |
| 399 | 413 | validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true); |
@@ -410,8 +424,9 @@ discard block |
||
| 410 | 424 | } |
| 411 | 425 | |
| 412 | 426 | // Check their activation status. |
| 413 | - if (!checkActivation()) |
|
| 414 | - return; |
|
| 427 | + if (!checkActivation()) { |
|
| 428 | + return; |
|
| 429 | + } |
|
| 415 | 430 | |
| 416 | 431 | DoLogin(); |
| 417 | 432 | } |
@@ -423,8 +438,9 @@ discard block |
||
| 423 | 438 | { |
| 424 | 439 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
| 425 | 440 | |
| 426 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
| 427 | - fatal_lang_error('no_access', false); |
|
| 441 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
| 442 | + fatal_lang_error('no_access', false); |
|
| 443 | + } |
|
| 428 | 444 | |
| 429 | 445 | loadLanguage('Profile'); |
| 430 | 446 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -432,8 +448,9 @@ discard block |
||
| 432 | 448 | $member = $context['tfa_member']; |
| 433 | 449 | |
| 434 | 450 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
| 435 | - if (time() - $member['last_login'] < 120) |
|
| 436 | - fatal_lang_error('tfa_wait', false); |
|
| 451 | + if (time() - $member['last_login'] < 120) { |
|
| 452 | + fatal_lang_error('tfa_wait', false); |
|
| 453 | + } |
|
| 437 | 454 | |
| 438 | 455 | $totp = new \TOTP\Auth($member['tfa_secret']); |
| 439 | 456 | $totp->setRange(1); |
@@ -447,8 +464,9 @@ discard block |
||
| 447 | 464 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
| 448 | 465 | { |
| 449 | 466 | // Check to ensure we're forcing SSL for authentication |
| 450 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 451 | - fatal_lang_error('login_ssl_required'); |
|
| 467 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 468 | + fatal_lang_error('login_ssl_required'); |
|
| 469 | + } |
|
| 452 | 470 | |
| 453 | 471 | $code = $_POST['tfa_code']; |
| 454 | 472 | |
@@ -458,20 +476,19 @@ discard block |
||
| 458 | 476 | |
| 459 | 477 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
| 460 | 478 | redirectexit(); |
| 461 | - } |
|
| 462 | - else |
|
| 479 | + } else |
|
| 463 | 480 | { |
| 464 | 481 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 465 | 482 | |
| 466 | 483 | $context['tfa_error'] = true; |
| 467 | 484 | $context['tfa_value'] = $_POST['tfa_code']; |
| 468 | 485 | } |
| 469 | - } |
|
| 470 | - elseif (!empty($_POST['tfa_backup'])) |
|
| 486 | + } elseif (!empty($_POST['tfa_backup'])) |
|
| 471 | 487 | { |
| 472 | 488 | // Check to ensure we're forcing SSL for authentication |
| 473 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
| 474 | - fatal_lang_error('login_ssl_required'); |
|
| 489 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
| 490 | + fatal_lang_error('login_ssl_required'); |
|
| 491 | + } |
|
| 475 | 492 | |
| 476 | 493 | $backup = $_POST['tfa_backup']; |
| 477 | 494 | |
@@ -485,8 +502,7 @@ discard block |
||
| 485 | 502 | )); |
| 486 | 503 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
| 487 | 504 | redirectexit('action=profile;area=tfasetup;backup'); |
| 488 | - } |
|
| 489 | - else |
|
| 505 | + } else |
|
| 490 | 506 | { |
| 491 | 507 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
| 492 | 508 | |
@@ -509,8 +525,9 @@ discard block |
||
| 509 | 525 | { |
| 510 | 526 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
| 511 | 527 | |
| 512 | - if (!isset($context['login_errors'])) |
|
| 513 | - $context['login_errors'] = array(); |
|
| 528 | + if (!isset($context['login_errors'])) { |
|
| 529 | + $context['login_errors'] = array(); |
|
| 530 | + } |
|
| 514 | 531 | |
| 515 | 532 | // What is the true activation status of this account? |
| 516 | 533 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -522,8 +539,9 @@ discard block |
||
| 522 | 539 | return false; |
| 523 | 540 | } |
| 524 | 541 | // Awaiting approval still? |
| 525 | - elseif ($activation_status == 3) |
|
| 526 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 542 | + elseif ($activation_status == 3) { |
|
| 543 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
| 544 | + } |
|
| 527 | 545 | // Awaiting deletion, changed their mind? |
| 528 | 546 | elseif ($activation_status == 4) |
| 529 | 547 | { |
@@ -531,8 +549,7 @@ discard block |
||
| 531 | 549 | { |
| 532 | 550 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
| 533 | 551 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
| 534 | - } |
|
| 535 | - else |
|
| 552 | + } else |
|
| 536 | 553 | { |
| 537 | 554 | $context['disable_login_hashing'] = true; |
| 538 | 555 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -572,8 +589,9 @@ discard block |
||
| 572 | 589 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
| 573 | 590 | |
| 574 | 591 | // Reset the login threshold. |
| 575 | - if (isset($_SESSION['failed_login'])) |
|
| 576 | - unset($_SESSION['failed_login']); |
|
| 592 | + if (isset($_SESSION['failed_login'])) { |
|
| 593 | + unset($_SESSION['failed_login']); |
|
| 594 | + } |
|
| 577 | 595 | |
| 578 | 596 | $user_info['is_guest'] = false; |
| 579 | 597 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -595,16 +613,18 @@ discard block |
||
| 595 | 613 | 'id_member' => $user_info['id'], |
| 596 | 614 | ) |
| 597 | 615 | ); |
| 598 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
| 599 | - $_SESSION['first_login'] = true; |
|
| 600 | - else |
|
| 601 | - unset($_SESSION['first_login']); |
|
| 616 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
| 617 | + $_SESSION['first_login'] = true; |
|
| 618 | + } else { |
|
| 619 | + unset($_SESSION['first_login']); |
|
| 620 | + } |
|
| 602 | 621 | $smcFunc['db_free_result']($request); |
| 603 | 622 | |
| 604 | 623 | // You've logged in, haven't you? |
| 605 | 624 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
| 606 | - if (empty($user_settings['tfa_secret'])) |
|
| 607 | - $update['last_login'] = time(); |
|
| 625 | + if (empty($user_settings['tfa_secret'])) { |
|
| 626 | + $update['last_login'] = time(); |
|
| 627 | + } |
|
| 608 | 628 | updateMemberData($user_info['id'], $update); |
| 609 | 629 | |
| 610 | 630 | // Get rid of the online entry for that old guest.... |
@@ -618,8 +638,8 @@ discard block |
||
| 618 | 638 | $_SESSION['log_time'] = 0; |
| 619 | 639 | |
| 620 | 640 | // Log this entry, only if we have it enabled. |
| 621 | - if (!empty($modSettings['loginHistoryDays'])) |
|
| 622 | - $smcFunc['db_insert']('insert', |
|
| 641 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
| 642 | + $smcFunc['db_insert']('insert', |
|
| 623 | 643 | '{db_prefix}member_logins', |
| 624 | 644 | array( |
| 625 | 645 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -631,13 +651,15 @@ discard block |
||
| 631 | 651 | 'id_member', 'time' |
| 632 | 652 | ) |
| 633 | 653 | ); |
| 654 | + } |
|
| 634 | 655 | |
| 635 | 656 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
| 636 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
| 637 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 638 | - else |
|
| 639 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 640 | -} |
|
| 657 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
| 658 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
| 659 | + } else { |
|
| 660 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
| 661 | + } |
|
| 662 | + } |
|
| 641 | 663 | |
| 642 | 664 | /** |
| 643 | 665 | * Logs the current user out of their account. |
@@ -653,13 +675,15 @@ discard block |
||
| 653 | 675 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
| 654 | 676 | |
| 655 | 677 | // Make sure they aren't being auto-logged out. |
| 656 | - if (!$internal) |
|
| 657 | - checkSession('get'); |
|
| 678 | + if (!$internal) { |
|
| 679 | + checkSession('get'); |
|
| 680 | + } |
|
| 658 | 681 | |
| 659 | 682 | require_once($sourcedir . '/Subs-Auth.php'); |
| 660 | 683 | |
| 661 | - if (isset($_SESSION['pack_ftp'])) |
|
| 662 | - $_SESSION['pack_ftp'] = null; |
|
| 684 | + if (isset($_SESSION['pack_ftp'])) { |
|
| 685 | + $_SESSION['pack_ftp'] = null; |
|
| 686 | + } |
|
| 663 | 687 | |
| 664 | 688 | // It won't be first login anymore. |
| 665 | 689 | unset($_SESSION['first_login']); |
@@ -687,8 +711,9 @@ discard block |
||
| 687 | 711 | |
| 688 | 712 | // And some other housekeeping while we're at it. |
| 689 | 713 | $salt = substr(md5(mt_rand()), 0, 4); |
| 690 | - if (!empty($user_info['id'])) |
|
| 691 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 714 | + if (!empty($user_info['id'])) { |
|
| 715 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
| 716 | + } |
|
| 692 | 717 | |
| 693 | 718 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
| 694 | 719 | { |
@@ -697,10 +722,11 @@ discard block |
||
| 697 | 722 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
| 698 | 723 | |
| 699 | 724 | // If we're preserving the cookie, reset it with updated salt |
| 700 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
| 701 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 702 | - else |
|
| 703 | - setTFACookie(-3600, 0, ''); |
|
| 725 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
| 726 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
| 727 | + } else { |
|
| 728 | + setTFACookie(-3600, 0, ''); |
|
| 729 | + } |
|
| 704 | 730 | } |
| 705 | 731 | |
| 706 | 732 | session_destroy(); |
@@ -708,14 +734,13 @@ discard block |
||
| 708 | 734 | // Off to the merry board index we go! |
| 709 | 735 | if ($redirect) |
| 710 | 736 | { |
| 711 | - if (empty($_SESSION['logout_url'])) |
|
| 712 | - redirectexit('', $context['server']['needs_login_fix']); |
|
| 713 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 737 | + if (empty($_SESSION['logout_url'])) { |
|
| 738 | + redirectexit('', $context['server']['needs_login_fix']); |
|
| 739 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
| 714 | 740 | { |
| 715 | 741 | unset ($_SESSION['logout_url']); |
| 716 | 742 | redirectexit(); |
| 717 | - } |
|
| 718 | - else |
|
| 743 | + } else |
|
| 719 | 744 | { |
| 720 | 745 | $temp = $_SESSION['logout_url']; |
| 721 | 746 | unset($_SESSION['logout_url']); |
@@ -748,8 +773,9 @@ discard block |
||
| 748 | 773 | function phpBB3_password_check($passwd, $passwd_hash) |
| 749 | 774 | { |
| 750 | 775 | // Too long or too short? |
| 751 | - if (strlen($passwd_hash) != 34) |
|
| 752 | - return; |
|
| 776 | + if (strlen($passwd_hash) != 34) { |
|
| 777 | + return; |
|
| 778 | + } |
|
| 753 | 779 | |
| 754 | 780 | // Range of characters allowed. |
| 755 | 781 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -760,8 +786,9 @@ discard block |
||
| 760 | 786 | $salt = substr($passwd_hash, 4, 8); |
| 761 | 787 | |
| 762 | 788 | $hash = md5($salt . $passwd, true); |
| 763 | - for (; $count != 0; --$count) |
|
| 764 | - $hash = md5($hash . $passwd, true); |
|
| 789 | + for (; $count != 0; --$count) { |
|
| 790 | + $hash = md5($hash . $passwd, true); |
|
| 791 | + } |
|
| 765 | 792 | |
| 766 | 793 | $output = substr($passwd_hash, 0, 12); |
| 767 | 794 | $i = 0; |
@@ -770,21 +797,25 @@ discard block |
||
| 770 | 797 | $value = ord($hash[$i++]); |
| 771 | 798 | $output .= $range[$value & 0x3f]; |
| 772 | 799 | |
| 773 | - if ($i < 16) |
|
| 774 | - $value |= ord($hash[$i]) << 8; |
|
| 800 | + if ($i < 16) { |
|
| 801 | + $value |= ord($hash[$i]) << 8; |
|
| 802 | + } |
|
| 775 | 803 | |
| 776 | 804 | $output .= $range[($value >> 6) & 0x3f]; |
| 777 | 805 | |
| 778 | - if ($i++ >= 16) |
|
| 779 | - break; |
|
| 806 | + if ($i++ >= 16) { |
|
| 807 | + break; |
|
| 808 | + } |
|
| 780 | 809 | |
| 781 | - if ($i < 16) |
|
| 782 | - $value |= ord($hash[$i]) << 16; |
|
| 810 | + if ($i < 16) { |
|
| 811 | + $value |= ord($hash[$i]) << 16; |
|
| 812 | + } |
|
| 783 | 813 | |
| 784 | 814 | $output .= $range[($value >> 12) & 0x3f]; |
| 785 | 815 | |
| 786 | - if ($i++ >= 16) |
|
| 787 | - break; |
|
| 816 | + if ($i++ >= 16) { |
|
| 817 | + break; |
|
| 818 | + } |
|
| 788 | 819 | |
| 789 | 820 | $output .= $range[($value >> 18) & 0x3f]; |
| 790 | 821 | } |
@@ -815,8 +846,9 @@ discard block |
||
| 815 | 846 | require_once($sourcedir . '/Subs-Auth.php'); |
| 816 | 847 | setLoginCookie(-3600, 0); |
| 817 | 848 | |
| 818 | - if (isset($_SESSION['login_' . $cookiename])) |
|
| 819 | - unset($_SESSION['login_' . $cookiename]); |
|
| 849 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
| 850 | + unset($_SESSION['login_' . $cookiename]); |
|
| 851 | + } |
|
| 820 | 852 | } |
| 821 | 853 | |
| 822 | 854 | // We need a member! |
@@ -830,8 +862,9 @@ discard block |
||
| 830 | 862 | } |
| 831 | 863 | |
| 832 | 864 | // Right, have we got a flood value? |
| 833 | - if ($password_flood_value !== false) |
|
| 834 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 865 | + if ($password_flood_value !== false) { |
|
| 866 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
| 867 | + } |
|
| 835 | 868 | |
| 836 | 869 | // Timestamp or number of tries invalid? |
| 837 | 870 | if (empty($number_tries) || empty($time_stamp)) |
@@ -847,15 +880,17 @@ discard block |
||
| 847 | 880 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
| 848 | 881 | |
| 849 | 882 | // They are trying too fast, make them wait longer |
| 850 | - if ($time_stamp < time() - 10) |
|
| 851 | - $time_stamp = time(); |
|
| 883 | + if ($time_stamp < time() - 10) { |
|
| 884 | + $time_stamp = time(); |
|
| 885 | + } |
|
| 852 | 886 | } |
| 853 | 887 | |
| 854 | 888 | $number_tries++; |
| 855 | 889 | |
| 856 | 890 | // Broken the law? |
| 857 | - if ($number_tries > 5) |
|
| 858 | - fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 891 | + if ($number_tries > 5) { |
|
| 892 | + fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
| 893 | + } |
|
| 859 | 894 | |
| 860 | 895 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
| 861 | 896 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -67,8 +67,9 @@ discard block |
||
| 67 | 67 | foreach ($context['categories'] as $category) |
| 68 | 68 | { |
| 69 | 69 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
| 70 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
| 71 | - continue; |
|
| 70 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | 74 | echo ' |
| 74 | 75 | <div class="main_container"> |
@@ -76,9 +77,10 @@ discard block |
||
| 76 | 77 | <h3 class="catbg">'; |
| 77 | 78 | |
| 78 | 79 | // If this category even can collapse, show a link to collapse it. |
| 79 | - if ($category['can_collapse']) |
|
| 80 | - echo ' |
|
| 80 | + if ($category['can_collapse']) { |
|
| 81 | + echo ' |
|
| 81 | 82 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
| 83 | + } |
|
| 82 | 84 | |
| 83 | 85 | echo ' |
| 84 | 86 | ', $category['link'], ' |
@@ -105,17 +107,19 @@ discard block |
||
| 105 | 107 | </a>'; |
| 106 | 108 | |
| 107 | 109 | // Has it outstanding posts for approval? |
| 108 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 109 | - echo ' |
|
| 110 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 111 | + echo ' |
|
| 110 | 112 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 113 | + } |
|
| 111 | 114 | |
| 112 | 115 | echo ' |
| 113 | 116 | <p class="board_description">', $board['description'], '</p>'; |
| 114 | 117 | |
| 115 | 118 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 116 | - if (!empty($board['link_moderators'])) |
|
| 117 | - echo ' |
|
| 119 | + if (!empty($board['link_moderators'])) { |
|
| 120 | + echo ' |
|
| 118 | 121 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | // Show some basic information about the number of posts, etc. |
| 121 | 125 | echo ' |
@@ -127,9 +131,10 @@ discard block |
||
| 127 | 131 | </div> |
| 128 | 132 | <div class="lastpost ',!empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">'; |
| 129 | 133 | |
| 130 | - if (!empty($board['last_post']['id'])) |
|
| 131 | - echo ' |
|
| 134 | + if (!empty($board['last_post']['id'])) { |
|
| 135 | + echo ' |
|
| 132 | 136 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 137 | + } |
|
| 133 | 138 | echo ' |
| 134 | 139 | </div>'; |
| 135 | 140 | // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...) |
@@ -141,14 +146,16 @@ discard block |
||
| 141 | 146 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 142 | 147 | foreach ($board['children'] as $child) |
| 143 | 148 | { |
| 144 | - if (!$child['is_redirect']) |
|
| 145 | - $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 146 | - else |
|
| 147 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 149 | + if (!$child['is_redirect']) { |
|
| 150 | + $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 151 | + } else { |
|
| 152 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
| 153 | + } |
|
| 148 | 154 | |
| 149 | 155 | // Has it posts awaiting approval? |
| 150 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
| 151 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 156 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
| 157 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 158 | + } |
|
| 152 | 159 | |
| 153 | 160 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 154 | 161 | } |
@@ -172,10 +179,11 @@ discard block |
||
| 172 | 179 | </div>'; |
| 173 | 180 | |
| 174 | 181 | // Show the mark all as read button? |
| 175 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
| 176 | - echo ' |
|
| 182 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
| 183 | + echo ' |
|
| 177 | 184 | <div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>'; |
| 178 | -} |
|
| 185 | + } |
|
| 186 | + } |
|
| 179 | 187 | |
| 180 | 188 | /** |
| 181 | 189 | * The lower part of the outer layer of the board index |
@@ -192,8 +200,9 @@ discard block |
||
| 192 | 200 | { |
| 193 | 201 | global $context, $options, $txt; |
| 194 | 202 | |
| 195 | - if (empty($context['info_center'])) |
|
| 196 | - return; |
|
| 203 | + if (empty($context['info_center'])) { |
|
| 204 | + return; |
|
| 205 | + } |
|
| 197 | 206 | |
| 198 | 207 | // Here's where the "Info Center" starts... |
| 199 | 208 | echo ' |
@@ -293,14 +302,15 @@ discard block |
||
| 293 | 302 | /* Each post in latest_posts has: |
| 294 | 303 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
| 295 | 304 | subject, short_subject (shortened with...), time, link, and href. */ |
| 296 | - foreach ($context['latest_posts'] as $post) |
|
| 297 | - echo ' |
|
| 305 | + foreach ($context['latest_posts'] as $post) { |
|
| 306 | + echo ' |
|
| 298 | 307 | <tr class="windowbg"> |
| 299 | 308 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
| 300 | 309 | <td class="recentposter">', $post['poster']['link'], '</td> |
| 301 | 310 | <td class="recentboard">', $post['board']['link'], '</td> |
| 302 | 311 | <td class="recenttime">', $post['time'], '</td> |
| 303 | 312 | </tr>'; |
| 313 | + } |
|
| 304 | 314 | echo ' |
| 305 | 315 | </table>'; |
| 306 | 316 | } |
@@ -324,9 +334,10 @@ discard block |
||
| 324 | 334 | </div>'; |
| 325 | 335 | |
| 326 | 336 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P. |
| 327 | - if (!empty($context['calendar_holidays'])) |
|
| 328 | - echo ' |
|
| 337 | + if (!empty($context['calendar_holidays'])) { |
|
| 338 | + echo ' |
|
| 329 | 339 | <p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>'; |
| 340 | + } |
|
| 330 | 341 | |
| 331 | 342 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
| 332 | 343 | if (!empty($context['calendar_birthdays'])) |
@@ -335,9 +346,10 @@ discard block |
||
| 335 | 346 | <p class="inline"> |
| 336 | 347 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
| 337 | 348 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
| 338 | - foreach ($context['calendar_birthdays'] as $member) |
|
| 339 | - echo ' |
|
| 349 | + foreach ($context['calendar_birthdays'] as $member) { |
|
| 350 | + echo ' |
|
| 340 | 351 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
| 352 | + } |
|
| 341 | 353 | echo ' |
| 342 | 354 | </p>'; |
| 343 | 355 | } |
@@ -351,9 +363,10 @@ discard block |
||
| 351 | 363 | |
| 352 | 364 | // Each event in calendar_events should have: |
| 353 | 365 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
| 354 | - foreach ($context['calendar_events'] as $event) |
|
| 355 | - echo ' |
|
| 366 | + foreach ($context['calendar_events'] as $event) { |
|
| 367 | + echo ' |
|
| 356 | 368 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
| 369 | + } |
|
| 357 | 370 | echo ' |
| 358 | 371 | </p>'; |
| 359 | 372 | } |
@@ -398,15 +411,19 @@ discard block |
||
| 398 | 411 | |
| 399 | 412 | // Handle hidden users and buddies. |
| 400 | 413 | $bracketList = array(); |
| 401 | - if ($context['show_buddies']) |
|
| 402 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 403 | - if (!empty($context['num_spiders'])) |
|
| 404 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 405 | - if (!empty($context['num_users_hidden'])) |
|
| 406 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 414 | + if ($context['show_buddies']) { |
|
| 415 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
| 416 | + } |
|
| 417 | + if (!empty($context['num_spiders'])) { |
|
| 418 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
| 419 | + } |
|
| 420 | + if (!empty($context['num_users_hidden'])) { |
|
| 421 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
| 422 | + } |
|
| 407 | 423 | |
| 408 | - if (!empty($bracketList)) |
|
| 409 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 424 | + if (!empty($bracketList)) { |
|
| 425 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
| 426 | + } |
|
| 410 | 427 | |
| 411 | 428 | echo $context['show_who'] ? '</a>' : '', ' |
| 412 | 429 | |
@@ -420,9 +437,10 @@ discard block |
||
| 420 | 437 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
| 421 | 438 | |
| 422 | 439 | // Showing membergroups? |
| 423 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
| 424 | - echo ' |
|
| 440 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
| 441 | + echo ' |
|
| 425 | 442 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
| 443 | + } |
|
| 426 | 444 | } |
| 427 | 445 | |
| 428 | 446 | echo ' |
@@ -48,17 +48,19 @@ discard block |
||
| 48 | 48 | </a>'; |
| 49 | 49 | |
| 50 | 50 | // Has it outstanding posts for approval? |
| 51 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
| 52 | - echo ' |
|
| 51 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
| 52 | + echo ' |
|
| 53 | 53 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
| 54 | + } |
|
| 54 | 55 | |
| 55 | 56 | echo ' |
| 56 | 57 | <p class="board_description">', $board['description'], '</p>'; |
| 57 | 58 | |
| 58 | 59 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
| 59 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
| 60 | - echo ' |
|
| 60 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
| 61 | + echo ' |
|
| 61 | 62 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | // Show some basic information about the number of posts, etc. |
| 64 | 66 | echo ' |
@@ -70,9 +72,10 @@ discard block |
||
| 70 | 72 | </div> |
| 71 | 73 | <div class="lastpost lpr_border">'; |
| 72 | 74 | |
| 73 | - if (!empty($board['last_post']['id'])) |
|
| 74 | - echo ' |
|
| 75 | + if (!empty($board['last_post']['id'])) { |
|
| 76 | + echo ' |
|
| 75 | 77 | <p>', $board['last_post']['last_post_message'], '</p>'; |
| 78 | + } |
|
| 76 | 79 | echo ' |
| 77 | 80 | </div>'; |
| 78 | 81 | |
@@ -85,14 +88,16 @@ discard block |
||
| 85 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
| 86 | 89 | foreach ($board['children'] as $child) |
| 87 | 90 | { |
| 88 | - if (!$child['is_redirect']) |
|
| 89 | - $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 90 | - else |
|
| 91 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 91 | + if (!$child['is_redirect']) { |
|
| 92 | + $child['link'] = '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . ($child['new'] ? '</a> <a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span>' : '') . '</a>'; |
|
| 93 | + } else { |
|
| 94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
| 95 | + } |
|
| 92 | 96 | |
| 93 | 97 | // Has it posts awaiting approval? |
| 94 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
| 95 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
| 99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
| 100 | + } |
|
| 96 | 101 | |
| 97 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
| 98 | 103 | } |
@@ -111,8 +116,9 @@ discard block |
||
| 111 | 116 | } |
| 112 | 117 | |
| 113 | 118 | // They can only mark read if they are logged in and it's enabled! |
| 114 | - if (!$context['user']['is_logged']) |
|
| 115 | - unset($context['normal_buttons']['markread']); |
|
| 119 | + if (!$context['user']['is_logged']) { |
|
| 120 | + unset($context['normal_buttons']['markread']); |
|
| 121 | + } |
|
| 116 | 122 | |
| 117 | 123 | if (!$context['no_topic_listing']) |
| 118 | 124 | { |
@@ -135,13 +141,15 @@ discard block |
||
| 135 | 141 | <div id="description_board" class="generic_list_wrapper"> |
| 136 | 142 | <h3>', $context['name'], '</h3> |
| 137 | 143 | <p>'; |
| 138 | - if ($context['description'] != '') |
|
| 139 | - echo ' |
|
| 144 | + if ($context['description'] != '') { |
|
| 145 | + echo ' |
|
| 140 | 146 | ', $context['description'], ' '; |
| 147 | + } |
|
| 141 | 148 | |
| 142 | - if (!empty($context['moderators'])) |
|
| 143 | - echo ' |
|
| 149 | + if (!empty($context['moderators'])) { |
|
| 150 | + echo ' |
|
| 144 | 151 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
| 152 | + } |
|
| 145 | 153 | |
| 146 | 154 | echo ' |
| 147 | 155 | </p> |
@@ -149,9 +157,10 @@ discard block |
||
| 149 | 157 | } |
| 150 | 158 | |
| 151 | 159 | // If Quick Moderation is enabled start the form. |
| 152 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 153 | - echo ' |
|
| 160 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 161 | + echo ' |
|
| 154 | 162 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
| 163 | + } |
|
| 155 | 164 | |
| 156 | 165 | echo ' |
| 157 | 166 | <div id="messageindex">'; |
@@ -159,10 +168,11 @@ discard block |
||
| 159 | 168 | { |
| 160 | 169 | echo ' |
| 161 | 170 | <div class="information">'; |
| 162 | - if ($settings['display_who_viewing'] == 1) |
|
| 163 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 164 | - else |
|
| 165 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 171 | + if ($settings['display_who_viewing'] == 1) { |
|
| 172 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
| 173 | + } else { |
|
| 174 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
| 175 | + } |
|
| 166 | 176 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
| 167 | 177 | |
| 168 | 178 | echo ' |
@@ -181,19 +191,22 @@ discard block |
||
| 181 | 191 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
| 182 | 192 | |
| 183 | 193 | // Show a "select all" box for quick moderation? |
| 184 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
| 185 | - echo ' |
|
| 194 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
| 195 | + echo ' |
|
| 186 | 196 | <div class="moderation"><input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"></div>'; |
| 197 | + } |
|
| 187 | 198 | |
| 188 | 199 | // If it's on in "image" mode, don't show anything but the column. |
| 189 | - elseif (!empty($context['can_quick_mod'])) |
|
| 190 | - echo ' |
|
| 200 | + elseif (!empty($context['can_quick_mod'])) { |
|
| 201 | + echo ' |
|
| 191 | 202 | <div class="moderation"> </div>'; |
| 203 | + } |
|
| 192 | 204 | } |
| 193 | 205 | // No topics.... just say, "sorry bub". |
| 194 | - else |
|
| 195 | - echo ' |
|
| 206 | + else { |
|
| 207 | + echo ' |
|
| 196 | 208 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
| 209 | + } |
|
| 197 | 210 | |
| 198 | 211 | echo ' |
| 199 | 212 | </div>'; |
@@ -225,21 +238,26 @@ discard block |
||
| 225 | 238 | // Now we handle the icons |
| 226 | 239 | echo ' |
| 227 | 240 | <div class="icons floatright">'; |
| 228 | - if ($topic['is_watched']) |
|
| 229 | - echo ' |
|
| 241 | + if ($topic['is_watched']) { |
|
| 242 | + echo ' |
|
| 230 | 243 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
| 231 | - if ($topic['is_locked']) |
|
| 232 | - echo ' |
|
| 244 | + } |
|
| 245 | + if ($topic['is_locked']) { |
|
| 246 | + echo ' |
|
| 233 | 247 | <span class="generic_icons lock"></span>'; |
| 234 | - if ($topic['is_sticky']) |
|
| 235 | - echo ' |
|
| 248 | + } |
|
| 249 | + if ($topic['is_sticky']) { |
|
| 250 | + echo ' |
|
| 236 | 251 | <span class="generic_icons sticky"></span>'; |
| 237 | - if ($topic['is_redirect']) |
|
| 238 | - echo ' |
|
| 252 | + } |
|
| 253 | + if ($topic['is_redirect']) { |
|
| 254 | + echo ' |
|
| 239 | 255 | <span class="generic_icons move"></span>'; |
| 240 | - if ($topic['is_poll']) |
|
| 241 | - echo ' |
|
| 256 | + } |
|
| 257 | + if ($topic['is_poll']) { |
|
| 258 | + echo ' |
|
| 242 | 259 | <span class="generic_icons poll"></span>'; |
| 260 | + } |
|
| 243 | 261 | echo ' |
| 244 | 262 | </div>'; |
| 245 | 263 | |
@@ -265,26 +283,31 @@ discard block |
||
| 265 | 283 | { |
| 266 | 284 | echo ' |
| 267 | 285 | <div class="moderation">'; |
| 268 | - if ($options['display_quick_mod'] == 1) |
|
| 269 | - echo ' |
|
| 286 | + if ($options['display_quick_mod'] == 1) { |
|
| 287 | + echo ' |
|
| 270 | 288 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check">'; |
| 271 | - else |
|
| 289 | + } else |
|
| 272 | 290 | { |
| 273 | 291 | // Check permissions on each and show only the ones they are allowed to use. |
| 274 | - if ($topic['quick_mod']['remove']) |
|
| 275 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 292 | + if ($topic['quick_mod']['remove']) { |
|
| 293 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
| 294 | + } |
|
| 276 | 295 | |
| 277 | - if ($topic['quick_mod']['lock']) |
|
| 278 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 296 | + if ($topic['quick_mod']['lock']) { |
|
| 297 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
| 298 | + } |
|
| 279 | 299 | |
| 280 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
| 281 | - echo '<br>'; |
|
| 300 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
| 301 | + echo '<br>'; |
|
| 302 | + } |
|
| 282 | 303 | |
| 283 | - if ($topic['quick_mod']['sticky']) |
|
| 284 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 304 | + if ($topic['quick_mod']['sticky']) { |
|
| 305 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
| 306 | + } |
|
| 285 | 307 | |
| 286 | - if ($topic['quick_mod']['move']) |
|
| 287 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 308 | + if ($topic['quick_mod']['move']) { |
|
| 309 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
| 310 | + } |
|
| 288 | 311 | } |
| 289 | 312 | echo ' |
| 290 | 313 | </div>'; |
@@ -302,18 +325,20 @@ discard block |
||
| 302 | 325 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
| 303 | 326 | <option value="">--------</option>'; |
| 304 | 327 | |
| 305 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
| 306 | - if ($context['can_' . $qmod_action]) |
|
| 328 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
| 329 | + if ($context['can_' . $qmod_action]) |
|
| 307 | 330 | echo ' |
| 308 | 331 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
| 332 | + } |
|
| 309 | 333 | |
| 310 | 334 | echo ' |
| 311 | 335 | </select>'; |
| 312 | 336 | |
| 313 | 337 | // Show a list of boards they can move the topic to. |
| 314 | - if ($context['can_move']) |
|
| 315 | - echo ' |
|
| 338 | + if ($context['can_move']) { |
|
| 339 | + echo ' |
|
| 316 | 340 | <span id="quick_mod_jump_to"> </span>'; |
| 341 | + } |
|
| 317 | 342 | |
| 318 | 343 | echo ' |
| 319 | 344 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button_submit qaction"> |
@@ -324,10 +349,11 @@ discard block |
||
| 324 | 349 | </div>'; |
| 325 | 350 | |
| 326 | 351 | // Finish off the form - again. |
| 327 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
| 328 | - echo ' |
|
| 352 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
| 353 | + echo ' |
|
| 329 | 354 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
| 330 | 355 | </form>'; |
| 356 | + } |
|
| 331 | 357 | |
| 332 | 358 | // Mobile action buttons (bottom) |
| 333 | 359 | echo ' |
@@ -346,8 +372,8 @@ discard block |
||
| 346 | 372 | // Show breadcrumbs at the bottom too. |
| 347 | 373 | theme_linktree(); |
| 348 | 374 | |
| 349 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
| 350 | - echo ' |
|
| 375 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
| 376 | + echo ' |
|
| 351 | 377 | <script> |
| 352 | 378 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 353 | 379 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -366,6 +392,7 @@ discard block |
||
| 366 | 392 | sCustomName: "move_to" |
| 367 | 393 | }); |
| 368 | 394 | </script>'; |
| 395 | + } |
|
| 369 | 396 | |
| 370 | 397 | // Javascript for inline editing. |
| 371 | 398 | echo ' |
@@ -401,8 +428,8 @@ discard block |
||
| 401 | 428 | <div class="information"> |
| 402 | 429 | <p class="floatright" id="message_index_jump_to"> </p>'; |
| 403 | 430 | |
| 404 | - if (empty($context['no_topic_listing'])) |
|
| 405 | - echo ' |
|
| 431 | + if (empty($context['no_topic_listing'])) { |
|
| 432 | + echo ' |
|
| 406 | 433 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
| 407 | 434 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
| 408 | 435 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -412,9 +439,10 @@ discard block |
||
| 412 | 439 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
| 413 | 440 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
| 414 | 441 | </p>'; |
| 442 | + } |
|
| 415 | 443 | |
| 416 | - if (!empty($context['jump_to'])) |
|
| 417 | - echo ' |
|
| 444 | + if (!empty($context['jump_to'])) { |
|
| 445 | + echo ' |
|
| 418 | 446 | <script> |
| 419 | 447 | if (typeof(window.XMLHttpRequest) != "undefined") |
| 420 | 448 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -430,6 +458,7 @@ discard block |
||
| 430 | 458 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
| 431 | 459 | }); |
| 432 | 460 | </script>'; |
| 461 | + } |
|
| 433 | 462 | |
| 434 | 463 | echo ' |
| 435 | 464 | <br class="clear"> |