@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -252,8 +260,7 @@ discard block |
||
252 | 260 | 'language' => $language_ftx |
253 | 261 | ) |
254 | 262 | ); |
255 | - } |
|
256 | - else |
|
263 | + } else |
|
257 | 264 | { |
258 | 265 | // Make sure it's gone before creating it. |
259 | 266 | $smcFunc['db_query']('', ' |
@@ -273,8 +280,7 @@ discard block |
||
273 | 280 | } |
274 | 281 | |
275 | 282 | $context['fulltext_index'] = 'body'; |
276 | - } |
|
277 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
283 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
278 | 284 | { |
279 | 285 | checkSession('get'); |
280 | 286 | validateToken('admin-msm', 'get'); |
@@ -291,12 +297,12 @@ discard block |
||
291 | 297 | $context['fulltext_index'] = ''; |
292 | 298 | |
293 | 299 | // Go back to the default search method. |
294 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
295 | - updateSettings(array( |
|
300 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
301 | + updateSettings(array( |
|
296 | 302 | 'search_index' => '', |
297 | 303 | )); |
298 | - } |
|
299 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
304 | + } |
|
305 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
300 | 306 | { |
301 | 307 | checkSession('get'); |
302 | 308 | validateToken('admin-msm', 'get'); |
@@ -318,12 +324,12 @@ discard block |
||
318 | 324 | )); |
319 | 325 | |
320 | 326 | // Go back to the default search method. |
321 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
322 | - updateSettings(array( |
|
327 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
328 | + updateSettings(array( |
|
323 | 329 | 'search_index' => '', |
324 | 330 | )); |
325 | - } |
|
326 | - elseif (isset($_POST['save'])) |
|
331 | + } |
|
332 | + } elseif (isset($_POST['save'])) |
|
327 | 333 | { |
328 | 334 | checkSession(); |
329 | 335 | validateToken('admin-msmpost'); |
@@ -345,8 +351,8 @@ discard block |
||
345 | 351 | // Get some info about the messages table, to show its size and index size. |
346 | 352 | if ($db_type == 'mysql') |
347 | 353 | { |
348 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
349 | - $request = $smcFunc['db_query']('', ' |
|
354 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
355 | + $request = $smcFunc['db_query']('', ' |
|
350 | 356 | SHOW TABLE STATUS |
351 | 357 | FROM {string:database_name} |
352 | 358 | LIKE {string:table_name}', |
@@ -355,14 +361,15 @@ discard block |
||
355 | 361 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
356 | 362 | ) |
357 | 363 | ); |
358 | - else |
|
359 | - $request = $smcFunc['db_query']('', ' |
|
364 | + } else { |
|
365 | + $request = $smcFunc['db_query']('', ' |
|
360 | 366 | SHOW TABLE STATUS |
361 | 367 | LIKE {string:table_name}', |
362 | 368 | array( |
363 | 369 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
364 | 370 | ) |
365 | 371 | ); |
372 | + } |
|
366 | 373 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
367 | 374 | { |
368 | 375 | // Only do this if the user has permission to execute this query. |
@@ -374,8 +381,8 @@ discard block |
||
374 | 381 | } |
375 | 382 | |
376 | 383 | // Now check the custom index table, if it exists at all. |
377 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
378 | - $request = $smcFunc['db_query']('', ' |
|
384 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
385 | + $request = $smcFunc['db_query']('', ' |
|
379 | 386 | SHOW TABLE STATUS |
380 | 387 | FROM {string:database_name} |
381 | 388 | LIKE {string:table_name}', |
@@ -384,14 +391,15 @@ discard block |
||
384 | 391 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
385 | 392 | ) |
386 | 393 | ); |
387 | - else |
|
388 | - $request = $smcFunc['db_query']('', ' |
|
394 | + } else { |
|
395 | + $request = $smcFunc['db_query']('', ' |
|
389 | 396 | SHOW TABLE STATUS |
390 | 397 | LIKE {string:table_name}', |
391 | 398 | array( |
392 | 399 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
393 | 400 | ) |
394 | 401 | ); |
402 | + } |
|
395 | 403 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
396 | 404 | { |
397 | 405 | // Only do this if the user has permission to execute this query. |
@@ -400,8 +408,7 @@ discard block |
||
400 | 408 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
401 | 409 | $smcFunc['db_free_result']($request); |
402 | 410 | } |
403 | - } |
|
404 | - elseif ($db_type == 'postgresql') |
|
411 | + } elseif ($db_type == 'postgresql') |
|
405 | 412 | { |
406 | 413 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
407 | 414 | //db_extend(); |
@@ -443,38 +450,38 @@ discard block |
||
443 | 450 | $context['table_info']['data_length'] = (int) $row['table_size']; |
444 | 451 | $context['table_info']['index_length'] = (int) $row['index_size']; |
445 | 452 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
446 | - } |
|
447 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
453 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
448 | 454 | { |
449 | 455 | $context['table_info']['index_length'] = (int) $row['index_size']; |
450 | 456 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
451 | 457 | } |
452 | 458 | } |
453 | 459 | $smcFunc['db_free_result']($request); |
454 | - } |
|
455 | - else |
|
456 | - // Didn't work for some reason... |
|
460 | + } else { |
|
461 | + // Didn't work for some reason... |
|
457 | 462 | $context['table_info'] = array( |
458 | 463 | 'data_length' => $txt['not_applicable'], |
459 | 464 | 'index_length' => $txt['not_applicable'], |
460 | 465 | 'fulltext_length' => $txt['not_applicable'], |
461 | 466 | 'custom_index_length' => $txt['not_applicable'], |
462 | 467 | ); |
463 | - } |
|
464 | - else |
|
465 | - $context['table_info'] = array( |
|
468 | + } |
|
469 | + } else { |
|
470 | + $context['table_info'] = array( |
|
466 | 471 | 'data_length' => $txt['not_applicable'], |
467 | 472 | 'index_length' => $txt['not_applicable'], |
468 | 473 | 'fulltext_length' => $txt['not_applicable'], |
469 | 474 | 'custom_index_length' => $txt['not_applicable'], |
470 | 475 | ); |
476 | + } |
|
471 | 477 | |
472 | 478 | // Format the data and index length in kilobytes. |
473 | 479 | foreach ($context['table_info'] as $type => $size) |
474 | 480 | { |
475 | 481 | // If it's not numeric then just break. This database engine doesn't support size. |
476 | - if (!is_numeric($size)) |
|
477 | - break; |
|
482 | + if (!is_numeric($size)) { |
|
483 | + break; |
|
484 | + } |
|
478 | 485 | |
479 | 486 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
480 | 487 | } |
@@ -503,8 +510,9 @@ discard block |
||
503 | 510 | |
504 | 511 | // Scotty, we need more time... |
505 | 512 | @set_time_limit(600); |
506 | - if (function_exists('apache_reset_timeout')) |
|
507 | - @apache_reset_timeout(); |
|
513 | + if (function_exists('apache_reset_timeout')) { |
|
514 | + @apache_reset_timeout(); |
|
515 | + } |
|
508 | 516 | |
509 | 517 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
510 | 518 | $context['page_title'] = $txt['search_index_custom']; |
@@ -534,8 +542,7 @@ discard block |
||
534 | 542 | $context['start'] = (int) $context['index_settings']['resume_at']; |
535 | 543 | unset($context['index_settings']['resume_at']); |
536 | 544 | $context['step'] = 1; |
537 | - } |
|
538 | - else |
|
545 | + } else |
|
539 | 546 | { |
540 | 547 | $context['index_settings'] = array( |
541 | 548 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -544,12 +551,14 @@ discard block |
||
544 | 551 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
545 | 552 | |
546 | 553 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
547 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
548 | - $_SESSION['admin_time'] = time(); |
|
554 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
555 | + $_SESSION['admin_time'] = time(); |
|
556 | + } |
|
549 | 557 | } |
550 | 558 | |
551 | - if ($context['step'] !== 0) |
|
552 | - checkSession('request'); |
|
559 | + if ($context['step'] !== 0) { |
|
560 | + checkSession('request'); |
|
561 | + } |
|
553 | 562 | |
554 | 563 | // Step 0: let the user determine how they like their index. |
555 | 564 | if ($context['step'] === 0) |
@@ -578,12 +587,14 @@ discard block |
||
578 | 587 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
579 | 588 | |
580 | 589 | // Temporarily switch back to not using a search index. |
581 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
582 | - updateSettings(array('search_index' => '')); |
|
590 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
591 | + updateSettings(array('search_index' => '')); |
|
592 | + } |
|
583 | 593 | |
584 | 594 | // Don't let simultanious processes be updating the search index. |
585 | - if (!empty($modSettings['search_custom_index_config'])) |
|
586 | - updateSettings(array('search_custom_index_config' => '')); |
|
595 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
596 | + updateSettings(array('search_custom_index_config' => '')); |
|
597 | + } |
|
587 | 598 | } |
588 | 599 | |
589 | 600 | $num_messages = array( |
@@ -599,16 +610,16 @@ discard block |
||
599 | 610 | 'starting_id' => $context['start'], |
600 | 611 | ) |
601 | 612 | ); |
602 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
603 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
615 | + } |
|
604 | 616 | |
605 | 617 | if (empty($num_messages['todo'])) |
606 | 618 | { |
607 | 619 | $context['step'] = 2; |
608 | 620 | $context['percentage'] = 80; |
609 | 621 | $context['start'] = 0; |
610 | - } |
|
611 | - else |
|
622 | + } else |
|
612 | 623 | { |
613 | 624 | // Number of seconds before the next step. |
614 | 625 | $stop = time() + 3; |
@@ -649,21 +660,22 @@ discard block |
||
649 | 660 | |
650 | 661 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
651 | 662 | |
652 | - if (!empty($inserts)) |
|
653 | - $smcFunc['db_insert']('ignore', |
|
663 | + if (!empty($inserts)) { |
|
664 | + $smcFunc['db_insert']('ignore', |
|
654 | 665 | '{db_prefix}log_search_words', |
655 | 666 | array('id_word' => 'int', 'id_msg' => 'int'), |
656 | 667 | $inserts, |
657 | 668 | array('id_word', 'id_msg') |
658 | 669 | ); |
670 | + } |
|
659 | 671 | if ($num_messages['todo'] === 0) |
660 | 672 | { |
661 | 673 | $context['step'] = 2; |
662 | 674 | $context['start'] = 0; |
663 | 675 | break; |
676 | + } else { |
|
677 | + updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
664 | 678 | } |
665 | - else |
|
666 | - updateSettings(array('search_custom_index_resume' => json_encode(array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
667 | 679 | } |
668 | 680 | |
669 | 681 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -674,9 +686,9 @@ discard block |
||
674 | 686 | // Step 2: removing the words that occur too often and are of no use. |
675 | 687 | elseif ($context['step'] === 2) |
676 | 688 | { |
677 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
678 | - $context['step'] = 3; |
|
679 | - else |
|
689 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
690 | + $context['step'] = 3; |
|
691 | + } else |
|
680 | 692 | { |
681 | 693 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
682 | 694 | $stop = time() + 3; |
@@ -697,20 +709,22 @@ discard block |
||
697 | 709 | 'minimum_messages' => $max_messages, |
698 | 710 | ) |
699 | 711 | ); |
700 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
701 | - $stop_words[] = $row['id_word']; |
|
712 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
713 | + $stop_words[] = $row['id_word']; |
|
714 | + } |
|
702 | 715 | $smcFunc['db_free_result']($request); |
703 | 716 | |
704 | 717 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
705 | 718 | |
706 | - if (!empty($stop_words)) |
|
707 | - $smcFunc['db_query']('', ' |
|
719 | + if (!empty($stop_words)) { |
|
720 | + $smcFunc['db_query']('', ' |
|
708 | 721 | DELETE FROM {db_prefix}log_search_words |
709 | 722 | WHERE id_word in ({array_int:stop_words})', |
710 | 723 | array( |
711 | 724 | 'stop_words' => $stop_words, |
712 | 725 | ) |
713 | 726 | ); |
727 | + } |
|
714 | 728 | |
715 | 729 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
716 | 730 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -771,8 +785,9 @@ discard block |
||
771 | 785 | $searchAPI = new $search_class_name(); |
772 | 786 | |
773 | 787 | // No Support? NEXT! |
774 | - if (!$searchAPI->is_supported) |
|
775 | - continue; |
|
788 | + if (!$searchAPI->is_supported) { |
|
789 | + continue; |
|
790 | + } |
|
776 | 791 | |
777 | 792 | $apis[$index_name] = array( |
778 | 793 | 'filename' => $file, |
@@ -819,10 +834,10 @@ discard block |
||
819 | 834 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
820 | 835 | ) |
821 | 836 | ); |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - $context['fulltext_index'][] = $row['indexname']; |
|
824 | - } |
|
825 | - else |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + $context['fulltext_index'][] = $row['indexname']; |
|
839 | + } |
|
840 | + } else |
|
826 | 841 | { |
827 | 842 | $request = $smcFunc['db_query']('', ' |
828 | 843 | SHOW INDEX |
@@ -833,17 +848,19 @@ discard block |
||
833 | 848 | $context['fulltext_index'] = ''; |
834 | 849 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
835 | 850 | { |
836 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
837 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
851 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
852 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
838 | 853 | $context['fulltext_index'][] = $row['Key_name']; |
854 | + } |
|
839 | 855 | $smcFunc['db_free_result']($request); |
840 | 856 | |
841 | - if (is_array($context['fulltext_index'])) |
|
842 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
857 | + if (is_array($context['fulltext_index'])) { |
|
858 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
859 | + } |
|
843 | 860 | } |
844 | 861 | |
845 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
846 | - $request = $smcFunc['db_query']('', ' |
|
862 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
863 | + $request = $smcFunc['db_query']('', ' |
|
847 | 864 | SHOW TABLE STATUS |
848 | 865 | FROM {string:database_name} |
849 | 866 | LIKE {string:table_name}', |
@@ -852,20 +869,22 @@ discard block |
||
852 | 869 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
853 | 870 | ) |
854 | 871 | ); |
855 | - else |
|
856 | - $request = $smcFunc['db_query']('', ' |
|
872 | + } else { |
|
873 | + $request = $smcFunc['db_query']('', ' |
|
857 | 874 | SHOW TABLE STATUS |
858 | 875 | LIKE {string:table_name}', |
859 | 876 | array( |
860 | 877 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
861 | 878 | ) |
862 | 879 | ); |
880 | + } |
|
863 | 881 | |
864 | 882 | if ($request !== false) |
865 | 883 | { |
866 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
867 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
884 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
885 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'], '5.6.4', '>='))) |
|
868 | 886 | $context['cannot_create_fulltext'] = true; |
887 | + } |
|
869 | 888 | $smcFunc['db_free_result']($request); |
870 | 889 | } |
871 | 890 | } |
@@ -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( |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point for the moderation center. |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | global $txt, $context, $scripturl, $modSettings, $user_info, $sourcedir, $options; |
27 | 28 | |
28 | 29 | // Don't run this twice... and don't conflict with the admin bar. |
29 | - if (isset($context['admin_area'])) |
|
30 | - return; |
|
30 | + if (isset($context['admin_area'])) { |
|
31 | + return; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $context['can_moderate_boards'] = $user_info['mod_cache']['bq'] != '0=1'; |
33 | 35 | $context['can_moderate_groups'] = $user_info['mod_cache']['gq'] != '0=1'; |
@@ -35,8 +37,9 @@ discard block |
||
35 | 37 | $context['can_moderate_users'] = allowedTo('moderate_forum'); |
36 | 38 | |
37 | 39 | // Everyone using this area must be allowed here! |
38 | - if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) |
|
39 | - isAllowedTo('access_mod_center'); |
|
40 | + if (!$context['can_moderate_boards'] && !$context['can_moderate_groups'] && !$context['can_moderate_approvals'] && !$context['can_moderate_users']) { |
|
41 | + isAllowedTo('access_mod_center'); |
|
42 | + } |
|
40 | 43 | |
41 | 44 | // We're gonna want a menu of some kind. |
42 | 45 | require_once($sourcedir . '/Subs-Menu.php'); |
@@ -195,8 +198,9 @@ discard block |
||
195 | 198 | unset($moderation_areas); |
196 | 199 | |
197 | 200 | // We got something - didn't we? DIDN'T WE! |
198 | - if ($mod_include_data == false) |
|
199 | - fatal_lang_error('no_access', false); |
|
201 | + if ($mod_include_data == false) { |
|
202 | + fatal_lang_error('no_access', false); |
|
203 | + } |
|
200 | 204 | |
201 | 205 | // Retain the ID information in case required by a subaction. |
202 | 206 | $context['moderation_menu_id'] = $context['max_menu_id']; |
@@ -219,22 +223,25 @@ discard block |
||
219 | 223 | 'url' => $scripturl . '?action=moderate', |
220 | 224 | 'name' => $txt['moderation_center'], |
221 | 225 | ); |
222 | - if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') |
|
223 | - $context['linktree'][] = array( |
|
226 | + if (isset($mod_include_data['current_area']) && $mod_include_data['current_area'] != 'index') { |
|
227 | + $context['linktree'][] = array( |
|
224 | 228 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'], |
225 | 229 | 'name' => $mod_include_data['label'], |
226 | 230 | ); |
227 | - if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) |
|
228 | - $context['linktree'][] = array( |
|
231 | + } |
|
232 | + if (!empty($mod_include_data['current_subsection']) && $mod_include_data['subsections'][$mod_include_data['current_subsection']][0] != $mod_include_data['label']) { |
|
233 | + $context['linktree'][] = array( |
|
229 | 234 | 'url' => $scripturl . '?action=moderate;area=' . $mod_include_data['current_area'] . ';sa=' . $mod_include_data['current_subsection'], |
230 | 235 | 'name' => $mod_include_data['subsections'][$mod_include_data['current_subsection']][0], |
231 | 236 | ); |
237 | + } |
|
232 | 238 | |
233 | 239 | // Now - finally - the bit before the encore - the main performance of course! |
234 | 240 | if (!$dont_call) |
235 | 241 | { |
236 | - if (isset($mod_include_data['file'])) |
|
237 | - require_once($sourcedir . '/' . $mod_include_data['file']); |
|
242 | + if (isset($mod_include_data['file'])) { |
|
243 | + require_once($sourcedir . '/' . $mod_include_data['file']); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | call_helper($mod_include_data['function']); |
240 | 247 | } |
@@ -259,8 +266,9 @@ discard block |
||
259 | 266 | // Load what blocks the user actually can see... |
260 | 267 | $valid_blocks = array(); |
261 | 268 | |
262 | - if ($context['can_moderate_groups']) |
|
263 | - $valid_blocks['g'] = 'GroupRequests'; |
|
269 | + if ($context['can_moderate_groups']) { |
|
270 | + $valid_blocks['g'] = 'GroupRequests'; |
|
271 | + } |
|
264 | 272 | if ($context['can_moderate_boards']) |
265 | 273 | { |
266 | 274 | $valid_blocks['r'] = 'ReportedPosts'; |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | if ($context['can_moderate_users']) |
270 | 278 | { |
271 | 279 | // This falls under the category of moderating users as well... |
272 | - if (!$context['can_moderate_boards']) |
|
273 | - $valid_blocks['w'] = 'WatchedUsers'; |
|
280 | + if (!$context['can_moderate_boards']) { |
|
281 | + $valid_blocks['w'] = 'WatchedUsers'; |
|
282 | + } |
|
274 | 283 | |
275 | 284 | $valid_blocks['rm'] = 'ReportedMembers'; |
276 | 285 | } |
@@ -281,8 +290,9 @@ discard block |
||
281 | 290 | foreach ($valid_blocks as $k => $block) |
282 | 291 | { |
283 | 292 | $block = 'ModBlock' . $block; |
284 | - if (function_exists($block)) |
|
285 | - $context['mod_blocks'][] = $block(); |
|
293 | + if (function_exists($block)) { |
|
294 | + $context['mod_blocks'][] = $block(); |
|
295 | + } |
|
286 | 296 | } |
287 | 297 | |
288 | 298 | $context['admin_prefs'] = !empty($options['admin_preferences']) ? smf_json_decode($options['admin_preferences'], true) : array(); |
@@ -309,8 +319,9 @@ discard block |
||
309 | 319 | ) |
310 | 320 | ); |
311 | 321 | $watched_users = array(); |
312 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
313 | - $watched_users[] = $row; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $watched_users[] = $row; |
|
324 | + } |
|
314 | 325 | $smcFunc['db_free_result']($request); |
315 | 326 | |
316 | 327 | cache_put_data('recent_user_watches', $watched_users, 240); |
@@ -402,8 +413,9 @@ discard block |
||
402 | 413 | $note_owner = $smcFunc['db_num_rows']($get_owner); |
403 | 414 | $smcFunc['db_free_result']($get_owner); |
404 | 415 | |
405 | - if (empty($note_owner)) |
|
406 | - fatal_lang_error('mc_notes_delete_own', false); |
|
416 | + if (empty($note_owner)) { |
|
417 | + fatal_lang_error('mc_notes_delete_own', false); |
|
418 | + } |
|
407 | 419 | } |
408 | 420 | |
409 | 421 | // Lets delete it. |
@@ -460,12 +472,14 @@ discard block |
||
460 | 472 | ) |
461 | 473 | ); |
462 | 474 | $moderator_notes = array(); |
463 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
464 | - $moderator_notes[] = $row; |
|
475 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
476 | + $moderator_notes[] = $row; |
|
477 | + } |
|
465 | 478 | $smcFunc['db_free_result']($request); |
466 | 479 | |
467 | - if ($offset == 0) |
|
468 | - cache_put_data('moderator_notes', $moderator_notes, 240); |
|
480 | + if ($offset == 0) { |
|
481 | + cache_put_data('moderator_notes', $moderator_notes, 240); |
|
482 | + } |
|
469 | 483 | } |
470 | 484 | |
471 | 485 | // Lets construct a page index. |
@@ -504,8 +518,9 @@ discard block |
||
504 | 518 | // Got the info already? |
505 | 519 | $cachekey = md5(json_encode($user_info['mod_cache']['bq'])); |
506 | 520 | $context['reported_posts'] = array(); |
507 | - if ($user_info['mod_cache']['bq'] == '0=1') |
|
508 | - return 'reported_posts_block'; |
|
521 | + if ($user_info['mod_cache']['bq'] == '0=1') { |
|
522 | + return 'reported_posts_block'; |
|
523 | + } |
|
509 | 524 | |
510 | 525 | if (($reported_posts = cache_get_data('reported_posts_' . $cachekey, 90)) === null) |
511 | 526 | { |
@@ -529,8 +544,9 @@ discard block |
||
529 | 544 | ) |
530 | 545 | ); |
531 | 546 | $reported_posts = array(); |
532 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
533 | - $reported_posts[] = $row; |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + $reported_posts[] = $row; |
|
549 | + } |
|
534 | 550 | $smcFunc['db_free_result']($request); |
535 | 551 | |
536 | 552 | // Cache it. |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | |
569 | 585 | $context['group_requests'] = array(); |
570 | 586 | // Make sure they can even moderate someone! |
571 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
572 | - return 'group_requests_block'; |
|
587 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
588 | + return 'group_requests_block'; |
|
589 | + } |
|
573 | 590 | |
574 | 591 | // What requests are outstanding? |
575 | 592 | $request = $smcFunc['db_query']('', ' |
@@ -618,8 +635,9 @@ discard block |
||
618 | 635 | // Got the info already? |
619 | 636 | $cachekey = md5(json_encode((int) allowedTo('moderate_forum'))); |
620 | 637 | $context['reported_users'] = array(); |
621 | - if (!allowedTo('moderate_forum')) |
|
622 | - return 'reported_users_block'; |
|
638 | + if (!allowedTo('moderate_forum')) { |
|
639 | + return 'reported_users_block'; |
|
640 | + } |
|
623 | 641 | |
624 | 642 | if (($reported_users = cache_get_data('reported_users_' . $cachekey, 90)) === null) |
625 | 643 | { |
@@ -642,8 +660,9 @@ discard block |
||
642 | 660 | ) |
643 | 661 | ); |
644 | 662 | $reported_users = array(); |
645 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
646 | - $reported_users[] = $row; |
|
663 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
664 | + $reported_users[] = $row; |
|
665 | + } |
|
647 | 666 | $smcFunc['db_free_result']($request); |
648 | 667 | |
649 | 668 | // Cache it. |
@@ -691,8 +710,9 @@ discard block |
||
691 | 710 | isAllowedTo('moderate_forum'); |
692 | 711 | |
693 | 712 | // Are they wanting to view a particular report? |
694 | - if (!empty($_REQUEST['report'])) |
|
695 | - return MemberReport(); |
|
713 | + if (!empty($_REQUEST['report'])) { |
|
714 | + return MemberReport(); |
|
715 | + } |
|
696 | 716 | |
697 | 717 | // Set up the comforting bits... |
698 | 718 | $context['page_title'] = $txt['mc_reported_members']; |
@@ -746,15 +766,15 @@ discard block |
||
746 | 766 | // Time to update. |
747 | 767 | updateSettings(array('last_mod_report_action' => time())); |
748 | 768 | recountOpenReports('members'); |
749 | - } |
|
750 | - elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
769 | + } elseif (isset($_POST['close']) && isset($_POST['close_selected'])) |
|
751 | 770 | { |
752 | 771 | checkSession(); |
753 | 772 | |
754 | 773 | // All the ones to update... |
755 | 774 | $toClose = array(); |
756 | - foreach ($_POST['close'] as $rid) |
|
757 | - $toClose[] = (int) $rid; |
|
775 | + foreach ($_POST['close'] as $rid) { |
|
776 | + $toClose[] = (int) $rid; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | if (!empty($toClose)) |
760 | 780 | { |
@@ -907,8 +927,9 @@ discard block |
||
907 | 927 | global $context, $user_info; |
908 | 928 | |
909 | 929 | // You need to be allowed to moderate groups... |
910 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
911 | - isAllowedTo('manage_membergroups'); |
|
930 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
931 | + isAllowedTo('manage_membergroups'); |
|
932 | + } |
|
912 | 933 | |
913 | 934 | // Load the group templates. |
914 | 935 | loadTemplate('ModerationCenter'); |
@@ -919,8 +940,9 @@ discard block |
||
919 | 940 | 'view' => 'ViewGroups', |
920 | 941 | ); |
921 | 942 | |
922 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
923 | - $_GET['sa'] = 'view'; |
|
943 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
944 | + $_GET['sa'] = 'view'; |
|
945 | + } |
|
924 | 946 | $context['sub_action'] = $_GET['sa']; |
925 | 947 | |
926 | 948 | // Call the relevant function. |
@@ -950,8 +972,9 @@ discard block |
||
950 | 972 | 'id_notice' => $id_notice, |
951 | 973 | ) |
952 | 974 | ); |
953 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
954 | - fatal_lang_error('no_access', false); |
|
975 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
976 | + fatal_lang_error('no_access', false); |
|
977 | + } |
|
955 | 978 | list ($context['notice_body'], $context['notice_subject']) = $smcFunc['db_fetch_row']($request); |
956 | 979 | $smcFunc['db_free_result']($request); |
957 | 980 | |
@@ -988,18 +1011,20 @@ discard block |
||
988 | 1011 | checkSession(!is_array($_REQUEST['delete']) ? 'get' : 'post'); |
989 | 1012 | |
990 | 1013 | $toDelete = array(); |
991 | - if (!is_array($_REQUEST['delete'])) |
|
992 | - $toDelete[] = (int) $_REQUEST['delete']; |
|
993 | - else |
|
994 | - foreach ($_REQUEST['delete'] as $did) |
|
1014 | + if (!is_array($_REQUEST['delete'])) { |
|
1015 | + $toDelete[] = (int) $_REQUEST['delete']; |
|
1016 | + } else { |
|
1017 | + foreach ($_REQUEST['delete'] as $did) |
|
995 | 1018 | $toDelete[] = (int) $did; |
1019 | + } |
|
996 | 1020 | |
997 | 1021 | if (!empty($toDelete)) |
998 | 1022 | { |
999 | 1023 | require_once($sourcedir . '/RemoveTopic.php'); |
1000 | 1024 | // If they don't have permission we'll let it error - either way no chance of a security slip here! |
1001 | - foreach ($toDelete as $did) |
|
1002 | - removeMessage($did); |
|
1025 | + foreach ($toDelete as $did) { |
|
1026 | + removeMessage($did); |
|
1027 | + } |
|
1003 | 1028 | } |
1004 | 1029 | } |
1005 | 1030 | |
@@ -1008,20 +1033,21 @@ discard block |
||
1008 | 1033 | { |
1009 | 1034 | $approve_query = ''; |
1010 | 1035 | $delete_boards = array(); |
1011 | - } |
|
1012 | - else |
|
1036 | + } else |
|
1013 | 1037 | { |
1014 | 1038 | // Still obey permissions! |
1015 | 1039 | $approve_boards = boardsAllowedTo('approve_posts'); |
1016 | 1040 | $delete_boards = boardsAllowedTo('delete_any'); |
1017 | 1041 | |
1018 | - if ($approve_boards == array(0)) |
|
1019 | - $approve_query = ''; |
|
1020 | - elseif (!empty($approve_boards)) |
|
1021 | - $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1042 | + if ($approve_boards == array(0)) { |
|
1043 | + $approve_query = ''; |
|
1044 | + } elseif (!empty($approve_boards)) { |
|
1045 | + $approve_query = ' AND m.id_board IN (' . implode(',', $approve_boards) . ')'; |
|
1046 | + } |
|
1022 | 1047 | // Nada, zip, etc... |
1023 | - else |
|
1024 | - $approve_query = ' AND 1=0'; |
|
1048 | + else { |
|
1049 | + $approve_query = ' AND 1=0'; |
|
1050 | + } |
|
1025 | 1051 | } |
1026 | 1052 | |
1027 | 1053 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1120,10 +1146,11 @@ discard block |
||
1120 | 1146 | 'data' => array( |
1121 | 1147 | 'function' => function($member) use ($scripturl) |
1122 | 1148 | { |
1123 | - if ($member['last_post_id']) |
|
1124 | - return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1125 | - else |
|
1126 | - return $member['last_post']; |
|
1149 | + if ($member['last_post_id']) { |
|
1150 | + return '<a href="' . $scripturl . '?msg=' . $member['last_post_id'] . '">' . $member['last_post'] . '</a>'; |
|
1151 | + } else { |
|
1152 | + return $member['last_post']; |
|
1153 | + } |
|
1127 | 1154 | }, |
1128 | 1155 | ), |
1129 | 1156 | ), |
@@ -1251,8 +1278,9 @@ discard block |
||
1251 | 1278 | ) |
1252 | 1279 | ); |
1253 | 1280 | $latest_posts = array(); |
1254 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1255 | - $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1281 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1282 | + $latest_posts[$row['id_member']] = $row['last_post_id']; |
|
1283 | + } |
|
1256 | 1284 | |
1257 | 1285 | if (!empty($latest_posts)) |
1258 | 1286 | { |
@@ -1443,15 +1471,17 @@ discard block |
||
1443 | 1471 | // Setup the direction stuff... |
1444 | 1472 | $context['order'] = isset($_REQUEST['sort']) && isset($sort_types[$_REQUEST['sort']]) ? $_REQUEST['sort'] : 'member'; |
1445 | 1473 | |
1446 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
1447 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1448 | - else |
|
1449 | - $search_params_string = $search_params['string']; |
|
1474 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
1475 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
1476 | + } else { |
|
1477 | + $search_params_string = $search_params['string']; |
|
1478 | + } |
|
1450 | 1479 | |
1451 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
1452 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1453 | - else |
|
1454 | - $search_params_type = $search_params['type']; |
|
1480 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
1481 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
1482 | + } else { |
|
1483 | + $search_params_type = $search_params['type']; |
|
1484 | + } |
|
1455 | 1485 | |
1456 | 1486 | $search_params = array( |
1457 | 1487 | 'string' => $search_params_string, |
@@ -1534,9 +1564,10 @@ discard block |
||
1534 | 1564 | ' . $rowData['reason'] . ' |
1535 | 1565 | </div>'; |
1536 | 1566 | |
1537 | - if (!empty($rowData['id_notice'])) |
|
1538 | - $output .= ' |
|
1567 | + if (!empty($rowData['id_notice'])) { |
|
1568 | + $output .= ' |
|
1539 | 1569 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $rowData['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>'; |
1570 | + } |
|
1540 | 1571 | return $output; |
1541 | 1572 | }, |
1542 | 1573 | ), |
@@ -1654,9 +1685,9 @@ discard block |
||
1654 | 1685 | global $smcFunc, $modSettings, $context, $txt, $scripturl, $sourcedir, $user_info; |
1655 | 1686 | |
1656 | 1687 | // Submitting a new one? |
1657 | - if (isset($_POST['add'])) |
|
1658 | - return ModifyWarningTemplate(); |
|
1659 | - elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1688 | + if (isset($_POST['add'])) { |
|
1689 | + return ModifyWarningTemplate(); |
|
1690 | + } elseif (isset($_POST['delete']) && !empty($_POST['deltpl'])) |
|
1660 | 1691 | { |
1661 | 1692 | checkSession(); |
1662 | 1693 | validateToken('mod-wt'); |
@@ -1675,8 +1706,9 @@ discard block |
||
1675 | 1706 | 'current_member' => $user_info['id'], |
1676 | 1707 | ) |
1677 | 1708 | ); |
1678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1679 | - logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1709 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1710 | + logAction('delete_warn_template', array('template' => $row['recipient_name'])); |
|
1711 | + } |
|
1680 | 1712 | $smcFunc['db_free_result']($request); |
1681 | 1713 | |
1682 | 1714 | // Do the deletes. |
@@ -1967,16 +1999,18 @@ discard block |
||
1967 | 1999 | ); |
1968 | 2000 | |
1969 | 2001 | // If it wasn't visible and now is they've effectively added it. |
1970 | - if ($context['template_data']['personal'] && !$recipient_id) |
|
1971 | - logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2002 | + if ($context['template_data']['personal'] && !$recipient_id) { |
|
2003 | + logAction('add_warn_template', array('template' => $_POST['template_title'])); |
|
2004 | + } |
|
1972 | 2005 | // Conversely if they made it personal it's a delete. |
1973 | - elseif (!$context['template_data']['personal'] && $recipient_id) |
|
1974 | - logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2006 | + elseif (!$context['template_data']['personal'] && $recipient_id) { |
|
2007 | + logAction('delete_warn_template', array('template' => $_POST['template_title'])); |
|
2008 | + } |
|
1975 | 2009 | // Otherwise just an edit. |
1976 | - else |
|
1977 | - logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
1978 | - } |
|
1979 | - else |
|
2010 | + else { |
|
2011 | + logAction('modify_warn_template', array('template' => $_POST['template_title'])); |
|
2012 | + } |
|
2013 | + } else |
|
1980 | 2014 | { |
1981 | 2015 | $smcFunc['db_insert']('', |
1982 | 2016 | '{db_prefix}log_comments', |
@@ -1996,17 +2030,18 @@ discard block |
||
1996 | 2030 | |
1997 | 2031 | // Get out of town... |
1998 | 2032 | redirectexit('action=moderate;area=warnings;sa=templates'); |
1999 | - } |
|
2000 | - else |
|
2033 | + } else |
|
2001 | 2034 | { |
2002 | 2035 | $context['warning_errors'] = array(); |
2003 | 2036 | $context['template_data']['title'] = !empty($_POST['template_title']) ? $_POST['template_title'] : ''; |
2004 | 2037 | $context['template_data']['body'] = !empty($_POST['template_body']) ? $_POST['template_body'] : $txt['mc_warning_template_body_default']; |
2005 | 2038 | $context['template_data']['personal'] = !empty($_POST['make_personal']); |
2006 | - if (empty($_POST['template_title'])) |
|
2007 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2008 | - if (empty($_POST['template_body'])) |
|
2009 | - $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2039 | + if (empty($_POST['template_title'])) { |
|
2040 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_title']; |
|
2041 | + } |
|
2042 | + if (empty($_POST['template_body'])) { |
|
2043 | + $context['warning_errors'][] = $txt['mc_warning_template_error_no_body']; |
|
2044 | + } |
|
2010 | 2045 | } |
2011 | 2046 | } |
2012 | 2047 | |
@@ -2051,8 +2086,9 @@ discard block |
||
2051 | 2086 | // Now check other options! |
2052 | 2087 | $pref_binary = 0; |
2053 | 2088 | |
2054 | - if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) |
|
2055 | - $pref_binary |= 4; |
|
2089 | + if ($context['can_moderate_approvals'] && !empty($_POST['mod_notify_approval'])) { |
|
2090 | + $pref_binary |= 4; |
|
2091 | + } |
|
2056 | 2092 | |
2057 | 2093 | // Put it all together. |
2058 | 2094 | $mod_prefs = '0||' . $pref_binary; |
@@ -2076,9 +2112,10 @@ discard block |
||
2076 | 2112 | unset($_SESSION['moderate_time']); |
2077 | 2113 | |
2078 | 2114 | // Clean any moderator tokens as well. |
2079 | - foreach ($_SESSION['token'] as $key => $token) |
|
2080 | - if (strpos($key, '-mod') !== false) |
|
2115 | + foreach ($_SESSION['token'] as $key => $token) { |
|
2116 | + if (strpos($key, '-mod') !== false) |
|
2081 | 2117 | unset($_SESSION['token'][$key]); |
2118 | + } |
|
2082 | 2119 | |
2083 | 2120 | redirectexit(); |
2084 | 2121 | } |
@@ -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 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -55,8 +58,9 @@ discard block |
||
55 | 58 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
56 | 59 | |
57 | 60 | // You must be posting to *some* board. |
58 | - if (empty($board) && !$context['make_event']) |
|
59 | - fatal_lang_error('no_board', false); |
|
61 | + if (empty($board) && !$context['make_event']) { |
|
62 | + fatal_lang_error('no_board', false); |
|
63 | + } |
|
60 | 64 | |
61 | 65 | require_once($sourcedir . '/Subs-Post.php'); |
62 | 66 | |
@@ -79,10 +83,11 @@ discard block |
||
79 | 83 | array( |
80 | 84 | 'msg' => (int) $_REQUEST['msg'], |
81 | 85 | )); |
82 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
83 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
84 | - else |
|
85 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
86 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
87 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
88 | + } else { |
|
89 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
90 | + } |
|
86 | 91 | $smcFunc['db_free_result']($request); |
87 | 92 | } |
88 | 93 | |
@@ -109,33 +114,36 @@ discard block |
||
109 | 114 | $smcFunc['db_free_result']($request); |
110 | 115 | |
111 | 116 | // If this topic already has a poll, they sure can't add another. |
112 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
113 | - unset($_REQUEST['poll']); |
|
117 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
118 | + unset($_REQUEST['poll']); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | if (empty($_REQUEST['msg'])) |
116 | 122 | { |
117 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
118 | - is_not_guest(); |
|
123 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
124 | + is_not_guest(); |
|
125 | + } |
|
119 | 126 | |
120 | 127 | // By default the reply will be approved... |
121 | 128 | $context['becomes_approved'] = true; |
122 | 129 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
123 | 130 | { |
124 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
125 | - $context['becomes_approved'] = false; |
|
126 | - else |
|
127 | - isAllowedTo('post_reply_any'); |
|
128 | - } |
|
129 | - elseif (!allowedTo('post_reply_any')) |
|
131 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
132 | + $context['becomes_approved'] = false; |
|
133 | + } else { |
|
134 | + isAllowedTo('post_reply_any'); |
|
135 | + } |
|
136 | + } elseif (!allowedTo('post_reply_any')) |
|
130 | 137 | { |
131 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
132 | - $context['becomes_approved'] = false; |
|
133 | - else |
|
134 | - isAllowedTo('post_reply_own'); |
|
138 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
139 | + $context['becomes_approved'] = false; |
|
140 | + } else { |
|
141 | + isAllowedTo('post_reply_own'); |
|
142 | + } |
|
135 | 143 | } |
144 | + } else { |
|
145 | + $context['becomes_approved'] = true; |
|
136 | 146 | } |
137 | - else |
|
138 | - $context['becomes_approved'] = true; |
|
139 | 147 | |
140 | 148 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
141 | 149 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -147,18 +155,19 @@ discard block |
||
147 | 155 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
148 | 156 | |
149 | 157 | // Check whether this is a really old post being bumped... |
150 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
151 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
152 | - } |
|
153 | - else |
|
158 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
159 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
160 | + } |
|
161 | + } else |
|
154 | 162 | { |
155 | 163 | $context['becomes_approved'] = true; |
156 | 164 | if ((!$context['make_event'] || !empty($board))) |
157 | 165 | { |
158 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
159 | - $context['becomes_approved'] = false; |
|
160 | - else |
|
161 | - isAllowedTo('post_new'); |
|
166 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
167 | + $context['becomes_approved'] = false; |
|
168 | + } else { |
|
169 | + isAllowedTo('post_new'); |
|
170 | + } |
|
162 | 171 | } |
163 | 172 | |
164 | 173 | $locked = 0; |
@@ -190,20 +199,24 @@ discard block |
||
190 | 199 | unset($_SESSION['already_attached']); |
191 | 200 | |
192 | 201 | // Don't allow a post if it's locked and you aren't all powerful. |
193 | - if ($locked && !allowedTo('moderate_board')) |
|
194 | - fatal_lang_error('topic_locked', false); |
|
202 | + if ($locked && !allowedTo('moderate_board')) { |
|
203 | + fatal_lang_error('topic_locked', false); |
|
204 | + } |
|
195 | 205 | // Check the users permissions - is the user allowed to add or post a poll? |
196 | 206 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
197 | 207 | { |
198 | 208 | // New topic, new poll. |
199 | - if (empty($topic)) |
|
200 | - isAllowedTo('poll_post'); |
|
209 | + if (empty($topic)) { |
|
210 | + isAllowedTo('poll_post'); |
|
211 | + } |
|
201 | 212 | // This is an old topic - but it is yours! Can you add to it? |
202 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
203 | - isAllowedTo('poll_add_own'); |
|
213 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
214 | + isAllowedTo('poll_add_own'); |
|
215 | + } |
|
204 | 216 | // If you're not the owner, can you add to any poll? |
205 | - else |
|
206 | - isAllowedTo('poll_add_any'); |
|
217 | + else { |
|
218 | + isAllowedTo('poll_add_any'); |
|
219 | + } |
|
207 | 220 | |
208 | 221 | require_once($sourcedir . '/Subs-Members.php'); |
209 | 222 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -232,8 +245,9 @@ discard block |
||
232 | 245 | if ($context['make_event']) |
233 | 246 | { |
234 | 247 | // They might want to pick a board. |
235 | - if (!isset($context['current_board'])) |
|
236 | - $context['current_board'] = 0; |
|
248 | + if (!isset($context['current_board'])) { |
|
249 | + $context['current_board'] = 0; |
|
250 | + } |
|
237 | 251 | |
238 | 252 | // Start loading up the event info. |
239 | 253 | $context['event'] = array(); |
@@ -247,10 +261,11 @@ discard block |
||
247 | 261 | isAllowedTo('calendar_post'); |
248 | 262 | |
249 | 263 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
250 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
251 | - $time_string = '%k:%M'; |
|
252 | - else |
|
253 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
264 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
265 | + $time_string = '%k:%M'; |
|
266 | + } else { |
|
267 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
268 | + } |
|
254 | 269 | |
255 | 270 | $js_time_string = str_replace( |
256 | 271 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -272,8 +287,7 @@ discard block |
||
272 | 287 | require_once($sourcedir . '/Subs-Calendar.php'); |
273 | 288 | $eventProperties = getEventProperties($context['event']['id']); |
274 | 289 | $context['event'] = array_merge($context['event'], $eventProperties); |
275 | - } |
|
276 | - else |
|
290 | + } else |
|
277 | 291 | { |
278 | 292 | // Get the current event information. |
279 | 293 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -281,15 +295,18 @@ discard block |
||
281 | 295 | $context['event'] = array_merge($context['event'], $eventProperties); |
282 | 296 | |
283 | 297 | // Make sure the year and month are in the valid range. |
284 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
285 | - fatal_lang_error('invalid_month', false); |
|
286 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
287 | - fatal_lang_error('invalid_year', false); |
|
298 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
299 | + fatal_lang_error('invalid_month', false); |
|
300 | + } |
|
301 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
302 | + fatal_lang_error('invalid_year', false); |
|
303 | + } |
|
288 | 304 | |
289 | 305 | // Get a list of boards they can post in. |
290 | 306 | $boards = boardsAllowedTo('post_new'); |
291 | - if (empty($boards)) |
|
292 | - fatal_lang_error('cannot_post_new', 'user'); |
|
307 | + if (empty($boards)) { |
|
308 | + fatal_lang_error('cannot_post_new', 'user'); |
|
309 | + } |
|
293 | 310 | |
294 | 311 | // Load a list of boards for this event in the context. |
295 | 312 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -408,10 +425,11 @@ discard block |
||
408 | 425 | |
409 | 426 | if (!empty($context['new_replies'])) |
410 | 427 | { |
411 | - if ($context['new_replies'] == 1) |
|
412 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
413 | - else |
|
414 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
428 | + if ($context['new_replies'] == 1) { |
|
429 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
430 | + } else { |
|
431 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
432 | + } |
|
415 | 433 | |
416 | 434 | $post_errors[] = 'new_replies'; |
417 | 435 | |
@@ -423,9 +441,9 @@ discard block |
||
423 | 441 | // Get a response prefix (like 'Re:') in the default forum language. |
424 | 442 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
425 | 443 | { |
426 | - if ($language === $user_info['language']) |
|
427 | - $context['response_prefix'] = $txt['response_prefix']; |
|
428 | - else |
|
444 | + if ($language === $user_info['language']) { |
|
445 | + $context['response_prefix'] = $txt['response_prefix']; |
|
446 | + } else |
|
429 | 447 | { |
430 | 448 | loadLanguage('index', $language, false); |
431 | 449 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -438,8 +456,9 @@ discard block |
||
438 | 456 | // Do we have a body, but an error happened. |
439 | 457 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
440 | 458 | { |
441 | - if (isset($_REQUEST['quickReply'])) |
|
442 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
459 | + if (isset($_REQUEST['quickReply'])) { |
|
460 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Validate inputs. |
445 | 464 | if (empty($context['post_error'])) |
@@ -447,15 +466,17 @@ discard block |
||
447 | 466 | // This means they didn't click Post and get an error. |
448 | 467 | $really_previewing = true; |
449 | 468 | |
450 | - } |
|
451 | - else |
|
469 | + } else |
|
452 | 470 | { |
453 | - if (!isset($_REQUEST['subject'])) |
|
454 | - $_REQUEST['subject'] = ''; |
|
455 | - if (!isset($_REQUEST['message'])) |
|
456 | - $_REQUEST['message'] = ''; |
|
457 | - if (!isset($_REQUEST['icon'])) |
|
458 | - $_REQUEST['icon'] = 'xx'; |
|
471 | + if (!isset($_REQUEST['subject'])) { |
|
472 | + $_REQUEST['subject'] = ''; |
|
473 | + } |
|
474 | + if (!isset($_REQUEST['message'])) { |
|
475 | + $_REQUEST['message'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['icon'])) { |
|
478 | + $_REQUEST['icon'] = 'xx'; |
|
479 | + } |
|
459 | 480 | |
460 | 481 | // They are previewing if they asked to preview (i.e. came from quick reply). |
461 | 482 | $really_previewing = !empty($_POST['preview']); |
@@ -471,8 +492,9 @@ discard block |
||
471 | 492 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
472 | 493 | |
473 | 494 | // Make sure the subject isn't too long - taking into account special characters. |
474 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
475 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
495 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
496 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
497 | + } |
|
476 | 498 | |
477 | 499 | if (isset($_REQUEST['poll'])) |
478 | 500 | { |
@@ -484,8 +506,9 @@ discard block |
||
484 | 506 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
485 | 507 | foreach ($_POST['options'] as $option) |
486 | 508 | { |
487 | - if (trim($option) == '') |
|
488 | - continue; |
|
509 | + if (trim($option) == '') { |
|
510 | + continue; |
|
511 | + } |
|
489 | 512 | |
490 | 513 | $context['choices'][] = array( |
491 | 514 | 'id' => $choice_id++, |
@@ -547,13 +570,14 @@ discard block |
||
547 | 570 | $context['preview_subject'] = $form_subject; |
548 | 571 | |
549 | 572 | censorText($context['preview_subject']); |
573 | + } else { |
|
574 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
550 | 575 | } |
551 | - else |
|
552 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 576 | |
554 | 577 | // Protect any CDATA blocks. |
555 | - if (isset($_REQUEST['xml'])) |
|
556 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
578 | + if (isset($_REQUEST['xml'])) { |
|
579 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
596 | - fatal_lang_error('no_board', false); |
|
619 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
620 | + fatal_lang_error('no_board', false); |
|
621 | + } |
|
597 | 622 | $row = $smcFunc['db_fetch_assoc']($request); |
598 | 623 | |
599 | 624 | $attachment_stuff = array($row); |
600 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
601 | - $attachment_stuff[] = $row2; |
|
625 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $attachment_stuff[] = $row2; |
|
627 | + } |
|
602 | 628 | $smcFunc['db_free_result']($request); |
603 | 629 | |
604 | 630 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
605 | 631 | { |
606 | 632 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
607 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
608 | - fatal_lang_error('modify_post_time_passed', false); |
|
609 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
610 | - isAllowedTo('modify_replies'); |
|
611 | - else |
|
612 | - isAllowedTo('modify_own'); |
|
633 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
634 | + fatal_lang_error('modify_post_time_passed', false); |
|
635 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
636 | + isAllowedTo('modify_replies'); |
|
637 | + } else { |
|
638 | + isAllowedTo('modify_own'); |
|
639 | + } |
|
640 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
641 | + isAllowedTo('modify_replies'); |
|
642 | + } else { |
|
643 | + isAllowedTo('modify_any'); |
|
613 | 644 | } |
614 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
615 | - isAllowedTo('modify_replies'); |
|
616 | - else |
|
617 | - isAllowedTo('modify_any'); |
|
618 | 645 | |
619 | 646 | if ($context['can_announce'] && !empty($row['id_action'])) |
620 | 647 | { |
@@ -638,8 +665,9 @@ discard block |
||
638 | 665 | |
639 | 666 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 667 | { |
641 | - if ($row['filesize'] <= 0) |
|
642 | - continue; |
|
668 | + if ($row['filesize'] <= 0) { |
|
669 | + continue; |
|
670 | + } |
|
643 | 671 | $context['current_attachments'][$row['id_attach']] = array( |
644 | 672 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
645 | 673 | 'size' => $row['filesize'], |
@@ -709,29 +737,32 @@ discard block |
||
709 | 737 | ) |
710 | 738 | ); |
711 | 739 | // The message they were trying to edit was most likely deleted. |
712 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
713 | - fatal_lang_error('no_message', false); |
|
740 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
741 | + fatal_lang_error('no_message', false); |
|
742 | + } |
|
714 | 743 | $row = $smcFunc['db_fetch_assoc']($request); |
715 | 744 | |
716 | 745 | $attachment_stuff = array($row); |
717 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
718 | - $attachment_stuff[] = $row2; |
|
746 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
747 | + $attachment_stuff[] = $row2; |
|
748 | + } |
|
719 | 749 | $smcFunc['db_free_result']($request); |
720 | 750 | |
721 | 751 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
722 | 752 | { |
723 | 753 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
724 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
725 | - fatal_lang_error('modify_post_time_passed', false); |
|
726 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
727 | - isAllowedTo('modify_replies'); |
|
728 | - else |
|
729 | - isAllowedTo('modify_own'); |
|
754 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
755 | + fatal_lang_error('modify_post_time_passed', false); |
|
756 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
757 | + isAllowedTo('modify_replies'); |
|
758 | + } else { |
|
759 | + isAllowedTo('modify_own'); |
|
760 | + } |
|
761 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
762 | + isAllowedTo('modify_replies'); |
|
763 | + } else { |
|
764 | + isAllowedTo('modify_any'); |
|
730 | 765 | } |
731 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
732 | - isAllowedTo('modify_replies'); |
|
733 | - else |
|
734 | - isAllowedTo('modify_any'); |
|
735 | 766 | |
736 | 767 | if ($context['can_announce'] && !empty($row['id_action'])) |
737 | 768 | { |
@@ -758,15 +789,17 @@ discard block |
||
758 | 789 | $context['icon'] = $row['icon']; |
759 | 790 | |
760 | 791 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
761 | - if (!$row['approved'] && !$context['show_approval']) |
|
762 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
792 | + if (!$row['approved'] && !$context['show_approval']) { |
|
793 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
794 | + } |
|
763 | 795 | |
764 | 796 | // Sort the attachments so they are in the order saved |
765 | 797 | $temp = array(); |
766 | 798 | foreach ($attachment_stuff as $attachment) |
767 | 799 | { |
768 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
769 | - $temp[$attachment['id_attach']] = $attachment; |
|
800 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
801 | + $temp[$attachment['id_attach']] = $attachment; |
|
802 | + } |
|
770 | 803 | |
771 | 804 | } |
772 | 805 | ksort($temp); |
@@ -828,14 +861,16 @@ discard block |
||
828 | 861 | 'is_approved' => 1, |
829 | 862 | ) |
830 | 863 | ); |
831 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
832 | - fatal_lang_error('quoted_post_deleted', false); |
|
864 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
865 | + fatal_lang_error('quoted_post_deleted', false); |
|
866 | + } |
|
833 | 867 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
834 | 868 | $smcFunc['db_free_result']($request); |
835 | 869 | |
836 | 870 | // Add 'Re: ' to the front of the quoted subject. |
837 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
838 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
871 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
872 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
873 | + } |
|
839 | 874 | |
840 | 875 | // Censor the message and subject. |
841 | 876 | censorText($form_message); |
@@ -848,10 +883,11 @@ discard block |
||
848 | 883 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
849 | 884 | { |
850 | 885 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
851 | - if ($i % 4 == 0) |
|
852 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
886 | + if ($i % 4 == 0) { |
|
887 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
853 | 888 | { |
854 | 889 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
890 | + } |
|
855 | 891 | }, $parts[$i]); |
856 | 892 | } |
857 | 893 | $form_message = implode('', $parts); |
@@ -860,8 +896,9 @@ discard block |
||
860 | 896 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
861 | 897 | |
862 | 898 | // Remove any nested quotes, if necessary. |
863 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
864 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
899 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
900 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
901 | + } |
|
865 | 902 | |
866 | 903 | // Add a quote string on the front and end. |
867 | 904 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -873,15 +910,15 @@ discard block |
||
873 | 910 | $form_subject = $first_subject; |
874 | 911 | |
875 | 912 | // Add 'Re: ' to the front of the subject. |
876 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
877 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
913 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
914 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
915 | + } |
|
878 | 916 | |
879 | 917 | // Censor the subject. |
880 | 918 | censorText($form_subject); |
881 | 919 | |
882 | 920 | $form_message = ''; |
883 | - } |
|
884 | - else |
|
921 | + } else |
|
885 | 922 | { |
886 | 923 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
887 | 924 | $form_message = ''; |
@@ -899,13 +936,15 @@ discard block |
||
899 | 936 | if (isset($_REQUEST['msg'])) |
900 | 937 | { |
901 | 938 | $context['attachments']['quantity'] = count($context['current_attachments']); |
902 | - foreach ($context['current_attachments'] as $attachment) |
|
903 | - $context['attachments']['total_size'] += $attachment['size']; |
|
939 | + foreach ($context['current_attachments'] as $attachment) { |
|
940 | + $context['attachments']['total_size'] += $attachment['size']; |
|
941 | + } |
|
904 | 942 | } |
905 | 943 | |
906 | 944 | // A bit of house keeping first. |
907 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
908 | - unset($_SESSION['temp_attachments']); |
|
945 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
946 | + unset($_SESSION['temp_attachments']); |
|
947 | + } |
|
909 | 948 | |
910 | 949 | if (!empty($_SESSION['temp_attachments'])) |
911 | 950 | { |
@@ -914,9 +953,10 @@ discard block |
||
914 | 953 | { |
915 | 954 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
916 | 955 | { |
917 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
918 | - if (file_exists($attachment['tmp_name'])) |
|
956 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
957 | + if (file_exists($attachment['tmp_name'])) |
|
919 | 958 | unlink($attachment['tmp_name']); |
959 | + } |
|
920 | 960 | } |
921 | 961 | $post_errors[] = 'temp_attachments_gone'; |
922 | 962 | $_SESSION['temp_attachments'] = array(); |
@@ -930,8 +970,9 @@ discard block |
||
930 | 970 | // See if any files still exist before showing the warning message and the files attached. |
931 | 971 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
932 | 972 | { |
933 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
934 | - continue; |
|
973 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
974 | + continue; |
|
975 | + } |
|
935 | 976 | |
936 | 977 | if (file_exists($attachment['tmp_name'])) |
937 | 978 | { |
@@ -941,20 +982,21 @@ discard block |
||
941 | 982 | break; |
942 | 983 | } |
943 | 984 | } |
944 | - } |
|
945 | - else |
|
985 | + } else |
|
946 | 986 | { |
947 | 987 | // Since, they don't belong here. Let's inform the user that they exist.. |
948 | - if (!empty($topic)) |
|
949 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
950 | - else |
|
951 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
988 | + if (!empty($topic)) { |
|
989 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
990 | + } else { |
|
991 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
992 | + } |
|
952 | 993 | |
953 | 994 | // Compile a list of the files to show the user. |
954 | 995 | $file_list = array(); |
955 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
956 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
996 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
997 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
957 | 998 | $file_list[] = $attachment['name']; |
999 | + } |
|
958 | 1000 | |
959 | 1001 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
960 | 1002 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -966,8 +1008,7 @@ discard block |
||
966 | 1008 | |
967 | 1009 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
968 | 1010 | $context['ignore_temp_attachments'] = true; |
969 | - } |
|
970 | - else |
|
1011 | + } else |
|
971 | 1012 | { |
972 | 1013 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
973 | 1014 | $context['ignore_temp_attachments'] = true; |
@@ -975,16 +1016,19 @@ discard block |
||
975 | 1016 | } |
976 | 1017 | } |
977 | 1018 | |
978 | - if (!empty($context['we_are_history'])) |
|
979 | - $post_errors[] = $context['we_are_history']; |
|
1019 | + if (!empty($context['we_are_history'])) { |
|
1020 | + $post_errors[] = $context['we_are_history']; |
|
1021 | + } |
|
980 | 1022 | |
981 | 1023 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
982 | 1024 | { |
983 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
984 | - break; |
|
1025 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1026 | + break; |
|
1027 | + } |
|
985 | 1028 | |
986 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
987 | - continue; |
|
1029 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1030 | + continue; |
|
1031 | + } |
|
988 | 1032 | |
989 | 1033 | if ($attachID == 'initial_error') |
990 | 1034 | { |
@@ -999,15 +1043,17 @@ discard block |
||
999 | 1043 | { |
1000 | 1044 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1001 | 1045 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1002 | - foreach ($attachment['errors'] as $error) |
|
1003 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1046 | + foreach ($attachment['errors'] as $error) { |
|
1047 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1048 | + } |
|
1004 | 1049 | $txt['error_attach_errors'] .= '</div>'; |
1005 | 1050 | $post_errors[] = 'attach_errors'; |
1006 | 1051 | |
1007 | 1052 | // Take out the trash. |
1008 | 1053 | unset($_SESSION['temp_attachments'][$attachID]); |
1009 | - if (file_exists($attachment['tmp_name'])) |
|
1010 | - unlink($attachment['tmp_name']); |
|
1054 | + if (file_exists($attachment['tmp_name'])) { |
|
1055 | + unlink($attachment['tmp_name']); |
|
1056 | + } |
|
1011 | 1057 | continue; |
1012 | 1058 | } |
1013 | 1059 | |
@@ -1020,8 +1066,9 @@ discard block |
||
1020 | 1066 | |
1021 | 1067 | $context['attachments']['quantity']++; |
1022 | 1068 | $context['attachments']['total_size'] += $attachment['size']; |
1023 | - if (!isset($context['files_in_session_warning'])) |
|
1024 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1069 | + if (!isset($context['files_in_session_warning'])) { |
|
1070 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1071 | + } |
|
1025 | 1072 | |
1026 | 1073 | $context['current_attachments'][$attachID] = array( |
1027 | 1074 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1049,8 +1096,9 @@ discard block |
||
1049 | 1096 | } |
1050 | 1097 | |
1051 | 1098 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1052 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1053 | - $post_errors[] = 'need_qr_verification'; |
|
1099 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1100 | + $post_errors[] = 'need_qr_verification'; |
|
1101 | + } |
|
1054 | 1102 | |
1055 | 1103 | /* |
1056 | 1104 | * There are two error types: serious and minor. Serious errors |
@@ -1067,52 +1115,56 @@ discard block |
||
1067 | 1115 | { |
1068 | 1116 | loadLanguage('Errors'); |
1069 | 1117 | $context['error_type'] = 'minor'; |
1070 | - foreach ($post_errors as $post_error) |
|
1071 | - if (is_array($post_error)) |
|
1118 | + foreach ($post_errors as $post_error) { |
|
1119 | + if (is_array($post_error)) |
|
1072 | 1120 | { |
1073 | 1121 | $post_error_id = $post_error[0]; |
1122 | + } |
|
1074 | 1123 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1075 | 1124 | |
1076 | 1125 | // If it's not a minor error flag it as such. |
1077 | - if (!in_array($post_error_id, $minor_errors)) |
|
1078 | - $context['error_type'] = 'serious'; |
|
1079 | - } |
|
1080 | - else |
|
1126 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1127 | + $context['error_type'] = 'serious'; |
|
1128 | + } |
|
1129 | + } else |
|
1081 | 1130 | { |
1082 | 1131 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1083 | 1132 | |
1084 | 1133 | // If it's not a minor error flag it as such. |
1085 | - if (!in_array($post_error, $minor_errors)) |
|
1086 | - $context['error_type'] = 'serious'; |
|
1134 | + if (!in_array($post_error, $minor_errors)) { |
|
1135 | + $context['error_type'] = 'serious'; |
|
1136 | + } |
|
1087 | 1137 | } |
1088 | 1138 | } |
1089 | 1139 | |
1090 | 1140 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1091 | - if (isset($_REQUEST['poll'])) |
|
1092 | - $context['page_title'] = $txt['new_poll']; |
|
1093 | - elseif ($context['make_event']) |
|
1094 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1095 | - elseif (isset($_REQUEST['msg'])) |
|
1096 | - $context['page_title'] = $txt['modify_msg']; |
|
1097 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1098 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1099 | - elseif (empty($topic)) |
|
1100 | - $context['page_title'] = $txt['start_new_topic']; |
|
1101 | - else |
|
1102 | - $context['page_title'] = $txt['post_reply']; |
|
1141 | + if (isset($_REQUEST['poll'])) { |
|
1142 | + $context['page_title'] = $txt['new_poll']; |
|
1143 | + } elseif ($context['make_event']) { |
|
1144 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1145 | + } elseif (isset($_REQUEST['msg'])) { |
|
1146 | + $context['page_title'] = $txt['modify_msg']; |
|
1147 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1148 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1149 | + } elseif (empty($topic)) { |
|
1150 | + $context['page_title'] = $txt['start_new_topic']; |
|
1151 | + } else { |
|
1152 | + $context['page_title'] = $txt['post_reply']; |
|
1153 | + } |
|
1103 | 1154 | |
1104 | 1155 | // Build the link tree. |
1105 | - if (empty($topic)) |
|
1106 | - $context['linktree'][] = array( |
|
1156 | + if (empty($topic)) { |
|
1157 | + $context['linktree'][] = array( |
|
1107 | 1158 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1108 | 1159 | ); |
1109 | - else |
|
1110 | - $context['linktree'][] = array( |
|
1160 | + } else { |
|
1161 | + $context['linktree'][] = array( |
|
1111 | 1162 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1112 | 1163 | 'name' => $form_subject, |
1113 | 1164 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1114 | 1165 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1115 | 1166 | ); |
1167 | + } |
|
1116 | 1168 | |
1117 | 1169 | $context['subject'] = addcslashes($form_subject, '"'); |
1118 | 1170 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1156,8 +1208,9 @@ discard block |
||
1156 | 1208 | // Message icons - customized icons are off? |
1157 | 1209 | $context['icons'] = getMessageIcons($board); |
1158 | 1210 | |
1159 | - if (!empty($context['icons'])) |
|
1160 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1211 | + if (!empty($context['icons'])) { |
|
1212 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1213 | + } |
|
1161 | 1214 | |
1162 | 1215 | // Are we starting a poll? if set the poll icon as selected if its available |
1163 | 1216 | if (isset($_REQUEST['poll'])) |
@@ -1177,8 +1230,9 @@ discard block |
||
1177 | 1230 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1178 | 1231 | { |
1179 | 1232 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1180 | - if ($context['icons'][$i]['selected']) |
|
1181 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1233 | + if ($context['icons'][$i]['selected']) { |
|
1234 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1235 | + } |
|
1182 | 1236 | } |
1183 | 1237 | if (empty($context['icon_url'])) |
1184 | 1238 | { |
@@ -1192,8 +1246,9 @@ discard block |
||
1192 | 1246 | )); |
1193 | 1247 | } |
1194 | 1248 | |
1195 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1196 | - getTopic(); |
|
1249 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1250 | + getTopic(); |
|
1251 | + } |
|
1197 | 1252 | |
1198 | 1253 | // If the user can post attachments prepare the warning labels. |
1199 | 1254 | if ($context['can_post_attachment']) |
@@ -1204,15 +1259,17 @@ discard block |
||
1204 | 1259 | $context['attachment_restrictions'] = array(); |
1205 | 1260 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1206 | 1261 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1207 | - foreach ($attachmentRestrictionTypes as $type) |
|
1208 | - if (!empty($modSettings[$type])) |
|
1262 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1263 | + if (!empty($modSettings[$type])) |
|
1209 | 1264 | { |
1210 | 1265 | $context['attachment_restrictions'][] = sprintf($txt['attach_restrict_' . $type . ($modSettings[$type] >= 1024 ? '_MB' : '')], comma_format($modSettings[$type], 0)); |
1266 | + } |
|
1211 | 1267 | // Show some numbers. If they exist. |
1212 | - if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) |
|
1213 | - $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
1214 | - elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) |
|
1215 | - $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
1268 | + if ($type == 'attachmentNumPerPostLimit' && $context['attachments']['quantity'] > 0) { |
|
1269 | + $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
|
1270 | + } elseif ($type == 'attachmentPostLimit' && $context['attachments']['total_size'] > 0) { |
|
1271 | + $context['attachment_restrictions'][] = sprintf($txt['attach_available'], comma_format(round(max($modSettings['attachmentPostLimit'] - ($context['attachments']['total_size'] / 1024), 0)), 0)); |
|
1272 | + } |
|
1216 | 1273 | } |
1217 | 1274 | } |
1218 | 1275 | |
@@ -1246,8 +1303,8 @@ discard block |
||
1246 | 1303 | |
1247 | 1304 | if (!empty($context['current_attachments'])) |
1248 | 1305 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1306 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1307 | + addInlineJavaScript(' |
|
1251 | 1308 | current_attachments.push({ |
1252 | 1309 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1310 | size: '. $mock['size'] . ', |
@@ -1256,6 +1313,7 @@ discard block |
||
1256 | 1313 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1314 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1315 | });', true); |
1316 | + } |
|
1259 | 1317 | } |
1260 | 1318 | |
1261 | 1319 | // File Upload. |
@@ -1300,8 +1358,9 @@ discard block |
||
1300 | 1358 | var current_board = '. (empty($context['current_board']) ? 'null' : $context['current_board']) . ';', false); |
1301 | 1359 | |
1302 | 1360 | // Finally, load the template. |
1303 | - if (!isset($_REQUEST['xml'])) |
|
1304 | - loadTemplate('Post'); |
|
1361 | + if (!isset($_REQUEST['xml'])) { |
|
1362 | + loadTemplate('Post'); |
|
1363 | + } |
|
1305 | 1364 | |
1306 | 1365 | call_integration_hook('integrate_post_end'); |
1307 | 1366 | } |
@@ -1322,13 +1381,14 @@ discard block |
||
1322 | 1381 | // Sneaking off, are we? |
1323 | 1382 | if (empty($_POST) && empty($topic)) |
1324 | 1383 | { |
1325 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1326 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1327 | - else |
|
1328 | - fatal_lang_error('post_upload_error', false); |
|
1384 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1385 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1386 | + } else { |
|
1387 | + fatal_lang_error('post_upload_error', false); |
|
1388 | + } |
|
1389 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1390 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1329 | 1391 | } |
1330 | - elseif (empty($_POST) && !empty($topic)) |
|
1331 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1332 | 1392 | |
1333 | 1393 | // No need! |
1334 | 1394 | $context['robot_no_index'] = true; |
@@ -1340,8 +1400,9 @@ discard block |
||
1340 | 1400 | $post_errors = array(); |
1341 | 1401 | |
1342 | 1402 | // If the session has timed out, let the user re-submit their form. |
1343 | - if (checkSession('post', '', false) != '') |
|
1344 | - $post_errors[] = 'session_timeout'; |
|
1403 | + if (checkSession('post', '', false) != '') { |
|
1404 | + $post_errors[] = 'session_timeout'; |
|
1405 | + } |
|
1345 | 1406 | |
1346 | 1407 | // Wrong verification code? |
1347 | 1408 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1351,33 +1412,38 @@ discard block |
||
1351 | 1412 | 'id' => 'post', |
1352 | 1413 | ); |
1353 | 1414 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1354 | - if (is_array($context['require_verification'])) |
|
1355 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1415 | + if (is_array($context['require_verification'])) { |
|
1416 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1417 | + } |
|
1356 | 1418 | } |
1357 | 1419 | |
1358 | 1420 | require_once($sourcedir . '/Subs-Post.php'); |
1359 | 1421 | loadLanguage('Post'); |
1360 | 1422 | |
1361 | 1423 | // Drafts enabled and needed? |
1362 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1363 | - require_once($sourcedir . '/Drafts.php'); |
|
1424 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1425 | + require_once($sourcedir . '/Drafts.php'); |
|
1426 | + } |
|
1364 | 1427 | |
1365 | 1428 | // First check to see if they are trying to delete any current attachments. |
1366 | 1429 | if (isset($_POST['attach_del'])) |
1367 | 1430 | { |
1368 | 1431 | $keep_temp = array(); |
1369 | 1432 | $keep_ids = array(); |
1370 | - foreach ($_POST['attach_del'] as $dummy) |
|
1371 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1433 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1434 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1372 | 1435 | $keep_temp[] = $dummy; |
1373 | - else |
|
1374 | - $keep_ids[] = (int) $dummy; |
|
1436 | + } |
|
1437 | + else { |
|
1438 | + $keep_ids[] = (int) $dummy; |
|
1439 | + } |
|
1375 | 1440 | |
1376 | - if (isset($_SESSION['temp_attachments'])) |
|
1377 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1441 | + if (isset($_SESSION['temp_attachments'])) { |
|
1442 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1378 | 1443 | { |
1379 | 1444 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1380 | 1445 | continue; |
1446 | + } |
|
1381 | 1447 | |
1382 | 1448 | unset($_SESSION['temp_attachments'][$attachID]); |
1383 | 1449 | unlink($attachment['tmp_name']); |
@@ -1419,24 +1485,28 @@ discard block |
||
1419 | 1485 | $smcFunc['db_free_result']($request); |
1420 | 1486 | |
1421 | 1487 | // Though the topic should be there, it might have vanished. |
1422 | - if (!is_array($topic_info)) |
|
1423 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1488 | + if (!is_array($topic_info)) { |
|
1489 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1490 | + } |
|
1424 | 1491 | |
1425 | 1492 | // Did this topic suddenly move? Just checking... |
1426 | - if ($topic_info['id_board'] != $board) |
|
1427 | - fatal_lang_error('not_a_topic'); |
|
1493 | + if ($topic_info['id_board'] != $board) { |
|
1494 | + fatal_lang_error('not_a_topic'); |
|
1495 | + } |
|
1428 | 1496 | } |
1429 | 1497 | |
1430 | 1498 | // Replying to a topic? |
1431 | 1499 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1432 | 1500 | { |
1433 | 1501 | // Don't allow a post if it's locked. |
1434 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1435 | - fatal_lang_error('topic_locked', false); |
|
1502 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1503 | + fatal_lang_error('topic_locked', false); |
|
1504 | + } |
|
1436 | 1505 | |
1437 | 1506 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1438 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1439 | - unset($_REQUEST['poll']); |
|
1507 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1508 | + unset($_REQUEST['poll']); |
|
1509 | + } |
|
1440 | 1510 | |
1441 | 1511 | // Do the permissions and approval stuff... |
1442 | 1512 | $becomesApproved = true; |
@@ -1452,44 +1522,43 @@ discard block |
||
1452 | 1522 | |
1453 | 1523 | // Set a nice session var... |
1454 | 1524 | $_SESSION['becomesUnapproved'] = true; |
1455 | - } |
|
1456 | - |
|
1457 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1525 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1458 | 1526 | { |
1459 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1460 | - $becomesApproved = false; |
|
1461 | - |
|
1462 | - else |
|
1463 | - isAllowedTo('post_reply_any'); |
|
1464 | - } |
|
1465 | - elseif (!allowedTo('post_reply_any')) |
|
1527 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1528 | + $becomesApproved = false; |
|
1529 | + } else { |
|
1530 | + isAllowedTo('post_reply_any'); |
|
1531 | + } |
|
1532 | + } elseif (!allowedTo('post_reply_any')) |
|
1466 | 1533 | { |
1467 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1468 | - $becomesApproved = false; |
|
1469 | - |
|
1470 | - else |
|
1471 | - isAllowedTo('post_reply_own'); |
|
1534 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1535 | + $becomesApproved = false; |
|
1536 | + } else { |
|
1537 | + isAllowedTo('post_reply_own'); |
|
1538 | + } |
|
1472 | 1539 | } |
1473 | 1540 | |
1474 | 1541 | if (isset($_POST['lock'])) |
1475 | 1542 | { |
1476 | 1543 | // Nothing is changed to the lock. |
1477 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1478 | - unset($_POST['lock']); |
|
1544 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1545 | + unset($_POST['lock']); |
|
1546 | + } |
|
1479 | 1547 | |
1480 | 1548 | // You're have no permission to lock this topic. |
1481 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1482 | - unset($_POST['lock']); |
|
1549 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1550 | + unset($_POST['lock']); |
|
1551 | + } |
|
1483 | 1552 | |
1484 | 1553 | // You are allowed to (un)lock your own topic only. |
1485 | 1554 | elseif (!allowedTo('lock_any')) |
1486 | 1555 | { |
1487 | 1556 | // You cannot override a moderator lock. |
1488 | - if ($topic_info['locked'] == 1) |
|
1489 | - unset($_POST['lock']); |
|
1490 | - |
|
1491 | - else |
|
1492 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1557 | + if ($topic_info['locked'] == 1) { |
|
1558 | + unset($_POST['lock']); |
|
1559 | + } else { |
|
1560 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1561 | + } |
|
1493 | 1562 | } |
1494 | 1563 | // Hail mighty moderator, (un)lock this topic immediately. |
1495 | 1564 | else |
@@ -1497,19 +1566,21 @@ discard block |
||
1497 | 1566 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1498 | 1567 | |
1499 | 1568 | // Did someone (un)lock this while you were posting? |
1500 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1501 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1569 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1570 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1571 | + } |
|
1502 | 1572 | } |
1503 | 1573 | } |
1504 | 1574 | |
1505 | 1575 | // So you wanna (un)sticky this...let's see. |
1506 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1507 | - unset($_POST['sticky']); |
|
1508 | - elseif (isset($_POST['sticky'])) |
|
1576 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1577 | + unset($_POST['sticky']); |
|
1578 | + } elseif (isset($_POST['sticky'])) |
|
1509 | 1579 | { |
1510 | 1580 | // Did someone (un)sticky this while you were posting? |
1511 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1512 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1581 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1582 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1583 | + } |
|
1513 | 1584 | } |
1514 | 1585 | |
1515 | 1586 | // If drafts are enabled, then pass this off |
@@ -1536,26 +1607,31 @@ discard block |
||
1536 | 1607 | |
1537 | 1608 | // Do like, the permissions, for safety and stuff... |
1538 | 1609 | $becomesApproved = true; |
1539 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1540 | - $becomesApproved = false; |
|
1541 | - else |
|
1542 | - isAllowedTo('post_new'); |
|
1610 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1611 | + $becomesApproved = false; |
|
1612 | + } else { |
|
1613 | + isAllowedTo('post_new'); |
|
1614 | + } |
|
1543 | 1615 | |
1544 | 1616 | if (isset($_POST['lock'])) |
1545 | 1617 | { |
1546 | 1618 | // New topics are by default not locked. |
1547 | - if (empty($_POST['lock'])) |
|
1548 | - unset($_POST['lock']); |
|
1619 | + if (empty($_POST['lock'])) { |
|
1620 | + unset($_POST['lock']); |
|
1621 | + } |
|
1549 | 1622 | // Besides, you need permission. |
1550 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1551 | - unset($_POST['lock']); |
|
1623 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1624 | + unset($_POST['lock']); |
|
1625 | + } |
|
1552 | 1626 | // A moderator-lock (1) can override a user-lock (2). |
1553 | - else |
|
1554 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1627 | + else { |
|
1628 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1629 | + } |
|
1555 | 1630 | } |
1556 | 1631 | |
1557 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1558 | - unset($_POST['sticky']); |
|
1632 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1633 | + unset($_POST['sticky']); |
|
1634 | + } |
|
1559 | 1635 | |
1560 | 1636 | // Saving your new topic as a draft first? |
1561 | 1637 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1580,31 +1656,37 @@ discard block |
||
1580 | 1656 | 'id_msg' => $_REQUEST['msg'], |
1581 | 1657 | ) |
1582 | 1658 | ); |
1583 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1584 | - fatal_lang_error('cant_find_messages', false); |
|
1659 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1660 | + fatal_lang_error('cant_find_messages', false); |
|
1661 | + } |
|
1585 | 1662 | $row = $smcFunc['db_fetch_assoc']($request); |
1586 | 1663 | $smcFunc['db_free_result']($request); |
1587 | 1664 | |
1588 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1589 | - fatal_lang_error('topic_locked', false); |
|
1665 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1666 | + fatal_lang_error('topic_locked', false); |
|
1667 | + } |
|
1590 | 1668 | |
1591 | 1669 | if (isset($_POST['lock'])) |
1592 | 1670 | { |
1593 | 1671 | // Nothing changes to the lock status. |
1594 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1595 | - unset($_POST['lock']); |
|
1672 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1673 | + unset($_POST['lock']); |
|
1674 | + } |
|
1596 | 1675 | // You're simply not allowed to (un)lock this. |
1597 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1598 | - unset($_POST['lock']); |
|
1676 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1677 | + unset($_POST['lock']); |
|
1678 | + } |
|
1599 | 1679 | // You're only allowed to lock your own topics. |
1600 | 1680 | elseif (!allowedTo('lock_any')) |
1601 | 1681 | { |
1602 | 1682 | // You're not allowed to break a moderator's lock. |
1603 | - if ($topic_info['locked'] == 1) |
|
1604 | - unset($_POST['lock']); |
|
1683 | + if ($topic_info['locked'] == 1) { |
|
1684 | + unset($_POST['lock']); |
|
1685 | + } |
|
1605 | 1686 | // Lock it with a soft lock or unlock it. |
1606 | - else |
|
1607 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1687 | + else { |
|
1688 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1689 | + } |
|
1608 | 1690 | } |
1609 | 1691 | // You must be the moderator. |
1610 | 1692 | else |
@@ -1612,44 +1694,46 @@ discard block |
||
1612 | 1694 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1613 | 1695 | |
1614 | 1696 | // Did someone (un)lock this while you were posting? |
1615 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1616 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1697 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1698 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1699 | + } |
|
1617 | 1700 | } |
1618 | 1701 | } |
1619 | 1702 | |
1620 | 1703 | // Change the sticky status of this topic? |
1621 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1622 | - unset($_POST['sticky']); |
|
1623 | - elseif (isset($_POST['sticky'])) |
|
1704 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1705 | + unset($_POST['sticky']); |
|
1706 | + } elseif (isset($_POST['sticky'])) |
|
1624 | 1707 | { |
1625 | 1708 | // Did someone (un)sticky this while you were posting? |
1626 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1627 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1709 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1710 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1711 | + } |
|
1628 | 1712 | } |
1629 | 1713 | |
1630 | 1714 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1631 | 1715 | { |
1632 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1633 | - fatal_lang_error('modify_post_time_passed', false); |
|
1634 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1635 | - isAllowedTo('modify_replies'); |
|
1636 | - else |
|
1637 | - isAllowedTo('modify_own'); |
|
1638 | - } |
|
1639 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1716 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1717 | + fatal_lang_error('modify_post_time_passed', false); |
|
1718 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1719 | + isAllowedTo('modify_replies'); |
|
1720 | + } else { |
|
1721 | + isAllowedTo('modify_own'); |
|
1722 | + } |
|
1723 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1640 | 1724 | { |
1641 | 1725 | isAllowedTo('modify_replies'); |
1642 | 1726 | |
1643 | 1727 | // If you're modifying a reply, I say it better be logged... |
1644 | 1728 | $moderationAction = true; |
1645 | - } |
|
1646 | - else |
|
1729 | + } else |
|
1647 | 1730 | { |
1648 | 1731 | isAllowedTo('modify_any'); |
1649 | 1732 | |
1650 | 1733 | // Log it, assuming you're not modifying your own post. |
1651 | - if ($row['id_member'] != $user_info['id']) |
|
1652 | - $moderationAction = true; |
|
1734 | + if ($row['id_member'] != $user_info['id']) { |
|
1735 | + $moderationAction = true; |
|
1736 | + } |
|
1653 | 1737 | } |
1654 | 1738 | |
1655 | 1739 | // If drafts are enabled, then lets send this off to save |
@@ -1686,20 +1770,24 @@ discard block |
||
1686 | 1770 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1687 | 1771 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1688 | 1772 | |
1689 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1690 | - $post_errors[] = 'no_name'; |
|
1691 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1692 | - $post_errors[] = 'long_name'; |
|
1773 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1774 | + $post_errors[] = 'no_name'; |
|
1775 | + } |
|
1776 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1777 | + $post_errors[] = 'long_name'; |
|
1778 | + } |
|
1693 | 1779 | |
1694 | 1780 | if (empty($modSettings['guest_post_no_email'])) |
1695 | 1781 | { |
1696 | 1782 | // Only check if they changed it! |
1697 | 1783 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1698 | 1784 | { |
1699 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1700 | - $post_errors[] = 'no_email'; |
|
1701 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1702 | - $post_errors[] = 'bad_email'; |
|
1785 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1786 | + $post_errors[] = 'no_email'; |
|
1787 | + } |
|
1788 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1789 | + $post_errors[] = 'bad_email'; |
|
1790 | + } |
|
1703 | 1791 | } |
1704 | 1792 | |
1705 | 1793 | // Now make sure this email address is not banned from posting. |
@@ -1715,75 +1803,89 @@ discard block |
||
1715 | 1803 | } |
1716 | 1804 | |
1717 | 1805 | // Coming from the quickReply? |
1718 | - if (isset($_POST['quickReply'])) |
|
1719 | - $_POST['message'] = $_POST['quickReply']; |
|
1806 | + if (isset($_POST['quickReply'])) { |
|
1807 | + $_POST['message'] = $_POST['quickReply']; |
|
1808 | + } |
|
1720 | 1809 | |
1721 | 1810 | // Check the subject and message. |
1722 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1723 | - $post_errors[] = 'no_subject'; |
|
1724 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1725 | - $post_errors[] = 'no_message'; |
|
1726 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1727 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1728 | - else |
|
1811 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1812 | + $post_errors[] = 'no_subject'; |
|
1813 | + } |
|
1814 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1815 | + $post_errors[] = 'no_message'; |
|
1816 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1817 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1818 | + } else |
|
1729 | 1819 | { |
1730 | 1820 | // Prepare the message a bit for some additional testing. |
1731 | 1821 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1732 | 1822 | |
1733 | 1823 | // Preparse code. (Zef) |
1734 | - if ($user_info['is_guest']) |
|
1735 | - $user_info['name'] = $_POST['guestname']; |
|
1824 | + if ($user_info['is_guest']) { |
|
1825 | + $user_info['name'] = $_POST['guestname']; |
|
1826 | + } |
|
1736 | 1827 | preparsecode($_POST['message']); |
1737 | 1828 | |
1738 | 1829 | // Let's see if there's still some content left without the tags. |
1739 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1740 | - $post_errors[] = 'no_message'; |
|
1830 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1831 | + $post_errors[] = 'no_message'; |
|
1832 | + } |
|
1833 | + } |
|
1834 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1835 | + $post_errors[] = 'no_event'; |
|
1741 | 1836 | } |
1742 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1743 | - $post_errors[] = 'no_event'; |
|
1744 | 1837 | // You are not! |
1745 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1746 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1838 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1839 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1840 | + } |
|
1747 | 1841 | |
1748 | 1842 | // Validate the poll... |
1749 | 1843 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1750 | 1844 | { |
1751 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1752 | - fatal_lang_error('no_access', false); |
|
1845 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1846 | + fatal_lang_error('no_access', false); |
|
1847 | + } |
|
1753 | 1848 | |
1754 | 1849 | // This is a new topic... so it's a new poll. |
1755 | - if (empty($topic)) |
|
1756 | - isAllowedTo('poll_post'); |
|
1850 | + if (empty($topic)) { |
|
1851 | + isAllowedTo('poll_post'); |
|
1852 | + } |
|
1757 | 1853 | // Can you add to your own topics? |
1758 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1759 | - isAllowedTo('poll_add_own'); |
|
1854 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1855 | + isAllowedTo('poll_add_own'); |
|
1856 | + } |
|
1760 | 1857 | // Can you add polls to any topic, then? |
1761 | - else |
|
1762 | - isAllowedTo('poll_add_any'); |
|
1858 | + else { |
|
1859 | + isAllowedTo('poll_add_any'); |
|
1860 | + } |
|
1763 | 1861 | |
1764 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1765 | - $post_errors[] = 'no_question'; |
|
1862 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1863 | + $post_errors[] = 'no_question'; |
|
1864 | + } |
|
1766 | 1865 | |
1767 | 1866 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1768 | 1867 | |
1769 | 1868 | // Get rid of empty ones. |
1770 | - foreach ($_POST['options'] as $k => $option) |
|
1771 | - if ($option == '') |
|
1869 | + foreach ($_POST['options'] as $k => $option) { |
|
1870 | + if ($option == '') |
|
1772 | 1871 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1872 | + } |
|
1773 | 1873 | |
1774 | 1874 | // What are you going to vote between with one choice?!? |
1775 | - if (count($_POST['options']) < 2) |
|
1776 | - $post_errors[] = 'poll_few'; |
|
1777 | - elseif (count($_POST['options']) > 256) |
|
1778 | - $post_errors[] = 'poll_many'; |
|
1875 | + if (count($_POST['options']) < 2) { |
|
1876 | + $post_errors[] = 'poll_few'; |
|
1877 | + } elseif (count($_POST['options']) > 256) { |
|
1878 | + $post_errors[] = 'poll_many'; |
|
1879 | + } |
|
1779 | 1880 | } |
1780 | 1881 | |
1781 | 1882 | if ($posterIsGuest) |
1782 | 1883 | { |
1783 | 1884 | // If user is a guest, make sure the chosen name isn't taken. |
1784 | 1885 | require_once($sourcedir . '/Subs-Members.php'); |
1785 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1786 | - $post_errors[] = 'bad_name'; |
|
1886 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1887 | + $post_errors[] = 'bad_name'; |
|
1888 | + } |
|
1787 | 1889 | } |
1788 | 1890 | // If the user isn't a guest, get his or her name and email. |
1789 | 1891 | elseif (!isset($_REQUEST['msg'])) |
@@ -1814,8 +1916,9 @@ discard block |
||
1814 | 1916 | } |
1815 | 1917 | |
1816 | 1918 | // Make sure the user isn't spamming the board. |
1817 | - if (!isset($_REQUEST['msg'])) |
|
1818 | - spamProtection('post'); |
|
1919 | + if (!isset($_REQUEST['msg'])) { |
|
1920 | + spamProtection('post'); |
|
1921 | + } |
|
1819 | 1922 | |
1820 | 1923 | // At about this point, we're posting and that's that. |
1821 | 1924 | ignore_user_abort(true); |
@@ -1828,32 +1931,36 @@ discard block |
||
1828 | 1931 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1829 | 1932 | |
1830 | 1933 | // At this point, we want to make sure the subject isn't too long. |
1831 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1832 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1934 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1935 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1936 | + } |
|
1833 | 1937 | |
1834 | 1938 | // Same with the "why did you edit this" text. |
1835 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1836 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1939 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1940 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1941 | + } |
|
1837 | 1942 | |
1838 | 1943 | // Make the poll... |
1839 | 1944 | if (isset($_REQUEST['poll'])) |
1840 | 1945 | { |
1841 | 1946 | // Make sure that the user has not entered a ridiculous number of options.. |
1842 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1843 | - $_POST['poll_max_votes'] = 1; |
|
1844 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1845 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1846 | - else |
|
1847 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1947 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1948 | + $_POST['poll_max_votes'] = 1; |
|
1949 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1950 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1951 | + } else { |
|
1952 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1953 | + } |
|
1848 | 1954 | |
1849 | 1955 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1850 | 1956 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1851 | 1957 | |
1852 | 1958 | // Just set it to zero if it's not there.. |
1853 | - if (!isset($_POST['poll_hide'])) |
|
1854 | - $_POST['poll_hide'] = 0; |
|
1855 | - else |
|
1856 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1959 | + if (!isset($_POST['poll_hide'])) { |
|
1960 | + $_POST['poll_hide'] = 0; |
|
1961 | + } else { |
|
1962 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1963 | + } |
|
1857 | 1964 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1858 | 1965 | |
1859 | 1966 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1862,16 +1969,19 @@ discard block |
||
1862 | 1969 | { |
1863 | 1970 | require_once($sourcedir . '/Subs-Members.php'); |
1864 | 1971 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1865 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1866 | - $_POST['poll_guest_vote'] = 0; |
|
1972 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
1973 | + $_POST['poll_guest_vote'] = 0; |
|
1974 | + } |
|
1867 | 1975 | } |
1868 | 1976 | |
1869 | 1977 | // If the user tries to set the poll too far in advance, don't let them. |
1870 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1871 | - fatal_lang_error('poll_range_error', false); |
|
1978 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
1979 | + fatal_lang_error('poll_range_error', false); |
|
1980 | + } |
|
1872 | 1981 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1873 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1874 | - $_POST['poll_hide'] = 1; |
|
1982 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
1983 | + $_POST['poll_hide'] = 1; |
|
1984 | + } |
|
1875 | 1985 | |
1876 | 1986 | // Clean up the question and answers. |
1877 | 1987 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1885,13 +1995,15 @@ discard block |
||
1885 | 1995 | { |
1886 | 1996 | $attachIDs = array(); |
1887 | 1997 | $attach_errors = array(); |
1888 | - if (!empty($context['we_are_history'])) |
|
1889 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
1998 | + if (!empty($context['we_are_history'])) { |
|
1999 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2000 | + } |
|
1890 | 2001 | |
1891 | 2002 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1892 | 2003 | { |
1893 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1894 | - continue; |
|
2004 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2005 | + continue; |
|
2006 | + } |
|
1895 | 2007 | |
1896 | 2008 | // If there was an initial error just show that message. |
1897 | 2009 | if ($attachID == 'initial_error') |
@@ -1920,12 +2032,13 @@ discard block |
||
1920 | 2032 | if (createAttachment($attachmentOptions)) |
1921 | 2033 | { |
1922 | 2034 | $attachIDs[] = $attachmentOptions['id']; |
1923 | - if (!empty($attachmentOptions['thumb'])) |
|
1924 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2035 | + if (!empty($attachmentOptions['thumb'])) { |
|
2036 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2037 | + } |
|
1925 | 2038 | } |
2039 | + } else { |
|
2040 | + $attach_errors[] = '<dt> </dt>'; |
|
1926 | 2041 | } |
1927 | - else |
|
1928 | - $attach_errors[] = '<dt> </dt>'; |
|
1929 | 2042 | |
1930 | 2043 | if (!empty($attachmentOptions['errors'])) |
1931 | 2044 | { |
@@ -1937,14 +2050,16 @@ discard block |
||
1937 | 2050 | if (!is_array($error)) |
1938 | 2051 | { |
1939 | 2052 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1940 | - if (in_array($error, $log_these)) |
|
1941 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2053 | + if (in_array($error, $log_these)) { |
|
2054 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2055 | + } |
|
2056 | + } else { |
|
2057 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1942 | 2058 | } |
1943 | - else |
|
1944 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1945 | 2059 | } |
1946 | - if (file_exists($attachment['tmp_name'])) |
|
1947 | - unlink($attachment['tmp_name']); |
|
2060 | + if (file_exists($attachment['tmp_name'])) { |
|
2061 | + unlink($attachment['tmp_name']); |
|
2062 | + } |
|
1948 | 2063 | } |
1949 | 2064 | } |
1950 | 2065 | unset($_SESSION['temp_attachments']); |
@@ -1985,24 +2100,24 @@ discard block |
||
1985 | 2100 | ); |
1986 | 2101 | |
1987 | 2102 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2103 | + } else { |
|
2104 | + $id_poll = 0; |
|
1988 | 2105 | } |
1989 | - else |
|
1990 | - $id_poll = 0; |
|
1991 | 2106 | |
1992 | 2107 | // Creating a new topic? |
1993 | 2108 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
1994 | 2109 | |
1995 | 2110 | // Check the icon. |
1996 | - if (!isset($_POST['icon'])) |
|
1997 | - $_POST['icon'] = 'xx'; |
|
1998 | - |
|
1999 | - else |
|
2111 | + if (!isset($_POST['icon'])) { |
|
2112 | + $_POST['icon'] = 'xx'; |
|
2113 | + } else |
|
2000 | 2114 | { |
2001 | 2115 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2002 | 2116 | |
2003 | 2117 | // Need to figure it out if this is a valid icon name. |
2004 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2005 | - $_POST['icon'] = 'xx'; |
|
2118 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2119 | + $_POST['icon'] = 'xx'; |
|
2120 | + } |
|
2006 | 2121 | } |
2007 | 2122 | |
2008 | 2123 | // Collect all parameters for the creation or modification of a post. |
@@ -2043,8 +2158,9 @@ discard block |
||
2043 | 2158 | } |
2044 | 2159 | |
2045 | 2160 | // This will save some time... |
2046 | - if (empty($approve_has_changed)) |
|
2047 | - unset($msgOptions['approved']); |
|
2161 | + if (empty($approve_has_changed)) { |
|
2162 | + unset($msgOptions['approved']); |
|
2163 | + } |
|
2048 | 2164 | |
2049 | 2165 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2050 | 2166 | } |
@@ -2053,8 +2169,9 @@ discard block |
||
2053 | 2169 | { |
2054 | 2170 | createPost($msgOptions, $topicOptions, $posterOptions); |
2055 | 2171 | |
2056 | - if (isset($topicOptions['id'])) |
|
2057 | - $topic = $topicOptions['id']; |
|
2172 | + if (isset($topicOptions['id'])) { |
|
2173 | + $topic = $topicOptions['id']; |
|
2174 | + } |
|
2058 | 2175 | } |
2059 | 2176 | |
2060 | 2177 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2066,8 +2183,9 @@ discard block |
||
2066 | 2183 | } |
2067 | 2184 | |
2068 | 2185 | // If we had a draft for this, its time to remove it since it was just posted |
2069 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2070 | - DeleteDraft($_POST['id_draft']); |
|
2186 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2187 | + DeleteDraft($_POST['id_draft']); |
|
2188 | + } |
|
2071 | 2189 | |
2072 | 2190 | // Editing or posting an event? |
2073 | 2191 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2086,8 +2204,7 @@ discard block |
||
2086 | 2204 | 'member' => $user_info['id'], |
2087 | 2205 | ); |
2088 | 2206 | insertEvent($eventOptions); |
2089 | - } |
|
2090 | - elseif (isset($_POST['calendar'])) |
|
2207 | + } elseif (isset($_POST['calendar'])) |
|
2091 | 2208 | { |
2092 | 2209 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2093 | 2210 | |
@@ -2115,14 +2232,15 @@ discard block |
||
2115 | 2232 | } |
2116 | 2233 | |
2117 | 2234 | // Delete it? |
2118 | - if (isset($_REQUEST['deleteevent'])) |
|
2119 | - $smcFunc['db_query']('', ' |
|
2235 | + if (isset($_REQUEST['deleteevent'])) { |
|
2236 | + $smcFunc['db_query']('', ' |
|
2120 | 2237 | DELETE FROM {db_prefix}calendar |
2121 | 2238 | WHERE id_event = {int:id_event}', |
2122 | 2239 | array( |
2123 | 2240 | 'id_event' => $_REQUEST['eventid'], |
2124 | 2241 | ) |
2125 | 2242 | ); |
2243 | + } |
|
2126 | 2244 | // ... or just update it? |
2127 | 2245 | else |
2128 | 2246 | { |
@@ -2164,9 +2282,8 @@ discard block |
||
2164 | 2282 | array($user_info['id'], $topic, 0), |
2165 | 2283 | array('id_member', 'id_topic', 'id_board') |
2166 | 2284 | ); |
2167 | - } |
|
2168 | - elseif (!$newTopic) |
|
2169 | - $smcFunc['db_query']('', ' |
|
2285 | + } elseif (!$newTopic) { |
|
2286 | + $smcFunc['db_query']('', ' |
|
2170 | 2287 | DELETE FROM {db_prefix}log_notify |
2171 | 2288 | WHERE id_member = {int:current_member} |
2172 | 2289 | AND id_topic = {int:current_topic}', |
@@ -2175,16 +2292,20 @@ discard block |
||
2175 | 2292 | 'current_topic' => $topic, |
2176 | 2293 | ) |
2177 | 2294 | ); |
2295 | + } |
|
2178 | 2296 | |
2179 | 2297 | // Log an act of moderation - modifying. |
2180 | - if (!empty($moderationAction)) |
|
2181 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2298 | + if (!empty($moderationAction)) { |
|
2299 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2300 | + } |
|
2182 | 2301 | |
2183 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2184 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2302 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2303 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2304 | + } |
|
2185 | 2305 | |
2186 | - if (isset($_POST['sticky'])) |
|
2187 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2306 | + if (isset($_POST['sticky'])) { |
|
2307 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2308 | + } |
|
2188 | 2309 | |
2189 | 2310 | // Returning to the topic? |
2190 | 2311 | if (!empty($_REQUEST['goback'])) |
@@ -2203,26 +2324,31 @@ discard block |
||
2203 | 2324 | ); |
2204 | 2325 | } |
2205 | 2326 | |
2206 | - if ($board_info['num_topics'] == 0) |
|
2207 | - cache_put_data('board-' . $board, null, 120); |
|
2327 | + if ($board_info['num_topics'] == 0) { |
|
2328 | + cache_put_data('board-' . $board, null, 120); |
|
2329 | + } |
|
2208 | 2330 | |
2209 | 2331 | call_integration_hook('integrate_post2_end'); |
2210 | 2332 | |
2211 | - if (!empty($_POST['announce_topic'])) |
|
2212 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2333 | + if (!empty($_POST['announce_topic'])) { |
|
2334 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2335 | + } |
|
2213 | 2336 | |
2214 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2215 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2337 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2338 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2339 | + } |
|
2216 | 2340 | |
2217 | 2341 | // Return to post if the mod is on. |
2218 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2219 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2220 | - elseif (!empty($_REQUEST['goback'])) |
|
2221 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2342 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2343 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2344 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2345 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2346 | + } |
|
2222 | 2347 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2223 | - else |
|
2224 | - redirectexit('board=' . $board . '.0'); |
|
2225 | -} |
|
2348 | + else { |
|
2349 | + redirectexit('board=' . $board . '.0'); |
|
2350 | + } |
|
2351 | + } |
|
2226 | 2352 | |
2227 | 2353 | /** |
2228 | 2354 | * Handle the announce topic function (action=announce). |
@@ -2240,8 +2366,9 @@ discard block |
||
2240 | 2366 | |
2241 | 2367 | validateSession(); |
2242 | 2368 | |
2243 | - if (empty($topic)) |
|
2244 | - fatal_lang_error('topic_gone', false); |
|
2369 | + if (empty($topic)) { |
|
2370 | + fatal_lang_error('topic_gone', false); |
|
2371 | + } |
|
2245 | 2372 | |
2246 | 2373 | loadLanguage('Post'); |
2247 | 2374 | loadTemplate('Post'); |
@@ -2268,8 +2395,9 @@ discard block |
||
2268 | 2395 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
2269 | 2396 | |
2270 | 2397 | $groups = array_merge($board_info['groups'], array(1)); |
2271 | - foreach ($groups as $id => $group) |
|
2272 | - $groups[$id] = (int) $group; |
|
2398 | + foreach ($groups as $id => $group) { |
|
2399 | + $groups[$id] = (int) $group; |
|
2400 | + } |
|
2273 | 2401 | |
2274 | 2402 | $context['groups'] = array(); |
2275 | 2403 | if (in_array(0, $groups)) |
@@ -2312,8 +2440,9 @@ discard block |
||
2312 | 2440 | 'group_list' => $groups, |
2313 | 2441 | ) |
2314 | 2442 | ); |
2315 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2316 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2443 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2444 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2445 | + } |
|
2317 | 2446 | $smcFunc['db_free_result']($request); |
2318 | 2447 | |
2319 | 2448 | // Get the subject of the topic we're about to announce. |
@@ -2355,16 +2484,19 @@ discard block |
||
2355 | 2484 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2356 | 2485 | $groups = array_merge($board_info['groups'], array(1)); |
2357 | 2486 | |
2358 | - if (isset($_POST['membergroups'])) |
|
2359 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2487 | + if (isset($_POST['membergroups'])) { |
|
2488 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2489 | + } |
|
2360 | 2490 | |
2361 | 2491 | // Check whether at least one membergroup was selected. |
2362 | - if (empty($_POST['who'])) |
|
2363 | - fatal_lang_error('no_membergroup_selected'); |
|
2492 | + if (empty($_POST['who'])) { |
|
2493 | + fatal_lang_error('no_membergroup_selected'); |
|
2494 | + } |
|
2364 | 2495 | |
2365 | 2496 | // Make sure all membergroups are integers and can access the board of the announcement. |
2366 | - foreach ($_POST['who'] as $id => $mg) |
|
2367 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2497 | + foreach ($_POST['who'] as $id => $mg) { |
|
2498 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2499 | + } |
|
2368 | 2500 | |
2369 | 2501 | // Get the topic subject and censor it. |
2370 | 2502 | $request = $smcFunc['db_query']('', ' |
@@ -2410,12 +2542,13 @@ discard block |
||
2410 | 2542 | if ($smcFunc['db_num_rows']($request) == 0) |
2411 | 2543 | { |
2412 | 2544 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2413 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2414 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2415 | - elseif (!empty($_REQUEST['goback'])) |
|
2416 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2417 | - else |
|
2418 | - redirectexit('board=' . $board . '.0'); |
|
2545 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2546 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2547 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2548 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2549 | + } else { |
|
2550 | + redirectexit('board=' . $board . '.0'); |
|
2551 | + } |
|
2419 | 2552 | } |
2420 | 2553 | |
2421 | 2554 | $announcements = array(); |
@@ -2434,8 +2567,9 @@ discard block |
||
2434 | 2567 | foreach ($rows as $row) |
2435 | 2568 | { |
2436 | 2569 | // Force them to have it? |
2437 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2438 | - continue; |
|
2570 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2571 | + continue; |
|
2572 | + } |
|
2439 | 2573 | |
2440 | 2574 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2441 | 2575 | |
@@ -2463,8 +2597,9 @@ discard block |
||
2463 | 2597 | } |
2464 | 2598 | |
2465 | 2599 | // For each language send a different mail - low priority... |
2466 | - foreach ($announcements as $lang => $mail) |
|
2467 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2600 | + foreach ($announcements as $lang => $mail) { |
|
2601 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2602 | + } |
|
2468 | 2603 | |
2469 | 2604 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2470 | 2605 | |
@@ -2474,9 +2609,10 @@ discard block |
||
2474 | 2609 | $context['sub_template'] = 'announcement_send'; |
2475 | 2610 | |
2476 | 2611 | // Go back to the correct language for the user ;). |
2477 | - if (!empty($modSettings['userLanguage'])) |
|
2478 | - loadLanguage('Post'); |
|
2479 | -} |
|
2612 | + if (!empty($modSettings['userLanguage'])) { |
|
2613 | + loadLanguage('Post'); |
|
2614 | + } |
|
2615 | + } |
|
2480 | 2616 | |
2481 | 2617 | /** |
2482 | 2618 | * Get the topic for display purposes. |
@@ -2489,12 +2625,13 @@ discard block |
||
2489 | 2625 | { |
2490 | 2626 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2491 | 2627 | |
2492 | - if (isset($_REQUEST['xml'])) |
|
2493 | - $limit = ' |
|
2628 | + if (isset($_REQUEST['xml'])) { |
|
2629 | + $limit = ' |
|
2494 | 2630 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2495 | - else |
|
2496 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2631 | + } else { |
|
2632 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2497 | 2633 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2634 | + } |
|
2498 | 2635 | |
2499 | 2636 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2500 | 2637 | $request = $smcFunc['db_query']('', ' |
@@ -2532,8 +2669,9 @@ discard block |
||
2532 | 2669 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2533 | 2670 | ); |
2534 | 2671 | |
2535 | - if (!empty($context['new_replies'])) |
|
2536 | - $context['new_replies']--; |
|
2672 | + if (!empty($context['new_replies'])) { |
|
2673 | + $context['new_replies']--; |
|
2674 | + } |
|
2537 | 2675 | } |
2538 | 2676 | $smcFunc['db_free_result']($request); |
2539 | 2677 | } |
@@ -2550,8 +2688,9 @@ discard block |
||
2550 | 2688 | global $sourcedir, $smcFunc; |
2551 | 2689 | |
2552 | 2690 | loadLanguage('Post'); |
2553 | - if (!isset($_REQUEST['xml'])) |
|
2554 | - loadTemplate('Post'); |
|
2691 | + if (!isset($_REQUEST['xml'])) { |
|
2692 | + loadTemplate('Post'); |
|
2693 | + } |
|
2555 | 2694 | |
2556 | 2695 | include_once($sourcedir . '/Subs-Post.php'); |
2557 | 2696 | |
@@ -2582,8 +2721,9 @@ discard block |
||
2582 | 2721 | $smcFunc['db_free_result']($request); |
2583 | 2722 | |
2584 | 2723 | $context['sub_template'] = 'quotefast'; |
2585 | - if (!empty($row)) |
|
2586 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2724 | + if (!empty($row)) { |
|
2725 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2726 | + } |
|
2587 | 2727 | |
2588 | 2728 | if (!empty($can_view_post)) |
2589 | 2729 | { |
@@ -2616,8 +2756,9 @@ discard block |
||
2616 | 2756 | } |
2617 | 2757 | |
2618 | 2758 | // Remove any nested quotes. |
2619 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2620 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2759 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2760 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2761 | + } |
|
2621 | 2762 | |
2622 | 2763 | $lb = "\n"; |
2623 | 2764 | |
@@ -2643,14 +2784,14 @@ discard block |
||
2643 | 2784 | 'time' => '', |
2644 | 2785 | ), |
2645 | 2786 | ); |
2646 | - } |
|
2647 | - else |
|
2648 | - $context['quote'] = array( |
|
2787 | + } else { |
|
2788 | + $context['quote'] = array( |
|
2649 | 2789 | 'xml' => '', |
2650 | 2790 | 'mozilla' => '', |
2651 | 2791 | 'text' => '', |
2652 | 2792 | ); |
2653 | -} |
|
2793 | + } |
|
2794 | + } |
|
2654 | 2795 | |
2655 | 2796 | /** |
2656 | 2797 | * Used to edit the body or subject of a message inline |
@@ -2662,8 +2803,9 @@ discard block |
||
2662 | 2803 | global $user_info, $context, $smcFunc, $language, $board_info; |
2663 | 2804 | |
2664 | 2805 | // We have to have a topic! |
2665 | - if (empty($topic)) |
|
2666 | - obExit(false); |
|
2806 | + if (empty($topic)) { |
|
2807 | + obExit(false); |
|
2808 | + } |
|
2667 | 2809 | |
2668 | 2810 | checkSession('get'); |
2669 | 2811 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2689,31 +2831,35 @@ discard block |
||
2689 | 2831 | 'guest_id' => 0, |
2690 | 2832 | ) |
2691 | 2833 | ); |
2692 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2693 | - fatal_lang_error('no_board', false); |
|
2834 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2835 | + fatal_lang_error('no_board', false); |
|
2836 | + } |
|
2694 | 2837 | $row = $smcFunc['db_fetch_assoc']($request); |
2695 | 2838 | $smcFunc['db_free_result']($request); |
2696 | 2839 | |
2697 | 2840 | // Change either body or subject requires permissions to modify messages. |
2698 | 2841 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2699 | 2842 | { |
2700 | - if (!empty($row['locked'])) |
|
2701 | - isAllowedTo('moderate_board'); |
|
2843 | + if (!empty($row['locked'])) { |
|
2844 | + isAllowedTo('moderate_board'); |
|
2845 | + } |
|
2702 | 2846 | |
2703 | 2847 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2704 | 2848 | { |
2705 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2706 | - fatal_lang_error('modify_post_time_passed', false); |
|
2707 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2708 | - isAllowedTo('modify_replies'); |
|
2709 | - else |
|
2710 | - isAllowedTo('modify_own'); |
|
2849 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2850 | + fatal_lang_error('modify_post_time_passed', false); |
|
2851 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2852 | + isAllowedTo('modify_replies'); |
|
2853 | + } else { |
|
2854 | + isAllowedTo('modify_own'); |
|
2855 | + } |
|
2711 | 2856 | } |
2712 | 2857 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2713 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2714 | - isAllowedTo('modify_replies'); |
|
2715 | - else |
|
2716 | - isAllowedTo('modify_any'); |
|
2858 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2859 | + isAllowedTo('modify_replies'); |
|
2860 | + } else { |
|
2861 | + isAllowedTo('modify_any'); |
|
2862 | + } |
|
2717 | 2863 | |
2718 | 2864 | // Only log this action if it wasn't your message. |
2719 | 2865 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2725,10 +2871,10 @@ discard block |
||
2725 | 2871 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2726 | 2872 | |
2727 | 2873 | // Maximum number of characters. |
2728 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2729 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2730 | - } |
|
2731 | - elseif (isset($_POST['subject'])) |
|
2874 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2875 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2876 | + } |
|
2877 | + } elseif (isset($_POST['subject'])) |
|
2732 | 2878 | { |
2733 | 2879 | $post_errors[] = 'no_subject'; |
2734 | 2880 | unset($_POST['subject']); |
@@ -2740,13 +2886,11 @@ discard block |
||
2740 | 2886 | { |
2741 | 2887 | $post_errors[] = 'no_message'; |
2742 | 2888 | unset($_POST['message']); |
2743 | - } |
|
2744 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2889 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2745 | 2890 | { |
2746 | 2891 | $post_errors[] = 'long_message'; |
2747 | 2892 | unset($_POST['message']); |
2748 | - } |
|
2749 | - else |
|
2893 | + } else |
|
2750 | 2894 | { |
2751 | 2895 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2752 | 2896 | |
@@ -2762,31 +2906,34 @@ discard block |
||
2762 | 2906 | |
2763 | 2907 | if (isset($_POST['lock'])) |
2764 | 2908 | { |
2765 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2766 | - unset($_POST['lock']); |
|
2767 | - elseif (!allowedTo('lock_any')) |
|
2909 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2910 | + unset($_POST['lock']); |
|
2911 | + } elseif (!allowedTo('lock_any')) |
|
2768 | 2912 | { |
2769 | - if ($row['locked'] == 1) |
|
2770 | - unset($_POST['lock']); |
|
2771 | - else |
|
2772 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2913 | + if ($row['locked'] == 1) { |
|
2914 | + unset($_POST['lock']); |
|
2915 | + } else { |
|
2916 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2917 | + } |
|
2918 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2919 | + unset($_POST['lock']); |
|
2920 | + } else { |
|
2921 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2773 | 2922 | } |
2774 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2775 | - unset($_POST['lock']); |
|
2776 | - else |
|
2777 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2778 | 2923 | } |
2779 | 2924 | |
2780 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2781 | - unset($_POST['sticky']); |
|
2925 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2926 | + unset($_POST['sticky']); |
|
2927 | + } |
|
2782 | 2928 | |
2783 | 2929 | if (isset($_POST['modify_reason'])) |
2784 | 2930 | { |
2785 | 2931 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2786 | 2932 | |
2787 | 2933 | // Maximum number of characters. |
2788 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2789 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2934 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2935 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2936 | + } |
|
2790 | 2937 | } |
2791 | 2938 | |
2792 | 2939 | if (empty($post_errors)) |
@@ -2823,8 +2970,9 @@ discard block |
||
2823 | 2970 | } |
2824 | 2971 | } |
2825 | 2972 | // If nothing was changed there's no need to add an entry to the moderation log. |
2826 | - else |
|
2827 | - $moderationAction = false; |
|
2973 | + else { |
|
2974 | + $moderationAction = false; |
|
2975 | + } |
|
2828 | 2976 | |
2829 | 2977 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2830 | 2978 | |
@@ -2842,9 +2990,9 @@ discard block |
||
2842 | 2990 | // Get the proper (default language) response prefix first. |
2843 | 2991 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2844 | 2992 | { |
2845 | - if ($language === $user_info['language']) |
|
2846 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2847 | - else |
|
2993 | + if ($language === $user_info['language']) { |
|
2994 | + $context['response_prefix'] = $txt['response_prefix']; |
|
2995 | + } else |
|
2848 | 2996 | { |
2849 | 2997 | loadLanguage('index', $language, false); |
2850 | 2998 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2866,8 +3014,9 @@ discard block |
||
2866 | 3014 | ); |
2867 | 3015 | } |
2868 | 3016 | |
2869 | - if (!empty($moderationAction)) |
|
2870 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3017 | + if (!empty($moderationAction)) { |
|
3018 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3019 | + } |
|
2871 | 3020 | } |
2872 | 3021 | |
2873 | 3022 | if (isset($_REQUEST['xml'])) |
@@ -2908,8 +3057,7 @@ discard block |
||
2908 | 3057 | ); |
2909 | 3058 | |
2910 | 3059 | censorText($context['message']['subject']); |
2911 | - } |
|
2912 | - else |
|
3060 | + } else |
|
2913 | 3061 | { |
2914 | 3062 | $context['message'] = array( |
2915 | 3063 | 'id' => $row['id_msg'], |
@@ -2921,15 +3069,16 @@ discard block |
||
2921 | 3069 | loadLanguage('Errors'); |
2922 | 3070 | foreach ($post_errors as $post_error) |
2923 | 3071 | { |
2924 | - if ($post_error == 'long_message') |
|
2925 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2926 | - else |
|
2927 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3072 | + if ($post_error == 'long_message') { |
|
3073 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3074 | + } else { |
|
3075 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3076 | + } |
|
2928 | 3077 | } |
2929 | 3078 | } |
3079 | + } else { |
|
3080 | + obExit(false); |
|
3081 | + } |
|
2930 | 3082 | } |
2931 | - else |
|
2932 | - obExit(false); |
|
2933 | -} |
|
2934 | 3083 | |
2935 | 3084 | ?> |
2936 | 3085 | \ No newline at end of file |
@@ -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 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date'])) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'register', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'register', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -196,9 +203,10 @@ discard block |
||
196 | 203 | $context['print_custom_fields'] = array(); |
197 | 204 | |
198 | 205 | // Any custom profile fields? |
199 | - if (!empty($context['custom_fields'])) |
|
200 | - foreach ($context['custom_fields'] as $custom) |
|
206 | + if (!empty($context['custom_fields'])) { |
|
207 | + foreach ($context['custom_fields'] as $custom) |
|
201 | 208 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
209 | + } |
|
202 | 210 | |
203 | 211 | } |
204 | 212 | |
@@ -242,14 +250,16 @@ discard block |
||
242 | 250 | $row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array(); |
243 | 251 | $alerts[$id_alert] = $row; |
244 | 252 | |
245 | - if (!empty($row['sender_id'])) |
|
246 | - $senders[] = $row['sender_id']; |
|
253 | + if (!empty($row['sender_id'])) { |
|
254 | + $senders[] = $row['sender_id']; |
|
255 | + } |
|
247 | 256 | } |
248 | 257 | $smcFunc['db_free_result']($request); |
249 | 258 | |
250 | 259 | $senders = loadMemberData($senders); |
251 | - foreach ($senders as $member) |
|
252 | - loadMemberContext($member); |
|
260 | + foreach ($senders as $member) { |
|
261 | + loadMemberContext($member); |
|
262 | + } |
|
253 | 263 | |
254 | 264 | // Now go through and actually make with the text. |
255 | 265 | loadLanguage('Alerts'); |
@@ -263,12 +273,15 @@ discard block |
||
263 | 273 | $msgs = array(); |
264 | 274 | foreach ($alerts as $id_alert => $alert) |
265 | 275 | { |
266 | - if (isset($alert['extra']['board'])) |
|
267 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
268 | - if (isset($alert['extra']['topic'])) |
|
269 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
270 | - if ($alert['content_type'] == 'msg') |
|
271 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
276 | + if (isset($alert['extra']['board'])) { |
|
277 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
278 | + } |
|
279 | + if (isset($alert['extra']['topic'])) { |
|
280 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
281 | + } |
|
282 | + if ($alert['content_type'] == 'msg') { |
|
283 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
284 | + } |
|
272 | 285 | } |
273 | 286 | |
274 | 287 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -283,8 +296,9 @@ discard block |
||
283 | 296 | 'boards' => array_keys($boards), |
284 | 297 | ) |
285 | 298 | ); |
286 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
287 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
299 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
300 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
301 | + } |
|
288 | 302 | } |
289 | 303 | if (!empty($topics)) |
290 | 304 | { |
@@ -299,8 +313,9 @@ discard block |
||
299 | 313 | 'topics' => array_keys($topics), |
300 | 314 | ) |
301 | 315 | ); |
302 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
303 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
316 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
317 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
318 | + } |
|
304 | 319 | } |
305 | 320 | if (!empty($msgs)) |
306 | 321 | { |
@@ -315,26 +330,33 @@ discard block |
||
315 | 330 | 'msgs' => array_keys($msgs), |
316 | 331 | ) |
317 | 332 | ); |
318 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
319 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
333 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
334 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
335 | + } |
|
320 | 336 | } |
321 | 337 | |
322 | 338 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
323 | 339 | foreach ($alerts as $id_alert => $alert) |
324 | 340 | { |
325 | - if (!empty($alert['text'])) |
|
326 | - continue; |
|
327 | - if (isset($alert['extra']['board'])) |
|
328 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
329 | - if (isset($alert['extra']['topic'])) |
|
330 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
331 | - if ($alert['content_type'] == 'msg') |
|
332 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
333 | - if ($alert['content_type'] == 'profile') |
|
334 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
335 | - |
|
336 | - if (!empty($memberContext[$alert['sender_id']])) |
|
337 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
341 | + if (!empty($alert['text'])) { |
|
342 | + continue; |
|
343 | + } |
|
344 | + if (isset($alert['extra']['board'])) { |
|
345 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
346 | + } |
|
347 | + if (isset($alert['extra']['topic'])) { |
|
348 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | + } |
|
350 | + if ($alert['content_type'] == 'msg') { |
|
351 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
352 | + } |
|
353 | + if ($alert['content_type'] == 'profile') { |
|
354 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
355 | + } |
|
356 | + |
|
357 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
358 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
359 | + } |
|
338 | 360 | |
339 | 361 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
340 | 362 | if (isset($txt[$string])) |
@@ -422,11 +444,11 @@ discard block |
||
422 | 444 | checkSession('request'); |
423 | 445 | |
424 | 446 | // Call it! |
425 | - if ($action == 'remove') |
|
426 | - alert_delete($toMark, $memID); |
|
427 | - |
|
428 | - else |
|
429 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
447 | + if ($action == 'remove') { |
|
448 | + alert_delete($toMark, $memID); |
|
449 | + } else { |
|
450 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
451 | + } |
|
430 | 452 | |
431 | 453 | // Set a nice update message. |
432 | 454 | $_SESSION['update_message'] = true; |
@@ -476,23 +498,27 @@ discard block |
||
476 | 498 | ); |
477 | 499 | |
478 | 500 | // Set the page title |
479 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
480 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
481 | - else |
|
482 | - $context['page_title'] = $txt['showPosts']; |
|
501 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
502 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
503 | + } else { |
|
504 | + $context['page_title'] = $txt['showPosts']; |
|
505 | + } |
|
483 | 506 | |
484 | 507 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
485 | 508 | |
486 | 509 | // Is the load average too high to allow searching just now? |
487 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
488 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
510 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
511 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
512 | + } |
|
489 | 513 | |
490 | 514 | // If we're specifically dealing with attachments use that function! |
491 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
492 | - return showAttachments($memID); |
|
515 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
516 | + return showAttachments($memID); |
|
517 | + } |
|
493 | 518 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
494 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
495 | - return showUnwatched($memID); |
|
519 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
520 | + return showUnwatched($memID); |
|
521 | + } |
|
496 | 522 | |
497 | 523 | // Are we just viewing topics? |
498 | 524 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -515,27 +541,30 @@ discard block |
||
515 | 541 | $smcFunc['db_free_result']($request); |
516 | 542 | |
517 | 543 | // Trying to remove a message that doesn't exist. |
518 | - if (empty($info)) |
|
519 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
544 | + if (empty($info)) { |
|
545 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
546 | + } |
|
520 | 547 | |
521 | 548 | // We can be lazy, since removeMessage() will check the permissions for us. |
522 | 549 | require_once($sourcedir . '/RemoveTopic.php'); |
523 | 550 | removeMessage((int) $_GET['delete']); |
524 | 551 | |
525 | 552 | // Add it to the mod log. |
526 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
527 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
553 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
554 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
555 | + } |
|
528 | 556 | |
529 | 557 | // Back to... where we are now ;). |
530 | 558 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
531 | 559 | } |
532 | 560 | |
533 | 561 | // Default to 10. |
534 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
535 | - $_REQUEST['viewscount'] = '10'; |
|
562 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
563 | + $_REQUEST['viewscount'] = '10'; |
|
564 | + } |
|
536 | 565 | |
537 | - if ($context['is_topics']) |
|
538 | - $request = $smcFunc['db_query']('', ' |
|
566 | + if ($context['is_topics']) { |
|
567 | + $request = $smcFunc['db_query']('', ' |
|
539 | 568 | SELECT COUNT(*) |
540 | 569 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
541 | 570 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -548,8 +577,8 @@ discard block |
||
548 | 577 | 'board' => $board, |
549 | 578 | ) |
550 | 579 | ); |
551 | - else |
|
552 | - $request = $smcFunc['db_query']('', ' |
|
580 | + } else { |
|
581 | + $request = $smcFunc['db_query']('', ' |
|
553 | 582 | SELECT COUNT(*) |
554 | 583 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
555 | 584 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -562,6 +591,7 @@ discard block |
||
562 | 591 | 'board' => $board, |
563 | 592 | ) |
564 | 593 | ); |
594 | + } |
|
565 | 595 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
566 | 596 | $smcFunc['db_free_result']($request); |
567 | 597 | |
@@ -582,10 +612,11 @@ discard block |
||
582 | 612 | |
583 | 613 | $range_limit = ''; |
584 | 614 | |
585 | - if ($context['is_topics']) |
|
586 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
587 | - else |
|
588 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
615 | + if ($context['is_topics']) { |
|
616 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
617 | + } else { |
|
618 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
619 | + } |
|
589 | 620 | |
590 | 621 | $maxIndex = $maxPerPage; |
591 | 622 | |
@@ -611,9 +642,9 @@ discard block |
||
611 | 642 | { |
612 | 643 | $margin *= 5; |
613 | 644 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
645 | + } else { |
|
646 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
614 | 647 | } |
615 | - else |
|
616 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
617 | 648 | } |
618 | 649 | |
619 | 650 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -645,8 +676,7 @@ discard block |
||
645 | 676 | 'max' => $maxIndex, |
646 | 677 | ) |
647 | 678 | ); |
648 | - } |
|
649 | - else |
|
679 | + } else |
|
650 | 680 | { |
651 | 681 | $request = $smcFunc['db_query']('', ' |
652 | 682 | SELECT |
@@ -675,8 +705,9 @@ discard block |
||
675 | 705 | } |
676 | 706 | |
677 | 707 | // Make sure we quit this loop. |
678 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
679 | - break; |
|
708 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
709 | + break; |
|
710 | + } |
|
680 | 711 | $looped = true; |
681 | 712 | $range_limit = ''; |
682 | 713 | } |
@@ -720,19 +751,21 @@ discard block |
||
720 | 751 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
721 | 752 | ); |
722 | 753 | |
723 | - if ($user_info['id'] == $row['id_member_started']) |
|
724 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
754 | + if ($user_info['id'] == $row['id_member_started']) { |
|
755 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
756 | + } |
|
725 | 757 | $board_ids['any'][$row['id_board']][] = $counter; |
726 | 758 | } |
727 | 759 | $smcFunc['db_free_result']($request); |
728 | 760 | |
729 | 761 | // All posts were retrieved in reverse order, get them right again. |
730 | - if ($reverse) |
|
731 | - $context['posts'] = array_reverse($context['posts'], true); |
|
762 | + if ($reverse) { |
|
763 | + $context['posts'] = array_reverse($context['posts'], true); |
|
764 | + } |
|
732 | 765 | |
733 | 766 | // These are all the permissions that are different from board to board.. |
734 | - if ($context['is_topics']) |
|
735 | - $permissions = array( |
|
767 | + if ($context['is_topics']) { |
|
768 | + $permissions = array( |
|
736 | 769 | 'own' => array( |
737 | 770 | 'post_reply_own' => 'can_reply', |
738 | 771 | ), |
@@ -740,8 +773,8 @@ discard block |
||
740 | 773 | 'post_reply_any' => 'can_reply', |
741 | 774 | ) |
742 | 775 | ); |
743 | - else |
|
744 | - $permissions = array( |
|
776 | + } else { |
|
777 | + $permissions = array( |
|
745 | 778 | 'own' => array( |
746 | 779 | 'post_reply_own' => 'can_reply', |
747 | 780 | 'delete_own' => 'can_delete', |
@@ -751,6 +784,7 @@ discard block |
||
751 | 784 | 'delete_any' => 'can_delete', |
752 | 785 | ) |
753 | 786 | ); |
787 | + } |
|
754 | 788 | |
755 | 789 | // For every permission in the own/any lists... |
756 | 790 | foreach ($permissions as $type => $list) |
@@ -761,19 +795,22 @@ discard block |
||
761 | 795 | $boards = boardsAllowedTo($permission); |
762 | 796 | |
763 | 797 | // Hmm, they can do it on all boards, can they? |
764 | - if (!empty($boards) && $boards[0] == 0) |
|
765 | - $boards = array_keys($board_ids[$type]); |
|
798 | + if (!empty($boards) && $boards[0] == 0) { |
|
799 | + $boards = array_keys($board_ids[$type]); |
|
800 | + } |
|
766 | 801 | |
767 | 802 | // Now go through each board they can do the permission on. |
768 | 803 | foreach ($boards as $board_id) |
769 | 804 | { |
770 | 805 | // There aren't any posts displayed from this board. |
771 | - if (!isset($board_ids[$type][$board_id])) |
|
772 | - continue; |
|
806 | + if (!isset($board_ids[$type][$board_id])) { |
|
807 | + continue; |
|
808 | + } |
|
773 | 809 | |
774 | 810 | // Set the permission to true ;). |
775 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
776 | - $context['posts'][$counter][$allowed] = true; |
|
811 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
812 | + $context['posts'][$counter][$allowed] = true; |
|
813 | + } |
|
777 | 814 | } |
778 | 815 | } |
779 | 816 | } |
@@ -804,8 +841,9 @@ discard block |
||
804 | 841 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
805 | 842 | |
806 | 843 | // Make sure we can't actually see anything... |
807 | - if (empty($boardsAllowed)) |
|
808 | - $boardsAllowed = array(-1); |
|
844 | + if (empty($boardsAllowed)) { |
|
845 | + $boardsAllowed = array(-1); |
|
846 | + } |
|
809 | 847 | |
810 | 848 | require_once($sourcedir . '/Subs-List.php'); |
811 | 849 | |
@@ -956,8 +994,8 @@ discard block |
||
956 | 994 | ) |
957 | 995 | ); |
958 | 996 | $attachments = array(); |
959 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
960 | - $attachments[] = array( |
|
997 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
998 | + $attachments[] = array( |
|
961 | 999 | 'id' => $row['id_attach'], |
962 | 1000 | 'filename' => $row['filename'], |
963 | 1001 | 'downloads' => $row['downloads'], |
@@ -969,6 +1007,7 @@ discard block |
||
969 | 1007 | 'board_name' => $row['name'], |
970 | 1008 | 'approved' => $row['approved'], |
971 | 1009 | ); |
1010 | + } |
|
972 | 1011 | |
973 | 1012 | $smcFunc['db_free_result']($request); |
974 | 1013 | |
@@ -1023,8 +1062,9 @@ discard block |
||
1023 | 1062 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1024 | 1063 | |
1025 | 1064 | // Only the owner can see the list (if the function is enabled of course) |
1026 | - if ($user_info['id'] != $memID) |
|
1027 | - return; |
|
1065 | + if ($user_info['id'] != $memID) { |
|
1066 | + return; |
|
1067 | + } |
|
1028 | 1068 | |
1029 | 1069 | require_once($sourcedir . '/Subs-List.php'); |
1030 | 1070 | |
@@ -1170,8 +1210,9 @@ discard block |
||
1170 | 1210 | ); |
1171 | 1211 | |
1172 | 1212 | $topics = array(); |
1173 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1174 | - $topics[] = $row['id_topic']; |
|
1213 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1214 | + $topics[] = $row['id_topic']; |
|
1215 | + } |
|
1175 | 1216 | |
1176 | 1217 | $smcFunc['db_free_result']($request); |
1177 | 1218 | |
@@ -1191,8 +1232,9 @@ discard block |
||
1191 | 1232 | 'topics' => $topics, |
1192 | 1233 | ) |
1193 | 1234 | ); |
1194 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1195 | - $topicsInfo[] = $row; |
|
1235 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1236 | + $topicsInfo[] = $row; |
|
1237 | + } |
|
1196 | 1238 | $smcFunc['db_free_result']($request); |
1197 | 1239 | } |
1198 | 1240 | |
@@ -1240,8 +1282,9 @@ discard block |
||
1240 | 1282 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1241 | 1283 | |
1242 | 1284 | // Is the load average too high to allow searching just now? |
1243 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1244 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1285 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1286 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1287 | + } |
|
1245 | 1288 | |
1246 | 1289 | // General user statistics. |
1247 | 1290 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1399,11 +1442,13 @@ discard block |
||
1399 | 1442 | } |
1400 | 1443 | $smcFunc['db_free_result']($result); |
1401 | 1444 | |
1402 | - if ($maxPosts > 0) |
|
1403 | - for ($hour = 0; $hour < 24; $hour++) |
|
1445 | + if ($maxPosts > 0) { |
|
1446 | + for ($hour = 0; |
|
1447 | + } |
|
1448 | + $hour < 24; $hour++) |
|
1404 | 1449 | { |
1405 | - if (!isset($context['posts_by_time'][$hour])) |
|
1406 | - $context['posts_by_time'][$hour] = array( |
|
1450 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1451 | + $context['posts_by_time'][$hour] = array( |
|
1407 | 1452 | 'hour' => $hour, |
1408 | 1453 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1409 | 1454 | 'posts' => 0, |
@@ -1411,7 +1456,7 @@ discard block |
||
1411 | 1456 | 'relative_percent' => 0, |
1412 | 1457 | 'is_last' => $hour == 23, |
1413 | 1458 | ); |
1414 | - else |
|
1459 | + } else |
|
1415 | 1460 | { |
1416 | 1461 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1417 | 1462 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1444,8 +1489,9 @@ discard block |
||
1444 | 1489 | |
1445 | 1490 | foreach ($subActions as $sa => $action) |
1446 | 1491 | { |
1447 | - if (!allowedTo($action[2])) |
|
1448 | - unset($subActions[$sa]); |
|
1492 | + if (!allowedTo($action[2])) { |
|
1493 | + unset($subActions[$sa]); |
|
1494 | + } |
|
1449 | 1495 | } |
1450 | 1496 | |
1451 | 1497 | // Create the tabs for the template. |
@@ -1463,15 +1509,18 @@ discard block |
||
1463 | 1509 | ); |
1464 | 1510 | |
1465 | 1511 | // Moderation must be on to track edits. |
1466 | - if (empty($modSettings['userlog_enabled'])) |
|
1467 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1512 | + if (empty($modSettings['userlog_enabled'])) { |
|
1513 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1514 | + } |
|
1468 | 1515 | |
1469 | 1516 | // Group requests must be active to show it... |
1470 | - if (empty($modSettings['show_group_membership'])) |
|
1471 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1517 | + if (empty($modSettings['show_group_membership'])) { |
|
1518 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1519 | + } |
|
1472 | 1520 | |
1473 | - if (empty($subActions)) |
|
1474 | - fatal_lang_error('no_access', false); |
|
1521 | + if (empty($subActions)) { |
|
1522 | + fatal_lang_error('no_access', false); |
|
1523 | + } |
|
1475 | 1524 | |
1476 | 1525 | $keys = array_keys($subActions); |
1477 | 1526 | $default = array_shift($keys); |
@@ -1484,9 +1533,10 @@ discard block |
||
1484 | 1533 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1485 | 1534 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1486 | 1535 | |
1487 | - if (!empty($call)) |
|
1488 | - call_user_func($call, $memID); |
|
1489 | -} |
|
1536 | + if (!empty($call)) { |
|
1537 | + call_user_func($call, $memID); |
|
1538 | + } |
|
1539 | + } |
|
1490 | 1540 | |
1491 | 1541 | /** |
1492 | 1542 | * Handles tracking a user's activity |
@@ -1502,8 +1552,9 @@ discard block |
||
1502 | 1552 | isAllowedTo('moderate_forum'); |
1503 | 1553 | |
1504 | 1554 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1505 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1506 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1555 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1556 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1557 | + } |
|
1507 | 1558 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1508 | 1559 | |
1509 | 1560 | // Set the options for the list component. |
@@ -1669,8 +1720,9 @@ discard block |
||
1669 | 1720 | ) |
1670 | 1721 | ); |
1671 | 1722 | $message_members = array(); |
1672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1673 | - $message_members[] = $row['id_member']; |
|
1723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1724 | + $message_members[] = $row['id_member']; |
|
1725 | + } |
|
1674 | 1726 | $smcFunc['db_free_result']($request); |
1675 | 1727 | |
1676 | 1728 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1685,8 +1737,9 @@ discard block |
||
1685 | 1737 | 'ip_list' => $ips, |
1686 | 1738 | ) |
1687 | 1739 | ); |
1688 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1689 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1740 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1741 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1742 | + } |
|
1690 | 1743 | $smcFunc['db_free_result']($request); |
1691 | 1744 | } |
1692 | 1745 | |
@@ -1700,8 +1753,9 @@ discard block |
||
1700 | 1753 | 'ip_list' => $ips, |
1701 | 1754 | ) |
1702 | 1755 | ); |
1703 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1704 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1756 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1757 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1758 | + } |
|
1705 | 1759 | $smcFunc['db_free_result']($request); |
1706 | 1760 | } |
1707 | 1761 | } |
@@ -1761,8 +1815,8 @@ discard block |
||
1761 | 1815 | )) |
1762 | 1816 | ); |
1763 | 1817 | $error_messages = array(); |
1764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1765 | - $error_messages[] = array( |
|
1818 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1819 | + $error_messages[] = array( |
|
1766 | 1820 | 'ip' => inet_dtop($row['ip']), |
1767 | 1821 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1768 | 1822 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1770,6 +1824,7 @@ discard block |
||
1770 | 1824 | 'time' => timeformat($row['log_time']), |
1771 | 1825 | 'timestamp' => forum_time(true, $row['log_time']), |
1772 | 1826 | ); |
1827 | + } |
|
1773 | 1828 | $smcFunc['db_free_result']($request); |
1774 | 1829 | |
1775 | 1830 | return $error_messages; |
@@ -1832,8 +1887,8 @@ discard block |
||
1832 | 1887 | )) |
1833 | 1888 | ); |
1834 | 1889 | $messages = array(); |
1835 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1836 | - $messages[] = array( |
|
1890 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1891 | + $messages[] = array( |
|
1837 | 1892 | 'ip' => inet_dtop($row['poster_ip']), |
1838 | 1893 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1839 | 1894 | 'board' => array( |
@@ -1846,6 +1901,7 @@ discard block |
||
1846 | 1901 | 'time' => timeformat($row['poster_time']), |
1847 | 1902 | 'timestamp' => forum_time(true, $row['poster_time']) |
1848 | 1903 | ); |
1904 | + } |
|
1849 | 1905 | $smcFunc['db_free_result']($request); |
1850 | 1906 | |
1851 | 1907 | return $messages; |
@@ -1872,19 +1928,20 @@ discard block |
||
1872 | 1928 | $context['sub_template'] = 'trackIP'; |
1873 | 1929 | $context['page_title'] = $txt['profile']; |
1874 | 1930 | $context['base_url'] = $scripturl . '?action=trackip'; |
1875 | - } |
|
1876 | - else |
|
1931 | + } else |
|
1877 | 1932 | { |
1878 | 1933 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1879 | 1934 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1880 | 1935 | } |
1881 | 1936 | |
1882 | 1937 | // Searching? |
1883 | - if (isset($_REQUEST['searchip'])) |
|
1884 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1938 | + if (isset($_REQUEST['searchip'])) { |
|
1939 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1940 | + } |
|
1885 | 1941 | |
1886 | - if (isValidIP($context['ip']) === false) |
|
1887 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1942 | + if (isValidIP($context['ip']) === false) { |
|
1943 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1944 | + } |
|
1888 | 1945 | |
1889 | 1946 | //mysql didn't support like search with varbinary |
1890 | 1947 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1892,8 +1949,9 @@ discard block |
||
1892 | 1949 | $ip_var = $context['ip']; |
1893 | 1950 | $ip_string = '= {inet:ip_address}'; |
1894 | 1951 | |
1895 | - if (empty($context['tracking_area'])) |
|
1896 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1952 | + if (empty($context['tracking_area'])) { |
|
1953 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1954 | + } |
|
1897 | 1955 | |
1898 | 1956 | $request = $smcFunc['db_query']('', ' |
1899 | 1957 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1904,8 +1962,9 @@ discard block |
||
1904 | 1962 | ) |
1905 | 1963 | ); |
1906 | 1964 | $context['ips'] = array(); |
1907 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1908 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1965 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1966 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1967 | + } |
|
1909 | 1968 | $smcFunc['db_free_result']($request); |
1910 | 1969 | |
1911 | 1970 | ksort($context['ips']); |
@@ -2134,8 +2193,9 @@ discard block |
||
2134 | 2193 | foreach ($context['whois_servers'] as $whois) |
2135 | 2194 | { |
2136 | 2195 | // Strip off the "decimal point" and anything following... |
2137 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2138 | - $context['auto_whois_server'] = $whois; |
|
2196 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2197 | + $context['auto_whois_server'] = $whois; |
|
2198 | + } |
|
2139 | 2199 | } |
2140 | 2200 | } |
2141 | 2201 | } |
@@ -2152,10 +2212,11 @@ discard block |
||
2152 | 2212 | // Gonna want this for the list. |
2153 | 2213 | require_once($sourcedir . '/Subs-List.php'); |
2154 | 2214 | |
2155 | - if ($memID == 0) |
|
2156 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2157 | - else |
|
2158 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2215 | + if ($memID == 0) { |
|
2216 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2217 | + } else { |
|
2218 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2219 | + } |
|
2159 | 2220 | |
2160 | 2221 | // Start with the user messages. |
2161 | 2222 | $listOptions = array( |
@@ -2265,12 +2326,13 @@ discard block |
||
2265 | 2326 | ) |
2266 | 2327 | ); |
2267 | 2328 | $logins = array(); |
2268 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2269 | - $logins[] = array( |
|
2329 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2330 | + $logins[] = array( |
|
2270 | 2331 | 'time' => timeformat($row['time']), |
2271 | 2332 | 'ip' => inet_dtop($row['ip']), |
2272 | 2333 | 'ip2' => inet_dtop($row['ip2']), |
2273 | 2334 | ); |
2335 | + } |
|
2274 | 2336 | $smcFunc['db_free_result']($request); |
2275 | 2337 | |
2276 | 2338 | return $logins; |
@@ -2295,11 +2357,12 @@ discard block |
||
2295 | 2357 | ) |
2296 | 2358 | ); |
2297 | 2359 | $context['custom_field_titles'] = array(); |
2298 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2299 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2360 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2361 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2300 | 2362 | 'title' => $row['field_name'], |
2301 | 2363 | 'parse_bbc' => $row['bbc'], |
2302 | 2364 | ); |
2365 | + } |
|
2303 | 2366 | $smcFunc['db_free_result']($request); |
2304 | 2367 | |
2305 | 2368 | // Set the options for the error lists. |
@@ -2438,19 +2501,22 @@ discard block |
||
2438 | 2501 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2439 | 2502 | { |
2440 | 2503 | $extra = smf_json_decode($row['extra'], true); |
2441 | - if (!empty($extra['applicator'])) |
|
2442 | - $members[] = $extra['applicator']; |
|
2504 | + if (!empty($extra['applicator'])) { |
|
2505 | + $members[] = $extra['applicator']; |
|
2506 | + } |
|
2443 | 2507 | |
2444 | 2508 | // Work out what the name of the action is. |
2445 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2446 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2447 | - elseif (isset($txt[$row['action']])) |
|
2448 | - $action_text = $txt[$row['action']]; |
|
2509 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2510 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2511 | + } elseif (isset($txt[$row['action']])) { |
|
2512 | + $action_text = $txt[$row['action']]; |
|
2513 | + } |
|
2449 | 2514 | // Custom field? |
2450 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2451 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2452 | - else |
|
2453 | - $action_text = $row['action']; |
|
2515 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2516 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2517 | + } else { |
|
2518 | + $action_text = $row['action']; |
|
2519 | + } |
|
2454 | 2520 | |
2455 | 2521 | // Parse BBC? |
2456 | 2522 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2482,13 +2548,15 @@ discard block |
||
2482 | 2548 | ) |
2483 | 2549 | ); |
2484 | 2550 | $members = array(); |
2485 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2486 | - $members[$row['id_member']] = $row['real_name']; |
|
2551 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2552 | + $members[$row['id_member']] = $row['real_name']; |
|
2553 | + } |
|
2487 | 2554 | $smcFunc['db_free_result']($request); |
2488 | 2555 | |
2489 | - foreach ($edits as $key => $value) |
|
2490 | - if (isset($members[$value['id_member']])) |
|
2556 | + foreach ($edits as $key => $value) { |
|
2557 | + if (isset($members[$value['id_member']])) |
|
2491 | 2558 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2559 | + } |
|
2492 | 2560 | } |
2493 | 2561 | |
2494 | 2562 | return $edits; |
@@ -2689,10 +2757,11 @@ discard block |
||
2689 | 2757 | $context['board'] = $board; |
2690 | 2758 | |
2691 | 2759 | // Determine which groups this user is in. |
2692 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2693 | - $curGroups = array(); |
|
2694 | - else |
|
2695 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2760 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2761 | + $curGroups = array(); |
|
2762 | + } else { |
|
2763 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2764 | + } |
|
2696 | 2765 | $curGroups[] = $user_profile[$memID]['id_group']; |
2697 | 2766 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2698 | 2767 | |
@@ -2712,28 +2781,30 @@ discard block |
||
2712 | 2781 | $context['no_access_boards'] = array(); |
2713 | 2782 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2714 | 2783 | { |
2715 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2716 | - $context['no_access_boards'][] = array( |
|
2784 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2785 | + $context['no_access_boards'][] = array( |
|
2717 | 2786 | 'id' => $row['id_board'], |
2718 | 2787 | 'name' => $row['name'], |
2719 | 2788 | 'is_last' => false, |
2720 | 2789 | ); |
2721 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2722 | - $context['boards'][$row['id_board']] = array( |
|
2790 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2791 | + $context['boards'][$row['id_board']] = array( |
|
2723 | 2792 | 'id' => $row['id_board'], |
2724 | 2793 | 'name' => $row['name'], |
2725 | 2794 | 'selected' => $board == $row['id_board'], |
2726 | 2795 | 'profile' => $row['id_profile'], |
2727 | 2796 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2728 | 2797 | ); |
2798 | + } |
|
2729 | 2799 | } |
2730 | 2800 | $smcFunc['db_free_result']($request); |
2731 | 2801 | |
2732 | 2802 | require_once($sourcedir . '/Subs-Boards.php'); |
2733 | 2803 | sortBoards($context['boards']); |
2734 | 2804 | |
2735 | - if (!empty($context['no_access_boards'])) |
|
2736 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2805 | + if (!empty($context['no_access_boards'])) { |
|
2806 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2807 | + } |
|
2737 | 2808 | |
2738 | 2809 | $context['member']['permissions'] = array( |
2739 | 2810 | 'general' => array(), |
@@ -2742,8 +2813,9 @@ discard block |
||
2742 | 2813 | |
2743 | 2814 | // If you're an admin we know you can do everything, we might as well leave. |
2744 | 2815 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2745 | - if ($context['member']['has_all_permissions']) |
|
2746 | - return; |
|
2816 | + if ($context['member']['has_all_permissions']) { |
|
2817 | + return; |
|
2818 | + } |
|
2747 | 2819 | |
2748 | 2820 | $denied = array(); |
2749 | 2821 | |
@@ -2762,21 +2834,24 @@ discard block |
||
2762 | 2834 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2763 | 2835 | { |
2764 | 2836 | // We don't know about this permission, it doesn't exist :P. |
2765 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2766 | - continue; |
|
2837 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2838 | + continue; |
|
2839 | + } |
|
2767 | 2840 | |
2768 | - if (empty($row['add_deny'])) |
|
2769 | - $denied[] = $row['permission']; |
|
2841 | + if (empty($row['add_deny'])) { |
|
2842 | + $denied[] = $row['permission']; |
|
2843 | + } |
|
2770 | 2844 | |
2771 | 2845 | // Permissions that end with _own or _any consist of two parts. |
2772 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2773 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2774 | - else |
|
2775 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2846 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2847 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2848 | + } else { |
|
2849 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2850 | + } |
|
2776 | 2851 | |
2777 | 2852 | // Add this permission if it doesn't exist yet. |
2778 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2779 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2853 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2854 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2780 | 2855 | 'id' => $row['permission'], |
2781 | 2856 | 'groups' => array( |
2782 | 2857 | 'allowed' => array(), |
@@ -2786,6 +2861,7 @@ discard block |
||
2786 | 2861 | 'is_denied' => false, |
2787 | 2862 | 'is_global' => true, |
2788 | 2863 | ); |
2864 | + } |
|
2789 | 2865 | |
2790 | 2866 | // Add the membergroup to either the denied or the allowed groups. |
2791 | 2867 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2819,18 +2895,20 @@ discard block |
||
2819 | 2895 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2820 | 2896 | { |
2821 | 2897 | // We don't know about this permission, it doesn't exist :P. |
2822 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2823 | - continue; |
|
2898 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2899 | + continue; |
|
2900 | + } |
|
2824 | 2901 | |
2825 | 2902 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2826 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2827 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2828 | - else |
|
2829 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2903 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2904 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2905 | + } else { |
|
2906 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2907 | + } |
|
2830 | 2908 | |
2831 | 2909 | // Create the structure for this permission. |
2832 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2833 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2910 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2911 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2834 | 2912 | 'id' => $row['permission'], |
2835 | 2913 | 'groups' => array( |
2836 | 2914 | 'allowed' => array(), |
@@ -2840,6 +2918,7 @@ discard block |
||
2840 | 2918 | 'is_denied' => false, |
2841 | 2919 | 'is_global' => empty($board), |
2842 | 2920 | ); |
2921 | + } |
|
2843 | 2922 | |
2844 | 2923 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2845 | 2924 | |
@@ -2858,8 +2937,9 @@ discard block |
||
2858 | 2937 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2859 | 2938 | |
2860 | 2939 | // Firstly, can we actually even be here? |
2861 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2862 | - fatal_lang_error('no_access', false); |
|
2940 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2941 | + fatal_lang_error('no_access', false); |
|
2942 | + } |
|
2863 | 2943 | |
2864 | 2944 | // Make sure things which are disabled stay disabled. |
2865 | 2945 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2946,9 +3026,10 @@ discard block |
||
2946 | 3026 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2947 | 3027 | ); |
2948 | 3028 | $context['current_level'] = 0; |
2949 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2950 | - if ($context['member']['warning'] >= $limit) |
|
3029 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3030 | + if ($context['member']['warning'] >= $limit) |
|
2951 | 3031 | $context['current_level'] = $limit; |
2952 | -} |
|
3032 | + } |
|
3033 | + } |
|
2953 | 3034 | |
2954 | 3035 | ?> |
2955 | 3036 | \ No newline at end of file |
@@ -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 | { |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
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 | * Takes a message and parses it, returning nothing. |
@@ -46,17 +47,19 @@ discard block |
||
46 | 47 | $message = preg_replace('~\.{100,}~', '...', $message); |
47 | 48 | |
48 | 49 | // Trim off trailing quotes - these often happen by accident. |
49 | - while (substr($message, -7) == '[quote]') |
|
50 | - $message = substr($message, 0, -7); |
|
51 | - while (substr($message, 0, 8) == '[/quote]') |
|
52 | - $message = substr($message, 8); |
|
50 | + while (substr($message, -7) == '[quote]') { |
|
51 | + $message = substr($message, 0, -7); |
|
52 | + } |
|
53 | + while (substr($message, 0, 8) == '[/quote]') { |
|
54 | + $message = substr($message, 8); |
|
55 | + } |
|
53 | 56 | |
54 | 57 | // Find all code blocks, work out whether we'd be parsing them, then ensure they are all closed. |
55 | 58 | $in_tag = false; |
56 | 59 | $had_tag = false; |
57 | 60 | $codeopen = 0; |
58 | - if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) |
|
59 | - foreach ($matches[0] as $index => $dummy) |
|
61 | + if (preg_match_all('~(\[(/)*code(?:=[^\]]+)?\])~is', $message, $matches)) { |
|
62 | + foreach ($matches[0] as $index => $dummy) |
|
60 | 63 | { |
61 | 64 | // Closing? |
62 | 65 | if (!empty($matches[2][$index])) |
@@ -64,6 +67,7 @@ discard block |
||
64 | 67 | // If it's closing and we're not in a tag we need to open it... |
65 | 68 | if (!$in_tag) |
66 | 69 | $codeopen = true; |
70 | + } |
|
67 | 71 | // Either way we ain't in one any more. |
68 | 72 | $in_tag = false; |
69 | 73 | } |
@@ -72,17 +76,20 @@ discard block |
||
72 | 76 | { |
73 | 77 | $had_tag = true; |
74 | 78 | // If we're in a tag don't do nought! |
75 | - if (!$in_tag) |
|
76 | - $in_tag = true; |
|
79 | + if (!$in_tag) { |
|
80 | + $in_tag = true; |
|
81 | + } |
|
77 | 82 | } |
78 | 83 | } |
79 | 84 | |
80 | 85 | // If we have an open tag, close it. |
81 | - if ($in_tag) |
|
82 | - $message .= '[/code]'; |
|
86 | + if ($in_tag) { |
|
87 | + $message .= '[/code]'; |
|
88 | + } |
|
83 | 89 | // Open any ones that need to be open, only if we've never had a tag. |
84 | - if ($codeopen && !$had_tag) |
|
85 | - $message = '[code]' . $message; |
|
90 | + if ($codeopen && !$had_tag) { |
|
91 | + $message = '[code]' . $message; |
|
92 | + } |
|
86 | 93 | |
87 | 94 | // Now that we've fixed all the code tags, let's fix the img and url tags... |
88 | 95 | $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); |
@@ -108,23 +115,26 @@ discard block |
||
108 | 115 | fixTags($message); |
109 | 116 | |
110 | 117 | // Replace /me.+?\n with [me=name]dsf[/me]\n. |
111 | - if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) |
|
112 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
113 | - else |
|
114 | - $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
118 | + if (strpos($user_info['name'], '[') !== false || strpos($user_info['name'], ']') !== false || strpos($user_info['name'], '\'') !== false || strpos($user_info['name'], '"') !== false) { |
|
119 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me="' . $user_info['name'] . '"]$2[/me]', $message); |
|
120 | + } else { |
|
121 | + $message = preg_replace('~(\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '$1[me=' . $user_info['name'] . ']$2[/me]', $message); |
|
122 | + } |
|
115 | 123 | |
116 | 124 | if (!$previewing && strpos($message, '[html]') !== false) |
117 | 125 | { |
118 | - if (allowedTo('admin_forum')) |
|
119 | - $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
126 | + if (allowedTo('admin_forum')) { |
|
127 | + $message = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) { |
|
120 | 128 | return '[html]' . strtr(un_htmlspecialchars($m[1]), array("\n" => ' ', ' ' => '  ', '[' => '[', ']' => ']')) . '[/html]'; |
129 | + } |
|
121 | 130 | }, $message); |
122 | 131 | |
123 | 132 | // We should edit them out, or else if an admin edits the message they will get shown... |
124 | 133 | else |
125 | 134 | { |
126 | - while (strpos($message, '[html]') !== false) |
|
127 | - $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
135 | + while (strpos($message, '[html]') !== false) { |
|
136 | + $message = preg_replace('~\[[/]?html\]~i', '', $message); |
|
137 | + } |
|
128 | 138 | } |
129 | 139 | } |
130 | 140 | |
@@ -146,10 +156,12 @@ discard block |
||
146 | 156 | |
147 | 157 | $list_open = substr_count($message, '[list]') + substr_count($message, '[list '); |
148 | 158 | $list_close = substr_count($message, '[/list]'); |
149 | - if ($list_close - $list_open > 0) |
|
150 | - $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
151 | - if ($list_open - $list_close > 0) |
|
152 | - $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
159 | + if ($list_close - $list_open > 0) { |
|
160 | + $message = str_repeat('[list]', $list_close - $list_open) . $message; |
|
161 | + } |
|
162 | + if ($list_open - $list_close > 0) { |
|
163 | + $message = $message . str_repeat('[/list]', $list_open - $list_close); |
|
164 | + } |
|
153 | 165 | |
154 | 166 | $mistake_fixes = array( |
155 | 167 | // Find [table]s not followed by [tr]. |
@@ -198,8 +210,9 @@ discard block |
||
198 | 210 | ); |
199 | 211 | |
200 | 212 | // Fix up some use of tables without [tr]s, etc. (it has to be done more than once to catch it all.) |
201 | - for ($j = 0; $j < 3; $j++) |
|
202 | - $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
213 | + for ($j = 0; $j < 3; $j++) { |
|
214 | + $message = preg_replace(array_keys($mistake_fixes), $mistake_fixes, $message); |
|
215 | + } |
|
203 | 216 | |
204 | 217 | // Remove empty bbc from the sections outside the code tags |
205 | 218 | $allowedEmpty = array( |
@@ -209,24 +222,28 @@ discard block |
||
209 | 222 | |
210 | 223 | require_once($sourcedir . '/Subs.php'); |
211 | 224 | |
212 | - foreach (($codes = parse_bbc(false)) as $code) |
|
213 | - if (!in_array($code['tag'], $allowedEmpty)) |
|
225 | + foreach (($codes = parse_bbc(false)) as $code) { |
|
226 | + if (!in_array($code['tag'], $allowedEmpty)) |
|
214 | 227 | $alltags[] = $code['tag']; |
228 | + } |
|
215 | 229 | |
216 | 230 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
217 | 231 | |
218 | - while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) |
|
219 | - $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
232 | + while (preg_match('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', $message)) { |
|
233 | + $message = preg_replace('~\[(' . $alltags_regex . ')[^\]]*\]\s*\[/\1\]\s?~i', '', $message); |
|
234 | + } |
|
220 | 235 | |
221 | 236 | // Restore code blocks |
222 | - if (!empty($code_tags)) |
|
223 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
237 | + if (!empty($code_tags)) { |
|
238 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
239 | + } |
|
224 | 240 | |
225 | 241 | // Restore white space entities |
226 | - if (!$previewing) |
|
227 | - $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
228 | - else |
|
229 | - $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
242 | + if (!$previewing) { |
|
243 | + $message = strtr($message, array(' ' => ' ', "\n" => '<br>', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
244 | + } else { |
|
245 | + $message = strtr($message, array(' ' => ' ', $context['utf8'] ? "\xC2\xA0" : "\xA0" => ' ')); |
|
246 | + } |
|
230 | 247 | |
231 | 248 | // Now let's quickly clean up things that will slow our parser (which are common in posted code.) |
232 | 249 | $message = strtr($message, array('[]' => '[]', '['' => '['')); |
@@ -269,8 +286,9 @@ discard block |
||
269 | 286 | return "[time]" . timeformat("$m[1]", false) . "[/time]"; |
270 | 287 | }, $message); |
271 | 288 | |
272 | - if (!empty($code_tags)) |
|
273 | - $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
289 | + if (!empty($code_tags)) { |
|
290 | + $message = str_replace(array_keys($code_tags), array_values($code_tags), $message); |
|
291 | + } |
|
274 | 292 | |
275 | 293 | // Change breaks back to \n's and &nsbp; back to spaces. |
276 | 294 | return preg_replace('~<br( /)?' . '>~', "\n", str_replace(' ', ' ', $message)); |
@@ -351,8 +369,9 @@ discard block |
||
351 | 369 | ); |
352 | 370 | |
353 | 371 | // Fix each type of tag. |
354 | - foreach ($fixArray as $param) |
|
355 | - fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
372 | + foreach ($fixArray as $param) { |
|
373 | + fixTag($message, $param['tag'], $param['protocols'], $param['embeddedUrl'], $param['hasEqualSign'], !empty($param['hasExtra'])); |
|
374 | + } |
|
356 | 375 | |
357 | 376 | // Now fix possible security problems with images loading links automatically... |
358 | 377 | $message = preg_replace_callback('~(\[img.*?\])(.+?)\[/img\]~is', function($m) |
@@ -388,16 +407,19 @@ discard block |
||
388 | 407 | $desired_height = $height; |
389 | 408 | } |
390 | 409 | // Scale it to the width... |
391 | - elseif (empty($desired_width) && !empty($height)) |
|
392 | - $desired_width = (int) (($desired_height * $width) / $height); |
|
410 | + elseif (empty($desired_width) && !empty($height)) { |
|
411 | + $desired_width = (int) (($desired_height * $width) / $height); |
|
412 | + } |
|
393 | 413 | // Scale if to the height. |
394 | - elseif (!empty($width)) |
|
395 | - $desired_height = (int) (($desired_width * $height) / $width); |
|
414 | + elseif (!empty($width)) { |
|
415 | + $desired_height = (int) (($desired_width * $height) / $width); |
|
416 | + } |
|
396 | 417 | } |
397 | 418 | |
398 | 419 | // If the width and height are fine, just continue along... |
399 | - if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) |
|
400 | - continue; |
|
420 | + if ($desired_width <= $modSettings['max_image_width'] && $desired_height <= $modSettings['max_image_height']) { |
|
421 | + continue; |
|
422 | + } |
|
401 | 423 | |
402 | 424 | // Too bad, it's too wide. Make it as wide as the maximum. |
403 | 425 | if ($desired_width > $modSettings['max_image_width'] && !empty($modSettings['max_image_width'])) |
@@ -417,8 +439,9 @@ discard block |
||
417 | 439 | } |
418 | 440 | |
419 | 441 | // If any img tags were actually changed... |
420 | - if (!empty($replaces)) |
|
421 | - $message = strtr($message, $replaces); |
|
442 | + if (!empty($replaces)) { |
|
443 | + $message = strtr($message, $replaces); |
|
444 | + } |
|
422 | 445 | } |
423 | 446 | } |
424 | 447 | |
@@ -437,10 +460,11 @@ discard block |
||
437 | 460 | { |
438 | 461 | global $boardurl, $scripturl; |
439 | 462 | |
440 | - if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) |
|
441 | - $domain_url = $match[1]; |
|
442 | - else |
|
443 | - $domain_url = $boardurl . '/'; |
|
463 | + if (preg_match('~^([^:]+://[^/]+)~', $boardurl, $match) != 0) { |
|
464 | + $domain_url = $match[1]; |
|
465 | + } else { |
|
466 | + $domain_url = $boardurl . '/'; |
|
467 | + } |
|
444 | 468 | |
445 | 469 | $replaces = array(); |
446 | 470 | |
@@ -448,11 +472,11 @@ discard block |
||
448 | 472 | { |
449 | 473 | $quoted = preg_match('~\[(' . $myTag . ')="~', $message); |
450 | 474 | preg_match_all('~\[(' . $myTag . ')=' . ($quoted ? '"(.*?)"' : '([^\]]*?)') . '\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
475 | + } elseif ($hasEqualSign) { |
|
476 | + preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
477 | + } else { |
|
478 | + preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
451 | 479 | } |
452 | - elseif ($hasEqualSign) |
|
453 | - preg_match_all('~\[(' . $myTag . ')=([^\]]*?)\](?:(.+?)\[/(' . $myTag . ')\])?~is', $message, $matches); |
|
454 | - else |
|
455 | - preg_match_all('~\[(' . $myTag . ($hasExtra ? '(?:[^\]]*?)' : '') . ')\](.+?)\[/(' . $myTag . ')\]~is', $message, $matches); |
|
456 | 480 | |
457 | 481 | foreach ($matches[0] as $k => $dummy) |
458 | 482 | { |
@@ -465,49 +489,53 @@ discard block |
||
465 | 489 | foreach ($protocols as $protocol) |
466 | 490 | { |
467 | 491 | $found = strncasecmp($replace, $protocol . '://', strlen($protocol) + 3) === 0; |
468 | - if ($found) |
|
469 | - break; |
|
492 | + if ($found) { |
|
493 | + break; |
|
494 | + } |
|
470 | 495 | } |
471 | 496 | |
472 | 497 | if (!$found && $protocols[0] == 'http') |
473 | 498 | { |
474 | - if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') |
|
475 | - $replace = $domain_url . $replace; |
|
476 | - elseif (substr($replace, 0, 1) == '?') |
|
477 | - $replace = $scripturl . $replace; |
|
478 | - elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
499 | + if (substr($replace, 0, 1) == '/' && substr($replace, 0, 2) != '//') { |
|
500 | + $replace = $domain_url . $replace; |
|
501 | + } elseif (substr($replace, 0, 1) == '?') { |
|
502 | + $replace = $scripturl . $replace; |
|
503 | + } elseif (substr($replace, 0, 1) == '#' && $embeddedUrl) |
|
479 | 504 | { |
480 | 505 | $replace = '#' . preg_replace('~[^A-Za-z0-9_\-#]~', '', substr($replace, 1)); |
481 | 506 | $this_tag = 'iurl'; |
482 | 507 | $this_close = 'iurl'; |
508 | + } elseif (substr($replace, 0, 2) != '//') { |
|
509 | + $replace = $protocols[0] . '://' . $replace; |
|
483 | 510 | } |
484 | - elseif (substr($replace, 0, 2) != '//') |
|
485 | - $replace = $protocols[0] . '://' . $replace; |
|
486 | - } |
|
487 | - elseif (!$found && $protocols[0] == 'ftp') |
|
488 | - $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
489 | - elseif (!$found) |
|
490 | - $replace = $protocols[0] . '://' . $replace; |
|
491 | - |
|
492 | - if ($hasEqualSign && $embeddedUrl) |
|
493 | - $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
494 | - elseif ($hasEqualSign) |
|
495 | - $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
496 | - elseif ($embeddedUrl) |
|
497 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
498 | - else |
|
499 | - $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
511 | + } elseif (!$found && $protocols[0] == 'ftp') { |
|
512 | + $replace = $protocols[0] . '://' . preg_replace('~^(?!ftps?)[^:]+://~', '', $replace); |
|
513 | + } elseif (!$found) { |
|
514 | + $replace = $protocols[0] . '://' . $replace; |
|
515 | + } |
|
516 | + |
|
517 | + if ($hasEqualSign && $embeddedUrl) { |
|
518 | + $replaces[$matches[0][$k]] = '[' . $this_tag . '="' . $replace . '"]' . (empty($matches[4][$k]) ? '' : $matches[3][$k] . '[/' . $this_close . ']'); |
|
519 | + } elseif ($hasEqualSign) { |
|
520 | + $replaces['[' . $matches[1][$k] . '=' . $matches[2][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']'; |
|
521 | + } elseif ($embeddedUrl) { |
|
522 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . '=' . $replace . ']' . $matches[2][$k] . '[/' . $this_close . ']'; |
|
523 | + } else { |
|
524 | + $replaces['[' . $matches[1][$k] . ']' . $matches[2][$k] . '[/' . $matches[3][$k] . ']'] = '[' . $this_tag . ']' . $replace . '[/' . $this_close . ']'; |
|
525 | + } |
|
500 | 526 | } |
501 | 527 | |
502 | 528 | foreach ($replaces as $k => $v) |
503 | 529 | { |
504 | - if ($k == $v) |
|
505 | - unset($replaces[$k]); |
|
530 | + if ($k == $v) { |
|
531 | + unset($replaces[$k]); |
|
532 | + } |
|
506 | 533 | } |
507 | 534 | |
508 | - if (!empty($replaces)) |
|
509 | - $message = strtr($message, $replaces); |
|
510 | -} |
|
535 | + if (!empty($replaces)) { |
|
536 | + $message = strtr($message, $replaces); |
|
537 | + } |
|
538 | + } |
|
511 | 539 | |
512 | 540 | /** |
513 | 541 | * This function sends an email to the specified recipient(s). |
@@ -551,8 +579,9 @@ discard block |
||
551 | 579 | } |
552 | 580 | |
553 | 581 | // Nothing left? Nothing else to do |
554 | - if (empty($to_array)) |
|
555 | - return true; |
|
582 | + if (empty($to_array)) { |
|
583 | + return true; |
|
584 | + } |
|
556 | 585 | |
557 | 586 | // Once upon a time, Hotmail could not interpret non-ASCII mails. |
558 | 587 | // In honour of those days, it's still called the 'hotmail fix'. |
@@ -569,15 +598,17 @@ discard block |
||
569 | 598 | } |
570 | 599 | |
571 | 600 | // Call this function recursively for the hotmail addresses. |
572 | - if (!empty($hotmail_to)) |
|
573 | - $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
601 | + if (!empty($hotmail_to)) { |
|
602 | + $mail_result = sendmail($hotmail_to, $subject, $message, $from, $message_id, $send_html, $priority, true, $is_private); |
|
603 | + } |
|
574 | 604 | |
575 | 605 | // The remaining addresses no longer need the fix. |
576 | 606 | $hotmail_fix = false; |
577 | 607 | |
578 | 608 | // No other addresses left? Return instantly. |
579 | - if (empty($to_array)) |
|
580 | - return $mail_result; |
|
609 | + if (empty($to_array)) { |
|
610 | + return $mail_result; |
|
611 | + } |
|
581 | 612 | } |
582 | 613 | |
583 | 614 | // Get rid of entities. |
@@ -602,13 +633,15 @@ discard block |
||
602 | 633 | $headers .= 'Return-Path: ' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . $line_break; |
603 | 634 | $headers .= 'Date: ' . gmdate('D, d M Y H:i:s') . ' -0000' . $line_break; |
604 | 635 | |
605 | - if ($message_id !== null && empty($modSettings['mail_no_message_id'])) |
|
606 | - $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
636 | + if ($message_id !== null && empty($modSettings['mail_no_message_id'])) { |
|
637 | + $headers .= 'Message-ID: <' . md5($scripturl . microtime()) . '-' . $message_id . strstr(empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from'], '@') . '>' . $line_break; |
|
638 | + } |
|
607 | 639 | $headers .= 'X-Mailer: SMF' . $line_break; |
608 | 640 | |
609 | 641 | // Pass this to the integration before we start modifying the output -- it'll make it easier later. |
610 | - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) |
|
611 | - return false; |
|
642 | + if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) { |
|
643 | + return false; |
|
644 | + } |
|
612 | 645 | |
613 | 646 | // Save the original message... |
614 | 647 | $orig_message = $message; |
@@ -657,17 +690,19 @@ discard block |
||
657 | 690 | } |
658 | 691 | |
659 | 692 | // Are we using the mail queue, if so this is where we butt in... |
660 | - if ($priority != 0) |
|
661 | - return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
693 | + if ($priority != 0) { |
|
694 | + return AddMailQueue(false, $to_array, $subject, $message, $headers, $send_html, $priority, $is_private); |
|
695 | + } |
|
662 | 696 | |
663 | 697 | // If it's a priority mail, send it now - note though that this should NOT be used for sending many at once. |
664 | 698 | elseif (!empty($modSettings['mail_limit'])) |
665 | 699 | { |
666 | 700 | list ($last_mail_time, $mails_this_minute) = @explode('|', $modSettings['mail_recent']); |
667 | - if (empty($mails_this_minute) || time() > $last_mail_time + 60) |
|
668 | - $new_queue_stat = time() . '|' . 1; |
|
669 | - else |
|
670 | - $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
701 | + if (empty($mails_this_minute) || time() > $last_mail_time + 60) { |
|
702 | + $new_queue_stat = time() . '|' . 1; |
|
703 | + } else { |
|
704 | + $new_queue_stat = $last_mail_time . '|' . ((int) $mails_this_minute + 1); |
|
705 | + } |
|
671 | 706 | |
672 | 707 | updateSettings(array('mail_recent' => $new_queue_stat)); |
673 | 708 | } |
@@ -692,12 +727,13 @@ discard block |
||
692 | 727 | |
693 | 728 | // Wait, wait, I'm still sending here! |
694 | 729 | @set_time_limit(300); |
695 | - if (function_exists('apache_reset_timeout')) |
|
696 | - @apache_reset_timeout(); |
|
730 | + if (function_exists('apache_reset_timeout')) { |
|
731 | + @apache_reset_timeout(); |
|
732 | + } |
|
697 | 733 | } |
734 | + } else { |
|
735 | + $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
698 | 736 | } |
699 | - else |
|
700 | - $mail_result = $mail_result && smtp_mail($to_array, $subject, $message, $headers); |
|
701 | 737 | |
702 | 738 | // Everything go smoothly? |
703 | 739 | return $mail_result; |
@@ -723,8 +759,9 @@ discard block |
||
723 | 759 | static $cur_insert = array(); |
724 | 760 | static $cur_insert_len = 0; |
725 | 761 | |
726 | - if ($cur_insert_len == 0) |
|
727 | - $cur_insert = array(); |
|
762 | + if ($cur_insert_len == 0) { |
|
763 | + $cur_insert = array(); |
|
764 | + } |
|
728 | 765 | |
729 | 766 | // If we're flushing, make the final inserts - also if we're near the MySQL length limit! |
730 | 767 | if (($flush || $cur_insert_len > 800000) && !empty($cur_insert)) |
@@ -799,8 +836,9 @@ discard block |
||
799 | 836 | } |
800 | 837 | |
801 | 838 | // If they are using SSI there is a good chance obExit will never be called. So lets be nice and flush it for them. |
802 | - if (SMF === 'SSI' || SMF === 'BACKGROUND') |
|
803 | - return AddMailQueue(true); |
|
839 | + if (SMF === 'SSI' || SMF === 'BACKGROUND') { |
|
840 | + return AddMailQueue(true); |
|
841 | + } |
|
804 | 842 | |
805 | 843 | return true; |
806 | 844 | } |
@@ -831,23 +869,26 @@ discard block |
||
831 | 869 | 'sent' => array() |
832 | 870 | ); |
833 | 871 | |
834 | - if ($from === null) |
|
835 | - $from = array( |
|
872 | + if ($from === null) { |
|
873 | + $from = array( |
|
836 | 874 | 'id' => $user_info['id'], |
837 | 875 | 'name' => $user_info['name'], |
838 | 876 | 'username' => $user_info['username'] |
839 | 877 | ); |
878 | + } |
|
840 | 879 | |
841 | 880 | // This is the one that will go in their inbox. |
842 | 881 | $htmlmessage = $smcFunc['htmlspecialchars']($message, ENT_QUOTES); |
843 | 882 | preparsecode($htmlmessage); |
844 | 883 | $htmlsubject = strtr($smcFunc['htmlspecialchars']($subject), array("\r" => '', "\n" => '', "\t" => '')); |
845 | - if ($smcFunc['strlen']($htmlsubject) > 100) |
|
846 | - $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
884 | + if ($smcFunc['strlen']($htmlsubject) > 100) { |
|
885 | + $htmlsubject = $smcFunc['substr']($htmlsubject, 0, 100); |
|
886 | + } |
|
847 | 887 | |
848 | 888 | // Make sure is an array |
849 | - if (!is_array($recipients)) |
|
850 | - $recipients = array($recipients); |
|
889 | + if (!is_array($recipients)) { |
|
890 | + $recipients = array($recipients); |
|
891 | + } |
|
851 | 892 | |
852 | 893 | // Integrated PMs |
853 | 894 | call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); |
@@ -875,21 +916,23 @@ discard block |
||
875 | 916 | 'usernames' => array_keys($usernames), |
876 | 917 | ) |
877 | 918 | ); |
878 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
879 | - if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
919 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
920 | + if (isset($usernames[$smcFunc['strtolower']($row['member_name'])])) |
|
880 | 921 | $usernames[$smcFunc['strtolower']($row['member_name'])] = $row['id_member']; |
922 | + } |
|
881 | 923 | $smcFunc['db_free_result']($request); |
882 | 924 | |
883 | 925 | // Replace the usernames with IDs. Drop usernames that couldn't be found. |
884 | - foreach ($recipients as $rec_type => $rec) |
|
885 | - foreach ($rec as $id => $member) |
|
926 | + foreach ($recipients as $rec_type => $rec) { |
|
927 | + foreach ($rec as $id => $member) |
|
886 | 928 | { |
887 | 929 | if (is_numeric($recipients[$rec_type][$id])) |
888 | 930 | continue; |
931 | + } |
|
889 | 932 | |
890 | - if (!empty($usernames[$member])) |
|
891 | - $recipients[$rec_type][$id] = $usernames[$member]; |
|
892 | - else |
|
933 | + if (!empty($usernames[$member])) { |
|
934 | + $recipients[$rec_type][$id] = $usernames[$member]; |
|
935 | + } else |
|
893 | 936 | { |
894 | 937 | $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]); |
895 | 938 | unset($recipients[$rec_type][$id]); |
@@ -927,8 +970,9 @@ discard block |
||
927 | 970 | $delete = false; |
928 | 971 | foreach ($criteria as $criterium) |
929 | 972 | { |
930 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) |
|
931 | - $delete = true; |
|
973 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $from['id']) || ($criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups'])) || ($criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false)) { |
|
974 | + $delete = true; |
|
975 | + } |
|
932 | 976 | // If we're adding and one criteria don't match then we stop! |
933 | 977 | elseif (!$row['is_or']) |
934 | 978 | { |
@@ -936,8 +980,9 @@ discard block |
||
936 | 980 | break; |
937 | 981 | } |
938 | 982 | } |
939 | - if ($delete) |
|
940 | - $deletes[$row['id_member']] = 1; |
|
983 | + if ($delete) { |
|
984 | + $deletes[$row['id_member']] = 1; |
|
985 | + } |
|
941 | 986 | } |
942 | 987 | $smcFunc['db_free_result']($request); |
943 | 988 | |
@@ -952,8 +997,9 @@ discard block |
||
952 | 997 | array( |
953 | 998 | ) |
954 | 999 | ); |
955 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
956 | - $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
1000 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1001 | + $message_limit_cache[$row['id_group']] = $row['max_messages']; |
|
1002 | + } |
|
957 | 1003 | $smcFunc['db_free_result']($request); |
958 | 1004 | } |
959 | 1005 | |
@@ -961,8 +1007,9 @@ discard block |
||
961 | 1007 | require_once($sourcedir . '/Subs-Members.php'); |
962 | 1008 | $pmReadGroups = groupsAllowedTo('pm_read'); |
963 | 1009 | |
964 | - if (empty($modSettings['permission_enable_deny'])) |
|
965 | - $pmReadGroups['denied'] = array(); |
|
1010 | + if (empty($modSettings['permission_enable_deny'])) { |
|
1011 | + $pmReadGroups['denied'] = array(); |
|
1012 | + } |
|
966 | 1013 | |
967 | 1014 | // Load their alert preferences |
968 | 1015 | require_once($sourcedir . '/Subs-Notify.php'); |
@@ -994,8 +1041,9 @@ discard block |
||
994 | 1041 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
995 | 1042 | { |
996 | 1043 | // Don't do anything for members to be deleted! |
997 | - if (isset($deletes[$row['id_member']])) |
|
998 | - continue; |
|
1044 | + if (isset($deletes[$row['id_member']])) { |
|
1045 | + continue; |
|
1046 | + } |
|
999 | 1047 | |
1000 | 1048 | // Load the preferences for this member (if any) |
1001 | 1049 | $prefs = !empty($notifyPrefs[$row['id_member']]) ? $notifyPrefs[$row['id_member']] : array(); |
@@ -1016,8 +1064,9 @@ discard block |
||
1016 | 1064 | { |
1017 | 1065 | foreach ($groups as $id) |
1018 | 1066 | { |
1019 | - if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) |
|
1020 | - $message_limit = $message_limit_cache[$id]; |
|
1067 | + if (isset($message_limit_cache[$id]) && $message_limit != 0 && $message_limit < $message_limit_cache[$id]) { |
|
1068 | + $message_limit = $message_limit_cache[$id]; |
|
1069 | + } |
|
1021 | 1070 | } |
1022 | 1071 | |
1023 | 1072 | if ($message_limit > 0 && $message_limit <= $row['instant_messages']) |
@@ -1065,8 +1114,9 @@ discard block |
||
1065 | 1114 | $smcFunc['db_free_result']($request); |
1066 | 1115 | |
1067 | 1116 | // Only 'send' the message if there are any recipients left. |
1068 | - if (empty($all_to)) |
|
1069 | - return $log; |
|
1117 | + if (empty($all_to)) { |
|
1118 | + return $log; |
|
1119 | + } |
|
1070 | 1120 | |
1071 | 1121 | // Insert the message itself and then grab the last insert id. |
1072 | 1122 | $id_pm = $smcFunc['db_insert']('', |
@@ -1087,8 +1137,8 @@ discard block |
||
1087 | 1137 | if (!empty($id_pm)) |
1088 | 1138 | { |
1089 | 1139 | // If this is new we need to set it part of it's own conversation. |
1090 | - if (empty($pm_head)) |
|
1091 | - $smcFunc['db_query']('', ' |
|
1140 | + if (empty($pm_head)) { |
|
1141 | + $smcFunc['db_query']('', ' |
|
1092 | 1142 | UPDATE {db_prefix}personal_messages |
1093 | 1143 | SET id_pm_head = {int:id_pm_head} |
1094 | 1144 | WHERE id_pm = {int:id_pm_head}', |
@@ -1096,6 +1146,7 @@ discard block |
||
1096 | 1146 | 'id_pm_head' => $id_pm, |
1097 | 1147 | ) |
1098 | 1148 | ); |
1149 | + } |
|
1099 | 1150 | |
1100 | 1151 | // Some people think manually deleting personal_messages is fun... it's not. We protect against it though :) |
1101 | 1152 | $smcFunc['db_query']('', ' |
@@ -1111,8 +1162,9 @@ discard block |
||
1111 | 1162 | foreach ($all_to as $to) |
1112 | 1163 | { |
1113 | 1164 | $insertRows[] = array($id_pm, $to, in_array($to, $recipients['bcc']) ? 1 : 0, isset($deletes[$to]) ? 1 : 0, 1); |
1114 | - if (!in_array($to, $recipients['bcc'])) |
|
1115 | - $to_list[] = $to; |
|
1165 | + if (!in_array($to, $recipients['bcc'])) { |
|
1166 | + $to_list[] = $to; |
|
1167 | + } |
|
1116 | 1168 | } |
1117 | 1169 | |
1118 | 1170 | $smcFunc['db_insert']('insert', |
@@ -1130,9 +1182,9 @@ discard block |
||
1130 | 1182 | { |
1131 | 1183 | censorText($message); |
1132 | 1184 | $message = trim(un_htmlspecialchars(strip_tags(strtr(parse_bbc($smcFunc['htmlspecialchars']($message), false), array('<br>' => "\n", '</div>' => "\n", '</li>' => "\n", '[' => '[', ']' => ']'))))); |
1185 | + } else { |
|
1186 | + $message = ''; |
|
1133 | 1187 | } |
1134 | - else |
|
1135 | - $message = ''; |
|
1136 | 1188 | |
1137 | 1189 | $to_names = array(); |
1138 | 1190 | if (count($to_list) > 1) |
@@ -1145,8 +1197,9 @@ discard block |
||
1145 | 1197 | 'to_members' => $to_list, |
1146 | 1198 | ) |
1147 | 1199 | ); |
1148 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1149 | - $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1200 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1201 | + $to_names[] = un_htmlspecialchars($row['real_name']); |
|
1202 | + } |
|
1150 | 1203 | $smcFunc['db_free_result']($request); |
1151 | 1204 | } |
1152 | 1205 | $replacements = array( |
@@ -1174,11 +1227,13 @@ discard block |
||
1174 | 1227 | loadLanguage('index+PersonalMessage'); |
1175 | 1228 | |
1176 | 1229 | // Add one to their unread and read message counts. |
1177 | - foreach ($all_to as $k => $id) |
|
1178 | - if (isset($deletes[$id])) |
|
1230 | + foreach ($all_to as $k => $id) { |
|
1231 | + if (isset($deletes[$id])) |
|
1179 | 1232 | unset($all_to[$k]); |
1180 | - if (!empty($all_to)) |
|
1181 | - updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1233 | + } |
|
1234 | + if (!empty($all_to)) { |
|
1235 | + updateMemberData($all_to, array('instant_messages' => '+', 'unread_messages' => '+', 'new_pm' => 1)); |
|
1236 | + } |
|
1182 | 1237 | |
1183 | 1238 | return $log; |
1184 | 1239 | } |
@@ -1208,15 +1263,17 @@ discard block |
||
1208 | 1263 | // Let's, for now, assume there are only 'ish characters. |
1209 | 1264 | $simple = true; |
1210 | 1265 | |
1211 | - foreach ($matches[1] as $entity) |
|
1212 | - if ($entity > 128) |
|
1266 | + foreach ($matches[1] as $entity) { |
|
1267 | + if ($entity > 128) |
|
1213 | 1268 | $simple = false; |
1269 | + } |
|
1214 | 1270 | unset($matches); |
1215 | 1271 | |
1216 | - if ($simple) |
|
1217 | - $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1272 | + if ($simple) { |
|
1273 | + $string = preg_replace_callback('~&#(\d{3,8});~', function($m) |
|
1218 | 1274 | { |
1219 | 1275 | return chr("$m[1]"); |
1276 | + } |
|
1220 | 1277 | }, $string); |
1221 | 1278 | else |
1222 | 1279 | { |
@@ -1224,8 +1281,9 @@ discard block |
||
1224 | 1281 | if (!$context['utf8'] && function_exists('iconv')) |
1225 | 1282 | { |
1226 | 1283 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1227 | - if ($newstring) |
|
1228 | - $string = $newstring; |
|
1284 | + if ($newstring) { |
|
1285 | + $string = $newstring; |
|
1286 | + } |
|
1229 | 1287 | } |
1230 | 1288 | |
1231 | 1289 | $string = preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $string); |
@@ -1241,23 +1299,25 @@ discard block |
||
1241 | 1299 | if (!$context['utf8'] && function_exists('iconv')) |
1242 | 1300 | { |
1243 | 1301 | $newstring = @iconv($context['character_set'], 'UTF-8', $string); |
1244 | - if ($newstring) |
|
1245 | - $string = $newstring; |
|
1302 | + if ($newstring) { |
|
1303 | + $string = $newstring; |
|
1304 | + } |
|
1246 | 1305 | } |
1247 | 1306 | |
1248 | 1307 | $entityConvert = function($m) |
1249 | 1308 | { |
1250 | 1309 | $c = $m[1]; |
1251 | - if (strlen($c) === 1 && ord($c[0]) <= 0x7F) |
|
1252 | - return $c; |
|
1253 | - elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) |
|
1254 | - return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1255 | - elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) |
|
1256 | - return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1257 | - elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) |
|
1258 | - return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1259 | - else |
|
1260 | - return ""; |
|
1310 | + if (strlen($c) === 1 && ord($c[0]) <= 0x7F) { |
|
1311 | + return $c; |
|
1312 | + } elseif (strlen($c) === 2 && ord($c[0]) >= 0xC0 && ord($c[0]) <= 0xDF) { |
|
1313 | + return "&#" . (((ord($c[0]) ^ 0xC0) << 6) + (ord($c[1]) ^ 0x80)) . ";"; |
|
1314 | + } elseif (strlen($c) === 3 && ord($c[0]) >= 0xE0 && ord($c[0]) <= 0xEF) { |
|
1315 | + return "&#" . (((ord($c[0]) ^ 0xE0) << 12) + ((ord($c[1]) ^ 0x80) << 6) + (ord($c[2]) ^ 0x80)) . ";"; |
|
1316 | + } elseif (strlen($c) === 4 && ord($c[0]) >= 0xF0 && ord($c[0]) <= 0xF7) { |
|
1317 | + return "&#" . (((ord($c[0]) ^ 0xF0) << 18) + ((ord($c[1]) ^ 0x80) << 12) + ((ord($c[2]) ^ 0x80) << 6) + (ord($c[3]) ^ 0x80)) . ";"; |
|
1318 | + } else { |
|
1319 | + return ""; |
|
1320 | + } |
|
1261 | 1321 | }; |
1262 | 1322 | |
1263 | 1323 | // Convert all 'special' characters to HTML entities. |
@@ -1271,19 +1331,20 @@ discard block |
||
1271 | 1331 | $string = base64_encode($string); |
1272 | 1332 | |
1273 | 1333 | // Show the characterset and the transfer-encoding for header strings. |
1274 | - if ($with_charset) |
|
1275 | - $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1334 | + if ($with_charset) { |
|
1335 | + $string = '=?' . $charset . '?B?' . $string . '?='; |
|
1336 | + } |
|
1276 | 1337 | |
1277 | 1338 | // Break it up in lines (mail body). |
1278 | - else |
|
1279 | - $string = chunk_split($string, 76, $line_break); |
|
1339 | + else { |
|
1340 | + $string = chunk_split($string, 76, $line_break); |
|
1341 | + } |
|
1280 | 1342 | |
1281 | 1343 | return array($charset, $string, 'base64'); |
1344 | + } else { |
|
1345 | + return array($charset, $string, '7bit'); |
|
1346 | + } |
|
1282 | 1347 | } |
1283 | - |
|
1284 | - else |
|
1285 | - return array($charset, $string, '7bit'); |
|
1286 | -} |
|
1287 | 1348 | |
1288 | 1349 | /** |
1289 | 1350 | * Sends mail, like mail() but over SMTP. |
@@ -1307,8 +1368,9 @@ discard block |
||
1307 | 1368 | if ($modSettings['mail_type'] == 3 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
1308 | 1369 | { |
1309 | 1370 | $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2); |
1310 | - if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) |
|
1311 | - $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1371 | + if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) { |
|
1372 | + $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2); |
|
1373 | + } |
|
1312 | 1374 | |
1313 | 1375 | if ($socket) |
1314 | 1376 | { |
@@ -1329,8 +1391,9 @@ discard block |
||
1329 | 1391 | // Maybe we can still save this? The port might be wrong. |
1330 | 1392 | if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) |
1331 | 1393 | { |
1332 | - if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) |
|
1333 | - log_error($txt['smtp_port_ssl']); |
|
1394 | + if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) { |
|
1395 | + log_error($txt['smtp_port_ssl']); |
|
1396 | + } |
|
1334 | 1397 | } |
1335 | 1398 | |
1336 | 1399 | // Unable to connect! Don't show any error message, but just log one and try to continue anyway. |
@@ -1342,20 +1405,23 @@ discard block |
||
1342 | 1405 | } |
1343 | 1406 | |
1344 | 1407 | // Wait for a response of 220, without "-" continuer. |
1345 | - if (!server_parse(null, $socket, '220')) |
|
1346 | - return false; |
|
1408 | + if (!server_parse(null, $socket, '220')) { |
|
1409 | + return false; |
|
1410 | + } |
|
1347 | 1411 | |
1348 | 1412 | // Try and determine the servers name, fall back to the mail servers if not found |
1349 | 1413 | $helo = false; |
1350 | - if (function_exists('gethostname') && gethostname() !== false) |
|
1351 | - $helo = gethostname(); |
|
1352 | - elseif (function_exists('php_uname')) |
|
1353 | - $helo = php_uname('n'); |
|
1354 | - elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) |
|
1355 | - $helo = $_SERVER['SERVER_NAME']; |
|
1414 | + if (function_exists('gethostname') && gethostname() !== false) { |
|
1415 | + $helo = gethostname(); |
|
1416 | + } elseif (function_exists('php_uname')) { |
|
1417 | + $helo = php_uname('n'); |
|
1418 | + } elseif (array_key_exists('SERVER_NAME', $_SERVER) && !empty($_SERVER['SERVER_NAME'])) { |
|
1419 | + $helo = $_SERVER['SERVER_NAME']; |
|
1420 | + } |
|
1356 | 1421 | |
1357 | - if (empty($helo)) |
|
1358 | - $helo = $modSettings['smtp_host']; |
|
1422 | + if (empty($helo)) { |
|
1423 | + $helo = $modSettings['smtp_host']; |
|
1424 | + } |
|
1359 | 1425 | |
1360 | 1426 | // SMTP = 1, SMTP - STARTTLS = 2 |
1361 | 1427 | if (in_array($modSettings['mail_type'], array(1, 2)) && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') |
@@ -1367,33 +1433,39 @@ discard block |
||
1367 | 1433 | if ($modSettings['mail_type'] == 2 && preg_match("~250( |-)STARTTLS~mi", $response)) |
1368 | 1434 | { |
1369 | 1435 | // Send STARTTLS to enable encryption |
1370 | - if (!server_parse('STARTTLS', $socket, '220')) |
|
1371 | - return false; |
|
1436 | + if (!server_parse('STARTTLS', $socket, '220')) { |
|
1437 | + return false; |
|
1438 | + } |
|
1372 | 1439 | // Enable the encryption |
1373 | - if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) |
|
1374 | - return false; |
|
1440 | + if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
|
1441 | + return false; |
|
1442 | + } |
|
1375 | 1443 | // Send the EHLO command again |
1376 | - if (!server_parse('EHLO ' . $helo, $socket, null) == '250') |
|
1377 | - return false; |
|
1444 | + if (!server_parse('EHLO ' . $helo, $socket, null) == '250') { |
|
1445 | + return false; |
|
1446 | + } |
|
1378 | 1447 | } |
1379 | 1448 | |
1380 | - if (!server_parse('AUTH LOGIN', $socket, '334')) |
|
1381 | - return false; |
|
1449 | + if (!server_parse('AUTH LOGIN', $socket, '334')) { |
|
1450 | + return false; |
|
1451 | + } |
|
1382 | 1452 | // Send the username and password, encoded. |
1383 | - if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) |
|
1384 | - return false; |
|
1453 | + if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) { |
|
1454 | + return false; |
|
1455 | + } |
|
1385 | 1456 | // The password is already encoded ;) |
1386 | - if (!server_parse($modSettings['smtp_password'], $socket, '235')) |
|
1387 | - return false; |
|
1457 | + if (!server_parse($modSettings['smtp_password'], $socket, '235')) { |
|
1458 | + return false; |
|
1459 | + } |
|
1460 | + } elseif (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1461 | + return false; |
|
1388 | 1462 | } |
1389 | - elseif (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1390 | - return false; |
|
1391 | - } |
|
1392 | - else |
|
1463 | + } else |
|
1393 | 1464 | { |
1394 | 1465 | // Just say "helo". |
1395 | - if (!server_parse('HELO ' . $helo, $socket, '250')) |
|
1396 | - return false; |
|
1466 | + if (!server_parse('HELO ' . $helo, $socket, '250')) { |
|
1467 | + return false; |
|
1468 | + } |
|
1397 | 1469 | } |
1398 | 1470 | |
1399 | 1471 | // Fix the message for any lines beginning with a period! (the first is ignored, you see.) |
@@ -1406,31 +1478,38 @@ discard block |
||
1406 | 1478 | // Reset the connection to send another email. |
1407 | 1479 | if ($i != 0) |
1408 | 1480 | { |
1409 | - if (!server_parse('RSET', $socket, '250')) |
|
1410 | - return false; |
|
1481 | + if (!server_parse('RSET', $socket, '250')) { |
|
1482 | + return false; |
|
1483 | + } |
|
1411 | 1484 | } |
1412 | 1485 | |
1413 | 1486 | // From, to, and then start the data... |
1414 | - if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) |
|
1415 | - return false; |
|
1416 | - if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) |
|
1417 | - return false; |
|
1418 | - if (!server_parse('DATA', $socket, '354')) |
|
1419 | - return false; |
|
1487 | + if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) { |
|
1488 | + return false; |
|
1489 | + } |
|
1490 | + if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) { |
|
1491 | + return false; |
|
1492 | + } |
|
1493 | + if (!server_parse('DATA', $socket, '354')) { |
|
1494 | + return false; |
|
1495 | + } |
|
1420 | 1496 | fputs($socket, 'Subject: ' . $subject . "\r\n"); |
1421 | - if (strlen($mail_to) > 0) |
|
1422 | - fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1497 | + if (strlen($mail_to) > 0) { |
|
1498 | + fputs($socket, 'To: <' . $mail_to . '>' . "\r\n"); |
|
1499 | + } |
|
1423 | 1500 | fputs($socket, $headers . "\r\n\r\n"); |
1424 | 1501 | fputs($socket, $message . "\r\n"); |
1425 | 1502 | |
1426 | 1503 | // Send a ., or in other words "end of data". |
1427 | - if (!server_parse('.', $socket, '250')) |
|
1428 | - return false; |
|
1504 | + if (!server_parse('.', $socket, '250')) { |
|
1505 | + return false; |
|
1506 | + } |
|
1429 | 1507 | |
1430 | 1508 | // Almost done, almost done... don't stop me just yet! |
1431 | 1509 | @set_time_limit(300); |
1432 | - if (function_exists('apache_reset_timeout')) |
|
1433 | - @apache_reset_timeout(); |
|
1510 | + if (function_exists('apache_reset_timeout')) { |
|
1511 | + @apache_reset_timeout(); |
|
1512 | + } |
|
1434 | 1513 | } |
1435 | 1514 | fputs($socket, 'QUIT' . "\r\n"); |
1436 | 1515 | fclose($socket); |
@@ -1454,8 +1533,9 @@ discard block |
||
1454 | 1533 | { |
1455 | 1534 | global $txt; |
1456 | 1535 | |
1457 | - if ($message !== null) |
|
1458 | - fputs($socket, $message . "\r\n"); |
|
1536 | + if ($message !== null) { |
|
1537 | + fputs($socket, $message . "\r\n"); |
|
1538 | + } |
|
1459 | 1539 | |
1460 | 1540 | // No response yet. |
1461 | 1541 | $server_response = ''; |
@@ -1471,8 +1551,9 @@ discard block |
||
1471 | 1551 | $response .= $server_response; |
1472 | 1552 | } |
1473 | 1553 | |
1474 | - if ($code === null) |
|
1475 | - return substr($server_response, 0, 3); |
|
1554 | + if ($code === null) { |
|
1555 | + return substr($server_response, 0, 3); |
|
1556 | + } |
|
1476 | 1557 | |
1477 | 1558 | if (substr($server_response, 0, 3) != $code) |
1478 | 1559 | { |
@@ -1502,8 +1583,9 @@ discard block |
||
1502 | 1583 | // Create a pspell or enchant dictionary resource |
1503 | 1584 | $dict = spell_init(); |
1504 | 1585 | |
1505 | - if (!isset($_POST['spellstring']) || !$dict) |
|
1506 | - die; |
|
1586 | + if (!isset($_POST['spellstring']) || !$dict) { |
|
1587 | + die; |
|
1588 | + } |
|
1507 | 1589 | |
1508 | 1590 | // Construct a bit of Javascript code. |
1509 | 1591 | $context['spell_js'] = ' |
@@ -1521,8 +1603,9 @@ discard block |
||
1521 | 1603 | $check_word = explode('|', $alphas[$i]); |
1522 | 1604 | |
1523 | 1605 | // If the word is a known word, or spelled right... |
1524 | - if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) |
|
1525 | - continue; |
|
1606 | + if (in_array($smcFunc['strtolower']($check_word[0]), $known_words) || spell_check($dict, $check_word[0]) || !isset($check_word[2])) { |
|
1607 | + continue; |
|
1608 | + } |
|
1526 | 1609 | |
1527 | 1610 | // Find the word, and move up the "last occurrence" to here. |
1528 | 1611 | $found_words = true; |
@@ -1536,20 +1619,23 @@ discard block |
||
1536 | 1619 | if (!empty($suggestions)) |
1537 | 1620 | { |
1538 | 1621 | // But first check they aren't going to be censored - no naughty words! |
1539 | - foreach ($suggestions as $k => $word) |
|
1540 | - if ($suggestions[$k] != censorText($word)) |
|
1622 | + foreach ($suggestions as $k => $word) { |
|
1623 | + if ($suggestions[$k] != censorText($word)) |
|
1541 | 1624 | unset($suggestions[$k]); |
1625 | + } |
|
1542 | 1626 | |
1543 | - if (!empty($suggestions)) |
|
1544 | - $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1627 | + if (!empty($suggestions)) { |
|
1628 | + $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"'; |
|
1629 | + } |
|
1545 | 1630 | } |
1546 | 1631 | |
1547 | 1632 | $context['spell_js'] .= ']),'; |
1548 | 1633 | } |
1549 | 1634 | |
1550 | 1635 | // If words were found, take off the last comma. |
1551 | - if ($found_words) |
|
1552 | - $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1636 | + if ($found_words) { |
|
1637 | + $context['spell_js'] = substr($context['spell_js'], 0, -1); |
|
1638 | + } |
|
1553 | 1639 | |
1554 | 1640 | $context['spell_js'] .= ' |
1555 | 1641 | );'; |
@@ -1584,11 +1670,13 @@ discard block |
||
1584 | 1670 | global $user_info, $smcFunc; |
1585 | 1671 | |
1586 | 1672 | // Can't do it if there's no topics. |
1587 | - if (empty($topics)) |
|
1588 | - return; |
|
1673 | + if (empty($topics)) { |
|
1674 | + return; |
|
1675 | + } |
|
1589 | 1676 | // It must be an array - it must! |
1590 | - if (!is_array($topics)) |
|
1591 | - $topics = array($topics); |
|
1677 | + if (!is_array($topics)) { |
|
1678 | + $topics = array($topics); |
|
1679 | + } |
|
1592 | 1680 | |
1593 | 1681 | // Get the subject and body... |
1594 | 1682 | $result = $smcFunc['db_query']('', ' |
@@ -1636,14 +1724,15 @@ discard block |
||
1636 | 1724 | } |
1637 | 1725 | $smcFunc['db_free_result']($result); |
1638 | 1726 | |
1639 | - if (!empty($task_rows)) |
|
1640 | - $smcFunc['db_insert']('', |
|
1727 | + if (!empty($task_rows)) { |
|
1728 | + $smcFunc['db_insert']('', |
|
1641 | 1729 | '{db_prefix}background_tasks', |
1642 | 1730 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1643 | 1731 | $task_rows, |
1644 | 1732 | array('id_task') |
1645 | 1733 | ); |
1646 | -} |
|
1734 | + } |
|
1735 | + } |
|
1647 | 1736 | |
1648 | 1737 | /** |
1649 | 1738 | * Create a post, either as new topic (id_topic = 0) or in an existing one. |
@@ -1681,9 +1770,9 @@ discard block |
||
1681 | 1770 | $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; |
1682 | 1771 | |
1683 | 1772 | // We need to know if the topic is approved. If we're told that's great - if not find out. |
1684 | - if (!$modSettings['postmod_active']) |
|
1685 | - $topicOptions['is_approved'] = true; |
|
1686 | - elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1773 | + if (!$modSettings['postmod_active']) { |
|
1774 | + $topicOptions['is_approved'] = true; |
|
1775 | + } elseif (!empty($topicOptions['id']) && !isset($topicOptions['is_approved'])) |
|
1687 | 1776 | { |
1688 | 1777 | $request = $smcFunc['db_query']('', ' |
1689 | 1778 | SELECT approved |
@@ -1706,8 +1795,7 @@ discard block |
||
1706 | 1795 | $posterOptions['id'] = 0; |
1707 | 1796 | $posterOptions['name'] = $txt['guest_title']; |
1708 | 1797 | $posterOptions['email'] = ''; |
1709 | - } |
|
1710 | - elseif ($posterOptions['id'] != $user_info['id']) |
|
1798 | + } elseif ($posterOptions['id'] != $user_info['id']) |
|
1711 | 1799 | { |
1712 | 1800 | $request = $smcFunc['db_query']('', ' |
1713 | 1801 | SELECT member_name, email_address |
@@ -1725,12 +1813,11 @@ discard block |
||
1725 | 1813 | $posterOptions['id'] = 0; |
1726 | 1814 | $posterOptions['name'] = $txt['guest_title']; |
1727 | 1815 | $posterOptions['email'] = ''; |
1816 | + } else { |
|
1817 | + list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1728 | 1818 | } |
1729 | - else |
|
1730 | - list ($posterOptions['name'], $posterOptions['email']) = $smcFunc['db_fetch_row']($request); |
|
1731 | 1819 | $smcFunc['db_free_result']($request); |
1732 | - } |
|
1733 | - else |
|
1820 | + } else |
|
1734 | 1821 | { |
1735 | 1822 | $posterOptions['name'] = $user_info['name']; |
1736 | 1823 | $posterOptions['email'] = $user_info['email']; |
@@ -1740,8 +1827,9 @@ discard block |
||
1740 | 1827 | if (!empty($modSettings['enable_mentions'])) |
1741 | 1828 | { |
1742 | 1829 | $msgOptions['mentioned_members'] = Mentions::getMentionedMembers($msgOptions['body']); |
1743 | - if (!empty($msgOptions['mentioned_members'])) |
|
1744 | - $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1830 | + if (!empty($msgOptions['mentioned_members'])) { |
|
1831 | + $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $msgOptions['mentioned_members']); |
|
1832 | + } |
|
1745 | 1833 | } |
1746 | 1834 | |
1747 | 1835 | // It's do or die time: forget any user aborts! |
@@ -1774,12 +1862,13 @@ discard block |
||
1774 | 1862 | ); |
1775 | 1863 | |
1776 | 1864 | // Something went wrong creating the message... |
1777 | - if (empty($msgOptions['id'])) |
|
1778 | - return false; |
|
1865 | + if (empty($msgOptions['id'])) { |
|
1866 | + return false; |
|
1867 | + } |
|
1779 | 1868 | |
1780 | 1869 | // Fix the attachments. |
1781 | - if (!empty($msgOptions['attachments'])) |
|
1782 | - $smcFunc['db_query']('', ' |
|
1870 | + if (!empty($msgOptions['attachments'])) { |
|
1871 | + $smcFunc['db_query']('', ' |
|
1783 | 1872 | UPDATE {db_prefix}attachments |
1784 | 1873 | SET id_msg = {int:id_msg} |
1785 | 1874 | WHERE id_attach IN ({array_int:attachment_list})', |
@@ -1788,6 +1877,7 @@ discard block |
||
1788 | 1877 | 'id_msg' => $msgOptions['id'], |
1789 | 1878 | ) |
1790 | 1879 | ); |
1880 | + } |
|
1791 | 1881 | |
1792 | 1882 | // What if we want to export new posts out to a CMS? |
1793 | 1883 | call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); |
@@ -1864,20 +1954,23 @@ discard block |
||
1864 | 1954 | 'id_topic' => $topicOptions['id'], |
1865 | 1955 | 'counter_increment' => 1, |
1866 | 1956 | ); |
1867 | - if ($msgOptions['approved']) |
|
1868 | - $topics_columns = array( |
|
1957 | + if ($msgOptions['approved']) { |
|
1958 | + $topics_columns = array( |
|
1869 | 1959 | 'id_member_updated = {int:poster_id}', |
1870 | 1960 | 'id_last_msg = {int:id_msg}', |
1871 | 1961 | 'num_replies = num_replies + {int:counter_increment}', |
1872 | 1962 | ); |
1873 | - else |
|
1874 | - $topics_columns = array( |
|
1963 | + } else { |
|
1964 | + $topics_columns = array( |
|
1875 | 1965 | 'unapproved_posts = unapproved_posts + {int:counter_increment}', |
1876 | 1966 | ); |
1877 | - if ($topicOptions['lock_mode'] !== null) |
|
1878 | - $topics_columns[] = 'locked = {int:locked}'; |
|
1879 | - if ($topicOptions['sticky_mode'] !== null) |
|
1880 | - $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1967 | + } |
|
1968 | + if ($topicOptions['lock_mode'] !== null) { |
|
1969 | + $topics_columns[] = 'locked = {int:locked}'; |
|
1970 | + } |
|
1971 | + if ($topicOptions['sticky_mode'] !== null) { |
|
1972 | + $topics_columns[] = 'is_sticky = {int:is_sticky}'; |
|
1973 | + } |
|
1881 | 1974 | |
1882 | 1975 | call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); |
1883 | 1976 | |
@@ -1906,8 +1999,8 @@ discard block |
||
1906 | 1999 | ); |
1907 | 2000 | |
1908 | 2001 | // Increase the number of posts and topics on the board. |
1909 | - if ($msgOptions['approved']) |
|
1910 | - $smcFunc['db_query']('', ' |
|
2002 | + if ($msgOptions['approved']) { |
|
2003 | + $smcFunc['db_query']('', ' |
|
1911 | 2004 | UPDATE {db_prefix}boards |
1912 | 2005 | SET num_posts = num_posts + 1' . ($new_topic ? ', num_topics = num_topics + 1' : '') . ' |
1913 | 2006 | WHERE id_board = {int:id_board}', |
@@ -1915,7 +2008,7 @@ discard block |
||
1915 | 2008 | 'id_board' => $topicOptions['board'], |
1916 | 2009 | ) |
1917 | 2010 | ); |
1918 | - else |
|
2011 | + } else |
|
1919 | 2012 | { |
1920 | 2013 | $smcFunc['db_query']('', ' |
1921 | 2014 | UPDATE {db_prefix}boards |
@@ -1985,8 +2078,8 @@ discard block |
||
1985 | 2078 | } |
1986 | 2079 | } |
1987 | 2080 | |
1988 | - if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) |
|
1989 | - $smcFunc['db_insert']('', |
|
2081 | + if ($msgOptions['approved'] && empty($topicOptions['is_approved'])) { |
|
2082 | + $smcFunc['db_insert']('', |
|
1990 | 2083 | '{db_prefix}background_tasks', |
1991 | 2084 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
1992 | 2085 | array( |
@@ -1998,19 +2091,22 @@ discard block |
||
1998 | 2091 | ), |
1999 | 2092 | array('id_task') |
2000 | 2093 | ); |
2094 | + } |
|
2001 | 2095 | |
2002 | 2096 | // If there's a custom search index, it may need updating... |
2003 | 2097 | require_once($sourcedir . '/Search.php'); |
2004 | 2098 | $searchAPI = findSearchAPI(); |
2005 | - if (is_callable(array($searchAPI, 'postCreated'))) |
|
2006 | - $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2099 | + if (is_callable(array($searchAPI, 'postCreated'))) { |
|
2100 | + $searchAPI->postCreated($msgOptions, $topicOptions, $posterOptions); |
|
2101 | + } |
|
2007 | 2102 | |
2008 | 2103 | // Increase the post counter for the user that created the post. |
2009 | 2104 | if (!empty($posterOptions['update_post_count']) && !empty($posterOptions['id']) && $msgOptions['approved']) |
2010 | 2105 | { |
2011 | 2106 | // Are you the one that happened to create this post? |
2012 | - if ($user_info['id'] == $posterOptions['id']) |
|
2013 | - $user_info['posts']++; |
|
2107 | + if ($user_info['id'] == $posterOptions['id']) { |
|
2108 | + $user_info['posts']++; |
|
2109 | + } |
|
2014 | 2110 | updateMemberData($posterOptions['id'], array('posts' => '+')); |
2015 | 2111 | } |
2016 | 2112 | |
@@ -2018,19 +2114,21 @@ discard block |
||
2018 | 2114 | $_SESSION['last_read_topic'] = 0; |
2019 | 2115 | |
2020 | 2116 | // Better safe than sorry. |
2021 | - if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) |
|
2022 | - $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2117 | + if (isset($_SESSION['topicseen_cache'][$topicOptions['board']])) { |
|
2118 | + $_SESSION['topicseen_cache'][$topicOptions['board']]--; |
|
2119 | + } |
|
2023 | 2120 | |
2024 | 2121 | // Update all the stats so everyone knows about this new topic and message. |
2025 | 2122 | updateStats('message', true, $msgOptions['id']); |
2026 | 2123 | |
2027 | 2124 | // Update the last message on the board assuming it's approved AND the topic is. |
2028 | - if ($msgOptions['approved']) |
|
2029 | - updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2125 | + if ($msgOptions['approved']) { |
|
2126 | + updateLastMessages($topicOptions['board'], $new_topic || !empty($topicOptions['is_approved']) ? $msgOptions['id'] : 0); |
|
2127 | + } |
|
2030 | 2128 | |
2031 | 2129 | // Queue createPost background notification |
2032 | - if ($msgOptions['send_notifications'] && $msgOptions['approved']) |
|
2033 | - $smcFunc['db_insert']('', |
|
2130 | + if ($msgOptions['send_notifications'] && $msgOptions['approved']) { |
|
2131 | + $smcFunc['db_insert']('', |
|
2034 | 2132 | '{db_prefix}background_tasks', |
2035 | 2133 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2036 | 2134 | array('$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array( |
@@ -2041,6 +2139,7 @@ discard block |
||
2041 | 2139 | )), 0), |
2042 | 2140 | array('id_task') |
2043 | 2141 | ); |
2142 | + } |
|
2044 | 2143 | |
2045 | 2144 | // Alright, done now... we can abort now, I guess... at least this much is done. |
2046 | 2145 | ignore_user_abort($previous_ignore_user_abort); |
@@ -2067,14 +2166,18 @@ discard block |
||
2067 | 2166 | |
2068 | 2167 | // This is longer than it has to be, but makes it so we only set/change what we have to. |
2069 | 2168 | $messages_columns = array(); |
2070 | - if (isset($posterOptions['name'])) |
|
2071 | - $messages_columns['poster_name'] = $posterOptions['name']; |
|
2072 | - if (isset($posterOptions['email'])) |
|
2073 | - $messages_columns['poster_email'] = $posterOptions['email']; |
|
2074 | - if (isset($msgOptions['icon'])) |
|
2075 | - $messages_columns['icon'] = $msgOptions['icon']; |
|
2076 | - if (isset($msgOptions['subject'])) |
|
2077 | - $messages_columns['subject'] = $msgOptions['subject']; |
|
2169 | + if (isset($posterOptions['name'])) { |
|
2170 | + $messages_columns['poster_name'] = $posterOptions['name']; |
|
2171 | + } |
|
2172 | + if (isset($posterOptions['email'])) { |
|
2173 | + $messages_columns['poster_email'] = $posterOptions['email']; |
|
2174 | + } |
|
2175 | + if (isset($msgOptions['icon'])) { |
|
2176 | + $messages_columns['icon'] = $msgOptions['icon']; |
|
2177 | + } |
|
2178 | + if (isset($msgOptions['subject'])) { |
|
2179 | + $messages_columns['subject'] = $msgOptions['subject']; |
|
2180 | + } |
|
2078 | 2181 | if (isset($msgOptions['body'])) |
2079 | 2182 | { |
2080 | 2183 | $messages_columns['body'] = $msgOptions['body']; |
@@ -2101,8 +2204,9 @@ discard block |
||
2101 | 2204 | $messages_columns['modified_reason'] = $msgOptions['modify_reason']; |
2102 | 2205 | $messages_columns['id_msg_modified'] = $modSettings['maxMsgID']; |
2103 | 2206 | } |
2104 | - if (isset($msgOptions['smileys_enabled'])) |
|
2105 | - $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2207 | + if (isset($msgOptions['smileys_enabled'])) { |
|
2208 | + $messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1; |
|
2209 | + } |
|
2106 | 2210 | |
2107 | 2211 | // Which columns need to be ints? |
2108 | 2212 | $messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled'); |
@@ -2120,23 +2224,27 @@ discard block |
||
2120 | 2224 | { |
2121 | 2225 | preg_match_all('/\[member\=([0-9]+)\]([^\[]*)\[\/member\]/U', $msgOptions['old_body'], $match); |
2122 | 2226 | |
2123 | - if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) |
|
2124 | - foreach ($match[1] as $i => $oldID) |
|
2227 | + if (isset($match[1]) && isset($match[2]) && is_array($match[1]) && is_array($match[2])) { |
|
2228 | + foreach ($match[1] as $i => $oldID) |
|
2125 | 2229 | $oldmentions[$oldID] = array('id' => $oldID, 'real_name' => $match[2][$i]); |
2230 | + } |
|
2126 | 2231 | |
2127 | - if (empty($modSettings['search_custom_index_config'])) |
|
2128 | - unset($msgOptions['old_body']); |
|
2232 | + if (empty($modSettings['search_custom_index_config'])) { |
|
2233 | + unset($msgOptions['old_body']); |
|
2234 | + } |
|
2129 | 2235 | } |
2130 | 2236 | |
2131 | 2237 | $mentions = Mentions::getMentionedMembers($msgOptions['body']); |
2132 | 2238 | $messages_columns['body'] = $msgOptions['body'] = Mentions::getBody($msgOptions['body'], $mentions); |
2133 | 2239 | |
2134 | 2240 | // Remove the poster. |
2135 | - if (isset($mentions[$user_info['id']])) |
|
2136 | - unset($mentions[$user_info['id']]); |
|
2241 | + if (isset($mentions[$user_info['id']])) { |
|
2242 | + unset($mentions[$user_info['id']]); |
|
2243 | + } |
|
2137 | 2244 | |
2138 | - if (isset($oldmentions[$user_info['id']])) |
|
2139 | - unset($oldmentions[$user_info['id']]); |
|
2245 | + if (isset($oldmentions[$user_info['id']])) { |
|
2246 | + unset($oldmentions[$user_info['id']]); |
|
2247 | + } |
|
2140 | 2248 | |
2141 | 2249 | if (is_array($mentions) && is_array($oldmentions) && count(array_diff_key($mentions, $oldmentions)) > 0 && count($mentions) > count($oldmentions)) |
2142 | 2250 | { |
@@ -2166,8 +2274,9 @@ discard block |
||
2166 | 2274 | } |
2167 | 2275 | |
2168 | 2276 | // Nothing to do? |
2169 | - if (empty($messages_columns)) |
|
2170 | - return true; |
|
2277 | + if (empty($messages_columns)) { |
|
2278 | + return true; |
|
2279 | + } |
|
2171 | 2280 | |
2172 | 2281 | // Change the post. |
2173 | 2282 | $smcFunc['db_query']('', ' |
@@ -2228,8 +2337,9 @@ discard block |
||
2228 | 2337 | // If there's a custom search index, it needs to be modified... |
2229 | 2338 | require_once($sourcedir . '/Search.php'); |
2230 | 2339 | $searchAPI = findSearchAPI(); |
2231 | - if (is_callable(array($searchAPI, 'postModified'))) |
|
2232 | - $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2340 | + if (is_callable(array($searchAPI, 'postModified'))) { |
|
2341 | + $searchAPI->postModified($msgOptions, $topicOptions, $posterOptions); |
|
2342 | + } |
|
2233 | 2343 | |
2234 | 2344 | if (isset($msgOptions['subject'])) |
2235 | 2345 | { |
@@ -2243,14 +2353,16 @@ discard block |
||
2243 | 2353 | 'id_first_msg' => $msgOptions['id'], |
2244 | 2354 | ) |
2245 | 2355 | ); |
2246 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
2247 | - updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2356 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
2357 | + updateStats('subject', $topicOptions['id'], $msgOptions['subject']); |
|
2358 | + } |
|
2248 | 2359 | $smcFunc['db_free_result']($request); |
2249 | 2360 | } |
2250 | 2361 | |
2251 | 2362 | // Finally, if we are setting the approved state we need to do much more work :( |
2252 | - if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) |
|
2253 | - approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2363 | + if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) { |
|
2364 | + approvePosts($msgOptions['id'], $msgOptions['approved']); |
|
2365 | + } |
|
2254 | 2366 | |
2255 | 2367 | return true; |
2256 | 2368 | } |
@@ -2267,11 +2379,13 @@ discard block |
||
2267 | 2379 | { |
2268 | 2380 | global $smcFunc; |
2269 | 2381 | |
2270 | - if (!is_array($msgs)) |
|
2271 | - $msgs = array($msgs); |
|
2382 | + if (!is_array($msgs)) { |
|
2383 | + $msgs = array($msgs); |
|
2384 | + } |
|
2272 | 2385 | |
2273 | - if (empty($msgs)) |
|
2274 | - return false; |
|
2386 | + if (empty($msgs)) { |
|
2387 | + return false; |
|
2388 | + } |
|
2275 | 2389 | |
2276 | 2390 | // May as well start at the beginning, working out *what* we need to change. |
2277 | 2391 | $request = $smcFunc['db_query']('', ' |
@@ -2303,20 +2417,22 @@ discard block |
||
2303 | 2417 | $topics[] = $row['id_topic']; |
2304 | 2418 | |
2305 | 2419 | // Ensure our change array exists already. |
2306 | - if (!isset($topic_changes[$row['id_topic']])) |
|
2307 | - $topic_changes[$row['id_topic']] = array( |
|
2420 | + if (!isset($topic_changes[$row['id_topic']])) { |
|
2421 | + $topic_changes[$row['id_topic']] = array( |
|
2308 | 2422 | 'id_last_msg' => $row['id_last_msg'], |
2309 | 2423 | 'approved' => $row['topic_approved'], |
2310 | 2424 | 'replies' => 0, |
2311 | 2425 | 'unapproved_posts' => 0, |
2312 | 2426 | ); |
2313 | - if (!isset($board_changes[$row['id_board']])) |
|
2314 | - $board_changes[$row['id_board']] = array( |
|
2427 | + } |
|
2428 | + if (!isset($board_changes[$row['id_board']])) { |
|
2429 | + $board_changes[$row['id_board']] = array( |
|
2315 | 2430 | 'posts' => 0, |
2316 | 2431 | 'topics' => 0, |
2317 | 2432 | 'unapproved_posts' => 0, |
2318 | 2433 | 'unapproved_topics' => 0, |
2319 | 2434 | ); |
2435 | + } |
|
2320 | 2436 | |
2321 | 2437 | // If it's the first message then the topic state changes! |
2322 | 2438 | if ($row['id_msg'] == $row['id_first_msg']) |
@@ -2337,14 +2453,13 @@ discard block |
||
2337 | 2453 | 'poster' => $row['id_member'], |
2338 | 2454 | 'new_topic' => true, |
2339 | 2455 | ); |
2340 | - } |
|
2341 | - else |
|
2456 | + } else |
|
2342 | 2457 | { |
2343 | 2458 | $topic_changes[$row['id_topic']]['replies'] += $approve ? 1 : -1; |
2344 | 2459 | |
2345 | 2460 | // This will be a post... but don't notify unless it's not followed by approved ones. |
2346 | - if ($row['id_msg'] > $row['id_last_msg']) |
|
2347 | - $notification_posts[$row['id_topic']] = array( |
|
2461 | + if ($row['id_msg'] > $row['id_last_msg']) { |
|
2462 | + $notification_posts[$row['id_topic']] = array( |
|
2348 | 2463 | 'id' => $row['id_msg'], |
2349 | 2464 | 'body' => $row['body'], |
2350 | 2465 | 'subject' => $row['subject'], |
@@ -2355,28 +2470,33 @@ discard block |
||
2355 | 2470 | 'new_topic' => false, |
2356 | 2471 | 'msg' => $row['id_msg'], |
2357 | 2472 | ); |
2473 | + } |
|
2358 | 2474 | } |
2359 | 2475 | |
2360 | 2476 | // If this is being approved and id_msg is higher than the current id_last_msg then it changes. |
2361 | - if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) |
|
2362 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2477 | + if ($approve && $row['id_msg'] > $topic_changes[$row['id_topic']]['id_last_msg']) { |
|
2478 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_msg']; |
|
2479 | + } |
|
2363 | 2480 | // If this is being unapproved, and it's equal to the id_last_msg we need to find a new one! |
2364 | - elseif (!$approve) |
|
2365 | - // Default to the first message and then we'll override in a bit ;) |
|
2481 | + elseif (!$approve) { |
|
2482 | + // Default to the first message and then we'll override in a bit ;) |
|
2366 | 2483 | $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_first_msg']; |
2484 | + } |
|
2367 | 2485 | |
2368 | 2486 | $topic_changes[$row['id_topic']]['unapproved_posts'] += $approve ? -1 : 1; |
2369 | 2487 | $board_changes[$row['id_board']]['unapproved_posts'] += $approve ? -1 : 1; |
2370 | 2488 | $board_changes[$row['id_board']]['posts'] += $approve ? 1 : -1; |
2371 | 2489 | |
2372 | 2490 | // Post count for the user? |
2373 | - if ($row['id_member'] && empty($row['count_posts'])) |
|
2374 | - $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2491 | + if ($row['id_member'] && empty($row['count_posts'])) { |
|
2492 | + $member_post_changes[$row['id_member']] = isset($member_post_changes[$row['id_member']]) ? $member_post_changes[$row['id_member']] + 1 : 1; |
|
2493 | + } |
|
2375 | 2494 | } |
2376 | 2495 | $smcFunc['db_free_result']($request); |
2377 | 2496 | |
2378 | - if (empty($msgs)) |
|
2379 | - return; |
|
2497 | + if (empty($msgs)) { |
|
2498 | + return; |
|
2499 | + } |
|
2380 | 2500 | |
2381 | 2501 | // Now we have the differences make the changes, first the easy one. |
2382 | 2502 | $smcFunc['db_query']('', ' |
@@ -2403,14 +2523,15 @@ discard block |
||
2403 | 2523 | 'approved' => 1, |
2404 | 2524 | ) |
2405 | 2525 | ); |
2406 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2407 | - $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2526 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2527 | + $topic_changes[$row['id_topic']]['id_last_msg'] = $row['id_last_msg']; |
|
2528 | + } |
|
2408 | 2529 | $smcFunc['db_free_result']($request); |
2409 | 2530 | } |
2410 | 2531 | |
2411 | 2532 | // ... next the topics... |
2412 | - foreach ($topic_changes as $id => $changes) |
|
2413 | - $smcFunc['db_query']('', ' |
|
2533 | + foreach ($topic_changes as $id => $changes) { |
|
2534 | + $smcFunc['db_query']('', ' |
|
2414 | 2535 | UPDATE {db_prefix}topics |
2415 | 2536 | SET approved = {int:approved}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2416 | 2537 | num_replies = num_replies + {int:num_replies}, id_last_msg = {int:id_last_msg} |
@@ -2423,10 +2544,11 @@ discard block |
||
2423 | 2544 | 'id_topic' => $id, |
2424 | 2545 | ) |
2425 | 2546 | ); |
2547 | + } |
|
2426 | 2548 | |
2427 | 2549 | // ... finally the boards... |
2428 | - foreach ($board_changes as $id => $changes) |
|
2429 | - $smcFunc['db_query']('', ' |
|
2550 | + foreach ($board_changes as $id => $changes) { |
|
2551 | + $smcFunc['db_query']('', ' |
|
2430 | 2552 | UPDATE {db_prefix}boards |
2431 | 2553 | SET num_posts = num_posts + {int:num_posts}, unapproved_posts = unapproved_posts + {int:unapproved_posts}, |
2432 | 2554 | num_topics = num_topics + {int:num_topics}, unapproved_topics = unapproved_topics + {int:unapproved_topics} |
@@ -2439,13 +2561,14 @@ discard block |
||
2439 | 2561 | 'id_board' => $id, |
2440 | 2562 | ) |
2441 | 2563 | ); |
2564 | + } |
|
2442 | 2565 | |
2443 | 2566 | // Finally, least importantly, notifications! |
2444 | 2567 | if ($approve) |
2445 | 2568 | { |
2446 | 2569 | $task_rows = array(); |
2447 | - foreach (array_merge($notification_topics, $notification_posts) as $topic) |
|
2448 | - $task_rows[] = array( |
|
2570 | + foreach (array_merge($notification_topics, $notification_posts) as $topic) { |
|
2571 | + $task_rows[] = array( |
|
2449 | 2572 | '$sourcedir/tasks/CreatePost-Notify.php', 'CreatePost_Notify_Background', json_encode(array( |
2450 | 2573 | 'msgOptions' => array( |
2451 | 2574 | 'id' => $topic['msg'], |
@@ -2463,14 +2586,16 @@ discard block |
||
2463 | 2586 | 'type' => $topic['new_topic'] ? 'topic' : 'reply', |
2464 | 2587 | )), 0 |
2465 | 2588 | ); |
2589 | + } |
|
2466 | 2590 | |
2467 | - if ($notify) |
|
2468 | - $smcFunc['db_insert']('', |
|
2591 | + if ($notify) { |
|
2592 | + $smcFunc['db_insert']('', |
|
2469 | 2593 | '{db_prefix}background_tasks', |
2470 | 2594 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
2471 | 2595 | $task_rows, |
2472 | 2596 | array('id_task') |
2473 | 2597 | ); |
2598 | + } |
|
2474 | 2599 | |
2475 | 2600 | $smcFunc['db_query']('', ' |
2476 | 2601 | DELETE FROM {db_prefix}approval_queue |
@@ -2486,8 +2611,9 @@ discard block |
||
2486 | 2611 | else |
2487 | 2612 | { |
2488 | 2613 | $msgInserts = array(); |
2489 | - foreach ($msgs as $msg) |
|
2490 | - $msgInserts[] = array($msg); |
|
2614 | + foreach ($msgs as $msg) { |
|
2615 | + $msgInserts[] = array($msg); |
|
2616 | + } |
|
2491 | 2617 | |
2492 | 2618 | $smcFunc['db_insert']('ignore', |
2493 | 2619 | '{db_prefix}approval_queue', |
@@ -2501,9 +2627,10 @@ discard block |
||
2501 | 2627 | updateLastMessages(array_keys($board_changes)); |
2502 | 2628 | |
2503 | 2629 | // Post count for the members? |
2504 | - if (!empty($member_post_changes)) |
|
2505 | - foreach ($member_post_changes as $id_member => $count_change) |
|
2630 | + if (!empty($member_post_changes)) { |
|
2631 | + foreach ($member_post_changes as $id_member => $count_change) |
|
2506 | 2632 | updateMemberData($id_member, array('posts' => 'posts ' . ($approve ? '+' : '-') . ' ' . $count_change)); |
2633 | + } |
|
2507 | 2634 | |
2508 | 2635 | return true; |
2509 | 2636 | } |
@@ -2520,11 +2647,13 @@ discard block |
||
2520 | 2647 | { |
2521 | 2648 | global $smcFunc; |
2522 | 2649 | |
2523 | - if (!is_array($topics)) |
|
2524 | - $topics = array($topics); |
|
2650 | + if (!is_array($topics)) { |
|
2651 | + $topics = array($topics); |
|
2652 | + } |
|
2525 | 2653 | |
2526 | - if (empty($topics)) |
|
2527 | - return false; |
|
2654 | + if (empty($topics)) { |
|
2655 | + return false; |
|
2656 | + } |
|
2528 | 2657 | |
2529 | 2658 | $approve_type = $approve ? 0 : 1; |
2530 | 2659 | |
@@ -2540,8 +2669,9 @@ discard block |
||
2540 | 2669 | ) |
2541 | 2670 | ); |
2542 | 2671 | $msgs = array(); |
2543 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2544 | - $msgs[] = $row['id_msg']; |
|
2672 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2673 | + $msgs[] = $row['id_msg']; |
|
2674 | + } |
|
2545 | 2675 | $smcFunc['db_free_result']($request); |
2546 | 2676 | |
2547 | 2677 | return approvePosts($msgs, $approve); |
@@ -2564,11 +2694,13 @@ discard block |
||
2564 | 2694 | global $board_info, $board, $smcFunc; |
2565 | 2695 | |
2566 | 2696 | // Please - let's be sane. |
2567 | - if (empty($setboards)) |
|
2568 | - return false; |
|
2697 | + if (empty($setboards)) { |
|
2698 | + return false; |
|
2699 | + } |
|
2569 | 2700 | |
2570 | - if (!is_array($setboards)) |
|
2571 | - $setboards = array($setboards); |
|
2701 | + if (!is_array($setboards)) { |
|
2702 | + $setboards = array($setboards); |
|
2703 | + } |
|
2572 | 2704 | |
2573 | 2705 | // If we don't know the id_msg we need to find it. |
2574 | 2706 | if (!$id_msg) |
@@ -2586,15 +2718,16 @@ discard block |
||
2586 | 2718 | ) |
2587 | 2719 | ); |
2588 | 2720 | $lastMsg = array(); |
2589 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2590 | - $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2721 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2722 | + $lastMsg[$row['id_board']] = $row['id_msg']; |
|
2723 | + } |
|
2591 | 2724 | $smcFunc['db_free_result']($request); |
2592 | - } |
|
2593 | - else |
|
2725 | + } else |
|
2594 | 2726 | { |
2595 | 2727 | // Just to note - there should only be one board passed if we are doing this. |
2596 | - foreach ($setboards as $id_board) |
|
2597 | - $lastMsg[$id_board] = $id_msg; |
|
2728 | + foreach ($setboards as $id_board) { |
|
2729 | + $lastMsg[$id_board] = $id_msg; |
|
2730 | + } |
|
2598 | 2731 | } |
2599 | 2732 | |
2600 | 2733 | $parent_boards = array(); |
@@ -2609,10 +2742,11 @@ discard block |
||
2609 | 2742 | $lastModified[$id_board] = 0; |
2610 | 2743 | } |
2611 | 2744 | |
2612 | - if (!empty($board) && $id_board == $board) |
|
2613 | - $parents = $board_info['parent_boards']; |
|
2614 | - else |
|
2615 | - $parents = getBoardParents($id_board); |
|
2745 | + if (!empty($board) && $id_board == $board) { |
|
2746 | + $parents = $board_info['parent_boards']; |
|
2747 | + } else { |
|
2748 | + $parents = getBoardParents($id_board); |
|
2749 | + } |
|
2616 | 2750 | |
2617 | 2751 | // Ignore any parents on the top child level. |
2618 | 2752 | // @todo Why? |
@@ -2621,10 +2755,11 @@ discard block |
||
2621 | 2755 | if ($parent['level'] != 0) |
2622 | 2756 | { |
2623 | 2757 | // If we're already doing this one as a board, is this a higher last modified? |
2624 | - if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) |
|
2625 | - $lastModified[$id] = $lastModified[$id_board]; |
|
2626 | - elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) |
|
2627 | - $parent_boards[$id] = $lastModified[$id_board]; |
|
2758 | + if (isset($lastModified[$id]) && $lastModified[$id_board] > $lastModified[$id]) { |
|
2759 | + $lastModified[$id] = $lastModified[$id_board]; |
|
2760 | + } elseif (!isset($lastModified[$id]) && (!isset($parent_boards[$id]) || $parent_boards[$id] < $lastModified[$id_board])) { |
|
2761 | + $parent_boards[$id] = $lastModified[$id_board]; |
|
2762 | + } |
|
2628 | 2763 | } |
2629 | 2764 | } |
2630 | 2765 | } |
@@ -2637,23 +2772,24 @@ discard block |
||
2637 | 2772 | // Finally, to save on queries make the changes... |
2638 | 2773 | foreach ($parent_boards as $id => $msg) |
2639 | 2774 | { |
2640 | - if (!isset($parent_updates[$msg])) |
|
2641 | - $parent_updates[$msg] = array($id); |
|
2642 | - else |
|
2643 | - $parent_updates[$msg][] = $id; |
|
2775 | + if (!isset($parent_updates[$msg])) { |
|
2776 | + $parent_updates[$msg] = array($id); |
|
2777 | + } else { |
|
2778 | + $parent_updates[$msg][] = $id; |
|
2779 | + } |
|
2644 | 2780 | } |
2645 | 2781 | |
2646 | 2782 | foreach ($lastMsg as $id => $msg) |
2647 | 2783 | { |
2648 | - if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) |
|
2649 | - $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2784 | + if (!isset($board_updates[$msg . '-' . $lastModified[$id]])) { |
|
2785 | + $board_updates[$msg . '-' . $lastModified[$id]] = array( |
|
2650 | 2786 | 'id' => $msg, |
2651 | 2787 | 'updated' => $lastModified[$id], |
2652 | 2788 | 'boards' => array($id) |
2653 | 2789 | ); |
2654 | - |
|
2655 | - else |
|
2656 | - $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2790 | + } else { |
|
2791 | + $board_updates[$msg . '-' . $lastModified[$id]]['boards'][] = $id; |
|
2792 | + } |
|
2657 | 2793 | } |
2658 | 2794 | |
2659 | 2795 | // Now commit the changes! |
@@ -2745,11 +2881,13 @@ discard block |
||
2745 | 2881 | global $txt, $mbname, $scripturl, $settings; |
2746 | 2882 | |
2747 | 2883 | // First things first, load up the email templates language file, if we need to. |
2748 | - if ($loadLang) |
|
2749 | - loadLanguage('EmailTemplates', $lang); |
|
2884 | + if ($loadLang) { |
|
2885 | + loadLanguage('EmailTemplates', $lang); |
|
2886 | + } |
|
2750 | 2887 | |
2751 | - if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) |
|
2752 | - fatal_lang_error('email_no_template', 'template', array($template)); |
|
2888 | + if (!isset($txt[$template . '_subject']) || !isset($txt[$template . '_body'])) { |
|
2889 | + fatal_lang_error('email_no_template', 'template', array($template)); |
|
2890 | + } |
|
2753 | 2891 | |
2754 | 2892 | $ret = array( |
2755 | 2893 | 'subject' => $txt[$template . '_subject'], |
@@ -2799,17 +2937,18 @@ discard block |
||
2799 | 2937 | function user_info_callback($matches) |
2800 | 2938 | { |
2801 | 2939 | global $user_info; |
2802 | - if (empty($matches[1])) |
|
2803 | - return ''; |
|
2940 | + if (empty($matches[1])) { |
|
2941 | + return ''; |
|
2942 | + } |
|
2804 | 2943 | |
2805 | 2944 | $use_ref = true; |
2806 | 2945 | $ref = &$user_info; |
2807 | 2946 | |
2808 | 2947 | foreach (explode('.', $matches[1]) as $index) |
2809 | 2948 | { |
2810 | - if ($use_ref && isset($ref[$index])) |
|
2811 | - $ref = &$ref[$index]; |
|
2812 | - else |
|
2949 | + if ($use_ref && isset($ref[$index])) { |
|
2950 | + $ref = &$ref[$index]; |
|
2951 | + } else |
|
2813 | 2952 | { |
2814 | 2953 | $use_ref = false; |
2815 | 2954 | break; |
@@ -2846,8 +2985,7 @@ discard block |
||
2846 | 2985 | if (!empty($lang_locale) && enchant_broker_dict_exists($context['enchant_broker'], $lang_locale)) |
2847 | 2986 | { |
2848 | 2987 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $lang_locale); |
2849 | - } |
|
2850 | - elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2988 | + } elseif (enchant_broker_dict_exists($context['enchant_broker'], $txt['lang_dictionary'])) |
|
2851 | 2989 | { |
2852 | 2990 | $enchant_link = enchant_broker_request_dict($context['enchant_broker'], $txt['lang_dictionary']); |
2853 | 2991 | } |
@@ -2857,8 +2995,7 @@ discard block |
||
2857 | 2995 | { |
2858 | 2996 | $context['provider'] = 'enchant'; |
2859 | 2997 | return $enchant_link; |
2860 | - } |
|
2861 | - else |
|
2998 | + } else |
|
2862 | 2999 | { |
2863 | 3000 | // Free up any resources used... |
2864 | 3001 | @enchant_broker_free($context['enchant_broker']); |
@@ -2879,8 +3016,9 @@ discard block |
||
2879 | 3016 | $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', strtr($context['character_set'], array('iso-' => 'iso', 'ISO-' => 'iso')), PSPELL_FAST | PSPELL_RUN_TOGETHER); |
2880 | 3017 | |
2881 | 3018 | // Most people don't have anything but English installed... So we use English as a last resort. |
2882 | - if (!$pspell_link) |
|
2883 | - $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3019 | + if (!$pspell_link) { |
|
3020 | + $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER); |
|
3021 | + } |
|
2884 | 3022 | |
2885 | 3023 | error_reporting($old); |
2886 | 3024 | ob_end_clean(); |
@@ -2920,8 +3058,7 @@ discard block |
||
2920 | 3058 | $word = iconv($txt['lang_character_set'], 'UTF-8', $word); |
2921 | 3059 | } |
2922 | 3060 | return enchant_dict_check($dict, $word); |
2923 | - } |
|
2924 | - elseif ($context['provider'] == 'pspell') |
|
3061 | + } elseif ($context['provider'] == 'pspell') |
|
2925 | 3062 | { |
2926 | 3063 | return pspell_check($dict, $word); |
2927 | 3064 | } |
@@ -2957,13 +3094,11 @@ discard block |
||
2957 | 3094 | } |
2958 | 3095 | |
2959 | 3096 | return $suggestions; |
2960 | - } |
|
2961 | - else |
|
3097 | + } else |
|
2962 | 3098 | { |
2963 | 3099 | return enchant_dict_suggest($dict, $word); |
2964 | 3100 | } |
2965 | - } |
|
2966 | - elseif ($context['provider'] == 'pspell') |
|
3101 | + } elseif ($context['provider'] == 'pspell') |
|
2967 | 3102 | { |
2968 | 3103 | return pspell_suggest($dict, $word); |
2969 | 3104 | } |