@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
62 | 63 | $context['activation_numbers'] = array(); |
63 | 64 | $context['awaiting_activation'] = 0; |
64 | 65 | $context['awaiting_approval'] = 0; |
65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
68 | + } |
|
67 | 69 | $smcFunc['db_free_result']($request); |
68 | 70 | |
69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
70 | 72 | { |
71 | - if (in_array($activation_type, array(0, 2))) |
|
72 | - $context['awaiting_activation'] += $total_members; |
|
73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
74 | - $context['awaiting_approval'] += $total_members; |
|
73 | + if (in_array($activation_type, array(0, 2))) { |
|
74 | + $context['awaiting_activation'] += $total_members; |
|
75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
76 | + $context['awaiting_approval'] += $total_members; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
126 | 129 | { |
127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
128 | - $context['tabs']['search']['is_last'] = true; |
|
130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
131 | + $context['tabs']['search']['is_last'] = true; |
|
132 | + } |
|
129 | 133 | unset($context['tabs']['approve']); |
130 | 134 | } |
131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
157 | 161 | foreach ($_POST['delete'] as $key => $value) |
158 | 162 | { |
159 | 163 | // Don't delete yourself, idiot. |
160 | - if ($value != $user_info['id']) |
|
161 | - $delete[$key] = (int) $value; |
|
164 | + if ($value != $user_info['id']) { |
|
165 | + $delete[$key] = (int) $value; |
|
166 | + } |
|
162 | 167 | } |
163 | 168 | |
164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
194 | 199 | ); |
195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
196 | 201 | { |
197 | - if ($row['min_posts'] == -1) |
|
198 | - $context['membergroups'][] = array( |
|
202 | + if ($row['min_posts'] == -1) { |
|
203 | + $context['membergroups'][] = array( |
|
199 | 204 | 'id' => $row['id_group'], |
200 | 205 | 'name' => $row['group_name'], |
201 | 206 | 'can_be_additional' => true |
202 | 207 | ); |
203 | - else |
|
204 | - $context['postgroups'][] = array( |
|
208 | + } else { |
|
209 | + $context['postgroups'][] = array( |
|
205 | 210 | 'id' => $row['id_group'], |
206 | 211 | 'name' => $row['group_name'] |
207 | 212 | ); |
213 | + } |
|
208 | 214 | } |
209 | 215 | $smcFunc['db_free_result']($request); |
210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
269 | 275 | |
270 | 276 | $search_params = array(); |
271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
272 | - $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
273 | - elseif (!empty($_POST)) |
|
277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
278 | + $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
279 | + } elseif (!empty($_POST)) |
|
274 | 280 | { |
275 | 281 | $search_params['types'] = $_POST['types']; |
276 | - foreach ($params as $param_name => $param_info) |
|
277 | - if (isset($_POST[$param_name])) |
|
282 | + foreach ($params as $param_name => $param_info) { |
|
283 | + if (isset($_POST[$param_name])) |
|
278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
285 | + } |
|
279 | 286 | } |
280 | 287 | |
281 | 288 | $search_url_params = isset($search_params) ? base64_encode(json_encode($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
288 | 295 | foreach ($params as $param_name => $param_info) |
289 | 296 | { |
290 | 297 | // Not filled in? |
291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
292 | - continue; |
|
298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
299 | + continue; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | // Make sure numeric values are really numeric. |
295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
305 | + } |
|
297 | 306 | // Date values have to match the specified format. |
298 | 307 | elseif ($param_info['type'] == 'date') |
299 | 308 | { |
300 | 309 | // Check if this date format is valid. |
301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
302 | - continue; |
|
310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
311 | + continue; |
|
312 | + } |
|
303 | 313 | |
304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | if (!empty($param_info['range'])) |
309 | 319 | { |
310 | 320 | // Default to '=', just in case... |
311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
312 | - $search_params['types'][$param_name] = '='; |
|
321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
322 | + $search_params['types'][$param_name] = '='; |
|
323 | + } |
|
313 | 324 | |
314 | 325 | // Handle special case 'age'. |
315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
338 | 349 | { |
339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
351 | + } else { |
|
352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
340 | 353 | } |
341 | - else |
|
342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
343 | 354 | } |
344 | 355 | // Checkboxes. |
345 | 356 | elseif ($param_info['type'] == 'checkbox') |
346 | 357 | { |
347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
349 | - continue; |
|
359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
360 | + continue; |
|
361 | + } |
|
350 | 362 | |
351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
353 | - } |
|
354 | - else |
|
365 | + } else |
|
355 | 366 | { |
356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
358 | 369 | |
359 | - if ($smcFunc['db_case_sensitive']) |
|
360 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
361 | - else |
|
362 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
370 | + if ($smcFunc['db_case_sensitive']) { |
|
371 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
372 | + } else { |
|
373 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
374 | + } |
|
363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
364 | 376 | } |
365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
375 | 387 | } |
376 | 388 | |
377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
380 | 392 | { |
381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
394 | + } |
|
382 | 395 | $where_params['add_group_' . $mg] = $mg; |
383 | 396 | } |
384 | 397 | |
385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
386 | - if (!empty($mg_query_parts)) |
|
387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
399 | + if (!empty($mg_query_parts)) { |
|
400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
401 | + } |
|
388 | 402 | |
389 | 403 | // Get all selected post count related membergroups. |
390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
396 | 410 | // Construct the where part of the query. |
397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
398 | 412 | AND ', $query_parts); |
413 | + } else { |
|
414 | + $search_url_params = null; |
|
399 | 415 | } |
400 | - else |
|
401 | - $search_url_params = null; |
|
402 | 416 | |
403 | 417 | // Construct the additional URL part with the query info in it. |
404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
521 | 535 | 'function' => function($rowData) use ($txt) |
522 | 536 | { |
523 | 537 | // Calculate number of days since last online. |
524 | - if (empty($rowData['last_login'])) |
|
525 | - $difference = $txt['never']; |
|
526 | - else |
|
538 | + if (empty($rowData['last_login'])) { |
|
539 | + $difference = $txt['never']; |
|
540 | + } else |
|
527 | 541 | { |
528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
529 | 543 | |
530 | 544 | // Today. |
531 | - if (empty($num_days_difference)) |
|
532 | - $difference = $txt['viewmembers_today']; |
|
545 | + if (empty($num_days_difference)) { |
|
546 | + $difference = $txt['viewmembers_today']; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | // Yesterday. |
535 | - elseif ($num_days_difference == 1) |
|
536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
550 | + elseif ($num_days_difference == 1) { |
|
551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
552 | + } |
|
537 | 553 | |
538 | 554 | // X days ago. |
539 | - else |
|
540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
555 | + else { |
|
556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
557 | + } |
|
541 | 558 | } |
542 | 559 | |
543 | 560 | // Show it in italics if they're not activated... |
544 | - if ($rowData['is_activated'] % 10 != 1) |
|
545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
563 | + } |
|
546 | 564 | |
547 | 565 | return $difference; |
548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
594 | 612 | ); |
595 | 613 | |
596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
597 | - if (!allowedTo('profile_remove_any')) |
|
598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
615 | + if (!allowedTo('profile_remove_any')) { |
|
616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
617 | + } |
|
599 | 618 | |
600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
638 | 657 | ); |
639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 659 | { |
641 | - if ($row['min_posts'] == -1) |
|
642 | - $context['membergroups'][] = array( |
|
660 | + if ($row['min_posts'] == -1) { |
|
661 | + $context['membergroups'][] = array( |
|
643 | 662 | 'id' => $row['id_group'], |
644 | 663 | 'name' => $row['group_name'], |
645 | 664 | 'can_be_additional' => true |
646 | 665 | ); |
647 | - else |
|
648 | - $context['postgroups'][] = array( |
|
666 | + } else { |
|
667 | + $context['postgroups'][] = array( |
|
649 | 668 | 'id' => $row['id_group'], |
650 | 669 | 'name' => $row['group_name'] |
651 | 670 | ); |
671 | + } |
|
652 | 672 | } |
653 | 673 | $smcFunc['db_free_result']($request); |
654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
675 | 695 | $context['page_title'] = $txt['admin_members']; |
676 | 696 | $context['sub_template'] = 'admin_browse'; |
677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
700 | + } |
|
680 | 701 | |
681 | 702 | // Allowed filters are those we can have, in theory. |
682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
688 | 709 | { |
689 | 710 | // We have some of these... |
690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
691 | - $context['available_filters'][] = array( |
|
711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
712 | + $context['available_filters'][] = array( |
|
692 | 713 | 'type' => $type, |
693 | 714 | 'amount' => $amount, |
694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
695 | 716 | 'selected' => $type == $context['current_filter'] |
696 | 717 | ); |
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
724 | + } |
|
702 | 725 | |
703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
713 | 736 | ); |
714 | 737 | |
715 | 738 | // Are we showing duplicate information? |
716 | - if (isset($_GET['showdupes'])) |
|
717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
739 | + if (isset($_GET['showdupes'])) { |
|
740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
741 | + } |
|
718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
719 | 743 | |
720 | 744 | // Determine which actions we should allow on this page. |
721 | 745 | if ($context['browse_type'] == 'approve') |
722 | 746 | { |
723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
724 | - if ($context['current_filter'] == 4) |
|
725 | - $context['allowed_actions'] = array( |
|
748 | + if ($context['current_filter'] == 4) { |
|
749 | + $context['allowed_actions'] = array( |
|
726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
728 | 752 | ); |
729 | - else |
|
730 | - $context['allowed_actions'] = array( |
|
753 | + } else { |
|
754 | + $context['allowed_actions'] = array( |
|
731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
736 | 760 | ); |
737 | - } |
|
738 | - elseif ($context['browse_type'] == 'activate') |
|
739 | - $context['allowed_actions'] = array( |
|
761 | + } |
|
762 | + } elseif ($context['browse_type'] == 'activate') { |
|
763 | + $context['allowed_actions'] = array( |
|
740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
745 | 769 | ); |
770 | + } |
|
746 | 771 | |
747 | 772 | // Create an option list for actions allowed to be done with selected members. |
748 | 773 | $allowed_actions = ' |
749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
750 | 775 | <option value="" disabled>-----------------------------</option>'; |
751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
752 | - $allowed_actions .= ' |
|
776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
777 | + $allowed_actions .= ' |
|
753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
779 | + } |
|
754 | 780 | |
755 | 781 | // Setup the Javascript function for selecting an action for the list. |
756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
762 | 788 | var message = "";'; |
763 | 789 | |
764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
765 | - if ($context['current_filter'] == 4) |
|
766 | - $javascript .= ' |
|
791 | + if ($context['current_filter'] == 4) { |
|
792 | + $javascript .= ' |
|
767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
769 | 795 | else |
770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
797 | + } |
|
771 | 798 | // Otherwise a nice standard message. |
772 | - else |
|
773 | - $javascript .= ' |
|
799 | + else { |
|
800 | + $javascript .= ' |
|
774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
780 | 807 | else |
781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
809 | + } |
|
782 | 810 | $javascript .= ' |
783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
911 | 939 | $member_links = array(); |
912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
913 | 941 | { |
914 | - if ($member['id']) |
|
915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
916 | - else |
|
917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
942 | + if ($member['id']) { |
|
943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
944 | + } else { |
|
945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
946 | + } |
|
918 | 947 | } |
919 | 948 | return implode(', ', $member_links); |
920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
963 | 992 | ); |
964 | 993 | |
965 | 994 | // Pick what column to actually include if we're showing duplicates. |
966 | - if ($context['show_duplicates']) |
|
967 | - unset($listOptions['columns']['email']); |
|
968 | - else |
|
969 | - unset($listOptions['columns']['duplicates']); |
|
995 | + if ($context['show_duplicates']) { |
|
996 | + unset($listOptions['columns']['email']); |
|
997 | + } else { |
|
998 | + unset($listOptions['columns']['duplicates']); |
|
999 | + } |
|
970 | 1000 | |
971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
973 | - unset($listOptions['columns']['hostname']); |
|
1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1003 | + unset($listOptions['columns']['hostname']); |
|
1004 | + } |
|
974 | 1005 | |
975 | 1006 | // Is there any need to show filters? |
976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
978 | 1009 | $filterOptions = ' |
979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
981 | - foreach ($context['available_filters'] as $filter) |
|
982 | - $filterOptions .= ' |
|
1012 | + foreach ($context['available_filters'] as $filter) { |
|
1013 | + $filterOptions .= ' |
|
983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1015 | + } |
|
984 | 1016 | $filterOptions .= ' |
985 | 1017 | </select> |
986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button_submit"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
992 | 1024 | } |
993 | 1025 | |
994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
996 | - $listOptions['additional_rows'][] = array( |
|
1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1028 | + $listOptions['additional_rows'][] = array( |
|
997 | 1029 | 'position' => 'above_column_headers', |
998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
999 | 1031 | 'class' => 'smalltext floatright', |
1000 | 1032 | ); |
1033 | + } |
|
1001 | 1034 | |
1002 | 1035 | // Now that we have all the options, create the list. |
1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1027,12 +1060,14 @@ discard block |
||
1027 | 1060 | $current_filter = (int) $_REQUEST['orig_filter']; |
1028 | 1061 | |
1029 | 1062 | // If we are applying a filter do just that - then redirect. |
1030 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1031 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1063 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1064 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1065 | + } |
|
1032 | 1066 | |
1033 | 1067 | // Nothing to do? |
1034 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1035 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1068 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1069 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1070 | + } |
|
1036 | 1071 | |
1037 | 1072 | // Are we dealing with members who have been waiting for > set amount of time? |
1038 | 1073 | if (isset($_POST['time_passed'])) |
@@ -1045,8 +1080,9 @@ discard block |
||
1045 | 1080 | else |
1046 | 1081 | { |
1047 | 1082 | $members = array(); |
1048 | - foreach ($_POST['todoAction'] as $id) |
|
1049 | - $members[] = (int) $id; |
|
1083 | + foreach ($_POST['todoAction'] as $id) { |
|
1084 | + $members[] = (int) $id; |
|
1085 | + } |
|
1050 | 1086 | $condition = ' |
1051 | 1087 | AND id_member IN ({array_int:members})'; |
1052 | 1088 | } |
@@ -1067,8 +1103,9 @@ discard block |
||
1067 | 1103 | $member_count = $smcFunc['db_num_rows']($request); |
1068 | 1104 | |
1069 | 1105 | // If no results then just return! |
1070 | - if ($member_count == 0) |
|
1071 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1106 | + if ($member_count == 0) { |
|
1107 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1108 | + } |
|
1072 | 1109 | |
1073 | 1110 | $member_info = array(); |
1074 | 1111 | $members = array(); |
@@ -1107,8 +1144,9 @@ discard block |
||
1107 | 1144 | // Do we have to let the integration code know about the activations? |
1108 | 1145 | if (!empty($modSettings['integrate_activate'])) |
1109 | 1146 | { |
1110 | - foreach ($member_info as $member) |
|
1111 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1147 | + foreach ($member_info as $member) { |
|
1148 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1149 | + } |
|
1112 | 1150 | } |
1113 | 1151 | |
1114 | 1152 | // Check for email. |
@@ -1238,20 +1276,23 @@ discard block |
||
1238 | 1276 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
1239 | 1277 | |
1240 | 1278 | require_once($sourcedir . '/Logging.php'); |
1241 | - foreach ($member_info as $member) |
|
1242 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1279 | + foreach ($member_info as $member) { |
|
1280 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1281 | + } |
|
1243 | 1282 | } |
1244 | 1283 | |
1245 | 1284 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1246 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1247 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1285 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1286 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1287 | + } |
|
1248 | 1288 | |
1249 | 1289 | // Update the member's stats. (but, we know the member didn't change their name.) |
1250 | 1290 | updateStats('member', false); |
1251 | 1291 | |
1252 | 1292 | // If they haven't been deleted, update the post group statistics on them... |
1253 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1254 | - updateStats('postgroups', $members); |
|
1293 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1294 | + updateStats('postgroups', $members); |
|
1295 | + } |
|
1255 | 1296 | |
1256 | 1297 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1257 | 1298 | } |
@@ -1276,10 +1317,11 @@ discard block |
||
1276 | 1317 | $dis = time() - $old; |
1277 | 1318 | |
1278 | 1319 | // Before midnight? |
1279 | - if ($dis < $sinceMidnight) |
|
1280 | - return 0; |
|
1281 | - else |
|
1282 | - $dis -= $sinceMidnight; |
|
1320 | + if ($dis < $sinceMidnight) { |
|
1321 | + return 0; |
|
1322 | + } else { |
|
1323 | + $dis -= $sinceMidnight; |
|
1324 | + } |
|
1283 | 1325 | |
1284 | 1326 | // Divide out the seconds in a day to get the number of days. |
1285 | 1327 | return ceil($dis / (24 * 60 * 60)); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * Original module by Mach8 - We'll never forget you. |
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 | * splits a topic into two topics. |
@@ -30,15 +31,17 @@ discard block |
||
30 | 31 | global $topic, $sourcedir; |
31 | 32 | |
32 | 33 | // And... which topic were you splitting, again? |
33 | - if (empty($topic)) |
|
34 | - fatal_lang_error('numbers_one_to_nine', false); |
|
34 | + if (empty($topic)) { |
|
35 | + fatal_lang_error('numbers_one_to_nine', false); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Are you allowed to split topics? |
37 | 39 | isAllowedTo('split_any'); |
38 | 40 | |
39 | 41 | // Load up the "dependencies" - the template, getMsgMemberID(), and sendNotifications(). |
40 | - if (!isset($_REQUEST['xml'])) |
|
41 | - loadTemplate('SplitTopics'); |
|
42 | + if (!isset($_REQUEST['xml'])) { |
|
43 | + loadTemplate('SplitTopics'); |
|
44 | + } |
|
42 | 45 | require_once($sourcedir . '/Subs-Boards.php'); |
43 | 46 | require_once($sourcedir . '/Subs-Post.php'); |
44 | 47 | |
@@ -50,12 +53,12 @@ discard block |
||
50 | 53 | ); |
51 | 54 | |
52 | 55 | // ?action=splittopics;sa=LETSBREAKIT won't work, sorry. |
53 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
54 | - SplitIndex(); |
|
55 | - |
|
56 | - else |
|
57 | - call_helper($subActions[$_REQUEST['sa']]); |
|
58 | -} |
|
56 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
57 | + SplitIndex(); |
|
58 | + } else { |
|
59 | + call_helper($subActions[$_REQUEST['sa']]); |
|
60 | + } |
|
61 | + } |
|
59 | 62 | |
60 | 63 | /** |
61 | 64 | * screen shown before the actual split. |
@@ -71,8 +74,9 @@ discard block |
||
71 | 74 | global $txt, $topic, $context, $smcFunc, $modSettings; |
72 | 75 | |
73 | 76 | // Validate "at". |
74 | - if (empty($_GET['at'])) |
|
75 | - fatal_lang_error('numbers_one_to_nine', false); |
|
77 | + if (empty($_GET['at'])) { |
|
78 | + fatal_lang_error('numbers_one_to_nine', false); |
|
79 | + } |
|
76 | 80 | $_GET['at'] = (int) $_GET['at']; |
77 | 81 | |
78 | 82 | // Retrieve the subject and stuff of the specific topic/message. |
@@ -89,26 +93,31 @@ discard block |
||
89 | 93 | 'split_at' => $_GET['at'], |
90 | 94 | ) |
91 | 95 | ); |
92 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
93 | - fatal_lang_error('cant_find_messages'); |
|
96 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
97 | + fatal_lang_error('cant_find_messages'); |
|
98 | + } |
|
94 | 99 | list ($_REQUEST['subname'], $num_replies, $unapproved_posts, $id_first_msg, $approved) = $smcFunc['db_fetch_row']($request); |
95 | 100 | $smcFunc['db_free_result']($request); |
96 | 101 | |
97 | 102 | // If not approved validate they can see it. |
98 | - if ($modSettings['postmod_active'] && !$approved) |
|
99 | - isAllowedTo('approve_posts'); |
|
103 | + if ($modSettings['postmod_active'] && !$approved) { |
|
104 | + isAllowedTo('approve_posts'); |
|
105 | + } |
|
100 | 106 | |
101 | 107 | // If this topic has unapproved posts, we need to count them too... |
102 | - if ($modSettings['postmod_active'] && allowedTo('approve_posts')) |
|
103 | - $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
108 | + if ($modSettings['postmod_active'] && allowedTo('approve_posts')) { |
|
109 | + $num_replies += $unapproved_posts - ($approved ? 0 : 1); |
|
110 | + } |
|
104 | 111 | |
105 | 112 | // Check if there is more than one message in the topic. (there should be.) |
106 | - if ($num_replies < 1) |
|
107 | - fatal_lang_error('topic_one_post', false); |
|
113 | + if ($num_replies < 1) { |
|
114 | + fatal_lang_error('topic_one_post', false); |
|
115 | + } |
|
108 | 116 | |
109 | 117 | // Check if this is the first message in the topic (if so, the first and second option won't be available) |
110 | - if ($id_first_msg == $_GET['at']) |
|
111 | - return SplitSelectTopics(); |
|
118 | + if ($id_first_msg == $_GET['at']) { |
|
119 | + return SplitSelectTopics(); |
|
120 | + } |
|
112 | 121 | |
113 | 122 | // Basic template information.... |
114 | 123 | $context['message'] = array( |
@@ -137,8 +146,9 @@ discard block |
||
137 | 146 | checkSession(); |
138 | 147 | |
139 | 148 | // Clean up the subject. |
140 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
141 | - $_POST['subname'] = $txt['new_topic']; |
|
149 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
150 | + $_POST['subname'] = $txt['new_topic']; |
|
151 | + } |
|
142 | 152 | |
143 | 153 | // Redirect to the selector if they chose selective. |
144 | 154 | if ($_POST['step2'] == 'selective') |
@@ -163,16 +173,19 @@ discard block |
||
163 | 173 | 'split_at' => $_POST['at'], |
164 | 174 | ) |
165 | 175 | ); |
166 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
167 | - $messagesToBeSplit[] = $row['id_msg']; |
|
176 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
177 | + $messagesToBeSplit[] = $row['id_msg']; |
|
178 | + } |
|
168 | 179 | $smcFunc['db_free_result']($request); |
169 | 180 | } |
170 | 181 | // Only the selected message has to be split. That should be easy. |
171 | - elseif ($_POST['step2'] == 'onlythis') |
|
172 | - $messagesToBeSplit[] = $_POST['at']; |
|
182 | + elseif ($_POST['step2'] == 'onlythis') { |
|
183 | + $messagesToBeSplit[] = $_POST['at']; |
|
184 | + } |
|
173 | 185 | // There's another action?! |
174 | - else |
|
175 | - fatal_lang_error('no_access', false); |
|
186 | + else { |
|
187 | + fatal_lang_error('no_access', false); |
|
188 | + } |
|
176 | 189 | |
177 | 190 | $context['old_topic'] = $topic; |
178 | 191 | $context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $_POST['subname']); |
@@ -199,8 +212,9 @@ discard block |
||
199 | 212 | $_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic]; |
200 | 213 | |
201 | 214 | // This is a special case for split topics from quick-moderation checkboxes |
202 | - if (isset($_REQUEST['subname_enc'])) |
|
203 | - $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
215 | + if (isset($_REQUEST['subname_enc'])) { |
|
216 | + $_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']); |
|
217 | + } |
|
204 | 218 | |
205 | 219 | $context['not_selected'] = array( |
206 | 220 | 'num_messages' => 0, |
@@ -252,10 +266,12 @@ discard block |
||
252 | 266 | ) |
253 | 267 | ); |
254 | 268 | // You can't split the last message off. |
255 | - if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') |
|
256 | - $_REQUEST['move'] = ''; |
|
257 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
258 | - $original_msgs['not_selected'][] = $row['id_msg']; |
|
269 | + if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') { |
|
270 | + $_REQUEST['move'] = ''; |
|
271 | + } |
|
272 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
273 | + $original_msgs['not_selected'][] = $row['id_msg']; |
|
274 | + } |
|
259 | 275 | $smcFunc['db_free_result']($request); |
260 | 276 | if (!empty($_SESSION['split_selection'][$topic])) |
261 | 277 | { |
@@ -275,8 +291,9 @@ discard block |
||
275 | 291 | 'messages_per_page' => $context['messages_per_page'], |
276 | 292 | ) |
277 | 293 | ); |
278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
279 | - $original_msgs['selected'][] = $row['id_msg']; |
|
294 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
295 | + $original_msgs['selected'][] = $row['id_msg']; |
|
296 | + } |
|
280 | 297 | $smcFunc['db_free_result']($request); |
281 | 298 | } |
282 | 299 | } |
@@ -286,12 +303,13 @@ discard block |
||
286 | 303 | { |
287 | 304 | $_REQUEST['msg'] = (int) $_REQUEST['msg']; |
288 | 305 | |
289 | - if ($_REQUEST['move'] == 'reset') |
|
290 | - $_SESSION['split_selection'][$topic] = array(); |
|
291 | - elseif ($_REQUEST['move'] == 'up') |
|
292 | - $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
293 | - else |
|
294 | - $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
306 | + if ($_REQUEST['move'] == 'reset') { |
|
307 | + $_SESSION['split_selection'][$topic] = array(); |
|
308 | + } elseif ($_REQUEST['move'] == 'up') { |
|
309 | + $_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg'])); |
|
310 | + } else { |
|
311 | + $_SESSION['split_selection'][$topic][] = $_REQUEST['msg']; |
|
312 | + } |
|
295 | 313 | } |
296 | 314 | |
297 | 315 | // Make sure the selection is still accurate. |
@@ -310,8 +328,9 @@ discard block |
||
310 | 328 | ) |
311 | 329 | ); |
312 | 330 | $_SESSION['split_selection'][$topic] = array(); |
313 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
314 | - $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
331 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
332 | + $_SESSION['split_selection'][$topic][] = $row['id_msg']; |
|
333 | + } |
|
315 | 334 | $smcFunc['db_free_result']($request); |
316 | 335 | } |
317 | 336 | |
@@ -328,13 +347,15 @@ discard block |
||
328 | 347 | 'is_approved' => 1, |
329 | 348 | ) |
330 | 349 | ); |
331 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
332 | - $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
350 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
351 | + $context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages']; |
|
352 | + } |
|
333 | 353 | $smcFunc['db_free_result']($request); |
334 | 354 | |
335 | 355 | // Fix an oversized starting page (to make sure both pageindexes are properly set). |
336 | - if ($context['selected']['start'] >= $context['selected']['num_messages']) |
|
337 | - $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
356 | + if ($context['selected']['start'] >= $context['selected']['num_messages']) { |
|
357 | + $context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page']))); |
|
358 | + } |
|
338 | 359 | |
339 | 360 | // Build a page list of the not-selected topics... |
340 | 361 | $context['not_selected']['page_index'] = constructPageIndex($scripturl . '?action=splittopics;sa=selectTopics;subname=' . strtr(urlencode($_REQUEST['subname']), array('%' => '%%')) . ';topic=' . $topic . '.%1$d;start2=' . $context['selected']['start'], $context['not_selected']['start'], $context['not_selected']['num_messages'], $context['messages_per_page'], true); |
@@ -434,11 +455,12 @@ discard block |
||
434 | 455 | ); |
435 | 456 | |
436 | 457 | $context['changes'] = array(); |
437 | - foreach ($changes as $change_type => $change_array) |
|
438 | - foreach ($change_array as $section => $msg_array) |
|
458 | + foreach ($changes as $change_type => $change_array) { |
|
459 | + foreach ($change_array as $section => $msg_array) |
|
439 | 460 | { |
440 | 461 | if (empty($msg_array)) |
441 | 462 | continue; |
463 | + } |
|
442 | 464 | |
443 | 465 | foreach ($msg_array as $id_msg) |
444 | 466 | { |
@@ -447,8 +469,9 @@ discard block |
||
447 | 469 | 'type' => $change_type, |
448 | 470 | 'section' => $section, |
449 | 471 | ); |
450 | - if ($change_type == 'insert') |
|
451 | - $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
472 | + if ($change_type == 'insert') { |
|
473 | + $context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg]; |
|
474 | + } |
|
452 | 475 | } |
453 | 476 | } |
454 | 477 | } |
@@ -468,12 +491,14 @@ discard block |
||
468 | 491 | checkSession(); |
469 | 492 | |
470 | 493 | // Default the subject in case it's blank. |
471 | - if (!isset($_POST['subname']) || $_POST['subname'] == '') |
|
472 | - $_POST['subname'] = $txt['new_topic']; |
|
494 | + if (!isset($_POST['subname']) || $_POST['subname'] == '') { |
|
495 | + $_POST['subname'] = $txt['new_topic']; |
|
496 | + } |
|
473 | 497 | |
474 | 498 | // You must've selected some messages! Can't split out none! |
475 | - if (empty($_SESSION['split_selection'][$topic])) |
|
476 | - fatal_lang_error('no_posts_selected', false); |
|
499 | + if (empty($_SESSION['split_selection'][$topic])) { |
|
500 | + fatal_lang_error('no_posts_selected', false); |
|
501 | + } |
|
477 | 502 | |
478 | 503 | $context['old_topic'] = $topic; |
479 | 504 | $context['new_topic'] = splitTopic($topic, $_SESSION['split_selection'][$topic], $_POST['subname']); |
@@ -499,8 +524,9 @@ discard block |
||
499 | 524 | global $smcFunc, $txt, $sourcedir; |
500 | 525 | |
501 | 526 | // Nothing to split? |
502 | - if (empty($splitMessages)) |
|
503 | - fatal_lang_error('no_posts_selected', false); |
|
527 | + if (empty($splitMessages)) { |
|
528 | + fatal_lang_error('no_posts_selected', false); |
|
529 | + } |
|
504 | 530 | |
505 | 531 | // Get some board info. |
506 | 532 | $request = $smcFunc['db_query']('', ' |
@@ -532,8 +558,9 @@ discard block |
||
532 | 558 | ) |
533 | 559 | ); |
534 | 560 | // You can't select ALL the messages! |
535 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
536 | - fatal_lang_error('selected_all_posts', false); |
|
561 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
562 | + fatal_lang_error('selected_all_posts', false); |
|
563 | + } |
|
537 | 564 | |
538 | 565 | $split1_first_msg = null; |
539 | 566 | $split1_last_msg = null; |
@@ -541,24 +568,27 @@ discard block |
||
541 | 568 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
542 | 569 | { |
543 | 570 | // Get the right first and last message dependant on approved state... |
544 | - if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) |
|
545 | - $split1_first_msg = $row['myid_first_msg']; |
|
546 | - if (empty($split1_last_msg) || $row['approved']) |
|
547 | - $split1_last_msg = $row['myid_last_msg']; |
|
571 | + if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) { |
|
572 | + $split1_first_msg = $row['myid_first_msg']; |
|
573 | + } |
|
574 | + if (empty($split1_last_msg) || $row['approved']) { |
|
575 | + $split1_last_msg = $row['myid_last_msg']; |
|
576 | + } |
|
548 | 577 | |
549 | 578 | // Get the counts correct... |
550 | 579 | if ($row['approved']) |
551 | 580 | { |
552 | 581 | $split1_replies = $row['message_count'] - 1; |
553 | 582 | $split1_unapprovedposts = 0; |
554 | - } |
|
555 | - else |
|
583 | + } else |
|
556 | 584 | { |
557 | - if (!isset($split1_replies)) |
|
558 | - $split1_replies = 0; |
|
585 | + if (!isset($split1_replies)) { |
|
586 | + $split1_replies = 0; |
|
587 | + } |
|
559 | 588 | // If the topic isn't approved then num replies must go up by one... as first post wouldn't be counted. |
560 | - elseif (!$split1_approved) |
|
561 | - $split1_replies++; |
|
589 | + elseif (!$split1_approved) { |
|
590 | + $split1_replies++; |
|
591 | + } |
|
562 | 592 | |
563 | 593 | $split1_unapprovedposts = $row['message_count']; |
564 | 594 | } |
@@ -584,10 +614,12 @@ discard block |
||
584 | 614 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
585 | 615 | { |
586 | 616 | // As before get the right first and last message dependant on approved state... |
587 | - if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) |
|
588 | - $split2_first_msg = $row['myid_first_msg']; |
|
589 | - if (empty($split2_last_msg) || $row['approved']) |
|
590 | - $split2_last_msg = $row['myid_last_msg']; |
|
617 | + if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) { |
|
618 | + $split2_first_msg = $row['myid_first_msg']; |
|
619 | + } |
|
620 | + if (empty($split2_last_msg) || $row['approved']) { |
|
621 | + $split2_last_msg = $row['myid_last_msg']; |
|
622 | + } |
|
591 | 623 | |
592 | 624 | // Then do the counts again... |
593 | 625 | if ($row['approved']) |
@@ -595,18 +627,20 @@ discard block |
||
595 | 627 | $split2_approved = true; |
596 | 628 | $split2_replies = $row['message_count'] - 1; |
597 | 629 | $split2_unapprovedposts = 0; |
598 | - } |
|
599 | - else |
|
630 | + } else |
|
600 | 631 | { |
601 | 632 | // Should this one be approved?? |
602 | - if ($split2_first_msg == $row['myid_first_msg']) |
|
603 | - $split2_approved = false; |
|
633 | + if ($split2_first_msg == $row['myid_first_msg']) { |
|
634 | + $split2_approved = false; |
|
635 | + } |
|
604 | 636 | |
605 | - if (!isset($split2_replies)) |
|
606 | - $split2_replies = 0; |
|
637 | + if (!isset($split2_replies)) { |
|
638 | + $split2_replies = 0; |
|
639 | + } |
|
607 | 640 | // As before, fix number of replies. |
608 | - elseif (!$split2_approved) |
|
609 | - $split2_replies++; |
|
641 | + elseif (!$split2_approved) { |
|
642 | + $split2_replies++; |
|
643 | + } |
|
610 | 644 | |
611 | 645 | $split2_unapprovedposts = $row['message_count']; |
612 | 646 | } |
@@ -616,12 +650,14 @@ discard block |
||
616 | 650 | $split2_lastMem = getMsgMemberID($split2_last_msg); |
617 | 651 | |
618 | 652 | // No database changes yet, so let's double check to see if everything makes at least a little sense. |
619 | - if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) |
|
620 | - fatal_lang_error('cant_find_messages'); |
|
653 | + if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) { |
|
654 | + fatal_lang_error('cant_find_messages'); |
|
655 | + } |
|
621 | 656 | |
622 | 657 | // You cannot split off the first message of a topic. |
623 | - if ($split1_first_msg > $split2_first_msg) |
|
624 | - fatal_lang_error('split_first_post', false); |
|
658 | + if ($split1_first_msg > $split2_first_msg) { |
|
659 | + fatal_lang_error('split_first_post', false); |
|
660 | + } |
|
625 | 661 | |
626 | 662 | // We're off to insert the new topic! Use 0 for now to avoid UNIQUE errors. |
627 | 663 | $split2_ID_TOPIC = $smcFunc['db_insert']('', |
@@ -644,14 +680,16 @@ discard block |
||
644 | 680 | array('id_topic'), |
645 | 681 | 1 |
646 | 682 | ); |
647 | - if ($split2_ID_TOPIC <= 0) |
|
648 | - fatal_lang_error('cant_insert_topic'); |
|
683 | + if ($split2_ID_TOPIC <= 0) { |
|
684 | + fatal_lang_error('cant_insert_topic'); |
|
685 | + } |
|
649 | 686 | |
650 | 687 | // Move the messages over to the other topic. |
651 | 688 | $new_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($new_subject)), array("\r" => '', "\n" => '', "\t" => '')); |
652 | 689 | // Check the subject length. |
653 | - if ($smcFunc['strlen']($new_subject) > 100) |
|
654 | - $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
690 | + if ($smcFunc['strlen']($new_subject) > 100) { |
|
691 | + $new_subject = $smcFunc['substr']($new_subject, 0, 100); |
|
692 | + } |
|
655 | 693 | // Valid subject? |
656 | 694 | if ($new_subject != '') |
657 | 695 | { |
@@ -722,8 +760,8 @@ discard block |
||
722 | 760 | ); |
723 | 761 | |
724 | 762 | // If the new topic isn't approved ensure the first message flags this just in case. |
725 | - if (!$split2_approved) |
|
726 | - $smcFunc['db_query']('', ' |
|
763 | + if (!$split2_approved) { |
|
764 | + $smcFunc['db_query']('', ' |
|
727 | 765 | UPDATE {db_prefix}messages |
728 | 766 | SET approved = {int:approved} |
729 | 767 | WHERE id_msg = {int:id_msg} |
@@ -734,6 +772,7 @@ discard block |
||
734 | 772 | 'id_topic' => $split2_ID_TOPIC, |
735 | 773 | ) |
736 | 774 | ); |
775 | + } |
|
737 | 776 | |
738 | 777 | // The board has more topics now (Or more unapproved ones!). |
739 | 778 | $smcFunc['db_query']('', ' |
@@ -760,8 +799,9 @@ discard block |
||
760 | 799 | if ($smcFunc['db_num_rows']($request) > 0) |
761 | 800 | { |
762 | 801 | $replaceEntries = array(); |
763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
764 | - $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
802 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
803 | + $replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']); |
|
804 | + } |
|
765 | 805 | |
766 | 806 | $smcFunc['db_insert']('ignore', |
767 | 807 | '{db_prefix}log_topics', |
@@ -785,8 +825,9 @@ discard block |
||
785 | 825 | // If there's a search index that needs updating, update it... |
786 | 826 | require_once($sourcedir . '/Search.php'); |
787 | 827 | $searchAPI = findSearchAPI(); |
788 | - if (is_callable(array($searchAPI, 'topicSplit'))) |
|
789 | - $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
828 | + if (is_callable(array($searchAPI, 'topicSplit'))) { |
|
829 | + $searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages); |
|
830 | + } |
|
790 | 831 | |
791 | 832 | // Maybe we want to let an external CMS know about this split |
792 | 833 | $split1 = array( |
@@ -833,12 +874,12 @@ discard block |
||
833 | 874 | ); |
834 | 875 | |
835 | 876 | // ?action=mergetopics;sa=LETSBREAKIT won't work, sorry. |
836 | - if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) |
|
837 | - MergeIndex(); |
|
838 | - |
|
839 | - else |
|
840 | - call_helper($subActions[$_REQUEST['sa']]); |
|
841 | -} |
|
877 | + if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) { |
|
878 | + MergeIndex(); |
|
879 | + } else { |
|
880 | + call_helper($subActions[$_REQUEST['sa']]); |
|
881 | + } |
|
882 | + } |
|
842 | 883 | |
843 | 884 | /** |
844 | 885 | * allows to pick a topic to merge the current topic with. |
@@ -852,8 +893,9 @@ discard block |
||
852 | 893 | global $txt, $board, $context, $smcFunc, $sourcedir; |
853 | 894 | global $scripturl, $modSettings; |
854 | 895 | |
855 | - if (!isset($_GET['from'])) |
|
856 | - fatal_lang_error('no_access', false); |
|
896 | + if (!isset($_GET['from'])) { |
|
897 | + fatal_lang_error('no_access', false); |
|
898 | + } |
|
857 | 899 | $_GET['from'] = (int) $_GET['from']; |
858 | 900 | |
859 | 901 | $_REQUEST['targetboard'] = isset($_REQUEST['targetboard']) ? (int) $_REQUEST['targetboard'] : $board; |
@@ -864,9 +906,9 @@ discard block |
||
864 | 906 | { |
865 | 907 | $can_approve_boards = boardsAllowedTo('approve_posts'); |
866 | 908 | $onlyApproved = $can_approve_boards !== array(0) && !in_array($_REQUEST['targetboard'], $can_approve_boards); |
909 | + } else { |
|
910 | + $onlyApproved = false; |
|
867 | 911 | } |
868 | - else |
|
869 | - $onlyApproved = false; |
|
870 | 912 | |
871 | 913 | // How many topics are on this board? (used for paging.) |
872 | 914 | $request = $smcFunc['db_query']('', ' |
@@ -900,8 +942,9 @@ discard block |
||
900 | 942 | 'is_approved' => 1, |
901 | 943 | ) |
902 | 944 | ); |
903 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
904 | - fatal_lang_error('no_board'); |
|
945 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
946 | + fatal_lang_error('no_board'); |
|
947 | + } |
|
905 | 948 | list ($subject) = $smcFunc['db_fetch_row']($request); |
906 | 949 | $smcFunc['db_free_result']($request); |
907 | 950 | |
@@ -914,8 +957,9 @@ discard block |
||
914 | 957 | // Check which boards you have merge permissions on. |
915 | 958 | $merge_boards = boardsAllowedTo('merge_any'); |
916 | 959 | |
917 | - if (empty($merge_boards)) |
|
918 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
960 | + if (empty($merge_boards)) { |
|
961 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
962 | + } |
|
919 | 963 | |
920 | 964 | // No sense in loading this if you can only merge on this board |
921 | 965 | if (count($merge_boards) > 1 || in_array(0, $merge_boards)) |
@@ -929,8 +973,9 @@ discard block |
||
929 | 973 | ); |
930 | 974 | |
931 | 975 | // Only include these boards in the list (0 means you're an admin') |
932 | - if (!in_array(0, $merge_boards)) |
|
933 | - $options['included_boards'] = $merge_boards; |
|
976 | + if (!in_array(0, $merge_boards)) { |
|
977 | + $options['included_boards'] = $merge_boards; |
|
978 | + } |
|
934 | 979 | |
935 | 980 | $context['merge_categories'] = getBoardList($options); |
936 | 981 | } |
@@ -976,8 +1021,9 @@ discard block |
||
976 | 1021 | } |
977 | 1022 | $smcFunc['db_free_result']($request); |
978 | 1023 | |
979 | - if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) |
|
980 | - fatal_lang_error('merge_need_more_topics'); |
|
1024 | + if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) { |
|
1025 | + fatal_lang_error('merge_need_more_topics'); |
|
1026 | + } |
|
981 | 1027 | |
982 | 1028 | $context['sub_template'] = 'merge'; |
983 | 1029 | } |
@@ -1007,24 +1053,29 @@ discard block |
||
1007 | 1053 | checkSession('request'); |
1008 | 1054 | |
1009 | 1055 | // Handle URLs from MergeIndex. |
1010 | - if (!empty($_GET['from']) && !empty($_GET['to'])) |
|
1011 | - $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
1056 | + if (!empty($_GET['from']) && !empty($_GET['to'])) { |
|
1057 | + $topics = array((int) $_GET['from'], (int) $_GET['to']); |
|
1058 | + } |
|
1012 | 1059 | |
1013 | 1060 | // If we came from a form, the topic IDs came by post. |
1014 | - if (!empty($_POST['topics']) && is_array($_POST['topics'])) |
|
1015 | - $topics = $_POST['topics']; |
|
1061 | + if (!empty($_POST['topics']) && is_array($_POST['topics'])) { |
|
1062 | + $topics = $_POST['topics']; |
|
1063 | + } |
|
1016 | 1064 | |
1017 | 1065 | // There's nothing to merge with just one topic... |
1018 | - if (empty($topics) || !is_array($topics) || count($topics) == 1) |
|
1019 | - fatal_lang_error('merge_need_more_topics'); |
|
1066 | + if (empty($topics) || !is_array($topics) || count($topics) == 1) { |
|
1067 | + fatal_lang_error('merge_need_more_topics'); |
|
1068 | + } |
|
1020 | 1069 | |
1021 | 1070 | // Make sure every topic is numeric, or some nasty things could be done with the DB. |
1022 | - foreach ($topics as $id => $topic) |
|
1023 | - $topics[$id] = (int) $topic; |
|
1071 | + foreach ($topics as $id => $topic) { |
|
1072 | + $topics[$id] = (int) $topic; |
|
1073 | + } |
|
1024 | 1074 | |
1025 | 1075 | // Joy of all joys, make sure they're not messing about with unapproved topics they can't see :P |
1026 | - if ($modSettings['postmod_active']) |
|
1027 | - $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
1076 | + if ($modSettings['postmod_active']) { |
|
1077 | + $can_approve_boards = boardsAllowedTo('approve_posts'); |
|
1078 | + } |
|
1028 | 1079 | |
1029 | 1080 | // Get info about the topics and polls that will be merged. |
1030 | 1081 | $request = $smcFunc['db_query']('', ' |
@@ -1045,8 +1096,9 @@ discard block |
||
1045 | 1096 | 'limit' => count($topics), |
1046 | 1097 | ) |
1047 | 1098 | ); |
1048 | - if ($smcFunc['db_num_rows']($request) < 2) |
|
1049 | - fatal_lang_error('no_topic_id'); |
|
1099 | + if ($smcFunc['db_num_rows']($request) < 2) { |
|
1100 | + fatal_lang_error('no_topic_id'); |
|
1101 | + } |
|
1050 | 1102 | $num_views = 0; |
1051 | 1103 | $is_sticky = 0; |
1052 | 1104 | $boardTotals = array(); |
@@ -1059,34 +1111,38 @@ discard block |
||
1059 | 1111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1060 | 1112 | { |
1061 | 1113 | // Sorry, redirection topics can't be merged |
1062 | - if (!empty($row['id_redirect_topic'])) |
|
1063 | - fatal_lang_error('cannot_merge_redirect', false); |
|
1114 | + if (!empty($row['id_redirect_topic'])) { |
|
1115 | + fatal_lang_error('cannot_merge_redirect', false); |
|
1116 | + } |
|
1064 | 1117 | |
1065 | 1118 | // Make a note for the board counts... |
1066 | - if (!isset($boardTotals[$row['id_board']])) |
|
1067 | - $boardTotals[$row['id_board']] = array( |
|
1119 | + if (!isset($boardTotals[$row['id_board']])) { |
|
1120 | + $boardTotals[$row['id_board']] = array( |
|
1068 | 1121 | 'posts' => 0, |
1069 | 1122 | 'topics' => 0, |
1070 | 1123 | 'unapproved_posts' => 0, |
1071 | 1124 | 'unapproved_topics' => 0 |
1072 | 1125 | ); |
1126 | + } |
|
1073 | 1127 | |
1074 | 1128 | // We can't see unapproved topics here? |
1075 | 1129 | if ($modSettings['postmod_active'] && !$row['approved'] && $can_approve_boards != array(0) && in_array($row['id_board'], $can_approve_boards)) |
1076 | 1130 | { |
1077 | 1131 | unset($topics[$row['id_topic']]); // If we can't see it, we should not merge it and not adjust counts! Instead skip it. |
1078 | 1132 | continue; |
1079 | - }elseif (!$row['approved']) |
|
1080 | - $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
1081 | - else |
|
1082 | - $boardTotals[$row['id_board']]['topics']++; |
|
1133 | + } elseif (!$row['approved']) { |
|
1134 | + $boardTotals[$row['id_board']]['unapproved_topics']++; |
|
1135 | + } else { |
|
1136 | + $boardTotals[$row['id_board']]['topics']++; |
|
1137 | + } |
|
1083 | 1138 | |
1084 | 1139 | $boardTotals[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
1085 | 1140 | $boardTotals[$row['id_board']]['posts'] += $row['num_replies'] + ($row['approved'] ? 1 : 0); |
1086 | 1141 | |
1087 | 1142 | // In the case of making a redirect, the topic count goes up by one due to the redirect topic. |
1088 | - if (isset($_POST['postRedirect'])) |
|
1089 | - $boardTotals[$row['id_board']]['topics']--; |
|
1143 | + if (isset($_POST['postRedirect'])) { |
|
1144 | + $boardTotals[$row['id_board']]['topics']--; |
|
1145 | + } |
|
1090 | 1146 | |
1091 | 1147 | $topic_data[$row['id_topic']] = array( |
1092 | 1148 | 'id' => $row['id_topic'], |
@@ -1112,11 +1168,13 @@ discard block |
||
1112 | 1168 | $boards[] = $row['id_board']; |
1113 | 1169 | |
1114 | 1170 | // If there's no poll, id_poll == 0... |
1115 | - if ($row['id_poll'] > 0) |
|
1116 | - $polls[] = $row['id_poll']; |
|
1171 | + if ($row['id_poll'] > 0) { |
|
1172 | + $polls[] = $row['id_poll']; |
|
1173 | + } |
|
1117 | 1174 | // Store the id_topic with the lowest id_first_msg. |
1118 | - if (empty($firstTopic)) |
|
1119 | - $firstTopic = $row['id_topic']; |
|
1175 | + if (empty($firstTopic)) { |
|
1176 | + $firstTopic = $row['id_topic']; |
|
1177 | + } |
|
1120 | 1178 | |
1121 | 1179 | // Lowest topic id gets selected as surviving topic id. We need to store this board so we can adjust the topic count (This one will not have a redirect topic) |
1122 | 1180 | if ($row['id_topic'] < $lowestTopicId || empty($lowestTopicId)) |
@@ -1130,11 +1188,13 @@ discard block |
||
1130 | 1188 | $smcFunc['db_free_result']($request); |
1131 | 1189 | |
1132 | 1190 | // If we didn't get any topics then they've been messing with unapproved stuff. |
1133 | - if (empty($topic_data)) |
|
1134 | - fatal_lang_error('no_topic_id'); |
|
1191 | + if (empty($topic_data)) { |
|
1192 | + fatal_lang_error('no_topic_id'); |
|
1193 | + } |
|
1135 | 1194 | |
1136 | - if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) |
|
1137 | - $boardTotals[$lowestTopicBoard]['topics']++; |
|
1195 | + if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) { |
|
1196 | + $boardTotals[$lowestTopicBoard]['topics']++; |
|
1197 | + } |
|
1138 | 1198 | |
1139 | 1199 | // Will this be approved? |
1140 | 1200 | $context['is_approved'] = $topic_data[$firstTopic]['approved']; |
@@ -1150,8 +1210,9 @@ discard block |
||
1150 | 1210 | |
1151 | 1211 | // Get the boards a user is allowed to merge in. |
1152 | 1212 | $merge_boards = boardsAllowedTo('merge_any'); |
1153 | - if (empty($merge_boards)) |
|
1154 | - fatal_lang_error('cannot_merge_any', 'user'); |
|
1213 | + if (empty($merge_boards)) { |
|
1214 | + fatal_lang_error('cannot_merge_any', 'user'); |
|
1215 | + } |
|
1155 | 1216 | |
1156 | 1217 | // Make sure they can see all boards.... |
1157 | 1218 | $request = $smcFunc['db_query']('', ' |
@@ -1168,8 +1229,9 @@ discard block |
||
1168 | 1229 | ) |
1169 | 1230 | ); |
1170 | 1231 | // If the number of boards that's in the output isn't exactly the same as we've put in there, you're in trouble. |
1171 | - if ($smcFunc['db_num_rows']($request) != count($boards)) |
|
1172 | - fatal_lang_error('no_board'); |
|
1232 | + if ($smcFunc['db_num_rows']($request) != count($boards)) { |
|
1233 | + fatal_lang_error('no_board'); |
|
1234 | + } |
|
1173 | 1235 | $smcFunc['db_free_result']($request); |
1174 | 1236 | |
1175 | 1237 | if (empty($_REQUEST['sa']) || $_REQUEST['sa'] == 'options') |
@@ -1188,8 +1250,8 @@ discard block |
||
1188 | 1250 | 'limit' => count($polls), |
1189 | 1251 | ) |
1190 | 1252 | ); |
1191 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1192 | - $context['polls'][] = array( |
|
1253 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1254 | + $context['polls'][] = array( |
|
1193 | 1255 | 'id' => $row['id_poll'], |
1194 | 1256 | 'topic' => array( |
1195 | 1257 | 'id' => $row['id_topic'], |
@@ -1198,6 +1260,7 @@ discard block |
||
1198 | 1260 | 'question' => $row['question'], |
1199 | 1261 | 'selected' => $row['id_topic'] == $firstTopic |
1200 | 1262 | ); |
1263 | + } |
|
1201 | 1264 | $smcFunc['db_free_result']($request); |
1202 | 1265 | } |
1203 | 1266 | if (count($boards) > 1) |
@@ -1213,18 +1276,20 @@ discard block |
||
1213 | 1276 | 'limit' => count($boards), |
1214 | 1277 | ) |
1215 | 1278 | ); |
1216 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1217 | - $context['boards'][] = array( |
|
1279 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1280 | + $context['boards'][] = array( |
|
1218 | 1281 | 'id' => $row['id_board'], |
1219 | 1282 | 'name' => $row['name'], |
1220 | 1283 | 'selected' => $row['id_board'] == $topic_data[$firstTopic]['board'] |
1221 | 1284 | ); |
1285 | + } |
|
1222 | 1286 | $smcFunc['db_free_result']($request); |
1223 | 1287 | } |
1224 | 1288 | |
1225 | 1289 | $context['topics'] = $topic_data; |
1226 | - foreach ($topic_data as $id => $topic) |
|
1227 | - $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
1290 | + foreach ($topic_data as $id => $topic) { |
|
1291 | + $context['topics'][$id]['selected'] = $topic['id'] == $firstTopic; |
|
1292 | + } |
|
1228 | 1293 | |
1229 | 1294 | $context['page_title'] = $txt['merge']; |
1230 | 1295 | $context['sub_template'] = 'merge_extra_options'; |
@@ -1233,13 +1298,15 @@ discard block |
||
1233 | 1298 | |
1234 | 1299 | // Determine target board. |
1235 | 1300 | $target_board = count($boards) > 1 ? (int) $_REQUEST['board'] : $boards[0]; |
1236 | - if (!in_array($target_board, $boards)) |
|
1237 | - fatal_lang_error('no_board'); |
|
1301 | + if (!in_array($target_board, $boards)) { |
|
1302 | + fatal_lang_error('no_board'); |
|
1303 | + } |
|
1238 | 1304 | |
1239 | 1305 | // Determine which poll will survive and which polls won't. |
1240 | 1306 | $target_poll = count($polls) > 1 ? (int) $_POST['poll'] : (count($polls) == 1 ? $polls[0] : 0); |
1241 | - if ($target_poll > 0 && !in_array($target_poll, $polls)) |
|
1242 | - fatal_lang_error('no_access', false); |
|
1307 | + if ($target_poll > 0 && !in_array($target_poll, $polls)) { |
|
1308 | + fatal_lang_error('no_access', false); |
|
1309 | + } |
|
1243 | 1310 | $deleted_polls = empty($target_poll) ? $polls : array_diff($polls, array($target_poll)); |
1244 | 1311 | |
1245 | 1312 | // Determine the subject of the newly merged topic - was a custom subject specified? |
@@ -1247,19 +1314,23 @@ discard block |
||
1247 | 1314 | { |
1248 | 1315 | $target_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
1249 | 1316 | // Keep checking the length. |
1250 | - if ($smcFunc['strlen']($target_subject) > 100) |
|
1251 | - $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
1317 | + if ($smcFunc['strlen']($target_subject) > 100) { |
|
1318 | + $target_subject = $smcFunc['substr']($target_subject, 0, 100); |
|
1319 | + } |
|
1252 | 1320 | |
1253 | 1321 | // Nothing left - odd but pick the first topics subject. |
1254 | - if ($target_subject == '') |
|
1255 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
1322 | + if ($target_subject == '') { |
|
1323 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
1324 | + } |
|
1256 | 1325 | } |
1257 | 1326 | // A subject was selected from the list. |
1258 | - elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) |
|
1259 | - $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
1327 | + elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) { |
|
1328 | + $target_subject = $topic_data[(int) $_POST['subject']]['subject']; |
|
1329 | + } |
|
1260 | 1330 | // Nothing worked? Just take the subject of the first message. |
1261 | - else |
|
1262 | - $target_subject = $topic_data[$firstTopic]['subject']; |
|
1331 | + else { |
|
1332 | + $target_subject = $topic_data[$firstTopic]['subject']; |
|
1333 | + } |
|
1263 | 1334 | |
1264 | 1335 | // Get the first and last message and the number of messages.... |
1265 | 1336 | $request = $smcFunc['db_query']('', ' |
@@ -1285,15 +1356,13 @@ discard block |
||
1285 | 1356 | { |
1286 | 1357 | $num_replies = $row['message_count'] - 1; |
1287 | 1358 | $num_unapproved = 0; |
1288 | - } |
|
1289 | - else |
|
1359 | + } else |
|
1290 | 1360 | { |
1291 | 1361 | $topic_approved = 0; |
1292 | 1362 | $num_replies = 0; |
1293 | 1363 | $num_unapproved = $row['message_count']; |
1294 | 1364 | } |
1295 | - } |
|
1296 | - else |
|
1365 | + } else |
|
1297 | 1366 | { |
1298 | 1367 | // If this has a lower first_msg then the first post is not approved and hence the number of replies was wrong! |
1299 | 1368 | if ($first_msg > $row['first_msg']) |
@@ -1339,8 +1408,9 @@ discard block |
||
1339 | 1408 | list ($member_started) = $smcFunc['db_fetch_row']($request); |
1340 | 1409 | list ($member_updated) = $smcFunc['db_fetch_row']($request); |
1341 | 1410 | // First and last message are the same, so only row was returned. |
1342 | - if ($member_updated === NULL) |
|
1343 | - $member_updated = $member_started; |
|
1411 | + if ($member_updated === NULL) { |
|
1412 | + $member_updated = $member_started; |
|
1413 | + } |
|
1344 | 1414 | |
1345 | 1415 | $smcFunc['db_free_result']($request); |
1346 | 1416 | |
@@ -1353,8 +1423,9 @@ discard block |
||
1353 | 1423 | array( |
1354 | 1424 | 'topic_list' => $topics, |
1355 | 1425 | )); |
1356 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
1357 | - $affected_msgs[] = $row[0]; |
|
1426 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
1427 | + $affected_msgs[] = $row[0]; |
|
1428 | + } |
|
1358 | 1429 | $smcFunc['db_free_result']($request); |
1359 | 1430 | |
1360 | 1431 | // Assign the first topic ID to be the merged topic. |
@@ -1432,9 +1503,9 @@ discard block |
||
1432 | 1503 | // Grab the response prefix (like 'Re: ') in the default forum language. |
1433 | 1504 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
1434 | 1505 | { |
1435 | - if ($language === $user_info['language']) |
|
1436 | - $context['response_prefix'] = $txt['response_prefix']; |
|
1437 | - else |
|
1506 | + if ($language === $user_info['language']) { |
|
1507 | + $context['response_prefix'] = $txt['response_prefix']; |
|
1508 | + } else |
|
1438 | 1509 | { |
1439 | 1510 | loadLanguage('index', $language, false); |
1440 | 1511 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1514,8 +1585,9 @@ discard block |
||
1514 | 1585 | if ($smcFunc['db_num_rows']($request) > 0) |
1515 | 1586 | { |
1516 | 1587 | $replaceEntries = array(); |
1517 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1518 | - $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
1588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1589 | + $replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']); |
|
1590 | + } |
|
1519 | 1591 | |
1520 | 1592 | $smcFunc['db_insert']('replace', |
1521 | 1593 | '{db_prefix}log_topics', |
@@ -1552,8 +1624,9 @@ discard block |
||
1552 | 1624 | if ($smcFunc['db_num_rows']($request) > 0) |
1553 | 1625 | { |
1554 | 1626 | $replaceEntries = array(); |
1555 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1556 | - $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
1627 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1628 | + $replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']); |
|
1629 | + } |
|
1557 | 1630 | |
1558 | 1631 | $smcFunc['db_insert']('replace', |
1559 | 1632 | '{db_prefix}log_notify', |
@@ -1728,8 +1801,9 @@ discard block |
||
1728 | 1801 | // If there's a search index that needs updating, update it... |
1729 | 1802 | require_once($sourcedir . '/Search.php'); |
1730 | 1803 | $searchAPI = findSearchAPI(); |
1731 | - if (is_callable(array($searchAPI, 'topicMerge'))) |
|
1732 | - $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
1804 | + if (is_callable(array($searchAPI, 'topicMerge'))) { |
|
1805 | + $searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject)); |
|
1806 | + } |
|
1733 | 1807 | |
1734 | 1808 | // Merging is the sort of thing an external CMS might want to know about |
1735 | 1809 | $merged_topic = array( |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -382,8 +396,7 @@ discard block |
||
382 | 396 | |
383 | 397 | // Put the tags back into the body. |
384 | 398 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
385 | - } |
|
386 | - else |
|
399 | + } else |
|
387 | 400 | { |
388 | 401 | // Just get rid of this evil tag. |
389 | 402 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -396,8 +409,9 @@ discard block |
||
396 | 409 | // Find the position of this again. |
397 | 410 | $start_pos = strpos($text, $matches[0]); |
398 | 411 | $end_pos = false; |
399 | - if ($start_pos === false) |
|
400 | - break; |
|
412 | + if ($start_pos === false) { |
|
413 | + break; |
|
414 | + } |
|
401 | 415 | |
402 | 416 | // This must have an end tag - and we must find the right one. |
403 | 417 | $lower_text = strtolower($text); |
@@ -430,8 +444,9 @@ discard block |
||
430 | 444 | break; |
431 | 445 | } |
432 | 446 | } |
433 | - if ($end_pos === false) |
|
434 | - break; |
|
447 | + if ($end_pos === false) { |
|
448 | + break; |
|
449 | + } |
|
435 | 450 | |
436 | 451 | // Now work out what the attributes are. |
437 | 452 | $attribs = fetchTagAttributes($matches[1]); |
@@ -445,11 +460,11 @@ discard block |
||
445 | 460 | $v = (int) trim($v); |
446 | 461 | $v = empty($v) ? 1 : $v; |
447 | 462 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
463 | + } elseif ($s == 'face') { |
|
464 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
465 | + } elseif ($s == 'color') { |
|
466 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
448 | 467 | } |
449 | - elseif ($s == 'face') |
|
450 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
451 | - elseif ($s == 'color') |
|
452 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
453 | 468 | } |
454 | 469 | |
455 | 470 | // As before add in our tags. |
@@ -457,8 +472,9 @@ discard block |
||
457 | 472 | foreach ($tags as $tag) |
458 | 473 | { |
459 | 474 | $before .= $tag[0]; |
460 | - if (isset($tag[1])) |
|
461 | - $after = $tag[1] . $after; |
|
475 | + if (isset($tag[1])) { |
|
476 | + $after = $tag[1] . $after; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Remove the tag so it's never checked again. |
@@ -469,8 +485,9 @@ discard block |
||
469 | 485 | } |
470 | 486 | |
471 | 487 | // Almost there, just a little more time. |
472 | - if (connection_aborted() && $context['server']['is_apache']) |
|
473 | - @apache_reset_timeout(); |
|
488 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
489 | + @apache_reset_timeout(); |
|
490 | + } |
|
474 | 491 | |
475 | 492 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
476 | 493 | { |
@@ -526,12 +543,13 @@ discard block |
||
526 | 543 | { |
527 | 544 | $inList = true; |
528 | 545 | |
529 | - if ($tag === 'ol') |
|
530 | - $listType = 'decimal'; |
|
531 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
532 | - $listType = $listTypeMapping[$match[1]]; |
|
533 | - else |
|
534 | - $listType = null; |
|
546 | + if ($tag === 'ol') { |
|
547 | + $listType = 'decimal'; |
|
548 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
549 | + $listType = $listTypeMapping[$match[1]]; |
|
550 | + } else { |
|
551 | + $listType = null; |
|
552 | + } |
|
535 | 553 | |
536 | 554 | $listDepth++; |
537 | 555 | |
@@ -595,9 +613,7 @@ discard block |
||
595 | 613 | $parts[$i + 1] = ''; |
596 | 614 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
597 | 615 | $parts[$i + 3] = ''; |
598 | - } |
|
599 | - |
|
600 | - else |
|
616 | + } else |
|
601 | 617 | { |
602 | 618 | // We're in a list item. |
603 | 619 | if ($listDepth > 0) |
@@ -634,9 +650,7 @@ discard block |
||
634 | 650 | $parts[$i + 1] = ''; |
635 | 651 | $parts[$i + 2] = ''; |
636 | 652 | $parts[$i + 3] = ''; |
637 | - } |
|
638 | - |
|
639 | - else |
|
653 | + } else |
|
640 | 654 | { |
641 | 655 | // Remove the trailing breaks from the list item. |
642 | 656 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -674,8 +688,9 @@ discard block |
||
674 | 688 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
675 | 689 | } |
676 | 690 | |
677 | - for ($i = $listDepth; $i > 0; $i--) |
|
678 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
691 | + for ($i = $listDepth; $i > 0; $i--) { |
|
692 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
693 | + } |
|
679 | 694 | |
680 | 695 | } |
681 | 696 | |
@@ -684,8 +699,9 @@ discard block |
||
684 | 699 | { |
685 | 700 | // Find the position of the image. |
686 | 701 | $start_pos = strpos($text, $matches[0]); |
687 | - if ($start_pos === false) |
|
688 | - break; |
|
702 | + if ($start_pos === false) { |
|
703 | + break; |
|
704 | + } |
|
689 | 705 | $end_pos = $start_pos + strlen($matches[0]); |
690 | 706 | |
691 | 707 | $params = ''; |
@@ -694,12 +710,13 @@ discard block |
||
694 | 710 | $attrs = fetchTagAttributes($matches[1]); |
695 | 711 | foreach ($attrs as $attrib => $value) |
696 | 712 | { |
697 | - if (in_array($attrib, array('width', 'height'))) |
|
698 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
699 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
700 | - $params .= ' alt=' . trim($value); |
|
701 | - elseif ($attrib == 'src') |
|
702 | - $src = trim($value); |
|
713 | + if (in_array($attrib, array('width', 'height'))) { |
|
714 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
715 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
716 | + $params .= ' alt=' . trim($value); |
|
717 | + } elseif ($attrib == 'src') { |
|
718 | + $src = trim($value); |
|
719 | + } |
|
703 | 720 | } |
704 | 721 | |
705 | 722 | $tag = ''; |
@@ -710,10 +727,11 @@ discard block |
||
710 | 727 | { |
711 | 728 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
712 | 729 | |
713 | - if (substr($src, 0, 1) === '/') |
|
714 | - $src = $baseURL . $src; |
|
715 | - else |
|
716 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
730 | + if (substr($src, 0, 1) === '/') { |
|
731 | + $src = $baseURL . $src; |
|
732 | + } else { |
|
733 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
734 | + } |
|
717 | 735 | } |
718 | 736 | |
719 | 737 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -891,20 +909,23 @@ discard block |
||
891 | 909 | }, |
892 | 910 | ); |
893 | 911 | |
894 | - foreach ($tags as $tag => $replace) |
|
895 | - $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + foreach ($tags as $tag => $replace) { |
|
913 | + $text = preg_replace_callback($tag, $replace, $text); |
|
914 | + } |
|
896 | 915 | |
897 | 916 | // Please give us just a little more time. |
898 | - if (connection_aborted() && $context['server']['is_apache']) |
|
899 | - @apache_reset_timeout(); |
|
917 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
918 | + @apache_reset_timeout(); |
|
919 | + } |
|
900 | 920 | |
901 | 921 | // What about URL's - the pain in the ass of the tag world. |
902 | 922 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
903 | 923 | { |
904 | 924 | // Find the position of the URL. |
905 | 925 | $start_pos = strpos($text, $matches[0]); |
906 | - if ($start_pos === false) |
|
907 | - break; |
|
926 | + if ($start_pos === false) { |
|
927 | + break; |
|
928 | + } |
|
908 | 929 | $end_pos = $start_pos + strlen($matches[0]); |
909 | 930 | |
910 | 931 | $tag_type = 'url'; |
@@ -918,8 +939,9 @@ discard block |
||
918 | 939 | $href = trim($value); |
919 | 940 | |
920 | 941 | // Are we dealing with an FTP link? |
921 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
922 | - $tag_type = 'ftp'; |
|
942 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
943 | + $tag_type = 'ftp'; |
|
944 | + } |
|
923 | 945 | |
924 | 946 | // Or is this a link to an email address? |
925 | 947 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -933,28 +955,31 @@ discard block |
||
933 | 955 | { |
934 | 956 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
935 | 957 | |
936 | - if (substr($href, 0, 1) === '/') |
|
937 | - $href = $baseURL . $href; |
|
938 | - else |
|
939 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
958 | + if (substr($href, 0, 1) === '/') { |
|
959 | + $href = $baseURL . $href; |
|
960 | + } else { |
|
961 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
962 | + } |
|
940 | 963 | } |
941 | 964 | } |
942 | 965 | |
943 | 966 | // External URL? |
944 | 967 | if ($attrib == 'target' && $tag_type == 'url') |
945 | 968 | { |
946 | - if (trim($value) == '_blank') |
|
947 | - $tag_type == 'iurl'; |
|
969 | + if (trim($value) == '_blank') { |
|
970 | + $tag_type == 'iurl'; |
|
971 | + } |
|
948 | 972 | } |
949 | 973 | } |
950 | 974 | |
951 | 975 | $tag = ''; |
952 | 976 | if ($href != '') |
953 | 977 | { |
954 | - if ($matches[2] == $href) |
|
955 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
956 | - else |
|
957 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
978 | + if ($matches[2] == $href) { |
|
979 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
980 | + } else { |
|
981 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
982 | + } |
|
958 | 983 | } |
959 | 984 | |
960 | 985 | // Replace the tag |
@@ -993,17 +1018,18 @@ discard block |
||
993 | 1018 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
994 | 1019 | if ($text[$i] == '=') |
995 | 1020 | { |
996 | - if ($tag_state == 0) |
|
997 | - $tag_state = 1; |
|
998 | - elseif ($tag_state == 2) |
|
999 | - $value .= '='; |
|
1021 | + if ($tag_state == 0) { |
|
1022 | + $tag_state = 1; |
|
1023 | + } elseif ($tag_state == 2) { |
|
1024 | + $value .= '='; |
|
1025 | + } |
|
1000 | 1026 | } |
1001 | 1027 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1002 | 1028 | elseif ($text[$i] == ' ') |
1003 | 1029 | { |
1004 | - if ($tag_state == 2) |
|
1005 | - $value .= ' '; |
|
1006 | - elseif ($tag_state == 1) |
|
1030 | + if ($tag_state == 2) { |
|
1031 | + $value .= ' '; |
|
1032 | + } elseif ($tag_state == 1) |
|
1007 | 1033 | { |
1008 | 1034 | $attribs[$key] = $value; |
1009 | 1035 | $key = $value = ''; |
@@ -1014,24 +1040,27 @@ discard block |
||
1014 | 1040 | elseif ($text[$i] == '"') |
1015 | 1041 | { |
1016 | 1042 | // Must be either going into or out of a string. |
1017 | - if ($tag_state == 1) |
|
1018 | - $tag_state = 2; |
|
1019 | - else |
|
1020 | - $tag_state = 1; |
|
1043 | + if ($tag_state == 1) { |
|
1044 | + $tag_state = 2; |
|
1045 | + } else { |
|
1046 | + $tag_state = 1; |
|
1047 | + } |
|
1021 | 1048 | } |
1022 | 1049 | // Otherwise it's fine. |
1023 | 1050 | else |
1024 | 1051 | { |
1025 | - if ($tag_state == 0) |
|
1026 | - $key .= $text[$i]; |
|
1027 | - else |
|
1028 | - $value .= $text[$i]; |
|
1052 | + if ($tag_state == 0) { |
|
1053 | + $key .= $text[$i]; |
|
1054 | + } else { |
|
1055 | + $value .= $text[$i]; |
|
1056 | + } |
|
1029 | 1057 | } |
1030 | 1058 | } |
1031 | 1059 | |
1032 | 1060 | // Anything left? |
1033 | - if ($key != '' && $value != '') |
|
1034 | - $attribs[$key] = $value; |
|
1061 | + if ($key != '' && $value != '') { |
|
1062 | + $attribs[$key] = $value; |
|
1063 | + } |
|
1035 | 1064 | |
1036 | 1065 | return $attribs; |
1037 | 1066 | } |
@@ -1047,15 +1076,17 @@ discard block |
||
1047 | 1076 | global $modSettings; |
1048 | 1077 | |
1049 | 1078 | // Don't care about the texts that are too short. |
1050 | - if (strlen($text) < 3) |
|
1051 | - return $text; |
|
1079 | + if (strlen($text) < 3) { |
|
1080 | + return $text; |
|
1081 | + } |
|
1052 | 1082 | |
1053 | 1083 | // A list of tags that's disabled by the admin. |
1054 | 1084 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1055 | 1085 | |
1056 | 1086 | // Add flash if it's disabled as embedded tag. |
1057 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1058 | - $disabled['flash'] = true; |
|
1087 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1088 | + $disabled['flash'] = true; |
|
1089 | + } |
|
1059 | 1090 | |
1060 | 1091 | // Get a list of all the tags that are not disabled. |
1061 | 1092 | $all_tags = parse_bbc(false); |
@@ -1063,10 +1094,12 @@ discard block |
||
1063 | 1094 | $self_closing_tags = array(); |
1064 | 1095 | foreach ($all_tags as $tag) |
1065 | 1096 | { |
1066 | - if (!isset($disabled[$tag['tag']])) |
|
1067 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1068 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1069 | - $self_closing_tags[] = $tag['tag']; |
|
1097 | + if (!isset($disabled[$tag['tag']])) { |
|
1098 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1099 | + } |
|
1100 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1101 | + $self_closing_tags[] = $tag['tag']; |
|
1102 | + } |
|
1070 | 1103 | } |
1071 | 1104 | |
1072 | 1105 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1093,16 +1126,19 @@ discard block |
||
1093 | 1126 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1094 | 1127 | |
1095 | 1128 | // We're closing the exact same tag that we opened. |
1096 | - if ($isClosingTag && $insideTag === $tagName) |
|
1097 | - $insideTag = null; |
|
1129 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1130 | + $insideTag = null; |
|
1131 | + } |
|
1098 | 1132 | |
1099 | 1133 | // We're opening a tag and we're not yet inside one either |
1100 | - elseif (!$isClosingTag && $insideTag === null) |
|
1101 | - $insideTag = $tagName; |
|
1134 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1135 | + $insideTag = $tagName; |
|
1136 | + } |
|
1102 | 1137 | |
1103 | 1138 | // In all other cases, this tag must be invalid |
1104 | - else |
|
1105 | - unset($matches[$i]); |
|
1139 | + else { |
|
1140 | + unset($matches[$i]); |
|
1141 | + } |
|
1106 | 1142 | } |
1107 | 1143 | |
1108 | 1144 | // The next one is gonna be the other one. |
@@ -1110,8 +1146,9 @@ discard block |
||
1110 | 1146 | } |
1111 | 1147 | |
1112 | 1148 | // We're still inside a tag and had no chance for closure? |
1113 | - if ($insideTag !== null) |
|
1114 | - $matches[] = '[/' . $insideTag . ']'; |
|
1149 | + if ($insideTag !== null) { |
|
1150 | + $matches[] = '[/' . $insideTag . ']'; |
|
1151 | + } |
|
1115 | 1152 | |
1116 | 1153 | // And a complete text string again. |
1117 | 1154 | $text = implode('', $matches); |
@@ -1120,8 +1157,9 @@ discard block |
||
1120 | 1157 | // Quickly remove any tags which are back to back. |
1121 | 1158 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1122 | 1159 | $lastlen = 0; |
1123 | - while (strlen($text) !== $lastlen) |
|
1124 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1160 | + while (strlen($text) !== $lastlen) { |
|
1161 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1162 | + } |
|
1125 | 1163 | |
1126 | 1164 | // Need to sort the tags my name length. |
1127 | 1165 | uksort($valid_tags, 'sort_array_length'); |
@@ -1158,8 +1196,9 @@ discard block |
||
1158 | 1196 | $isCompetingTag = in_array($tag, $competing_tags); |
1159 | 1197 | |
1160 | 1198 | // Check if this might be one of those cleaned out tags. |
1161 | - if ($tag === '') |
|
1162 | - continue; |
|
1199 | + if ($tag === '') { |
|
1200 | + continue; |
|
1201 | + } |
|
1163 | 1202 | |
1164 | 1203 | // Special case: inside [code] blocks any code is left untouched. |
1165 | 1204 | elseif ($tag === 'code') |
@@ -1170,8 +1209,9 @@ discard block |
||
1170 | 1209 | $inCode = false; |
1171 | 1210 | |
1172 | 1211 | // Reopen tags that were closed before the code block. |
1173 | - if (!empty($inlineElements)) |
|
1174 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1212 | + if (!empty($inlineElements)) { |
|
1213 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1214 | + } |
|
1175 | 1215 | } |
1176 | 1216 | |
1177 | 1217 | // We're outside a coding and nobbc block and opening it. |
@@ -1200,8 +1240,9 @@ discard block |
||
1200 | 1240 | $inNoBbc = false; |
1201 | 1241 | |
1202 | 1242 | // Some inline elements might've been closed that need reopening. |
1203 | - if (!empty($inlineElements)) |
|
1204 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1243 | + if (!empty($inlineElements)) { |
|
1244 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1245 | + } |
|
1205 | 1246 | } |
1206 | 1247 | |
1207 | 1248 | // We're outside a nobbc and coding block and opening it. |
@@ -1221,8 +1262,9 @@ discard block |
||
1221 | 1262 | } |
1222 | 1263 | |
1223 | 1264 | // So, we're inside one of the special blocks: ignore any tag. |
1224 | - elseif ($inCode || $inNoBbc) |
|
1225 | - continue; |
|
1265 | + elseif ($inCode || $inNoBbc) { |
|
1266 | + continue; |
|
1267 | + } |
|
1226 | 1268 | |
1227 | 1269 | // We're dealing with an opening tag. |
1228 | 1270 | if ($isOpeningTag) |
@@ -1263,8 +1305,9 @@ discard block |
||
1263 | 1305 | if ($parts[$j + 3] === $tag) |
1264 | 1306 | { |
1265 | 1307 | // If it's an opening tag, increase the level. |
1266 | - if ($parts[$j + 2] === '') |
|
1267 | - $curLevel++; |
|
1308 | + if ($parts[$j + 2] === '') { |
|
1309 | + $curLevel++; |
|
1310 | + } |
|
1268 | 1311 | |
1269 | 1312 | // A closing tag, decrease the level. |
1270 | 1313 | else |
@@ -1287,13 +1330,15 @@ discard block |
||
1287 | 1330 | { |
1288 | 1331 | if ($isCompetingTag) |
1289 | 1332 | { |
1290 | - if (!isset($competingElements[$tag])) |
|
1291 | - $competingElements[$tag] = array(); |
|
1333 | + if (!isset($competingElements[$tag])) { |
|
1334 | + $competingElements[$tag] = array(); |
|
1335 | + } |
|
1292 | 1336 | |
1293 | 1337 | $competingElements[$tag][] = $parts[$i + 4]; |
1294 | 1338 | |
1295 | - if (count($competingElements[$tag]) > 1) |
|
1296 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1339 | + if (count($competingElements[$tag]) > 1) { |
|
1340 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1341 | + } |
|
1297 | 1342 | } |
1298 | 1343 | |
1299 | 1344 | $inlineElements[$elementContent] = $tag; |
@@ -1314,15 +1359,17 @@ discard block |
||
1314 | 1359 | $addClosingTags = array(); |
1315 | 1360 | while ($element = array_pop($blockElements)) |
1316 | 1361 | { |
1317 | - if ($element === $tag) |
|
1318 | - break; |
|
1362 | + if ($element === $tag) { |
|
1363 | + break; |
|
1364 | + } |
|
1319 | 1365 | |
1320 | 1366 | // Still a block tag was open not equal to this tag. |
1321 | 1367 | $addClosingTags[] = $element['type']; |
1322 | 1368 | } |
1323 | 1369 | |
1324 | - if (!empty($addClosingTags)) |
|
1325 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1370 | + if (!empty($addClosingTags)) { |
|
1371 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1372 | + } |
|
1326 | 1373 | |
1327 | 1374 | // Apparently the closing tag was not found on the stack. |
1328 | 1375 | if (!is_string($element) || $element !== $tag) |
@@ -1332,8 +1379,7 @@ discard block |
||
1332 | 1379 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1333 | 1380 | continue; |
1334 | 1381 | } |
1335 | - } |
|
1336 | - else |
|
1382 | + } else |
|
1337 | 1383 | { |
1338 | 1384 | // Get rid of this closing tag! |
1339 | 1385 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1362,53 +1408,62 @@ discard block |
||
1362 | 1408 | unset($inlineElements[$tagContentToBeClosed]); |
1363 | 1409 | |
1364 | 1410 | // Was this the tag we were looking for? |
1365 | - if ($tagToBeClosed === $tag) |
|
1366 | - break; |
|
1411 | + if ($tagToBeClosed === $tag) { |
|
1412 | + break; |
|
1413 | + } |
|
1367 | 1414 | |
1368 | 1415 | // Nope, close it and look further! |
1369 | - else |
|
1370 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1416 | + else { |
|
1417 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1418 | + } |
|
1371 | 1419 | } |
1372 | 1420 | |
1373 | 1421 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1374 | 1422 | { |
1375 | 1423 | array_pop($competingElements[$tag]); |
1376 | 1424 | |
1377 | - if (count($competingElements[$tag]) > 0) |
|
1378 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1425 | + if (count($competingElements[$tag]) > 0) { |
|
1426 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1427 | + } |
|
1379 | 1428 | } |
1380 | 1429 | } |
1381 | 1430 | |
1382 | 1431 | // Unexpected closing tag, ex-ter-mi-nate. |
1383 | - else |
|
1384 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1432 | + else { |
|
1433 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1434 | + } |
|
1385 | 1435 | } |
1386 | 1436 | } |
1387 | 1437 | } |
1388 | 1438 | |
1389 | 1439 | // Close the code tags. |
1390 | - if ($inCode) |
|
1391 | - $parts[$i] .= '[/code]'; |
|
1440 | + if ($inCode) { |
|
1441 | + $parts[$i] .= '[/code]'; |
|
1442 | + } |
|
1392 | 1443 | |
1393 | 1444 | // The same for nobbc tags. |
1394 | - elseif ($inNoBbc) |
|
1395 | - $parts[$i] .= '[/nobbc]'; |
|
1445 | + elseif ($inNoBbc) { |
|
1446 | + $parts[$i] .= '[/nobbc]'; |
|
1447 | + } |
|
1396 | 1448 | |
1397 | 1449 | // Still inline tags left unclosed? Close them now, better late than never. |
1398 | - elseif (!empty($inlineElements)) |
|
1399 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1450 | + elseif (!empty($inlineElements)) { |
|
1451 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1452 | + } |
|
1400 | 1453 | |
1401 | 1454 | // Now close the block elements. |
1402 | - if (!empty($blockElements)) |
|
1403 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1455 | + if (!empty($blockElements)) { |
|
1456 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1457 | + } |
|
1404 | 1458 | |
1405 | 1459 | $text = implode('', $parts); |
1406 | 1460 | } |
1407 | 1461 | |
1408 | 1462 | // Final clean up of back to back tags. |
1409 | 1463 | $lastlen = 0; |
1410 | - while (strlen($text) !== $lastlen) |
|
1411 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1464 | + while (strlen($text) !== $lastlen) { |
|
1465 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1466 | + } |
|
1412 | 1467 | |
1413 | 1468 | return $text; |
1414 | 1469 | } |
@@ -1437,22 +1492,25 @@ discard block |
||
1437 | 1492 | $context['template_layers'] = array(); |
1438 | 1493 | // Lets make sure we aren't going to output anything nasty. |
1439 | 1494 | @ob_end_clean(); |
1440 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1441 | - @ob_start('ob_gzhandler'); |
|
1442 | - else |
|
1443 | - @ob_start(); |
|
1495 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1496 | + @ob_start('ob_gzhandler'); |
|
1497 | + } else { |
|
1498 | + @ob_start(); |
|
1499 | + } |
|
1444 | 1500 | |
1445 | 1501 | // If we don't have any locale better avoid broken js |
1446 | - if (empty($txt['lang_locale'])) |
|
1447 | - die(); |
|
1502 | + if (empty($txt['lang_locale'])) { |
|
1503 | + die(); |
|
1504 | + } |
|
1448 | 1505 | |
1449 | 1506 | $file_data = '(function ($) { |
1450 | 1507 | \'use strict\'; |
1451 | 1508 | |
1452 | 1509 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
1453 | - foreach ($editortxt as $key => $val) |
|
1454 | - $file_data .= ' |
|
1510 | + foreach ($editortxt as $key => $val) { |
|
1511 | + $file_data .= ' |
|
1455 | 1512 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
1513 | + } |
|
1456 | 1514 | |
1457 | 1515 | $file_data .= ' |
1458 | 1516 | dateFormat: "day.month.year" |
@@ -1520,8 +1578,9 @@ discard block |
||
1520 | 1578 | ) |
1521 | 1579 | ); |
1522 | 1580 | $icon_data = array(); |
1523 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1524 | - $icon_data[] = $row; |
|
1581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1582 | + $icon_data[] = $row; |
|
1583 | + } |
|
1525 | 1584 | $smcFunc['db_free_result']($request); |
1526 | 1585 | |
1527 | 1586 | $icons = array(); |
@@ -1536,9 +1595,9 @@ discard block |
||
1536 | 1595 | } |
1537 | 1596 | |
1538 | 1597 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1598 | + } else { |
|
1599 | + $icons = $temp; |
|
1539 | 1600 | } |
1540 | - else |
|
1541 | - $icons = $temp; |
|
1542 | 1601 | } |
1543 | 1602 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1544 | 1603 | |
@@ -1579,8 +1638,9 @@ discard block |
||
1579 | 1638 | { |
1580 | 1639 | // Some general stuff. |
1581 | 1640 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1582 | - if (!empty($context['drafts_autosave'])) |
|
1583 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + if (!empty($context['drafts_autosave'])) { |
|
1642 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1643 | + } |
|
1584 | 1644 | |
1585 | 1645 | // This really has some WYSIWYG stuff. |
1586 | 1646 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1598 | 1658 | // editor language file |
1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + } |
|
1601 | 1662 | |
1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')]; |
1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
1606 | 1667 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
1607 | 1668 | |
1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
1609 | - if (!isset($_REQUEST['xml'])) |
|
1610 | - $context['insert_after_template'] .= ' |
|
1670 | + if (!isset($_REQUEST['xml'])) { |
|
1671 | + $context['insert_after_template'] .= ' |
|
1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
1613 | 1674 | </form>'; |
1675 | + } |
|
1614 | 1676 | } |
1615 | 1677 | } |
1616 | 1678 | |
@@ -1767,10 +1829,12 @@ discard block |
||
1767 | 1829 | |
1768 | 1830 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1769 | 1831 | $disabled_tags = array(); |
1770 | - if (!empty($modSettings['disabledBBC'])) |
|
1771 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1772 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1773 | - $disabled_tags[] = 'flash'; |
|
1832 | + if (!empty($modSettings['disabledBBC'])) { |
|
1833 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1834 | + } |
|
1835 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1836 | + $disabled_tags[] = 'flash'; |
|
1837 | + } |
|
1774 | 1838 | |
1775 | 1839 | foreach ($disabled_tags as $tag) |
1776 | 1840 | { |
@@ -1780,9 +1844,10 @@ discard block |
||
1780 | 1844 | $context['disabled_tags']['orderedlist'] = true; |
1781 | 1845 | } |
1782 | 1846 | |
1783 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1784 | - if ($tag === $thisTag) |
|
1847 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1848 | + if ($tag === $thisTag) |
|
1785 | 1849 | $context['disabled_tags'][$tagNameBBC] = true; |
1850 | + } |
|
1786 | 1851 | |
1787 | 1852 | $context['disabled_tags'][trim($tag)] = true; |
1788 | 1853 | } |
@@ -1792,19 +1857,21 @@ discard block |
||
1792 | 1857 | $context['bbc_toolbar'] = array(); |
1793 | 1858 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1794 | 1859 | { |
1795 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1796 | - $context['bbc_toolbar'][$row] = array(); |
|
1860 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1861 | + $context['bbc_toolbar'][$row] = array(); |
|
1862 | + } |
|
1797 | 1863 | $tagsRow = array(); |
1798 | 1864 | foreach ($tagRow as $tag) |
1799 | 1865 | { |
1800 | 1866 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
1801 | 1867 | { |
1802 | 1868 | $tagsRow[] = $tag['code']; |
1803 | - if (isset($tag['image'])) |
|
1804 | - $bbcodes_styles .= ' |
|
1869 | + if (isset($tag['image'])) { |
|
1870 | + $bbcodes_styles .= ' |
|
1805 | 1871 | .sceditor-button-' . $tag['code'] . ' div { |
1806 | 1872 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
1807 | 1873 | }'; |
1874 | + } |
|
1808 | 1875 | if (isset($tag['before'])) |
1809 | 1876 | { |
1810 | 1877 | $context['bbcodes_handlers'] .= ' |
@@ -1818,8 +1885,7 @@ discard block |
||
1818 | 1885 | });'; |
1819 | 1886 | } |
1820 | 1887 | |
1821 | - } |
|
1822 | - else |
|
1888 | + } else |
|
1823 | 1889 | { |
1824 | 1890 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1825 | 1891 | $tagsRow = array(); |
@@ -1830,14 +1896,16 @@ discard block |
||
1830 | 1896 | { |
1831 | 1897 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1832 | 1898 | $tagsRow = array(); |
1833 | - if (!isset($context['disabled_tags']['font'])) |
|
1834 | - $tagsRow[] = 'font'; |
|
1835 | - if (!isset($context['disabled_tags']['size'])) |
|
1836 | - $tagsRow[] = 'size'; |
|
1837 | - if (!isset($context['disabled_tags']['color'])) |
|
1838 | - $tagsRow[] = 'color'; |
|
1839 | - } |
|
1840 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1899 | + if (!isset($context['disabled_tags']['font'])) { |
|
1900 | + $tagsRow[] = 'font'; |
|
1901 | + } |
|
1902 | + if (!isset($context['disabled_tags']['size'])) { |
|
1903 | + $tagsRow[] = 'size'; |
|
1904 | + } |
|
1905 | + if (!isset($context['disabled_tags']['color'])) { |
|
1906 | + $tagsRow[] = 'color'; |
|
1907 | + } |
|
1908 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1841 | 1909 | { |
1842 | 1910 | $tmp = array(); |
1843 | 1911 | $tagsRow[] = 'removeformat'; |
@@ -1848,13 +1916,15 @@ discard block |
||
1848 | 1916 | } |
1849 | 1917 | } |
1850 | 1918 | |
1851 | - if (!empty($tagsRow)) |
|
1852 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1919 | + if (!empty($tagsRow)) { |
|
1920 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1921 | + } |
|
1853 | 1922 | } |
1854 | - if (!empty($bbcodes_styles)) |
|
1855 | - $context['html_headers'] .= ' |
|
1923 | + if (!empty($bbcodes_styles)) { |
|
1924 | + $context['html_headers'] .= ' |
|
1856 | 1925 | <style>' . $bbcodes_styles . ' |
1857 | 1926 | </style>'; |
1927 | + } |
|
1858 | 1928 | } |
1859 | 1929 | |
1860 | 1930 | // Initialize smiley array... if not loaded before. |
@@ -1866,8 +1936,8 @@ discard block |
||
1866 | 1936 | ); |
1867 | 1937 | |
1868 | 1938 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1869 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1870 | - $context['smileys']['postform'][] = array( |
|
1939 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1940 | + $context['smileys']['postform'][] = array( |
|
1871 | 1941 | 'smileys' => array( |
1872 | 1942 | array( |
1873 | 1943 | 'code' => ':)', |
@@ -1953,7 +2023,7 @@ discard block |
||
1953 | 2023 | ), |
1954 | 2024 | 'isLast' => true, |
1955 | 2025 | ); |
1956 | - elseif ($user_info['smiley_set'] != 'none') |
|
2026 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1957 | 2027 | { |
1958 | 2028 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1959 | 2029 | { |
@@ -1976,17 +2046,19 @@ discard block |
||
1976 | 2046 | |
1977 | 2047 | foreach ($context['smileys'] as $section => $smileyRows) |
1978 | 2048 | { |
1979 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
1980 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2049 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2050 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2051 | + } |
|
1981 | 2052 | |
1982 | - if (!empty($smileyRows)) |
|
1983 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2053 | + if (!empty($smileyRows)) { |
|
2054 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2055 | + } |
|
1984 | 2056 | } |
1985 | 2057 | |
1986 | 2058 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2059 | + } else { |
|
2060 | + $context['smileys'] = $temp; |
|
1987 | 2061 | } |
1988 | - else |
|
1989 | - $context['smileys'] = $temp; |
|
1990 | 2062 | } |
1991 | 2063 | } |
1992 | 2064 | |
@@ -2012,8 +2084,9 @@ discard block |
||
2012 | 2084 | loadTemplate('GenericControls'); |
2013 | 2085 | |
2014 | 2086 | // Some javascript ma'am? |
2015 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2016 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2087 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2088 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2089 | + } |
|
2017 | 2090 | |
2018 | 2091 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2019 | 2092 | |
@@ -2026,8 +2099,8 @@ discard block |
||
2026 | 2099 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2027 | 2100 | |
2028 | 2101 | // Log this into our collection. |
2029 | - if ($isNew) |
|
2030 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2102 | + if ($isNew) { |
|
2103 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2031 | 2104 | 'id' => $verificationOptions['id'], |
2032 | 2105 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2033 | 2106 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2038,13 +2111,15 @@ discard block |
||
2038 | 2111 | 'questions' => array(), |
2039 | 2112 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2040 | 2113 | ); |
2114 | + } |
|
2041 | 2115 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2042 | 2116 | |
2043 | 2117 | // Is there actually going to be anything? |
2044 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2045 | - return false; |
|
2046 | - elseif (!$isNew && !$do_test) |
|
2047 | - return true; |
|
2118 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2119 | + return false; |
|
2120 | + } elseif (!$isNew && !$do_test) { |
|
2121 | + return true; |
|
2122 | + } |
|
2048 | 2123 | |
2049 | 2124 | // Sanitize reCAPTCHA fields? |
2050 | 2125 | if ($thisVerification['can_recaptcha']) |
@@ -2057,11 +2132,12 @@ discard block |
||
2057 | 2132 | } |
2058 | 2133 | |
2059 | 2134 | // Add javascript for the object. |
2060 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2061 | - $context['insert_after_template'] .= ' |
|
2135 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2136 | + $context['insert_after_template'] .= ' |
|
2062 | 2137 | <script> |
2063 | 2138 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2064 | 2139 | </script>'; |
2140 | + } |
|
2065 | 2141 | |
2066 | 2142 | // If we want questions do we have a cache of all the IDs? |
2067 | 2143 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2084,8 +2160,9 @@ discard block |
||
2084 | 2160 | unset ($row['id_question']); |
2085 | 2161 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2086 | 2162 | $row['answers'] = smf_json_decode($row['answers'], true); |
2087 | - foreach ($row['answers'] as $k => $v) |
|
2088 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2163 | + foreach ($row['answers'] as $k => $v) { |
|
2164 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2165 | + } |
|
2089 | 2166 | |
2090 | 2167 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2091 | 2168 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2096,35 +2173,42 @@ discard block |
||
2096 | 2173 | } |
2097 | 2174 | } |
2098 | 2175 | |
2099 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2100 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2176 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2177 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2178 | + } |
|
2101 | 2179 | |
2102 | 2180 | // Do we need to refresh the verification? |
2103 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2104 | - $force_refresh = true; |
|
2105 | - else |
|
2106 | - $force_refresh = false; |
|
2181 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2182 | + $force_refresh = true; |
|
2183 | + } else { |
|
2184 | + $force_refresh = false; |
|
2185 | + } |
|
2107 | 2186 | |
2108 | 2187 | // This can also force a fresh, although unlikely. |
2109 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2110 | - $force_refresh = true; |
|
2188 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2189 | + $force_refresh = true; |
|
2190 | + } |
|
2111 | 2191 | |
2112 | 2192 | $verification_errors = array(); |
2113 | 2193 | // Start with any testing. |
2114 | 2194 | if ($do_test) |
2115 | 2195 | { |
2116 | 2196 | // This cannot happen! |
2117 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2118 | - fatal_lang_error('no_access', false); |
|
2197 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2198 | + fatal_lang_error('no_access', false); |
|
2199 | + } |
|
2119 | 2200 | // ... nor this! |
2120 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2121 | - fatal_lang_error('no_access', false); |
|
2201 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2202 | + fatal_lang_error('no_access', false); |
|
2203 | + } |
|
2122 | 2204 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2123 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2124 | - fatal_lang_error('no_access', false); |
|
2205 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2206 | + fatal_lang_error('no_access', false); |
|
2207 | + } |
|
2125 | 2208 | // While we're here, did the user do something bad? |
2126 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2127 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2209 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2210 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2211 | + } |
|
2128 | 2212 | |
2129 | 2213 | if ($thisVerification['can_recaptcha']) |
2130 | 2214 | { |
@@ -2135,22 +2219,25 @@ discard block |
||
2135 | 2219 | { |
2136 | 2220 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2137 | 2221 | |
2138 | - if (!$resp->isSuccess()) |
|
2139 | - $verification_errors[] = 'wrong_verification_code'; |
|
2222 | + if (!$resp->isSuccess()) { |
|
2223 | + $verification_errors[] = 'wrong_verification_code'; |
|
2224 | + } |
|
2225 | + } else { |
|
2226 | + $verification_errors[] = 'wrong_verification_code'; |
|
2140 | 2227 | } |
2141 | - else |
|
2142 | - $verification_errors[] = 'wrong_verification_code'; |
|
2143 | 2228 | } |
2144 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2145 | - $verification_errors[] = 'wrong_verification_code'; |
|
2229 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2230 | + $verification_errors[] = 'wrong_verification_code'; |
|
2231 | + } |
|
2146 | 2232 | if ($thisVerification['number_questions']) |
2147 | 2233 | { |
2148 | 2234 | $incorrectQuestions = array(); |
2149 | 2235 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2150 | 2236 | { |
2151 | 2237 | // We don't have this question any more, thus no answers. |
2152 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2153 | - continue; |
|
2238 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2239 | + continue; |
|
2240 | + } |
|
2154 | 2241 | // This is quite complex. We have our question but it might have multiple answers. |
2155 | 2242 | // First, did they actually answer this question? |
2156 | 2243 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2162,24 +2249,28 @@ discard block |
||
2162 | 2249 | else |
2163 | 2250 | { |
2164 | 2251 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2165 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2166 | - $incorrectQuestions[] = $q; |
|
2252 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2253 | + $incorrectQuestions[] = $q; |
|
2254 | + } |
|
2167 | 2255 | } |
2168 | 2256 | } |
2169 | 2257 | |
2170 | - if (!empty($incorrectQuestions)) |
|
2171 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2258 | + if (!empty($incorrectQuestions)) { |
|
2259 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2260 | + } |
|
2172 | 2261 | } |
2173 | 2262 | } |
2174 | 2263 | |
2175 | 2264 | // Any errors means we refresh potentially. |
2176 | 2265 | if (!empty($verification_errors)) |
2177 | 2266 | { |
2178 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2179 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2267 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2268 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2269 | + } |
|
2180 | 2270 | // Too many errors? |
2181 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2182 | - $force_refresh = true; |
|
2271 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2272 | + $force_refresh = true; |
|
2273 | + } |
|
2183 | 2274 | |
2184 | 2275 | // Keep a track of these. |
2185 | 2276 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2212,8 +2303,9 @@ discard block |
||
2212 | 2303 | // Are we overriding the range? |
2213 | 2304 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2214 | 2305 | |
2215 | - for ($i = 0; $i < 6; $i++) |
|
2216 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2306 | + for ($i = 0; $i < 6; $i++) { |
|
2307 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2308 | + } |
|
2217 | 2309 | } |
2218 | 2310 | |
2219 | 2311 | // Getting some new questions? |
@@ -2221,8 +2313,9 @@ discard block |
||
2221 | 2313 | { |
2222 | 2314 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2223 | 2315 | $possible_langs = array(); |
2224 | - if (isset($_SESSION['language'])) |
|
2225 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2316 | + if (isset($_SESSION['language'])) { |
|
2317 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2318 | + } |
|
2226 | 2319 | if (!empty($user_info['language'])); |
2227 | 2320 | $possible_langs[] = $user_info['language']; |
2228 | 2321 | $possible_langs[] = $language; |
@@ -2241,8 +2334,7 @@ discard block |
||
2241 | 2334 | } |
2242 | 2335 | } |
2243 | 2336 | } |
2244 | - } |
|
2245 | - else |
|
2337 | + } else |
|
2246 | 2338 | { |
2247 | 2339 | // Same questions as before. |
2248 | 2340 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2252,8 +2344,9 @@ discard block |
||
2252 | 2344 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2253 | 2345 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2254 | 2346 | { |
2255 | - if (!isset($context['html_headers'])) |
|
2256 | - $context['html_headers'] = ''; |
|
2347 | + if (!isset($context['html_headers'])) { |
|
2348 | + $context['html_headers'] = ''; |
|
2349 | + } |
|
2257 | 2350 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2258 | 2351 | } |
2259 | 2352 | |
@@ -2279,11 +2372,13 @@ discard block |
||
2279 | 2372 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2280 | 2373 | |
2281 | 2374 | // Return errors if we have them. |
2282 | - if (!empty($verification_errors)) |
|
2283 | - return $verification_errors; |
|
2375 | + if (!empty($verification_errors)) { |
|
2376 | + return $verification_errors; |
|
2377 | + } |
|
2284 | 2378 | // If we had a test that one, make a note. |
2285 | - elseif ($do_test) |
|
2286 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2379 | + elseif ($do_test) { |
|
2380 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2381 | + } |
|
2287 | 2382 | |
2288 | 2383 | // Say that everything went well chaps. |
2289 | 2384 | return true; |
@@ -2308,8 +2403,9 @@ discard block |
||
2308 | 2403 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2309 | 2404 | |
2310 | 2405 | // If we're just checking the callback function is registered return true or false. |
2311 | - if ($checkRegistered != null) |
|
2312 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2406 | + if ($checkRegistered != null) { |
|
2407 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2408 | + } |
|
2313 | 2409 | |
2314 | 2410 | checkSession('get'); |
2315 | 2411 | loadTemplate('Xml'); |
@@ -2460,24 +2556,27 @@ discard block |
||
2460 | 2556 | foreach ($possible_versions as $ver) |
2461 | 2557 | { |
2462 | 2558 | $ver = trim($ver); |
2463 | - if (strpos($ver, 'SMF') === 0) |
|
2464 | - $versions[] = $ver; |
|
2559 | + if (strpos($ver, 'SMF') === 0) { |
|
2560 | + $versions[] = $ver; |
|
2561 | + } |
|
2465 | 2562 | } |
2466 | 2563 | } |
2467 | 2564 | $smcFunc['db_free_result']($request); |
2468 | 2565 | |
2469 | 2566 | // Just in case we don't have ANYthing. |
2470 | - if (empty($versions)) |
|
2471 | - $versions = array('SMF 2.0'); |
|
2567 | + if (empty($versions)) { |
|
2568 | + $versions = array('SMF 2.0'); |
|
2569 | + } |
|
2472 | 2570 | |
2473 | - foreach ($versions as $id => $version) |
|
2474 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2571 | + foreach ($versions as $id => $version) { |
|
2572 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2475 | 2573 | $xml_data['items']['children'][] = array( |
2476 | 2574 | 'attributes' => array( |
2477 | 2575 | 'id' => $id, |
2478 | 2576 | ), |
2479 | 2577 | 'value' => $version, |
2480 | 2578 | ); |
2579 | + } |
|
2481 | 2580 | |
2482 | 2581 | return $xml_data; |
2483 | 2582 | } |
@@ -12,8 +12,9 @@ discard block |
||
12 | 12 | * @version 2.1 Beta 3 |
13 | 13 | */ |
14 | 14 | |
15 | -if (!defined('SMF')) |
|
15 | +if (!defined('SMF')) { |
|
16 | 16 | die('No direct access...'); |
17 | +} |
|
17 | 18 | |
18 | 19 | /** |
19 | 20 | * Report a post or profile to the moderator... ask for a comment. |
@@ -35,10 +36,11 @@ discard block |
||
35 | 36 | |
36 | 37 | // You can't use this if it's off or you are not allowed to do it. |
37 | 38 | // If we don't have the ID of something to report, we'll die with a no_access error below |
38 | - if (isset($_REQUEST['msg'])) |
|
39 | - isAllowedTo('report_any'); |
|
40 | - elseif (isset($_REQUEST['u'])) |
|
41 | - isAllowedTo('report_user'); |
|
39 | + if (isset($_REQUEST['msg'])) { |
|
40 | + isAllowedTo('report_any'); |
|
41 | + } elseif (isset($_REQUEST['u'])) { |
|
42 | + isAllowedTo('report_user'); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Previewing or modifying? |
44 | 46 | if (isset($_POST['preview']) && !isset($_POST['save'])) |
@@ -56,19 +58,23 @@ discard block |
||
56 | 58 | } |
57 | 59 | |
58 | 60 | // If they're posting, it should be processed by ReportToModerator2. |
59 | - if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) |
|
60 | - ReportToModerator2(); |
|
61 | + if ((isset($_POST[$context['session_var']]) || isset($_POST['save'])) && empty($context['post_errors']) && !isset($_POST['preview'])) { |
|
62 | + ReportToModerator2(); |
|
63 | + } |
|
61 | 64 | |
62 | 65 | // We need a message ID or user ID to check! |
63 | - if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) |
|
64 | - fatal_lang_error('no_access', false); |
|
66 | + if (empty($_REQUEST['msg']) && empty($_REQUEST['mid']) && empty($_REQUEST['u'])) { |
|
67 | + fatal_lang_error('no_access', false); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // For compatibility, accept mid, but we should be using msg. (not the flavor kind!) |
67 | - if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) |
|
68 | - $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
71 | + if (!empty($_REQUEST['msg']) || !empty($_REQUEST['mid'])) { |
|
72 | + $_REQUEST['msg'] = empty($_REQUEST['msg']) ? (int) $_REQUEST['mid'] : (int) $_REQUEST['msg']; |
|
73 | + } |
|
69 | 74 | // msg and mid empty - assume we're reporting a user |
70 | - elseif (!empty($_REQUEST['u'])) |
|
71 | - $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
75 | + elseif (!empty($_REQUEST['u'])) { |
|
76 | + $_REQUEST['u'] = (int) $_REQUEST['u']; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // Set up some form values |
74 | 80 | $context['report_type'] = isset($_REQUEST['msg']) ? 'msg' : 'u'; |
@@ -89,8 +95,9 @@ discard block |
||
89 | 95 | 'id_msg' => $_REQUEST['msg'], |
90 | 96 | ) |
91 | 97 | ); |
92 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
93 | - fatal_lang_error('no_board', false); |
|
98 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
99 | + fatal_lang_error('no_board', false); |
|
100 | + } |
|
94 | 101 | list ($_REQUEST['msg'], $member, $starter) = $smcFunc['db_fetch_row']($result); |
95 | 102 | $smcFunc['db_free_result']($result); |
96 | 103 | |
@@ -101,8 +108,7 @@ discard block |
||
101 | 108 | |
102 | 109 | // The submit URL is different for users than it is for posts |
103 | 110 | $context['submit_url'] = $scripturl . '?action=reporttm;msg=' . $_REQUEST['msg'] . ';topic=' . $topic; |
104 | - } |
|
105 | - else |
|
111 | + } else |
|
106 | 112 | { |
107 | 113 | // Check the user's ID |
108 | 114 | $result = $smcFunc['db_query']('', ' |
@@ -114,8 +120,9 @@ discard block |
||
114 | 120 | ) |
115 | 121 | ); |
116 | 122 | |
117 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
118 | - fatal_lang_error('no_user', false); |
|
123 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
124 | + fatal_lang_error('no_user', false); |
|
125 | + } |
|
119 | 126 | list($_REQUEST['u'], $display_name, $username) = $smcFunc['db_fetch_row']($result); |
120 | 127 | |
121 | 128 | $context['current_user'] = $_REQUEST['u']; |
@@ -170,10 +177,11 @@ discard block |
||
170 | 177 | is_not_guest(); |
171 | 178 | |
172 | 179 | // You must have the proper permissions! |
173 | - if (isset($_REQUEST['msg'])) |
|
174 | - isAllowedTo('report_any'); |
|
175 | - else |
|
176 | - isAllowedTo('report_user'); |
|
180 | + if (isset($_REQUEST['msg'])) { |
|
181 | + isAllowedTo('report_any'); |
|
182 | + } else { |
|
183 | + isAllowedTo('report_user'); |
|
184 | + } |
|
177 | 185 | |
178 | 186 | // Make sure they aren't spamming. |
179 | 187 | spamProtection('reporttm'); |
@@ -187,17 +195,20 @@ discard block |
||
187 | 195 | $post_errors = array(); |
188 | 196 | |
189 | 197 | // Check their session. |
190 | - if (checkSession('post', '', false) != '') |
|
191 | - $post_errors[] = 'session_timeout'; |
|
198 | + if (checkSession('post', '', false) != '') { |
|
199 | + $post_errors[] = 'session_timeout'; |
|
200 | + } |
|
192 | 201 | |
193 | 202 | // Make sure we have a comment and it's clean. |
194 | - if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') |
|
195 | - $post_errors[] = 'no_comment'; |
|
203 | + if (!isset($_POST['comment']) || $smcFunc['htmltrim']($_POST['comment']) === '') { |
|
204 | + $post_errors[] = 'no_comment'; |
|
205 | + } |
|
196 | 206 | |
197 | 207 | $poster_comment = strtr($smcFunc['htmlspecialchars']($_POST['comment']), array("\r" => '', "\t" => '')); |
198 | 208 | |
199 | - if ($smcFunc['strlen']($poster_comment) > 254) |
|
200 | - $post_errors[] = 'post_too_long'; |
|
209 | + if ($smcFunc['strlen']($poster_comment) > 254) { |
|
210 | + $post_errors[] = 'post_too_long'; |
|
211 | + } |
|
201 | 212 | |
202 | 213 | // Any errors? |
203 | 214 | if (!empty($post_errors)) |
@@ -205,8 +216,9 @@ discard block |
||
205 | 216 | loadLanguage('Errors'); |
206 | 217 | |
207 | 218 | $context['post_errors'] = array(); |
208 | - foreach ($post_errors as $post_error) |
|
209 | - $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
219 | + foreach ($post_errors as $post_error) { |
|
220 | + $context['post_errors'][$post_error] = $txt['error_' . $post_error]; |
|
221 | + } |
|
210 | 222 | |
211 | 223 | return ReportToModerator(); |
212 | 224 | } |
@@ -215,8 +227,7 @@ discard block |
||
215 | 227 | { |
216 | 228 | // Handle this elsewhere to keep things from getting too long |
217 | 229 | reportPost($_POST['msg'], $poster_comment); |
218 | - } |
|
219 | - else |
|
230 | + } else |
|
220 | 231 | { |
221 | 232 | reportUser($_POST['u'], $poster_comment); |
222 | 233 | } |
@@ -247,8 +258,9 @@ discard block |
||
247 | 258 | 'id_msg' => $_POST['msg'], |
248 | 259 | ) |
249 | 260 | ); |
250 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
251 | - fatal_lang_error('no_board', false); |
|
261 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
262 | + fatal_lang_error('no_board', false); |
|
263 | + } |
|
252 | 264 | $message = $smcFunc['db_fetch_assoc']($request); |
253 | 265 | $smcFunc['db_free_result']($request); |
254 | 266 | |
@@ -264,18 +276,20 @@ discard block |
||
264 | 276 | 'ignored' => 1, |
265 | 277 | ) |
266 | 278 | ); |
267 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
268 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
279 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
280 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
281 | + } |
|
269 | 282 | |
270 | 283 | $smcFunc['db_free_result']($request); |
271 | 284 | |
272 | 285 | // If we're just going to ignore these, then who gives a monkeys... |
273 | - if (!empty($ignore)) |
|
274 | - redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
286 | + if (!empty($ignore)) { |
|
287 | + redirectexit('topic=' . $topic . '.msg' . $_POST['msg'] . '#msg' . $_POST['msg']); |
|
288 | + } |
|
275 | 289 | |
276 | 290 | // Already reported? My god, we could be dealing with a real rogue here... |
277 | - if (!empty($id_report)) |
|
278 | - $smcFunc['db_query']('', ' |
|
291 | + if (!empty($id_report)) { |
|
292 | + $smcFunc['db_query']('', ' |
|
279 | 293 | UPDATE {db_prefix}log_reported |
280 | 294 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
281 | 295 | WHERE id_report = {int:id_report}', |
@@ -284,11 +298,13 @@ discard block |
||
284 | 298 | 'id_report' => $id_report, |
285 | 299 | ) |
286 | 300 | ); |
301 | + } |
|
287 | 302 | // Otherwise, we shall make one! |
288 | 303 | else |
289 | 304 | { |
290 | - if (empty($message['real_name'])) |
|
291 | - $message['real_name'] = $message['poster_name']; |
|
305 | + if (empty($message['real_name'])) { |
|
306 | + $message['real_name'] = $message['poster_name']; |
|
307 | + } |
|
292 | 308 | |
293 | 309 | $id_report = $smcFunc['db_insert']('', |
294 | 310 | '{db_prefix}log_reported', |
@@ -367,8 +383,9 @@ discard block |
||
367 | 383 | 'id_member' => $_POST['u'] |
368 | 384 | ) |
369 | 385 | ); |
370 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
371 | - fatal_lang_error('no_user', false); |
|
386 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
387 | + fatal_lang_error('no_user', false); |
|
388 | + } |
|
372 | 389 | $user = $smcFunc['db_fetch_assoc']($request); |
373 | 390 | $smcFunc['db_free_result']($request); |
374 | 391 | |
@@ -388,18 +405,20 @@ discard block |
||
388 | 405 | 'ignored' => 1, |
389 | 406 | ) |
390 | 407 | ); |
391 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
392 | - list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
408 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
409 | + list ($id_report, $ignore) = $smcFunc['db_fetch_row']($request); |
|
410 | + } |
|
393 | 411 | |
394 | 412 | $smcFunc['db_free_result']($request); |
395 | 413 | |
396 | 414 | // If we're just going to ignore these, then who gives a monkeys... |
397 | - if (!empty($ignore)) |
|
398 | - redirectexit('action=profile;u=' . $_POST['u']); |
|
415 | + if (!empty($ignore)) { |
|
416 | + redirectexit('action=profile;u=' . $_POST['u']); |
|
417 | + } |
|
399 | 418 | |
400 | 419 | // Already reported? My god, we could be dealing with a real rogue here... |
401 | - if (!empty($id_report)) |
|
402 | - $smcFunc['db_query']('', ' |
|
420 | + if (!empty($id_report)) { |
|
421 | + $smcFunc['db_query']('', ' |
|
403 | 422 | UPDATE {db_prefix}log_reported |
404 | 423 | SET num_reports = num_reports + 1, time_updated = {int:current_time} |
405 | 424 | WHERE id_report = {int:id_report}', |
@@ -408,6 +427,7 @@ discard block |
||
408 | 427 | 'id_report' => $id_report, |
409 | 428 | ) |
410 | 429 | ); |
430 | + } |
|
411 | 431 | // Otherwise, we shall make one! |
412 | 432 | else |
413 | 433 | { |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |