@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -232,8 +236,9 @@ discard block |
||
232 | 236 | $_SESSION['adm-save'] = true; |
233 | 237 | |
234 | 238 | // Do a bit of housekeeping |
235 | - if (empty($_POST['minimize_files'])) |
|
236 | - deleteAllMinified(); |
|
239 | + if (empty($_POST['minimize_files'])) { |
|
240 | + deleteAllMinified(); |
|
241 | + } |
|
237 | 242 | |
238 | 243 | writeLog(); |
239 | 244 | redirectexit('action=admin;area=featuresettings;sa=basic'); |
@@ -273,8 +278,9 @@ discard block |
||
273 | 278 | |
274 | 279 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
275 | 280 | |
276 | - if ($return_config) |
|
277 | - return $config_vars; |
|
281 | + if ($return_config) { |
|
282 | + return $config_vars; |
|
283 | + } |
|
278 | 284 | |
279 | 285 | // Setup the template. |
280 | 286 | require_once($sourcedir . '/ManageServer.php'); |
@@ -291,13 +297,15 @@ discard block |
||
291 | 297 | |
292 | 298 | // Clean up the tags. |
293 | 299 | $bbcTags = array(); |
294 | - foreach (parse_bbc(false) as $tag) |
|
295 | - $bbcTags[] = $tag['tag']; |
|
300 | + foreach (parse_bbc(false) as $tag) { |
|
301 | + $bbcTags[] = $tag['tag']; |
|
302 | + } |
|
296 | 303 | |
297 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
298 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
299 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
300 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
304 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
305 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
306 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
307 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
308 | + } |
|
301 | 309 | // Work out what is actually disabled! |
302 | 310 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
303 | 311 | |
@@ -341,8 +349,9 @@ discard block |
||
341 | 349 | |
342 | 350 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
343 | 351 | |
344 | - if ($return_config) |
|
345 | - return $config_vars; |
|
352 | + if ($return_config) { |
|
353 | + return $config_vars; |
|
354 | + } |
|
346 | 355 | |
347 | 356 | // Saving? |
348 | 357 | if (isset($_GET['save'])) |
@@ -382,8 +391,9 @@ discard block |
||
382 | 391 | |
383 | 392 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
384 | 393 | |
385 | - if ($return_config) |
|
386 | - return $config_vars; |
|
394 | + if ($return_config) { |
|
395 | + return $config_vars; |
|
396 | + } |
|
387 | 397 | |
388 | 398 | // Saving? |
389 | 399 | if (isset($_GET['save'])) |
@@ -421,8 +431,9 @@ discard block |
||
421 | 431 | |
422 | 432 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
423 | 433 | |
424 | - if ($return_config) |
|
425 | - return $config_vars; |
|
434 | + if ($return_config) { |
|
435 | + return $config_vars; |
|
436 | + } |
|
426 | 437 | |
427 | 438 | // Saving? |
428 | 439 | if (isset($_GET['save'])) |
@@ -466,8 +477,8 @@ discard block |
||
466 | 477 | 'enable' => array('check', 'warning_enable'), |
467 | 478 | ); |
468 | 479 | |
469 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
470 | - $config_vars += array( |
|
480 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
481 | + $config_vars += array( |
|
471 | 482 | '', |
472 | 483 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
473 | 484 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -476,15 +487,18 @@ discard block |
||
476 | 487 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
477 | 488 | array('permissions', 'view_warning'), |
478 | 489 | ); |
490 | + } |
|
479 | 491 | |
480 | 492 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
481 | 493 | |
482 | - if ($return_config) |
|
483 | - return $config_vars; |
|
494 | + if ($return_config) { |
|
495 | + return $config_vars; |
|
496 | + } |
|
484 | 497 | |
485 | 498 | // Cannot use moderation if post moderation is not enabled. |
486 | - if (!$modSettings['postmod_active']) |
|
487 | - unset($config_vars['moderate']); |
|
499 | + if (!$modSettings['postmod_active']) { |
|
500 | + unset($config_vars['moderate']); |
|
501 | + } |
|
488 | 502 | |
489 | 503 | // Will need the utility functions from here. |
490 | 504 | require_once($sourcedir . '/ManageServer.php'); |
@@ -509,16 +523,16 @@ discard block |
||
509 | 523 | 'warning_watch' => 10, |
510 | 524 | 'warning_mute' => 60, |
511 | 525 | ); |
512 | - if ($modSettings['postmod_active']) |
|
513 | - $vars['warning_moderate'] = 35; |
|
526 | + if ($modSettings['postmod_active']) { |
|
527 | + $vars['warning_moderate'] = 35; |
|
528 | + } |
|
514 | 529 | |
515 | 530 | foreach ($vars as $var => $value) |
516 | 531 | { |
517 | 532 | $config_vars[] = array('int', $var); |
518 | 533 | $_POST[$var] = $value; |
519 | 534 | } |
520 | - } |
|
521 | - else |
|
535 | + } else |
|
522 | 536 | { |
523 | 537 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
524 | 538 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -606,8 +620,9 @@ discard block |
||
606 | 620 | |
607 | 621 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
608 | 622 | |
609 | - if ($return_config) |
|
610 | - return $config_vars; |
|
623 | + if ($return_config) { |
|
624 | + return $config_vars; |
|
625 | + } |
|
611 | 626 | |
612 | 627 | // You need to be an admin to edit settings! |
613 | 628 | isAllowedTo('admin_forum'); |
@@ -641,8 +656,9 @@ discard block |
||
641 | 656 | |
642 | 657 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
643 | 658 | { |
644 | - if (empty($context['settings_insert_above'])) |
|
645 | - $context['settings_insert_above'] = ''; |
|
659 | + if (empty($context['settings_insert_above'])) { |
|
660 | + $context['settings_insert_above'] = ''; |
|
661 | + } |
|
646 | 662 | |
647 | 663 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
648 | 664 | } |
@@ -685,8 +701,9 @@ discard block |
||
685 | 701 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
686 | 702 | |
687 | 703 | // Hack in guest requiring verification! |
688 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
689 | - $_POST['posts_require_captcha'] = -1; |
|
704 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
705 | + $_POST['posts_require_captcha'] = -1; |
|
706 | + } |
|
690 | 707 | |
691 | 708 | $save_vars = $config_vars; |
692 | 709 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -703,14 +720,16 @@ discard block |
||
703 | 720 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
704 | 721 | { |
705 | 722 | // If we had some questions for this language before, but don't now, delete everything from that language. |
706 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
707 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
723 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
724 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
725 | + } |
|
708 | 726 | |
709 | 727 | // Now step through and see if any existing questions no longer exist. |
710 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
711 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
728 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
729 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
712 | 730 | if (empty($_POST['question'][$lang_id][$q_id])) |
713 | 731 | $changes['delete'][] = $q_id; |
732 | + } |
|
714 | 733 | |
715 | 734 | // Now let's see if there are new questions or ones that need updating. |
716 | 735 | if (isset($_POST['question'][$lang_id])) |
@@ -719,14 +738,16 @@ discard block |
||
719 | 738 | { |
720 | 739 | // Ignore junky ids. |
721 | 740 | $q_id = (int) $q_id; |
722 | - if ($q_id <= 0) |
|
723 | - continue; |
|
741 | + if ($q_id <= 0) { |
|
742 | + continue; |
|
743 | + } |
|
724 | 744 | |
725 | 745 | // Check the question isn't empty (because they want to delete it?) |
726 | 746 | if (empty($question) || trim($question) == '') |
727 | 747 | { |
728 | - if (isset($context['question_answers'][$q_id])) |
|
729 | - $changes['delete'][] = $q_id; |
|
748 | + if (isset($context['question_answers'][$q_id])) { |
|
749 | + $changes['delete'][] = $q_id; |
|
750 | + } |
|
730 | 751 | continue; |
731 | 752 | } |
732 | 753 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -734,19 +755,22 @@ discard block |
||
734 | 755 | // Get the answers. Firstly check there actually might be some. |
735 | 756 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
736 | 757 | { |
737 | - if (isset($context['question_answers'][$q_id])) |
|
738 | - $changes['delete'][] = $q_id; |
|
758 | + if (isset($context['question_answers'][$q_id])) { |
|
759 | + $changes['delete'][] = $q_id; |
|
760 | + } |
|
739 | 761 | continue; |
740 | 762 | } |
741 | 763 | // Now get them and check that they might be viable. |
742 | 764 | $answers = array(); |
743 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
744 | - if (!empty($answer) && trim($answer) !== '') |
|
765 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
766 | + if (!empty($answer) && trim($answer) !== '') |
|
745 | 767 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
768 | + } |
|
746 | 769 | if (empty($answers)) |
747 | 770 | { |
748 | - if (isset($context['question_answers'][$q_id])) |
|
749 | - $changes['delete'][] = $q_id; |
|
771 | + if (isset($context['question_answers'][$q_id])) { |
|
772 | + $changes['delete'][] = $q_id; |
|
773 | + } |
|
750 | 774 | continue; |
751 | 775 | } |
752 | 776 | $answers = $smcFunc['json_encode']($answers); |
@@ -756,16 +780,17 @@ discard block |
||
756 | 780 | { |
757 | 781 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
758 | 782 | $changes['insert'][] = array($lang_id, $question, $answers); |
759 | - } |
|
760 | - else |
|
783 | + } else |
|
761 | 784 | { |
762 | 785 | // It's an existing question. Let's see what's changed, if anything. |
763 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
764 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
786 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
787 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
788 | + } |
|
765 | 789 | } |
766 | 790 | |
767 | - if (!isset($qs_per_lang[$lang_id])) |
|
768 | - $qs_per_lang[$lang_id] = 0; |
|
791 | + if (!isset($qs_per_lang[$lang_id])) { |
|
792 | + $qs_per_lang[$lang_id] = 0; |
|
793 | + } |
|
769 | 794 | $qs_per_lang[$lang_id]++; |
770 | 795 | } |
771 | 796 | } |
@@ -815,8 +840,9 @@ discard block |
||
815 | 840 | |
816 | 841 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
817 | 842 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
818 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
819 | - $_POST['qa_verification_number'] = $count_questions; |
|
843 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
844 | + $_POST['qa_verification_number'] = $count_questions; |
|
845 | + } |
|
820 | 846 | |
821 | 847 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
822 | 848 | |
@@ -831,24 +857,27 @@ discard block |
||
831 | 857 | |
832 | 858 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
833 | 859 | $_SESSION['visual_verification_code'] = ''; |
834 | - for ($i = 0; $i < 6; $i++) |
|
835 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
860 | + for ($i = 0; $i < 6; $i++) { |
|
861 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
862 | + } |
|
836 | 863 | |
837 | 864 | // Some javascript for CAPTCHA. |
838 | 865 | $context['settings_post_javascript'] = ''; |
839 | - if ($context['use_graphic_library']) |
|
840 | - $context['settings_post_javascript'] .= ' |
|
866 | + if ($context['use_graphic_library']) { |
|
867 | + $context['settings_post_javascript'] .= ' |
|
841 | 868 | function refreshImages() |
842 | 869 | { |
843 | 870 | var imageType = document.getElementById(\'visual_verification_type\').value; |
844 | 871 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
845 | 872 | }'; |
873 | + } |
|
846 | 874 | |
847 | 875 | // Show the image itself, or text saying we can't. |
848 | - if ($context['use_graphic_library']) |
|
849 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
850 | - else |
|
851 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + if ($context['use_graphic_library']) { |
|
877 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
878 | + } else { |
|
879 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
880 | + } |
|
852 | 881 | |
853 | 882 | // Hack for PM spam settings. |
854 | 883 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -858,9 +887,10 @@ discard block |
||
858 | 887 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
859 | 888 | |
860 | 889 | // Some minor javascript for the guest post setting. |
861 | - if ($modSettings['posts_require_captcha']) |
|
862 | - $context['settings_post_javascript'] .= ' |
|
890 | + if ($modSettings['posts_require_captcha']) { |
|
891 | + $context['settings_post_javascript'] .= ' |
|
863 | 892 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
893 | + } |
|
864 | 894 | |
865 | 895 | // And everything else. |
866 | 896 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -907,8 +937,9 @@ discard block |
||
907 | 937 | |
908 | 938 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
909 | 939 | |
910 | - if ($return_config) |
|
911 | - return $config_vars; |
|
940 | + if ($return_config) { |
|
941 | + return $config_vars; |
|
942 | + } |
|
912 | 943 | |
913 | 944 | // Setup the template. |
914 | 945 | $context['page_title'] = $txt['signature_settings']; |
@@ -963,8 +994,9 @@ discard block |
||
963 | 994 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
964 | 995 | |
965 | 996 | // Max characters... |
966 | - if (!empty($sig_limits[1])) |
|
967 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
997 | + if (!empty($sig_limits[1])) { |
|
998 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
999 | + } |
|
968 | 1000 | // Max lines... |
969 | 1001 | if (!empty($sig_limits[2])) |
970 | 1002 | { |
@@ -974,8 +1006,9 @@ discard block |
||
974 | 1006 | if ($sig[$i] == "\n") |
975 | 1007 | { |
976 | 1008 | $count++; |
977 | - if ($count >= $sig_limits[2]) |
|
978 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1009 | + if ($count >= $sig_limits[2]) { |
|
1010 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1011 | + } |
|
979 | 1012 | } |
980 | 1013 | } |
981 | 1014 | } |
@@ -986,17 +1019,19 @@ discard block |
||
986 | 1019 | { |
987 | 1020 | $limit_broke = 0; |
988 | 1021 | // Attempt to allow all sizes of abuse, so to speak. |
989 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
990 | - $limit_broke = $sig_limits[7] . 'px'; |
|
991 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
992 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
993 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
994 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
995 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
996 | - $limit_broke = 'large'; |
|
997 | - |
|
998 | - if ($limit_broke) |
|
999 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1022 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1023 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1024 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1025 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1026 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1027 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1028 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1029 | + $limit_broke = 'large'; |
|
1030 | + } |
|
1031 | + |
|
1032 | + if ($limit_broke) { |
|
1033 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1034 | + } |
|
1000 | 1035 | } |
1001 | 1036 | } |
1002 | 1037 | |
@@ -1052,32 +1087,34 @@ discard block |
||
1052 | 1087 | $img_offset = false; |
1053 | 1088 | } |
1054 | 1089 | } |
1090 | + } else { |
|
1091 | + $replaces[$image] = ''; |
|
1055 | 1092 | } |
1056 | - else |
|
1057 | - $replaces[$image] = ''; |
|
1058 | 1093 | |
1059 | 1094 | continue; |
1060 | 1095 | } |
1061 | 1096 | |
1062 | 1097 | // Does it have predefined restraints? Width first. |
1063 | - if ($matches[6][$key]) |
|
1064 | - $matches[2][$key] = $matches[6][$key]; |
|
1098 | + if ($matches[6][$key]) { |
|
1099 | + $matches[2][$key] = $matches[6][$key]; |
|
1100 | + } |
|
1065 | 1101 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1066 | 1102 | { |
1067 | 1103 | $width = $sig_limits[5]; |
1068 | 1104 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1105 | + } elseif ($matches[2][$key]) { |
|
1106 | + $width = $matches[2][$key]; |
|
1069 | 1107 | } |
1070 | - elseif ($matches[2][$key]) |
|
1071 | - $width = $matches[2][$key]; |
|
1072 | 1108 | // ... and height. |
1073 | 1109 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1074 | 1110 | { |
1075 | 1111 | $height = $sig_limits[6]; |
1076 | - if ($width != -1) |
|
1077 | - $width = $width * ($height / $matches[4][$key]); |
|
1112 | + if ($width != -1) { |
|
1113 | + $width = $width * ($height / $matches[4][$key]); |
|
1114 | + } |
|
1115 | + } elseif ($matches[4][$key]) { |
|
1116 | + $height = $matches[4][$key]; |
|
1078 | 1117 | } |
1079 | - elseif ($matches[4][$key]) |
|
1080 | - $height = $matches[4][$key]; |
|
1081 | 1118 | |
1082 | 1119 | // If the dimensions are still not fixed - we need to check the actual image. |
1083 | 1120 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1095,12 +1132,13 @@ discard block |
||
1095 | 1132 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1096 | 1133 | { |
1097 | 1134 | $height = $sig_limits[6]; |
1098 | - if ($width == -1) |
|
1099 | - $width = $sizes[0]; |
|
1135 | + if ($width == -1) { |
|
1136 | + $width = $sizes[0]; |
|
1137 | + } |
|
1100 | 1138 | $width = $width * ($height / $sizes[1]); |
1139 | + } elseif ($width != -1) { |
|
1140 | + $height = $sizes[1]; |
|
1101 | 1141 | } |
1102 | - elseif ($width != -1) |
|
1103 | - $height = $sizes[1]; |
|
1104 | 1142 | } |
1105 | 1143 | } |
1106 | 1144 | |
@@ -1113,8 +1151,9 @@ discard block |
||
1113 | 1151 | // Record that we got one. |
1114 | 1152 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1115 | 1153 | } |
1116 | - if (!empty($replaces)) |
|
1117 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1154 | + if (!empty($replaces)) { |
|
1155 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1156 | + } |
|
1118 | 1157 | } |
1119 | 1158 | } |
1120 | 1159 | // Try to fix disabled tags. |
@@ -1126,18 +1165,20 @@ discard block |
||
1126 | 1165 | |
1127 | 1166 | $sig = strtr($sig, array("\n" => '<br>')); |
1128 | 1167 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1129 | - if ($sig != $row['signature']) |
|
1130 | - $changes[$row['id_member']] = $sig; |
|
1168 | + if ($sig != $row['signature']) { |
|
1169 | + $changes[$row['id_member']] = $sig; |
|
1170 | + } |
|
1171 | + } |
|
1172 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1173 | + $done = true; |
|
1131 | 1174 | } |
1132 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1133 | - $done = true; |
|
1134 | 1175 | $smcFunc['db_free_result']($request); |
1135 | 1176 | |
1136 | 1177 | // Do we need to delete what we have? |
1137 | 1178 | if (!empty($changes)) |
1138 | 1179 | { |
1139 | - foreach ($changes as $id => $sig) |
|
1140 | - $smcFunc['db_query']('', ' |
|
1180 | + foreach ($changes as $id => $sig) { |
|
1181 | + $smcFunc['db_query']('', ' |
|
1141 | 1182 | UPDATE {db_prefix}members |
1142 | 1183 | SET signature = {string:signature} |
1143 | 1184 | WHERE id_member = {int:id_member}', |
@@ -1146,11 +1187,13 @@ discard block |
||
1146 | 1187 | 'signature' => $sig, |
1147 | 1188 | ) |
1148 | 1189 | ); |
1190 | + } |
|
1149 | 1191 | } |
1150 | 1192 | |
1151 | 1193 | $_GET['step'] += 50; |
1152 | - if (!$done) |
|
1153 | - pauseSignatureApplySettings(); |
|
1194 | + if (!$done) { |
|
1195 | + pauseSignatureApplySettings(); |
|
1196 | + } |
|
1154 | 1197 | } |
1155 | 1198 | $settings_applied = true; |
1156 | 1199 | } |
@@ -1168,8 +1211,9 @@ discard block |
||
1168 | 1211 | ); |
1169 | 1212 | |
1170 | 1213 | // Temporarily make each setting a modSetting! |
1171 | - foreach ($context['signature_settings'] as $key => $value) |
|
1172 | - $modSettings['signature_' . $key] = $value; |
|
1214 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1215 | + $modSettings['signature_' . $key] = $value; |
|
1216 | + } |
|
1173 | 1217 | |
1174 | 1218 | // Make sure we check the right tags! |
1175 | 1219 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1181,23 +1225,26 @@ discard block |
||
1181 | 1225 | |
1182 | 1226 | // Clean up the tag stuff! |
1183 | 1227 | $bbcTags = array(); |
1184 | - foreach (parse_bbc(false) as $tag) |
|
1185 | - $bbcTags[] = $tag['tag']; |
|
1228 | + foreach (parse_bbc(false) as $tag) { |
|
1229 | + $bbcTags[] = $tag['tag']; |
|
1230 | + } |
|
1186 | 1231 | |
1187 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1188 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1189 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1190 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1233 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1234 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1235 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1236 | + } |
|
1191 | 1237 | |
1192 | 1238 | $sig_limits = array(); |
1193 | 1239 | foreach ($context['signature_settings'] as $key => $value) |
1194 | 1240 | { |
1195 | - if ($key == 'allow_smileys') |
|
1196 | - continue; |
|
1197 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1198 | - $sig_limits[] = -1; |
|
1199 | - else |
|
1200 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1241 | + if ($key == 'allow_smileys') { |
|
1242 | + continue; |
|
1243 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1244 | + $sig_limits[] = -1; |
|
1245 | + } else { |
|
1246 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1247 | + } |
|
1201 | 1248 | } |
1202 | 1249 | |
1203 | 1250 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1230,12 +1277,14 @@ discard block |
||
1230 | 1277 | |
1231 | 1278 | // Try get more time... |
1232 | 1279 | @set_time_limit(600); |
1233 | - if (function_exists('apache_reset_timeout')) |
|
1234 | - @apache_reset_timeout(); |
|
1280 | + if (function_exists('apache_reset_timeout')) { |
|
1281 | + @apache_reset_timeout(); |
|
1282 | + } |
|
1235 | 1283 | |
1236 | 1284 | // Have we exhausted all the time we allowed? |
1237 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1238 | - return; |
|
1285 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1286 | + return; |
|
1287 | + } |
|
1239 | 1288 | |
1240 | 1289 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1241 | 1290 | $context['page_title'] = $txt['not_done_title']; |
@@ -1281,9 +1330,10 @@ discard block |
||
1281 | 1330 | $disable_fields = array_flip($standard_fields); |
1282 | 1331 | if (!empty($_POST['active'])) |
1283 | 1332 | { |
1284 | - foreach ($_POST['active'] as $value) |
|
1285 | - if (isset($disable_fields[$value])) |
|
1333 | + foreach ($_POST['active'] as $value) { |
|
1334 | + if (isset($disable_fields[$value])) |
|
1286 | 1335 | unset($disable_fields[$value]); |
1336 | + } |
|
1287 | 1337 | } |
1288 | 1338 | // What we have left! |
1289 | 1339 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1292,16 +1342,18 @@ discard block |
||
1292 | 1342 | $reg_fields = array(); |
1293 | 1343 | if (!empty($_POST['reg'])) |
1294 | 1344 | { |
1295 | - foreach ($_POST['reg'] as $value) |
|
1296 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1345 | + foreach ($_POST['reg'] as $value) { |
|
1346 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1297 | 1347 | $reg_fields[] = $value; |
1348 | + } |
|
1298 | 1349 | } |
1299 | 1350 | // What we have left! |
1300 | 1351 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1301 | 1352 | |
1302 | 1353 | $_SESSION['adm-save'] = true; |
1303 | - if (!empty($changes)) |
|
1304 | - updateSettings($changes); |
|
1354 | + if (!empty($changes)) { |
|
1355 | + updateSettings($changes); |
|
1356 | + } |
|
1305 | 1357 | } |
1306 | 1358 | |
1307 | 1359 | createToken('admin-scp'); |
@@ -1404,11 +1456,13 @@ discard block |
||
1404 | 1456 | { |
1405 | 1457 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1406 | 1458 | |
1407 | - if ($rowData['field_order'] > 1) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] > 1) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1411 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1463 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1464 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1465 | + } |
|
1412 | 1466 | |
1413 | 1467 | $return .= '</p>'; |
1414 | 1468 | |
@@ -1546,16 +1600,16 @@ discard block |
||
1546 | 1600 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1547 | 1601 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1548 | 1602 | |
1549 | - foreach ($standard_fields as $field) |
|
1550 | - $list[] = array( |
|
1603 | + foreach ($standard_fields as $field) { |
|
1604 | + $list[] = array( |
|
1551 | 1605 | 'id' => $field, |
1552 | 1606 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1553 | 1607 | 'disabled' => in_array($field, $disabled_fields), |
1554 | 1608 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1555 | 1609 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1556 | 1610 | ); |
1557 | - } |
|
1558 | - else |
|
1611 | + } |
|
1612 | + } else |
|
1559 | 1613 | { |
1560 | 1614 | // Load all the fields. |
1561 | 1615 | $request = $smcFunc['db_query']('', ' |
@@ -1569,8 +1623,9 @@ discard block |
||
1569 | 1623 | 'items_per_page' => $items_per_page, |
1570 | 1624 | ) |
1571 | 1625 | ); |
1572 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1573 | - $list[] = $row; |
|
1626 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1627 | + $list[] = $row; |
|
1628 | + } |
|
1574 | 1629 | $smcFunc['db_free_result']($request); |
1575 | 1630 | } |
1576 | 1631 | |
@@ -1636,9 +1691,9 @@ discard block |
||
1636 | 1691 | $context['field'] = array(); |
1637 | 1692 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1638 | 1693 | { |
1639 | - if ($row['field_type'] == 'textarea') |
|
1640 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1641 | - else |
|
1694 | + if ($row['field_type'] == 'textarea') { |
|
1695 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1696 | + } else |
|
1642 | 1697 | { |
1643 | 1698 | $rows = 3; |
1644 | 1699 | $cols = 30; |
@@ -1674,8 +1729,8 @@ discard block |
||
1674 | 1729 | } |
1675 | 1730 | |
1676 | 1731 | // Setup the default values as needed. |
1677 | - if (empty($context['field'])) |
|
1678 | - $context['field'] = array( |
|
1732 | + if (empty($context['field'])) { |
|
1733 | + $context['field'] = array( |
|
1679 | 1734 | 'name' => '', |
1680 | 1735 | 'col_name' => '???', |
1681 | 1736 | 'desc' => '', |
@@ -1700,6 +1755,7 @@ discard block |
||
1700 | 1755 | 'enclose' => '', |
1701 | 1756 | 'placement' => 0, |
1702 | 1757 | ); |
1758 | + } |
|
1703 | 1759 | |
1704 | 1760 | // Are we moving it? |
1705 | 1761 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1708,8 +1764,10 @@ discard block |
||
1708 | 1764 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1709 | 1765 | |
1710 | 1766 | // Is this a valid position? |
1711 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1712 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1767 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1768 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1769 | + } |
|
1770 | + // @todo implement an error handler |
|
1713 | 1771 | |
1714 | 1772 | // All good, proceed. |
1715 | 1773 | $smcFunc['db_query']('',' |
@@ -1740,12 +1798,14 @@ discard block |
||
1740 | 1798 | validateToken('admin-ecp'); |
1741 | 1799 | |
1742 | 1800 | // Everyone needs a name - even the (bracket) unknown... |
1743 | - if (trim($_POST['field_name']) == '') |
|
1744 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1801 | + if (trim($_POST['field_name']) == '') { |
|
1802 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1803 | + } |
|
1745 | 1804 | |
1746 | 1805 | // Regex you say? Do a very basic test to see if the pattern is valid |
1747 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1748 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1806 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1807 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1808 | + } |
|
1749 | 1809 | |
1750 | 1810 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1751 | 1811 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1762,8 +1822,9 @@ discard block |
||
1762 | 1822 | |
1763 | 1823 | // Some masking stuff... |
1764 | 1824 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1765 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1766 | - $mask .= $_POST['regex']; |
|
1825 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1826 | + $mask .= $_POST['regex']; |
|
1827 | + } |
|
1767 | 1828 | |
1768 | 1829 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1769 | 1830 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1782,8 +1843,9 @@ discard block |
||
1782 | 1843 | $v = strtr($v, array(',' => '')); |
1783 | 1844 | |
1784 | 1845 | // Nada, zip, etc... |
1785 | - if (trim($v) == '') |
|
1786 | - continue; |
|
1846 | + if (trim($v) == '') { |
|
1847 | + continue; |
|
1848 | + } |
|
1787 | 1849 | |
1788 | 1850 | // Otherwise, save it boy. |
1789 | 1851 | $field_options .= $v . ','; |
@@ -1791,15 +1853,17 @@ discard block |
||
1791 | 1853 | $newOptions[$k] = $v; |
1792 | 1854 | |
1793 | 1855 | // Is it default? |
1794 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1795 | - $default = $v; |
|
1856 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1857 | + $default = $v; |
|
1858 | + } |
|
1796 | 1859 | } |
1797 | 1860 | $field_options = substr($field_options, 0, -1); |
1798 | 1861 | } |
1799 | 1862 | |
1800 | 1863 | // Text area has default has dimensions |
1801 | - if ($_POST['field_type'] == 'textarea') |
|
1802 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1864 | + if ($_POST['field_type'] == 'textarea') { |
|
1865 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1866 | + } |
|
1803 | 1867 | |
1804 | 1868 | // Come up with the unique name? |
1805 | 1869 | if (empty($context['fid'])) |
@@ -1808,32 +1872,36 @@ discard block |
||
1808 | 1872 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1809 | 1873 | |
1810 | 1874 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1811 | - if (isset($matches[1])) |
|
1812 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1813 | - else |
|
1814 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + if (isset($matches[1])) { |
|
1876 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1877 | + } else { |
|
1878 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1879 | + } |
|
1815 | 1880 | |
1816 | 1881 | // Make sure this is unique. |
1817 | 1882 | $current_fields = array(); |
1818 | 1883 | $request = $smcFunc['db_query']('', ' |
1819 | 1884 | SELECT id_field, col_name |
1820 | 1885 | FROM {db_prefix}custom_fields'); |
1821 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1822 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1886 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1887 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1888 | + } |
|
1823 | 1889 | $smcFunc['db_free_result']($request); |
1824 | 1890 | |
1825 | 1891 | $unique = false; |
1826 | 1892 | for ($i = 0; !$unique && $i < 9; $i ++) |
1827 | 1893 | { |
1828 | - if (!in_array($col_name, $current_fields)) |
|
1829 | - $unique = true; |
|
1830 | - else |
|
1831 | - $col_name = $initial_col_name . $i; |
|
1894 | + if (!in_array($col_name, $current_fields)) { |
|
1895 | + $unique = true; |
|
1896 | + } else { |
|
1897 | + $col_name = $initial_col_name . $i; |
|
1898 | + } |
|
1832 | 1899 | } |
1833 | 1900 | |
1834 | 1901 | // Still not a unique column name? Leave it up to the user, then. |
1835 | - if (!$unique) |
|
1836 | - fatal_lang_error('custom_option_not_unique'); |
|
1902 | + if (!$unique) { |
|
1903 | + fatal_lang_error('custom_option_not_unique'); |
|
1904 | + } |
|
1837 | 1905 | } |
1838 | 1906 | // Work out what to do with the user data otherwise... |
1839 | 1907 | else |
@@ -1861,8 +1929,9 @@ discard block |
||
1861 | 1929 | // Work out what's changed! |
1862 | 1930 | foreach ($context['field']['options'] as $k => $option) |
1863 | 1931 | { |
1864 | - if (trim($option) == '') |
|
1865 | - continue; |
|
1932 | + if (trim($option) == '') { |
|
1933 | + continue; |
|
1934 | + } |
|
1866 | 1935 | |
1867 | 1936 | // Still exists? |
1868 | 1937 | if (in_array($option, $newOptions)) |
@@ -1876,8 +1945,8 @@ discard block |
||
1876 | 1945 | foreach ($optionChanges as $k => $option) |
1877 | 1946 | { |
1878 | 1947 | // Just been renamed? |
1879 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1880 | - $smcFunc['db_query']('', ' |
|
1948 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1949 | + $smcFunc['db_query']('', ' |
|
1881 | 1950 | UPDATE {db_prefix}themes |
1882 | 1951 | SET value = {string:new_value} |
1883 | 1952 | WHERE variable = {string:current_column} |
@@ -1890,6 +1959,7 @@ discard block |
||
1890 | 1959 | 'old_value' => $option, |
1891 | 1960 | ) |
1892 | 1961 | ); |
1962 | + } |
|
1893 | 1963 | } |
1894 | 1964 | } |
1895 | 1965 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1932,8 +2002,8 @@ discard block |
||
1932 | 2002 | ); |
1933 | 2003 | |
1934 | 2004 | // Just clean up any old selects - these are a pain! |
1935 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1936 | - $smcFunc['db_query']('', ' |
|
2005 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2006 | + $smcFunc['db_query']('', ' |
|
1937 | 2007 | DELETE FROM {db_prefix}themes |
1938 | 2008 | WHERE variable = {string:current_column} |
1939 | 2009 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1944,8 +2014,8 @@ discard block |
||
1944 | 2014 | 'current_column' => $context['field']['col_name'], |
1945 | 2015 | ) |
1946 | 2016 | ); |
1947 | - } |
|
1948 | - else |
|
2017 | + } |
|
2018 | + } else |
|
1949 | 2019 | { |
1950 | 2020 | // Gotta figure it out the order. |
1951 | 2021 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2120,11 +2190,13 @@ discard block |
||
2120 | 2190 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2121 | 2191 | |
2122 | 2192 | $prune_toggle_dt = array(); |
2123 | - foreach ($prune_toggle as $item) |
|
2124 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2193 | + foreach ($prune_toggle as $item) { |
|
2194 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2195 | + } |
|
2125 | 2196 | |
2126 | - if ($return_config) |
|
2127 | - return $config_vars; |
|
2197 | + if ($return_config) { |
|
2198 | + return $config_vars; |
|
2199 | + } |
|
2128 | 2200 | |
2129 | 2201 | addInlineJavaScript(' |
2130 | 2202 | function togglePruned() |
@@ -2162,15 +2234,16 @@ discard block |
||
2162 | 2234 | $vals = array(); |
2163 | 2235 | foreach ($config_vars as $index => $dummy) |
2164 | 2236 | { |
2165 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2166 | - continue; |
|
2237 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2238 | + continue; |
|
2239 | + } |
|
2167 | 2240 | |
2168 | 2241 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2169 | 2242 | } |
2170 | 2243 | $_POST['pruningOptions'] = implode(',', $vals); |
2244 | + } else { |
|
2245 | + $_POST['pruningOptions'] = ''; |
|
2171 | 2246 | } |
2172 | - else |
|
2173 | - $_POST['pruningOptions'] = ''; |
|
2174 | 2247 | |
2175 | 2248 | saveDBSettings($savevar); |
2176 | 2249 | $_SESSION['adm-save'] = true; |
@@ -2182,10 +2255,11 @@ discard block |
||
2182 | 2255 | $context['sub_template'] = 'show_settings'; |
2183 | 2256 | |
2184 | 2257 | // Get the actual values |
2185 | - if (!empty($modSettings['pruningOptions'])) |
|
2186 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2187 | - else |
|
2188 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2258 | + if (!empty($modSettings['pruningOptions'])) { |
|
2259 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2260 | + } else { |
|
2261 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2262 | + } |
|
2189 | 2263 | |
2190 | 2264 | prepareDBSettingContext($config_vars); |
2191 | 2265 | } |
@@ -2207,8 +2281,9 @@ discard block |
||
2207 | 2281 | // Make it even easier to add new settings. |
2208 | 2282 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2209 | 2283 | |
2210 | - if ($return_config) |
|
2211 | - return $config_vars; |
|
2284 | + if ($return_config) { |
|
2285 | + return $config_vars; |
|
2286 | + } |
|
2212 | 2287 | |
2213 | 2288 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2214 | 2289 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
257 | 257 | |
258 | 258 | $js_time_string = str_replace( |
259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
261 | 261 | $time_string |
262 | 262 | ); |
263 | 263 | |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | if (isset($context['name']) && isset($context['email'])) |
1306 | 1306 | { |
1307 | 1307 | $context['posting_fields']['guestname'] = array( |
1308 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1308 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1309 | 1309 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>', |
1310 | 1310 | ); |
1311 | 1311 | |
1312 | 1312 | if (empty($modSettings['guest_post_no_email'])) |
1313 | 1313 | { |
1314 | 1314 | $context['posting_fields']['email'] = array( |
1315 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1315 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1316 | 1316 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>', |
1317 | 1317 | ); |
1318 | 1318 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * 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']); |
@@ -58,12 +61,14 @@ discard block |
||
58 | 61 | { |
59 | 62 | // Get ids of all the boards they can post in. |
60 | 63 | $post_permissions = array('post_new'); |
61 | - if ($modSettings['postmod_active']) |
|
62 | - $post_permissions[] = 'post_unapproved_topics'; |
|
64 | + if ($modSettings['postmod_active']) { |
|
65 | + $post_permissions[] = 'post_unapproved_topics'; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | $boards = boardsAllowedTo($post_permissions); |
65 | - if (empty($boards)) |
|
66 | - fatal_lang_error('cannot_post_new', false); |
|
69 | + if (empty($boards)) { |
|
70 | + fatal_lang_error('cannot_post_new', false); |
|
71 | + } |
|
67 | 72 | |
68 | 73 | // Get a list of boards for the select menu |
69 | 74 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -76,8 +81,9 @@ discard block |
||
76 | 81 | $board_list = getBoardList($boardListOptions); |
77 | 82 | } |
78 | 83 | // Let's keep things simple for ourselves below |
79 | - else |
|
80 | - $boards = array($board); |
|
84 | + else { |
|
85 | + $boards = array($board); |
|
86 | + } |
|
81 | 87 | |
82 | 88 | require_once($sourcedir . '/Subs-Post.php'); |
83 | 89 | |
@@ -100,10 +106,11 @@ discard block |
||
100 | 106 | array( |
101 | 107 | 'msg' => (int) $_REQUEST['msg'], |
102 | 108 | )); |
103 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
104 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
105 | - else |
|
106 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
109 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
110 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
111 | + } else { |
|
112 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
113 | + } |
|
107 | 114 | $smcFunc['db_free_result']($request); |
108 | 115 | } |
109 | 116 | |
@@ -130,33 +137,36 @@ discard block |
||
130 | 137 | $smcFunc['db_free_result']($request); |
131 | 138 | |
132 | 139 | // If this topic already has a poll, they sure can't add another. |
133 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
134 | - unset($_REQUEST['poll']); |
|
140 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
141 | + unset($_REQUEST['poll']); |
|
142 | + } |
|
135 | 143 | |
136 | 144 | if (empty($_REQUEST['msg'])) |
137 | 145 | { |
138 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
139 | - is_not_guest(); |
|
146 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
140 | 149 | |
141 | 150 | // By default the reply will be approved... |
142 | 151 | $context['becomes_approved'] = true; |
143 | 152 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
144 | 153 | { |
145 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
146 | - $context['becomes_approved'] = false; |
|
147 | - else |
|
148 | - isAllowedTo('post_reply_any'); |
|
149 | - } |
|
150 | - elseif (!allowedTo('post_reply_any')) |
|
154 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
155 | + $context['becomes_approved'] = false; |
|
156 | + } else { |
|
157 | + isAllowedTo('post_reply_any'); |
|
158 | + } |
|
159 | + } elseif (!allowedTo('post_reply_any')) |
|
151 | 160 | { |
152 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
153 | - $context['becomes_approved'] = false; |
|
154 | - else |
|
155 | - isAllowedTo('post_reply_own'); |
|
161 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
162 | + $context['becomes_approved'] = false; |
|
163 | + } else { |
|
164 | + isAllowedTo('post_reply_own'); |
|
165 | + } |
|
156 | 166 | } |
167 | + } else { |
|
168 | + $context['becomes_approved'] = true; |
|
157 | 169 | } |
158 | - else |
|
159 | - $context['becomes_approved'] = true; |
|
160 | 170 | |
161 | 171 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
162 | 172 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -171,17 +181,18 @@ discard block |
||
171 | 181 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
172 | 182 | |
173 | 183 | // Check whether this is a really old post being bumped... |
174 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
175 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
176 | - } |
|
177 | - else |
|
184 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
185 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
186 | + } |
|
187 | + } else |
|
178 | 188 | { |
179 | 189 | // @todo Should use JavaScript to hide and show the warning based on the selection in the board select menu |
180 | 190 | $context['becomes_approved'] = true; |
181 | - if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) |
|
182 | - $context['becomes_approved'] = false; |
|
183 | - else |
|
184 | - isAllowedTo('post_new', $boards, true); |
|
191 | + if ($modSettings['postmod_active'] && !allowedTo('post_new', $boards, true) && allowedTo('post_unapproved_topics', $boards, true)) { |
|
192 | + $context['becomes_approved'] = false; |
|
193 | + } else { |
|
194 | + isAllowedTo('post_new', $boards, true); |
|
195 | + } |
|
185 | 196 | |
186 | 197 | $locked = 0; |
187 | 198 | $context['already_locked'] = 0; |
@@ -211,27 +222,32 @@ discard block |
||
211 | 222 | if (empty($_REQUEST['message']) && empty($_REQUEST['preview']) && !empty($_SESSION['already_attached'])) |
212 | 223 | { |
213 | 224 | require_once($sourcedir . '/ManageAttachments.php'); |
214 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
215 | - removeAttachments(array('id_attach' => $attachID)); |
|
225 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
226 | + removeAttachments(array('id_attach' => $attachID)); |
|
227 | + } |
|
216 | 228 | |
217 | 229 | unset($_SESSION['already_attached']); |
218 | 230 | } |
219 | 231 | |
220 | 232 | // Don't allow a post if it's locked and you aren't all powerful. |
221 | - if ($locked && !allowedTo('moderate_board')) |
|
222 | - fatal_lang_error('topic_locked', false); |
|
233 | + if ($locked && !allowedTo('moderate_board')) { |
|
234 | + fatal_lang_error('topic_locked', false); |
|
235 | + } |
|
223 | 236 | // Check the users permissions - is the user allowed to add or post a poll? |
224 | 237 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
225 | 238 | { |
226 | 239 | // New topic, new poll. |
227 | - if (empty($topic)) |
|
228 | - isAllowedTo('poll_post'); |
|
240 | + if (empty($topic)) { |
|
241 | + isAllowedTo('poll_post'); |
|
242 | + } |
|
229 | 243 | // This is an old topic - but it is yours! Can you add to it? |
230 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
231 | - isAllowedTo('poll_add_own'); |
|
244 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
245 | + isAllowedTo('poll_add_own'); |
|
246 | + } |
|
232 | 247 | // If you're not the owner, can you add to any poll? |
233 | - else |
|
234 | - isAllowedTo('poll_add_any'); |
|
248 | + else { |
|
249 | + isAllowedTo('poll_add_any'); |
|
250 | + } |
|
235 | 251 | |
236 | 252 | if (!empty($board)) |
237 | 253 | { |
@@ -240,8 +256,9 @@ discard block |
||
240 | 256 | $guest_vote_enabled = in_array(-1, $allowedVoteGroups['allowed']); |
241 | 257 | } |
242 | 258 | // No board, so we'll have to check this again in Post2 |
243 | - else |
|
244 | - $guest_vote_enabled = true; |
|
259 | + else { |
|
260 | + $guest_vote_enabled = true; |
|
261 | + } |
|
245 | 262 | |
246 | 263 | // Set up the poll options. |
247 | 264 | $context['poll_options'] = array( |
@@ -267,8 +284,9 @@ discard block |
||
267 | 284 | if ($context['make_event']) |
268 | 285 | { |
269 | 286 | // They might want to pick a board. |
270 | - if (!isset($context['current_board'])) |
|
271 | - $context['current_board'] = 0; |
|
287 | + if (!isset($context['current_board'])) { |
|
288 | + $context['current_board'] = 0; |
|
289 | + } |
|
272 | 290 | |
273 | 291 | // Start loading up the event info. |
274 | 292 | $context['event'] = array(); |
@@ -282,10 +300,11 @@ discard block |
||
282 | 300 | isAllowedTo('calendar_post'); |
283 | 301 | |
284 | 302 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
285 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
286 | - $time_string = '%k:%M'; |
|
287 | - else |
|
288 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
303 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
304 | + $time_string = '%k:%M'; |
|
305 | + } else { |
|
306 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
307 | + } |
|
289 | 308 | |
290 | 309 | $js_time_string = str_replace( |
291 | 310 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -307,8 +326,7 @@ discard block |
||
307 | 326 | require_once($sourcedir . '/Subs-Calendar.php'); |
308 | 327 | $eventProperties = getEventProperties($context['event']['id']); |
309 | 328 | $context['event'] = array_merge($context['event'], $eventProperties); |
310 | - } |
|
311 | - else |
|
329 | + } else |
|
312 | 330 | { |
313 | 331 | // Get the current event information. |
314 | 332 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -316,10 +334,12 @@ discard block |
||
316 | 334 | $context['event'] = array_merge($context['event'], $eventProperties); |
317 | 335 | |
318 | 336 | // Make sure the year and month are in the valid range. |
319 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
320 | - fatal_lang_error('invalid_month', false); |
|
321 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
322 | - fatal_lang_error('invalid_year', false); |
|
337 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
338 | + fatal_lang_error('invalid_month', false); |
|
339 | + } |
|
340 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
341 | + fatal_lang_error('invalid_year', false); |
|
342 | + } |
|
323 | 343 | |
324 | 344 | $context['event']['categories'] = $board_list; |
325 | 345 | } |
@@ -430,10 +450,11 @@ discard block |
||
430 | 450 | |
431 | 451 | if (!empty($context['new_replies'])) |
432 | 452 | { |
433 | - if ($context['new_replies'] == 1) |
|
434 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
435 | - else |
|
436 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
453 | + if ($context['new_replies'] == 1) { |
|
454 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
455 | + } else { |
|
456 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
457 | + } |
|
437 | 458 | |
438 | 459 | $post_errors[] = 'new_replies'; |
439 | 460 | |
@@ -445,9 +466,9 @@ discard block |
||
445 | 466 | // Get a response prefix (like 'Re:') in the default forum language. |
446 | 467 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
447 | 468 | { |
448 | - if ($language === $user_info['language']) |
|
449 | - $context['response_prefix'] = $txt['response_prefix']; |
|
450 | - else |
|
469 | + if ($language === $user_info['language']) { |
|
470 | + $context['response_prefix'] = $txt['response_prefix']; |
|
471 | + } else |
|
451 | 472 | { |
452 | 473 | loadLanguage('index', $language, false); |
453 | 474 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -460,23 +481,26 @@ discard block |
||
460 | 481 | // Do we have a body, but an error happened. |
461 | 482 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
462 | 483 | { |
463 | - if (isset($_REQUEST['quickReply'])) |
|
464 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
484 | + if (isset($_REQUEST['quickReply'])) { |
|
485 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
486 | + } |
|
465 | 487 | |
466 | 488 | // Validate inputs. |
467 | 489 | if (empty($context['post_error'])) |
468 | 490 | { |
469 | 491 | // This means they didn't click Post and get an error. |
470 | 492 | $really_previewing = true; |
471 | - } |
|
472 | - else |
|
493 | + } else |
|
473 | 494 | { |
474 | - if (!isset($_REQUEST['subject'])) |
|
475 | - $_REQUEST['subject'] = ''; |
|
476 | - if (!isset($_REQUEST['message'])) |
|
477 | - $_REQUEST['message'] = ''; |
|
478 | - if (!isset($_REQUEST['icon'])) |
|
479 | - $_REQUEST['icon'] = 'xx'; |
|
495 | + if (!isset($_REQUEST['subject'])) { |
|
496 | + $_REQUEST['subject'] = ''; |
|
497 | + } |
|
498 | + if (!isset($_REQUEST['message'])) { |
|
499 | + $_REQUEST['message'] = ''; |
|
500 | + } |
|
501 | + if (!isset($_REQUEST['icon'])) { |
|
502 | + $_REQUEST['icon'] = 'xx'; |
|
503 | + } |
|
480 | 504 | |
481 | 505 | // They are previewing if they asked to preview (i.e. came from quick reply). |
482 | 506 | $really_previewing = !empty($_POST['preview']); |
@@ -492,8 +516,9 @@ discard block |
||
492 | 516 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
493 | 517 | |
494 | 518 | // Make sure the subject isn't too long - taking into account special characters. |
495 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
496 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
519 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
520 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
521 | + } |
|
497 | 522 | |
498 | 523 | if (isset($_REQUEST['poll'])) |
499 | 524 | { |
@@ -505,8 +530,9 @@ discard block |
||
505 | 530 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
506 | 531 | foreach ($_POST['options'] as $option) |
507 | 532 | { |
508 | - if (trim($option) == '') |
|
509 | - continue; |
|
533 | + if (trim($option) == '') { |
|
534 | + continue; |
|
535 | + } |
|
510 | 536 | |
511 | 537 | $context['choices'][] = array( |
512 | 538 | 'id' => $choice_id++, |
@@ -568,13 +594,14 @@ discard block |
||
568 | 594 | $context['preview_subject'] = $form_subject; |
569 | 595 | |
570 | 596 | censorText($context['preview_subject']); |
597 | + } else { |
|
598 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
571 | 599 | } |
572 | - else |
|
573 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
574 | 600 | |
575 | 601 | // Protect any CDATA blocks. |
576 | - if (isset($_REQUEST['xml'])) |
|
577 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
602 | + if (isset($_REQUEST['xml'])) { |
|
603 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
617 | - fatal_lang_error('no_board', false); |
|
643 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
644 | + fatal_lang_error('no_board', false); |
|
645 | + } |
|
618 | 646 | $row = $smcFunc['db_fetch_assoc']($request); |
619 | 647 | |
620 | 648 | $attachment_stuff = array($row); |
621 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
622 | - $attachment_stuff[] = $row2; |
|
649 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
650 | + $attachment_stuff[] = $row2; |
|
651 | + } |
|
623 | 652 | $smcFunc['db_free_result']($request); |
624 | 653 | |
625 | 654 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
626 | 655 | { |
627 | 656 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
628 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
629 | - fatal_lang_error('modify_post_time_passed', false); |
|
630 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
631 | - isAllowedTo('modify_replies'); |
|
632 | - else |
|
633 | - isAllowedTo('modify_own'); |
|
657 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
658 | + fatal_lang_error('modify_post_time_passed', false); |
|
659 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
660 | + isAllowedTo('modify_replies'); |
|
661 | + } else { |
|
662 | + isAllowedTo('modify_own'); |
|
663 | + } |
|
664 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
665 | + isAllowedTo('modify_replies'); |
|
666 | + } else { |
|
667 | + isAllowedTo('modify_any'); |
|
634 | 668 | } |
635 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
636 | - isAllowedTo('modify_replies'); |
|
637 | - else |
|
638 | - isAllowedTo('modify_any'); |
|
639 | 669 | |
640 | 670 | if ($context['can_announce'] && !empty($row['id_action'])) |
641 | 671 | { |
@@ -659,8 +689,9 @@ discard block |
||
659 | 689 | |
660 | 690 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
661 | 691 | { |
662 | - if ($row['filesize'] <= 0) |
|
663 | - continue; |
|
692 | + if ($row['filesize'] <= 0) { |
|
693 | + continue; |
|
694 | + } |
|
664 | 695 | $context['current_attachments'][$row['id_attach']] = array( |
665 | 696 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
666 | 697 | 'size' => $row['filesize'], |
@@ -730,29 +761,32 @@ discard block |
||
730 | 761 | ) |
731 | 762 | ); |
732 | 763 | // The message they were trying to edit was most likely deleted. |
733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
734 | - fatal_lang_error('no_message', false); |
|
764 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
765 | + fatal_lang_error('no_message', false); |
|
766 | + } |
|
735 | 767 | $row = $smcFunc['db_fetch_assoc']($request); |
736 | 768 | |
737 | 769 | $attachment_stuff = array($row); |
738 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
739 | - $attachment_stuff[] = $row2; |
|
770 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
771 | + $attachment_stuff[] = $row2; |
|
772 | + } |
|
740 | 773 | $smcFunc['db_free_result']($request); |
741 | 774 | |
742 | 775 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
743 | 776 | { |
744 | 777 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
745 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
746 | - fatal_lang_error('modify_post_time_passed', false); |
|
747 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
748 | - isAllowedTo('modify_replies'); |
|
749 | - else |
|
750 | - isAllowedTo('modify_own'); |
|
778 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
779 | + fatal_lang_error('modify_post_time_passed', false); |
|
780 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
781 | + isAllowedTo('modify_replies'); |
|
782 | + } else { |
|
783 | + isAllowedTo('modify_own'); |
|
784 | + } |
|
785 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
786 | + isAllowedTo('modify_replies'); |
|
787 | + } else { |
|
788 | + isAllowedTo('modify_any'); |
|
751 | 789 | } |
752 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
753 | - isAllowedTo('modify_replies'); |
|
754 | - else |
|
755 | - isAllowedTo('modify_any'); |
|
756 | 790 | |
757 | 791 | if ($context['can_announce'] && !empty($row['id_action'])) |
758 | 792 | { |
@@ -779,15 +813,17 @@ discard block |
||
779 | 813 | $context['icon'] = $row['icon']; |
780 | 814 | |
781 | 815 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
782 | - if (!$row['approved'] && !$context['show_approval']) |
|
783 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
816 | + if (!$row['approved'] && !$context['show_approval']) { |
|
817 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
818 | + } |
|
784 | 819 | |
785 | 820 | // Sort the attachments so they are in the order saved |
786 | 821 | $temp = array(); |
787 | 822 | foreach ($attachment_stuff as $attachment) |
788 | 823 | { |
789 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
790 | - $temp[$attachment['id_attach']] = $attachment; |
|
824 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
825 | + $temp[$attachment['id_attach']] = $attachment; |
|
826 | + } |
|
791 | 827 | } |
792 | 828 | ksort($temp); |
793 | 829 | |
@@ -848,14 +884,16 @@ discard block |
||
848 | 884 | 'is_approved' => 1, |
849 | 885 | ) |
850 | 886 | ); |
851 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
852 | - fatal_lang_error('quoted_post_deleted', false); |
|
887 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
888 | + fatal_lang_error('quoted_post_deleted', false); |
|
889 | + } |
|
853 | 890 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
854 | 891 | $smcFunc['db_free_result']($request); |
855 | 892 | |
856 | 893 | // Add 'Re: ' to the front of the quoted subject. |
857 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
858 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
894 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
895 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
896 | + } |
|
859 | 897 | |
860 | 898 | // Censor the message and subject. |
861 | 899 | censorText($form_message); |
@@ -868,10 +906,11 @@ discard block |
||
868 | 906 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
869 | 907 | { |
870 | 908 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
871 | - if ($i % 4 == 0) |
|
872 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
909 | + if ($i % 4 == 0) { |
|
910 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
873 | 911 | { |
874 | 912 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
913 | + } |
|
875 | 914 | }, $parts[$i]); |
876 | 915 | } |
877 | 916 | $form_message = implode('', $parts); |
@@ -880,8 +919,9 @@ discard block |
||
880 | 919 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
881 | 920 | |
882 | 921 | // Remove any nested quotes, if necessary. |
883 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
884 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
922 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
923 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
924 | + } |
|
885 | 925 | |
886 | 926 | // Add a quote string on the front and end. |
887 | 927 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -893,15 +933,15 @@ discard block |
||
893 | 933 | $form_subject = $first_subject; |
894 | 934 | |
895 | 935 | // Add 'Re: ' to the front of the subject. |
896 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
897 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
936 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
937 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
938 | + } |
|
898 | 939 | |
899 | 940 | // Censor the subject. |
900 | 941 | censorText($form_subject); |
901 | 942 | |
902 | 943 | $form_message = ''; |
903 | - } |
|
904 | - else |
|
944 | + } else |
|
905 | 945 | { |
906 | 946 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
907 | 947 | $form_message = ''; |
@@ -920,13 +960,15 @@ discard block |
||
920 | 960 | if (isset($_REQUEST['msg'])) |
921 | 961 | { |
922 | 962 | $context['attachments']['quantity'] = count($context['current_attachments']); |
923 | - foreach ($context['current_attachments'] as $attachment) |
|
924 | - $context['attachments']['total_size'] += $attachment['size']; |
|
963 | + foreach ($context['current_attachments'] as $attachment) { |
|
964 | + $context['attachments']['total_size'] += $attachment['size']; |
|
965 | + } |
|
925 | 966 | } |
926 | 967 | |
927 | 968 | // A bit of house keeping first. |
928 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
929 | - unset($_SESSION['temp_attachments']); |
|
969 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
970 | + unset($_SESSION['temp_attachments']); |
|
971 | + } |
|
930 | 972 | |
931 | 973 | if (!empty($_SESSION['temp_attachments'])) |
932 | 974 | { |
@@ -935,9 +977,10 @@ discard block |
||
935 | 977 | { |
936 | 978 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
937 | 979 | { |
938 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
939 | - if (file_exists($attachment['tmp_name'])) |
|
980 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
981 | + if (file_exists($attachment['tmp_name'])) |
|
940 | 982 | unlink($attachment['tmp_name']); |
983 | + } |
|
941 | 984 | } |
942 | 985 | $post_errors[] = 'temp_attachments_gone'; |
943 | 986 | $_SESSION['temp_attachments'] = array(); |
@@ -951,8 +994,9 @@ discard block |
||
951 | 994 | // See if any files still exist before showing the warning message and the files attached. |
952 | 995 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
953 | 996 | { |
954 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
955 | - continue; |
|
997 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
998 | + continue; |
|
999 | + } |
|
956 | 1000 | |
957 | 1001 | if (file_exists($attachment['tmp_name'])) |
958 | 1002 | { |
@@ -962,20 +1006,21 @@ discard block |
||
962 | 1006 | break; |
963 | 1007 | } |
964 | 1008 | } |
965 | - } |
|
966 | - else |
|
1009 | + } else |
|
967 | 1010 | { |
968 | 1011 | // Since, they don't belong here. Let's inform the user that they exist.. |
969 | - if (!empty($topic)) |
|
970 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
971 | - else |
|
972 | - $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1012 | + if (!empty($topic)) { |
|
1013 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
1014 | + } else { |
|
1015 | + $delete_url = $scripturl . '?action=post' . (!empty($board) ? ';board=' . $board : '') . ';delete_temp'; |
|
1016 | + } |
|
973 | 1017 | |
974 | 1018 | // Compile a list of the files to show the user. |
975 | 1019 | $file_list = array(); |
976 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
977 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
1020 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1021 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
978 | 1022 | $file_list[] = $attachment['name']; |
1023 | + } |
|
979 | 1024 | |
980 | 1025 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
981 | 1026 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -987,8 +1032,7 @@ discard block |
||
987 | 1032 | |
988 | 1033 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
989 | 1034 | $context['ignore_temp_attachments'] = true; |
990 | - } |
|
991 | - else |
|
1035 | + } else |
|
992 | 1036 | { |
993 | 1037 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
994 | 1038 | $context['ignore_temp_attachments'] = true; |
@@ -996,16 +1040,19 @@ discard block |
||
996 | 1040 | } |
997 | 1041 | } |
998 | 1042 | |
999 | - if (!empty($context['we_are_history'])) |
|
1000 | - $post_errors[] = $context['we_are_history']; |
|
1043 | + if (!empty($context['we_are_history'])) { |
|
1044 | + $post_errors[] = $context['we_are_history']; |
|
1045 | + } |
|
1001 | 1046 | |
1002 | 1047 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1003 | 1048 | { |
1004 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
1005 | - break; |
|
1049 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1050 | + break; |
|
1051 | + } |
|
1006 | 1052 | |
1007 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1008 | - continue; |
|
1053 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1054 | + continue; |
|
1055 | + } |
|
1009 | 1056 | |
1010 | 1057 | if ($attachID == 'initial_error') |
1011 | 1058 | { |
@@ -1020,15 +1067,17 @@ discard block |
||
1020 | 1067 | { |
1021 | 1068 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1022 | 1069 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1023 | - foreach ($attachment['errors'] as $error) |
|
1024 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1070 | + foreach ($attachment['errors'] as $error) { |
|
1071 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1072 | + } |
|
1025 | 1073 | $txt['error_attach_errors'] .= '</div>'; |
1026 | 1074 | $post_errors[] = 'attach_errors'; |
1027 | 1075 | |
1028 | 1076 | // Take out the trash. |
1029 | 1077 | unset($_SESSION['temp_attachments'][$attachID]); |
1030 | - if (file_exists($attachment['tmp_name'])) |
|
1031 | - unlink($attachment['tmp_name']); |
|
1078 | + if (file_exists($attachment['tmp_name'])) { |
|
1079 | + unlink($attachment['tmp_name']); |
|
1080 | + } |
|
1032 | 1081 | continue; |
1033 | 1082 | } |
1034 | 1083 | |
@@ -1041,8 +1090,9 @@ discard block |
||
1041 | 1090 | |
1042 | 1091 | $context['attachments']['quantity']++; |
1043 | 1092 | $context['attachments']['total_size'] += $attachment['size']; |
1044 | - if (!isset($context['files_in_session_warning'])) |
|
1045 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1093 | + if (!isset($context['files_in_session_warning'])) { |
|
1094 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1095 | + } |
|
1046 | 1096 | |
1047 | 1097 | $context['current_attachments'][$attachID] = array( |
1048 | 1098 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1070,8 +1120,9 @@ discard block |
||
1070 | 1120 | } |
1071 | 1121 | |
1072 | 1122 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1073 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1074 | - $post_errors[] = 'need_qr_verification'; |
|
1123 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1124 | + $post_errors[] = 'need_qr_verification'; |
|
1125 | + } |
|
1075 | 1126 | |
1076 | 1127 | /* |
1077 | 1128 | * There are two error types: serious and minor. Serious errors |
@@ -1088,52 +1139,56 @@ discard block |
||
1088 | 1139 | { |
1089 | 1140 | loadLanguage('Errors'); |
1090 | 1141 | $context['error_type'] = 'minor'; |
1091 | - foreach ($post_errors as $post_error) |
|
1092 | - if (is_array($post_error)) |
|
1142 | + foreach ($post_errors as $post_error) { |
|
1143 | + if (is_array($post_error)) |
|
1093 | 1144 | { |
1094 | 1145 | $post_error_id = $post_error[0]; |
1146 | + } |
|
1095 | 1147 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1096 | 1148 | |
1097 | 1149 | // If it's not a minor error flag it as such. |
1098 | - if (!in_array($post_error_id, $minor_errors)) |
|
1099 | - $context['error_type'] = 'serious'; |
|
1100 | - } |
|
1101 | - else |
|
1150 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1151 | + $context['error_type'] = 'serious'; |
|
1152 | + } |
|
1153 | + } else |
|
1102 | 1154 | { |
1103 | 1155 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1104 | 1156 | |
1105 | 1157 | // If it's not a minor error flag it as such. |
1106 | - if (!in_array($post_error, $minor_errors)) |
|
1107 | - $context['error_type'] = 'serious'; |
|
1158 | + if (!in_array($post_error, $minor_errors)) { |
|
1159 | + $context['error_type'] = 'serious'; |
|
1160 | + } |
|
1108 | 1161 | } |
1109 | 1162 | } |
1110 | 1163 | |
1111 | 1164 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1112 | - if (isset($_REQUEST['poll'])) |
|
1113 | - $context['page_title'] = $txt['new_poll']; |
|
1114 | - elseif ($context['make_event']) |
|
1115 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1116 | - elseif (isset($_REQUEST['msg'])) |
|
1117 | - $context['page_title'] = $txt['modify_msg']; |
|
1118 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1119 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1120 | - elseif (empty($topic)) |
|
1121 | - $context['page_title'] = $txt['start_new_topic']; |
|
1122 | - else |
|
1123 | - $context['page_title'] = $txt['post_reply']; |
|
1165 | + if (isset($_REQUEST['poll'])) { |
|
1166 | + $context['page_title'] = $txt['new_poll']; |
|
1167 | + } elseif ($context['make_event']) { |
|
1168 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1169 | + } elseif (isset($_REQUEST['msg'])) { |
|
1170 | + $context['page_title'] = $txt['modify_msg']; |
|
1171 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1172 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1173 | + } elseif (empty($topic)) { |
|
1174 | + $context['page_title'] = $txt['start_new_topic']; |
|
1175 | + } else { |
|
1176 | + $context['page_title'] = $txt['post_reply']; |
|
1177 | + } |
|
1124 | 1178 | |
1125 | 1179 | // Build the link tree. |
1126 | - if (empty($topic)) |
|
1127 | - $context['linktree'][] = array( |
|
1180 | + if (empty($topic)) { |
|
1181 | + $context['linktree'][] = array( |
|
1128 | 1182 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1129 | 1183 | ); |
1130 | - else |
|
1131 | - $context['linktree'][] = array( |
|
1184 | + } else { |
|
1185 | + $context['linktree'][] = array( |
|
1132 | 1186 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1133 | 1187 | 'name' => $form_subject, |
1134 | 1188 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1135 | 1189 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1136 | 1190 | ); |
1191 | + } |
|
1137 | 1192 | |
1138 | 1193 | $context['subject'] = addcslashes($form_subject, '"'); |
1139 | 1194 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1177,8 +1232,9 @@ discard block |
||
1177 | 1232 | // Message icons - customized icons are off? |
1178 | 1233 | $context['icons'] = getMessageIcons(!empty($board) ? $board : 0); |
1179 | 1234 | |
1180 | - if (!empty($context['icons'])) |
|
1181 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1235 | + if (!empty($context['icons'])) { |
|
1236 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1237 | + } |
|
1182 | 1238 | |
1183 | 1239 | // Are we starting a poll? if set the poll icon as selected if its available |
1184 | 1240 | if (isset($_REQUEST['poll'])) |
@@ -1198,8 +1254,9 @@ discard block |
||
1198 | 1254 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1199 | 1255 | { |
1200 | 1256 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1201 | - if ($context['icons'][$i]['selected']) |
|
1202 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1257 | + if ($context['icons'][$i]['selected']) { |
|
1258 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1259 | + } |
|
1203 | 1260 | } |
1204 | 1261 | if (empty($context['icon_url'])) |
1205 | 1262 | { |
@@ -1213,8 +1270,9 @@ discard block |
||
1213 | 1270 | )); |
1214 | 1271 | } |
1215 | 1272 | |
1216 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1217 | - getTopic(); |
|
1273 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1274 | + getTopic(); |
|
1275 | + } |
|
1218 | 1276 | |
1219 | 1277 | // If the user can post attachments prepare the warning labels. |
1220 | 1278 | if ($context['can_post_attachment']) |
@@ -1225,12 +1283,13 @@ discard block |
||
1225 | 1283 | $context['attachment_restrictions'] = array(); |
1226 | 1284 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1227 | 1285 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1228 | - foreach ($attachmentRestrictionTypes as $type) |
|
1229 | - if (!empty($modSettings[$type])) |
|
1286 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1287 | + if (!empty($modSettings[$type])) |
|
1230 | 1288 | { |
1231 | 1289 | // Show the max number of attachments if not 0. |
1232 | 1290 | if ($type == 'attachmentNumPerPostLimit') |
1233 | 1291 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1292 | + } |
|
1234 | 1293 | } |
1235 | 1294 | } |
1236 | 1295 | |
@@ -1264,8 +1323,8 @@ discard block |
||
1264 | 1323 | |
1265 | 1324 | if (!empty($context['current_attachments'])) |
1266 | 1325 | { |
1267 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1268 | - addInlineJavaScript(' |
|
1326 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1327 | + addInlineJavaScript(' |
|
1269 | 1328 | current_attachments.push({ |
1270 | 1329 | name: '. JavaScriptEscape($mock['name']) . ', |
1271 | 1330 | size: '. $mock['size'] . ', |
@@ -1274,6 +1333,7 @@ discard block |
||
1274 | 1333 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1275 | 1334 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1276 | 1335 | });'); |
1336 | + } |
|
1277 | 1337 | } |
1278 | 1338 | |
1279 | 1339 | // File Upload. |
@@ -1348,9 +1408,10 @@ discard block |
||
1348 | 1408 | $context['posting_fields']['board']['dd'] .= ' |
1349 | 1409 | <optgroup label="' . $category['name'] . '">'; |
1350 | 1410 | |
1351 | - foreach ($category['boards'] as $brd) |
|
1352 | - $context['posting_fields']['board']['dd'] .= ' |
|
1411 | + foreach ($category['boards'] as $brd) { |
|
1412 | + $context['posting_fields']['board']['dd'] .= ' |
|
1353 | 1413 | <option value="' . $brd['id'] . '"' . ($brd['selected'] ? ' selected' : '') . '>' . ($brd['child_level'] > 0 ? str_repeat('==', $brd['child_level'] - 1) . '=>' : '') . ' ' . $brd['name'] . '</option>'; |
1414 | + } |
|
1354 | 1415 | |
1355 | 1416 | $context['posting_fields']['board']['dd'] .= ' |
1356 | 1417 | </optgroup>'; |
@@ -1381,8 +1442,9 @@ discard block |
||
1381 | 1442 | |
1382 | 1443 | |
1383 | 1444 | // Finally, load the template. |
1384 | - if (!isset($_REQUEST['xml'])) |
|
1385 | - loadTemplate('Post'); |
|
1445 | + if (!isset($_REQUEST['xml'])) { |
|
1446 | + loadTemplate('Post'); |
|
1447 | + } |
|
1386 | 1448 | |
1387 | 1449 | call_integration_hook('integrate_post_end'); |
1388 | 1450 | } |
@@ -1403,13 +1465,14 @@ discard block |
||
1403 | 1465 | // Sneaking off, are we? |
1404 | 1466 | if (empty($_POST) && empty($topic)) |
1405 | 1467 | { |
1406 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1407 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1408 | - else |
|
1409 | - fatal_lang_error('post_upload_error', false); |
|
1468 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1469 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1470 | + } else { |
|
1471 | + fatal_lang_error('post_upload_error', false); |
|
1472 | + } |
|
1473 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1474 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1410 | 1475 | } |
1411 | - elseif (empty($_POST) && !empty($topic)) |
|
1412 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1413 | 1476 | |
1414 | 1477 | // No need! |
1415 | 1478 | $context['robot_no_index'] = true; |
@@ -1421,8 +1484,9 @@ discard block |
||
1421 | 1484 | $post_errors = array(); |
1422 | 1485 | |
1423 | 1486 | // If the session has timed out, let the user re-submit their form. |
1424 | - if (checkSession('post', '', false) != '') |
|
1425 | - $post_errors[] = 'session_timeout'; |
|
1487 | + if (checkSession('post', '', false) != '') { |
|
1488 | + $post_errors[] = 'session_timeout'; |
|
1489 | + } |
|
1426 | 1490 | |
1427 | 1491 | // Wrong verification code? |
1428 | 1492 | 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))) |
@@ -1432,33 +1496,38 @@ discard block |
||
1432 | 1496 | 'id' => 'post', |
1433 | 1497 | ); |
1434 | 1498 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1435 | - if (is_array($context['require_verification'])) |
|
1436 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1499 | + if (is_array($context['require_verification'])) { |
|
1500 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1501 | + } |
|
1437 | 1502 | } |
1438 | 1503 | |
1439 | 1504 | require_once($sourcedir . '/Subs-Post.php'); |
1440 | 1505 | loadLanguage('Post'); |
1441 | 1506 | |
1442 | 1507 | // Drafts enabled and needed? |
1443 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1444 | - require_once($sourcedir . '/Drafts.php'); |
|
1508 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1509 | + require_once($sourcedir . '/Drafts.php'); |
|
1510 | + } |
|
1445 | 1511 | |
1446 | 1512 | // First check to see if they are trying to delete any current attachments. |
1447 | 1513 | if (isset($_POST['attach_del'])) |
1448 | 1514 | { |
1449 | 1515 | $keep_temp = array(); |
1450 | 1516 | $keep_ids = array(); |
1451 | - foreach ($_POST['attach_del'] as $dummy) |
|
1452 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1517 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1518 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1453 | 1519 | $keep_temp[] = $dummy; |
1454 | - else |
|
1455 | - $keep_ids[] = (int) $dummy; |
|
1520 | + } |
|
1521 | + else { |
|
1522 | + $keep_ids[] = (int) $dummy; |
|
1523 | + } |
|
1456 | 1524 | |
1457 | - if (isset($_SESSION['temp_attachments'])) |
|
1458 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1525 | + if (isset($_SESSION['temp_attachments'])) { |
|
1526 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1459 | 1527 | { |
1460 | 1528 | 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) |
1461 | 1529 | continue; |
1530 | + } |
|
1462 | 1531 | |
1463 | 1532 | unset($_SESSION['temp_attachments'][$attachID]); |
1464 | 1533 | unlink($attachment['tmp_name']); |
@@ -1490,8 +1559,9 @@ discard block |
||
1490 | 1559 | { |
1491 | 1560 | require_once($sourcedir . '/ManageAttachments.php'); |
1492 | 1561 | |
1493 | - foreach ($_SESSION['already_attached'] as $attachID => $attachment) |
|
1494 | - removeAttachments(array('id_attach' => $attachID)); |
|
1562 | + foreach ($_SESSION['already_attached'] as $attachID => $attachment) { |
|
1563 | + removeAttachments(array('id_attach' => $attachID)); |
|
1564 | + } |
|
1495 | 1565 | |
1496 | 1566 | unset($_SESSION['already_attached']); |
1497 | 1567 | |
@@ -1514,12 +1584,14 @@ discard block |
||
1514 | 1584 | $smcFunc['db_free_result']($request); |
1515 | 1585 | |
1516 | 1586 | // Though the topic should be there, it might have vanished. |
1517 | - if (!is_array($topic_info)) |
|
1518 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1587 | + if (!is_array($topic_info)) { |
|
1588 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1589 | + } |
|
1519 | 1590 | |
1520 | 1591 | // Did this topic suddenly move? Just checking... |
1521 | - if ($topic_info['id_board'] != $board) |
|
1522 | - fatal_lang_error('not_a_topic'); |
|
1592 | + if ($topic_info['id_board'] != $board) { |
|
1593 | + fatal_lang_error('not_a_topic'); |
|
1594 | + } |
|
1523 | 1595 | |
1524 | 1596 | // Do the permissions and approval stuff... |
1525 | 1597 | $becomesApproved = true; |
@@ -1542,49 +1614,50 @@ discard block |
||
1542 | 1614 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1543 | 1615 | { |
1544 | 1616 | // Don't allow a post if it's locked. |
1545 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1546 | - fatal_lang_error('topic_locked', false); |
|
1617 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1618 | + fatal_lang_error('topic_locked', false); |
|
1619 | + } |
|
1547 | 1620 | |
1548 | 1621 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1549 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1550 | - unset($_REQUEST['poll']); |
|
1551 | - |
|
1552 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1553 | - { |
|
1554 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1555 | - $becomesApproved = false; |
|
1556 | - |
|
1557 | - else |
|
1558 | - isAllowedTo('post_reply_any'); |
|
1559 | - } |
|
1560 | - elseif (!allowedTo('post_reply_any')) |
|
1622 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1623 | + unset($_REQUEST['poll']); |
|
1624 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1625 | + { |
|
1626 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1627 | + $becomesApproved = false; |
|
1628 | + } else { |
|
1629 | + isAllowedTo('post_reply_any'); |
|
1630 | + } |
|
1631 | + } elseif (!allowedTo('post_reply_any')) |
|
1561 | 1632 | { |
1562 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1563 | - $becomesApproved = false; |
|
1564 | - |
|
1565 | - else |
|
1566 | - isAllowedTo('post_reply_own'); |
|
1633 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1634 | + $becomesApproved = false; |
|
1635 | + } else { |
|
1636 | + isAllowedTo('post_reply_own'); |
|
1637 | + } |
|
1567 | 1638 | } |
1568 | 1639 | |
1569 | 1640 | if (isset($_POST['lock'])) |
1570 | 1641 | { |
1571 | 1642 | // Nothing is changed to the lock. |
1572 | - if (empty($topic_info['locked']) == empty($_POST['lock'])) |
|
1573 | - unset($_POST['lock']); |
|
1643 | + if (empty($topic_info['locked']) == empty($_POST['lock'])) { |
|
1644 | + unset($_POST['lock']); |
|
1645 | + } |
|
1574 | 1646 | |
1575 | 1647 | // You're have no permission to lock this topic. |
1576 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1577 | - unset($_POST['lock']); |
|
1648 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1649 | + unset($_POST['lock']); |
|
1650 | + } |
|
1578 | 1651 | |
1579 | 1652 | // You are allowed to (un)lock your own topic only. |
1580 | 1653 | elseif (!allowedTo('lock_any')) |
1581 | 1654 | { |
1582 | 1655 | // You cannot override a moderator lock. |
1583 | - if ($topic_info['locked'] == 1) |
|
1584 | - unset($_POST['lock']); |
|
1585 | - |
|
1586 | - else |
|
1587 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1656 | + if ($topic_info['locked'] == 1) { |
|
1657 | + unset($_POST['lock']); |
|
1658 | + } else { |
|
1659 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1660 | + } |
|
1588 | 1661 | } |
1589 | 1662 | // Hail mighty moderator, (un)lock this topic immediately. |
1590 | 1663 | else |
@@ -1592,19 +1665,21 @@ discard block |
||
1592 | 1665 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1593 | 1666 | |
1594 | 1667 | // Did someone (un)lock this while you were posting? |
1595 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1596 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1668 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1669 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1670 | + } |
|
1597 | 1671 | } |
1598 | 1672 | } |
1599 | 1673 | |
1600 | 1674 | // So you wanna (un)sticky this...let's see. |
1601 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1602 | - unset($_POST['sticky']); |
|
1603 | - elseif (isset($_POST['sticky'])) |
|
1675 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1676 | + unset($_POST['sticky']); |
|
1677 | + } elseif (isset($_POST['sticky'])) |
|
1604 | 1678 | { |
1605 | 1679 | // Did someone (un)sticky this while you were posting? |
1606 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1607 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1680 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1681 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1682 | + } |
|
1608 | 1683 | } |
1609 | 1684 | |
1610 | 1685 | // If drafts are enabled, then pass this off |
@@ -1631,26 +1706,31 @@ discard block |
||
1631 | 1706 | |
1632 | 1707 | // Do like, the permissions, for safety and stuff... |
1633 | 1708 | $becomesApproved = true; |
1634 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1635 | - $becomesApproved = false; |
|
1636 | - else |
|
1637 | - isAllowedTo('post_new'); |
|
1709 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1710 | + $becomesApproved = false; |
|
1711 | + } else { |
|
1712 | + isAllowedTo('post_new'); |
|
1713 | + } |
|
1638 | 1714 | |
1639 | 1715 | if (isset($_POST['lock'])) |
1640 | 1716 | { |
1641 | 1717 | // New topics are by default not locked. |
1642 | - if (empty($_POST['lock'])) |
|
1643 | - unset($_POST['lock']); |
|
1718 | + if (empty($_POST['lock'])) { |
|
1719 | + unset($_POST['lock']); |
|
1720 | + } |
|
1644 | 1721 | // Besides, you need permission. |
1645 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1646 | - unset($_POST['lock']); |
|
1722 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1647 | 1725 | // A moderator-lock (1) can override a user-lock (2). |
1648 | - else |
|
1649 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1726 | + else { |
|
1727 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1728 | + } |
|
1650 | 1729 | } |
1651 | 1730 | |
1652 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1653 | - unset($_POST['sticky']); |
|
1731 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1732 | + unset($_POST['sticky']); |
|
1733 | + } |
|
1654 | 1734 | |
1655 | 1735 | // Saving your new topic as a draft first? |
1656 | 1736 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1675,31 +1755,37 @@ discard block |
||
1675 | 1755 | 'id_msg' => $_REQUEST['msg'], |
1676 | 1756 | ) |
1677 | 1757 | ); |
1678 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1679 | - fatal_lang_error('cant_find_messages', false); |
|
1758 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1759 | + fatal_lang_error('cant_find_messages', false); |
|
1760 | + } |
|
1680 | 1761 | $row = $smcFunc['db_fetch_assoc']($request); |
1681 | 1762 | $smcFunc['db_free_result']($request); |
1682 | 1763 | |
1683 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1684 | - fatal_lang_error('topic_locked', false); |
|
1764 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1765 | + fatal_lang_error('topic_locked', false); |
|
1766 | + } |
|
1685 | 1767 | |
1686 | 1768 | if (isset($_POST['lock'])) |
1687 | 1769 | { |
1688 | 1770 | // Nothing changes to the lock status. |
1689 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1690 | - unset($_POST['lock']); |
|
1771 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1772 | + unset($_POST['lock']); |
|
1773 | + } |
|
1691 | 1774 | // You're simply not allowed to (un)lock this. |
1692 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1693 | - unset($_POST['lock']); |
|
1775 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1776 | + unset($_POST['lock']); |
|
1777 | + } |
|
1694 | 1778 | // You're only allowed to lock your own topics. |
1695 | 1779 | elseif (!allowedTo('lock_any')) |
1696 | 1780 | { |
1697 | 1781 | // You're not allowed to break a moderator's lock. |
1698 | - if ($topic_info['locked'] == 1) |
|
1699 | - unset($_POST['lock']); |
|
1782 | + if ($topic_info['locked'] == 1) { |
|
1783 | + unset($_POST['lock']); |
|
1784 | + } |
|
1700 | 1785 | // Lock it with a soft lock or unlock it. |
1701 | - else |
|
1702 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1786 | + else { |
|
1787 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1788 | + } |
|
1703 | 1789 | } |
1704 | 1790 | // You must be the moderator. |
1705 | 1791 | else |
@@ -1707,44 +1793,46 @@ discard block |
||
1707 | 1793 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1708 | 1794 | |
1709 | 1795 | // Did someone (un)lock this while you were posting? |
1710 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1711 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1796 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1797 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1798 | + } |
|
1712 | 1799 | } |
1713 | 1800 | } |
1714 | 1801 | |
1715 | 1802 | // Change the sticky status of this topic? |
1716 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1717 | - unset($_POST['sticky']); |
|
1718 | - elseif (isset($_POST['sticky'])) |
|
1803 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1804 | + unset($_POST['sticky']); |
|
1805 | + } elseif (isset($_POST['sticky'])) |
|
1719 | 1806 | { |
1720 | 1807 | // Did someone (un)sticky this while you were posting? |
1721 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1722 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1808 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1809 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1810 | + } |
|
1723 | 1811 | } |
1724 | 1812 | |
1725 | 1813 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1726 | 1814 | { |
1727 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1728 | - fatal_lang_error('modify_post_time_passed', false); |
|
1729 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1730 | - isAllowedTo('modify_replies'); |
|
1731 | - else |
|
1732 | - isAllowedTo('modify_own'); |
|
1733 | - } |
|
1734 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1815 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1816 | + fatal_lang_error('modify_post_time_passed', false); |
|
1817 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1818 | + isAllowedTo('modify_replies'); |
|
1819 | + } else { |
|
1820 | + isAllowedTo('modify_own'); |
|
1821 | + } |
|
1822 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1735 | 1823 | { |
1736 | 1824 | isAllowedTo('modify_replies'); |
1737 | 1825 | |
1738 | 1826 | // If you're modifying a reply, I say it better be logged... |
1739 | 1827 | $moderationAction = true; |
1740 | - } |
|
1741 | - else |
|
1828 | + } else |
|
1742 | 1829 | { |
1743 | 1830 | isAllowedTo('modify_any'); |
1744 | 1831 | |
1745 | 1832 | // Log it, assuming you're not modifying your own post. |
1746 | - if ($row['id_member'] != $user_info['id']) |
|
1747 | - $moderationAction = true; |
|
1833 | + if ($row['id_member'] != $user_info['id']) { |
|
1834 | + $moderationAction = true; |
|
1835 | + } |
|
1748 | 1836 | } |
1749 | 1837 | |
1750 | 1838 | // If drafts are enabled, then lets send this off to save |
@@ -1783,20 +1871,24 @@ discard block |
||
1783 | 1871 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1784 | 1872 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1785 | 1873 | |
1786 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1787 | - $post_errors[] = 'no_name'; |
|
1788 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1789 | - $post_errors[] = 'long_name'; |
|
1874 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1875 | + $post_errors[] = 'no_name'; |
|
1876 | + } |
|
1877 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1878 | + $post_errors[] = 'long_name'; |
|
1879 | + } |
|
1790 | 1880 | |
1791 | 1881 | if (empty($modSettings['guest_post_no_email'])) |
1792 | 1882 | { |
1793 | 1883 | // Only check if they changed it! |
1794 | 1884 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1795 | 1885 | { |
1796 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1797 | - $post_errors[] = 'no_email'; |
|
1798 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1799 | - $post_errors[] = 'bad_email'; |
|
1886 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1887 | + $post_errors[] = 'no_email'; |
|
1888 | + } |
|
1889 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1890 | + $post_errors[] = 'bad_email'; |
|
1891 | + } |
|
1800 | 1892 | } |
1801 | 1893 | |
1802 | 1894 | // Now make sure this email address is not banned from posting. |
@@ -1812,81 +1904,95 @@ discard block |
||
1812 | 1904 | } |
1813 | 1905 | |
1814 | 1906 | // Coming from the quickReply? |
1815 | - if (isset($_POST['quickReply'])) |
|
1816 | - $_POST['message'] = $_POST['quickReply']; |
|
1907 | + if (isset($_POST['quickReply'])) { |
|
1908 | + $_POST['message'] = $_POST['quickReply']; |
|
1909 | + } |
|
1817 | 1910 | |
1818 | 1911 | // Check the subject and message. |
1819 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1820 | - $post_errors[] = 'no_subject'; |
|
1821 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1822 | - $post_errors[] = 'no_message'; |
|
1823 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1824 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1825 | - else |
|
1912 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1913 | + $post_errors[] = 'no_subject'; |
|
1914 | + } |
|
1915 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1916 | + $post_errors[] = 'no_message'; |
|
1917 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1918 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1919 | + } else |
|
1826 | 1920 | { |
1827 | 1921 | // Prepare the message a bit for some additional testing. |
1828 | 1922 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1829 | 1923 | |
1830 | 1924 | // Preparse code. (Zef) |
1831 | - if ($user_info['is_guest']) |
|
1832 | - $user_info['name'] = $_POST['guestname']; |
|
1925 | + if ($user_info['is_guest']) { |
|
1926 | + $user_info['name'] = $_POST['guestname']; |
|
1927 | + } |
|
1833 | 1928 | preparsecode($_POST['message']); |
1834 | 1929 | |
1835 | 1930 | // Youtube BBC would be stripped out in the next check without this |
1836 | 1931 | $context['allowed_html_tags'][] = '<iframe>'; |
1837 | 1932 | |
1838 | 1933 | // Let's see if there's still some content left without the tags. |
1839 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1840 | - $post_errors[] = 'no_message'; |
|
1934 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1935 | + $post_errors[] = 'no_message'; |
|
1936 | + } |
|
1841 | 1937 | |
1842 | 1938 | // Remove iframe from the list |
1843 | 1939 | array_pop($context['allowed_html_tags']); |
1844 | 1940 | } |
1845 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1846 | - $post_errors[] = 'no_event'; |
|
1941 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1942 | + $post_errors[] = 'no_event'; |
|
1943 | + } |
|
1847 | 1944 | // You are not! |
1848 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1849 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1945 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1946 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1947 | + } |
|
1850 | 1948 | |
1851 | 1949 | // Validate the poll... |
1852 | 1950 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1853 | 1951 | { |
1854 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1855 | - fatal_lang_error('no_access', false); |
|
1952 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1953 | + fatal_lang_error('no_access', false); |
|
1954 | + } |
|
1856 | 1955 | |
1857 | 1956 | // This is a new topic... so it's a new poll. |
1858 | - if (empty($topic)) |
|
1859 | - isAllowedTo('poll_post'); |
|
1957 | + if (empty($topic)) { |
|
1958 | + isAllowedTo('poll_post'); |
|
1959 | + } |
|
1860 | 1960 | // Can you add to your own topics? |
1861 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1862 | - isAllowedTo('poll_add_own'); |
|
1961 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1962 | + isAllowedTo('poll_add_own'); |
|
1963 | + } |
|
1863 | 1964 | // Can you add polls to any topic, then? |
1864 | - else |
|
1865 | - isAllowedTo('poll_add_any'); |
|
1965 | + else { |
|
1966 | + isAllowedTo('poll_add_any'); |
|
1967 | + } |
|
1866 | 1968 | |
1867 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1868 | - $post_errors[] = 'no_question'; |
|
1969 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1970 | + $post_errors[] = 'no_question'; |
|
1971 | + } |
|
1869 | 1972 | |
1870 | 1973 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1871 | 1974 | |
1872 | 1975 | // Get rid of empty ones. |
1873 | - foreach ($_POST['options'] as $k => $option) |
|
1874 | - if ($option == '') |
|
1976 | + foreach ($_POST['options'] as $k => $option) { |
|
1977 | + if ($option == '') |
|
1875 | 1978 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1979 | + } |
|
1876 | 1980 | |
1877 | 1981 | // What are you going to vote between with one choice?!? |
1878 | - if (count($_POST['options']) < 2) |
|
1879 | - $post_errors[] = 'poll_few'; |
|
1880 | - elseif (count($_POST['options']) > 256) |
|
1881 | - $post_errors[] = 'poll_many'; |
|
1982 | + if (count($_POST['options']) < 2) { |
|
1983 | + $post_errors[] = 'poll_few'; |
|
1984 | + } elseif (count($_POST['options']) > 256) { |
|
1985 | + $post_errors[] = 'poll_many'; |
|
1986 | + } |
|
1882 | 1987 | } |
1883 | 1988 | |
1884 | 1989 | if ($posterIsGuest) |
1885 | 1990 | { |
1886 | 1991 | // If user is a guest, make sure the chosen name isn't taken. |
1887 | 1992 | require_once($sourcedir . '/Subs-Members.php'); |
1888 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1889 | - $post_errors[] = 'bad_name'; |
|
1993 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1994 | + $post_errors[] = 'bad_name'; |
|
1995 | + } |
|
1890 | 1996 | } |
1891 | 1997 | // If the user isn't a guest, get his or her name and email. |
1892 | 1998 | elseif (!isset($_REQUEST['msg'])) |
@@ -1917,8 +2023,9 @@ discard block |
||
1917 | 2023 | } |
1918 | 2024 | |
1919 | 2025 | // Make sure the user isn't spamming the board. |
1920 | - if (!isset($_REQUEST['msg'])) |
|
1921 | - spamProtection('post'); |
|
2026 | + if (!isset($_REQUEST['msg'])) { |
|
2027 | + spamProtection('post'); |
|
2028 | + } |
|
1922 | 2029 | |
1923 | 2030 | // At about this point, we're posting and that's that. |
1924 | 2031 | ignore_user_abort(true); |
@@ -1931,32 +2038,36 @@ discard block |
||
1931 | 2038 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1932 | 2039 | |
1933 | 2040 | // At this point, we want to make sure the subject isn't too long. |
1934 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1935 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2041 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2042 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2043 | + } |
|
1936 | 2044 | |
1937 | 2045 | // Same with the "why did you edit this" text. |
1938 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1939 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2046 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2047 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2048 | + } |
|
1940 | 2049 | |
1941 | 2050 | // Make the poll... |
1942 | 2051 | if (isset($_REQUEST['poll'])) |
1943 | 2052 | { |
1944 | 2053 | // Make sure that the user has not entered a ridiculous number of options.. |
1945 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1946 | - $_POST['poll_max_votes'] = 1; |
|
1947 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1948 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1949 | - else |
|
1950 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2054 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
2055 | + $_POST['poll_max_votes'] = 1; |
|
2056 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
2057 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
2058 | + } else { |
|
2059 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
2060 | + } |
|
1951 | 2061 | |
1952 | 2062 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1953 | 2063 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1954 | 2064 | |
1955 | 2065 | // Just set it to zero if it's not there.. |
1956 | - if (!isset($_POST['poll_hide'])) |
|
1957 | - $_POST['poll_hide'] = 0; |
|
1958 | - else |
|
1959 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2066 | + if (!isset($_POST['poll_hide'])) { |
|
2067 | + $_POST['poll_hide'] = 0; |
|
2068 | + } else { |
|
2069 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2070 | + } |
|
1960 | 2071 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1961 | 2072 | |
1962 | 2073 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1965,16 +2076,19 @@ discard block |
||
1965 | 2076 | { |
1966 | 2077 | require_once($sourcedir . '/Subs-Members.php'); |
1967 | 2078 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1968 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1969 | - $_POST['poll_guest_vote'] = 0; |
|
2079 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2080 | + $_POST['poll_guest_vote'] = 0; |
|
2081 | + } |
|
1970 | 2082 | } |
1971 | 2083 | |
1972 | 2084 | // If the user tries to set the poll too far in advance, don't let them. |
1973 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1974 | - fatal_lang_error('poll_range_error', false); |
|
2085 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2086 | + fatal_lang_error('poll_range_error', false); |
|
2087 | + } |
|
1975 | 2088 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1976 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1977 | - $_POST['poll_hide'] = 1; |
|
2089 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2090 | + $_POST['poll_hide'] = 1; |
|
2091 | + } |
|
1978 | 2092 | |
1979 | 2093 | // Clean up the question and answers. |
1980 | 2094 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1988,13 +2102,15 @@ discard block |
||
1988 | 2102 | { |
1989 | 2103 | $attachIDs = array(); |
1990 | 2104 | $attach_errors = array(); |
1991 | - if (!empty($context['we_are_history'])) |
|
1992 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2105 | + if (!empty($context['we_are_history'])) { |
|
2106 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2107 | + } |
|
1993 | 2108 | |
1994 | 2109 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1995 | 2110 | { |
1996 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1997 | - continue; |
|
2111 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2112 | + continue; |
|
2113 | + } |
|
1998 | 2114 | |
1999 | 2115 | // If there was an initial error just show that message. |
2000 | 2116 | if ($attachID == 'initial_error') |
@@ -2023,12 +2139,13 @@ discard block |
||
2023 | 2139 | if (createAttachment($attachmentOptions)) |
2024 | 2140 | { |
2025 | 2141 | $attachIDs[] = $attachmentOptions['id']; |
2026 | - if (!empty($attachmentOptions['thumb'])) |
|
2027 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2142 | + if (!empty($attachmentOptions['thumb'])) { |
|
2143 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2144 | + } |
|
2028 | 2145 | } |
2146 | + } else { |
|
2147 | + $attach_errors[] = '<dt> </dt>'; |
|
2029 | 2148 | } |
2030 | - else |
|
2031 | - $attach_errors[] = '<dt> </dt>'; |
|
2032 | 2149 | |
2033 | 2150 | if (!empty($attachmentOptions['errors'])) |
2034 | 2151 | { |
@@ -2040,14 +2157,16 @@ discard block |
||
2040 | 2157 | if (!is_array($error)) |
2041 | 2158 | { |
2042 | 2159 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
2043 | - if (in_array($error, $log_these)) |
|
2044 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2160 | + if (in_array($error, $log_these)) { |
|
2161 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2162 | + } |
|
2163 | + } else { |
|
2164 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2045 | 2165 | } |
2046 | - else |
|
2047 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
2048 | 2166 | } |
2049 | - if (file_exists($attachment['tmp_name'])) |
|
2050 | - unlink($attachment['tmp_name']); |
|
2167 | + if (file_exists($attachment['tmp_name'])) { |
|
2168 | + unlink($attachment['tmp_name']); |
|
2169 | + } |
|
2051 | 2170 | } |
2052 | 2171 | } |
2053 | 2172 | unset($_SESSION['temp_attachments']); |
@@ -2088,24 +2207,24 @@ discard block |
||
2088 | 2207 | ); |
2089 | 2208 | |
2090 | 2209 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2210 | + } else { |
|
2211 | + $id_poll = 0; |
|
2091 | 2212 | } |
2092 | - else |
|
2093 | - $id_poll = 0; |
|
2094 | 2213 | |
2095 | 2214 | // Creating a new topic? |
2096 | 2215 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2097 | 2216 | |
2098 | 2217 | // Check the icon. |
2099 | - if (!isset($_POST['icon'])) |
|
2100 | - $_POST['icon'] = 'xx'; |
|
2101 | - |
|
2102 | - else |
|
2218 | + if (!isset($_POST['icon'])) { |
|
2219 | + $_POST['icon'] = 'xx'; |
|
2220 | + } else |
|
2103 | 2221 | { |
2104 | 2222 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2105 | 2223 | |
2106 | 2224 | // Need to figure it out if this is a valid icon name. |
2107 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2108 | - $_POST['icon'] = 'xx'; |
|
2225 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2226 | + $_POST['icon'] = 'xx'; |
|
2227 | + } |
|
2109 | 2228 | } |
2110 | 2229 | |
2111 | 2230 | // Collect all parameters for the creation or modification of a post. |
@@ -2146,8 +2265,9 @@ discard block |
||
2146 | 2265 | } |
2147 | 2266 | |
2148 | 2267 | // This will save some time... |
2149 | - if (empty($approve_has_changed)) |
|
2150 | - unset($msgOptions['approved']); |
|
2268 | + if (empty($approve_has_changed)) { |
|
2269 | + unset($msgOptions['approved']); |
|
2270 | + } |
|
2151 | 2271 | |
2152 | 2272 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2153 | 2273 | } |
@@ -2156,8 +2276,9 @@ discard block |
||
2156 | 2276 | { |
2157 | 2277 | createPost($msgOptions, $topicOptions, $posterOptions); |
2158 | 2278 | |
2159 | - if (isset($topicOptions['id'])) |
|
2160 | - $topic = $topicOptions['id']; |
|
2279 | + if (isset($topicOptions['id'])) { |
|
2280 | + $topic = $topicOptions['id']; |
|
2281 | + } |
|
2161 | 2282 | } |
2162 | 2283 | |
2163 | 2284 | // Are there attachments already uploaded and waiting to be assigned? |
@@ -2169,8 +2290,9 @@ discard block |
||
2169 | 2290 | } |
2170 | 2291 | |
2171 | 2292 | // If we had a draft for this, its time to remove it since it was just posted |
2172 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2173 | - DeleteDraft($_POST['id_draft']); |
|
2293 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2294 | + DeleteDraft($_POST['id_draft']); |
|
2295 | + } |
|
2174 | 2296 | |
2175 | 2297 | // Editing or posting an event? |
2176 | 2298 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2189,8 +2311,7 @@ discard block |
||
2189 | 2311 | 'member' => $user_info['id'], |
2190 | 2312 | ); |
2191 | 2313 | insertEvent($eventOptions); |
2192 | - } |
|
2193 | - elseif (isset($_POST['calendar'])) |
|
2314 | + } elseif (isset($_POST['calendar'])) |
|
2194 | 2315 | { |
2195 | 2316 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2196 | 2317 | |
@@ -2218,14 +2339,15 @@ discard block |
||
2218 | 2339 | } |
2219 | 2340 | |
2220 | 2341 | // Delete it? |
2221 | - if (isset($_REQUEST['deleteevent'])) |
|
2222 | - $smcFunc['db_query']('', ' |
|
2342 | + if (isset($_REQUEST['deleteevent'])) { |
|
2343 | + $smcFunc['db_query']('', ' |
|
2223 | 2344 | DELETE FROM {db_prefix}calendar |
2224 | 2345 | WHERE id_event = {int:id_event}', |
2225 | 2346 | array( |
2226 | 2347 | 'id_event' => $_REQUEST['eventid'], |
2227 | 2348 | ) |
2228 | 2349 | ); |
2350 | + } |
|
2229 | 2351 | // ... or just update it? |
2230 | 2352 | else |
2231 | 2353 | { |
@@ -2267,9 +2389,8 @@ discard block |
||
2267 | 2389 | array($user_info['id'], $topic, 0), |
2268 | 2390 | array('id_member', 'id_topic', 'id_board') |
2269 | 2391 | ); |
2270 | - } |
|
2271 | - elseif (!$newTopic) |
|
2272 | - $smcFunc['db_query']('', ' |
|
2392 | + } elseif (!$newTopic) { |
|
2393 | + $smcFunc['db_query']('', ' |
|
2273 | 2394 | DELETE FROM {db_prefix}log_notify |
2274 | 2395 | WHERE id_member = {int:current_member} |
2275 | 2396 | AND id_topic = {int:current_topic}', |
@@ -2278,16 +2399,20 @@ discard block |
||
2278 | 2399 | 'current_topic' => $topic, |
2279 | 2400 | ) |
2280 | 2401 | ); |
2402 | + } |
|
2281 | 2403 | |
2282 | 2404 | // Log an act of moderation - modifying. |
2283 | - if (!empty($moderationAction)) |
|
2284 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2405 | + if (!empty($moderationAction)) { |
|
2406 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2407 | + } |
|
2285 | 2408 | |
2286 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2287 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2409 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2410 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2411 | + } |
|
2288 | 2412 | |
2289 | - if (isset($_POST['sticky'])) |
|
2290 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2413 | + if (isset($_POST['sticky'])) { |
|
2414 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2415 | + } |
|
2291 | 2416 | |
2292 | 2417 | // Returning to the topic? |
2293 | 2418 | if (!empty($_REQUEST['goback'])) |
@@ -2306,26 +2431,31 @@ discard block |
||
2306 | 2431 | ); |
2307 | 2432 | } |
2308 | 2433 | |
2309 | - if ($board_info['num_topics'] == 0) |
|
2310 | - cache_put_data('board-' . $board, null, 120); |
|
2434 | + if ($board_info['num_topics'] == 0) { |
|
2435 | + cache_put_data('board-' . $board, null, 120); |
|
2436 | + } |
|
2311 | 2437 | |
2312 | 2438 | call_integration_hook('integrate_post2_end'); |
2313 | 2439 | |
2314 | - if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) |
|
2315 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2440 | + if (!empty($_POST['announce_topic']) && allowedTo('announce_topic')) { |
|
2441 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2442 | + } |
|
2316 | 2443 | |
2317 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2318 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2444 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2445 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2446 | + } |
|
2319 | 2447 | |
2320 | 2448 | // Return to post if the mod is on. |
2321 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2322 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2323 | - elseif (!empty($_REQUEST['goback'])) |
|
2324 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2449 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2450 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2451 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2452 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2453 | + } |
|
2325 | 2454 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2326 | - else |
|
2327 | - redirectexit('board=' . $board . '.0'); |
|
2328 | -} |
|
2455 | + else { |
|
2456 | + redirectexit('board=' . $board . '.0'); |
|
2457 | + } |
|
2458 | + } |
|
2329 | 2459 | |
2330 | 2460 | /** |
2331 | 2461 | * Handle the announce topic function (action=announce). |
@@ -2343,8 +2473,9 @@ discard block |
||
2343 | 2473 | |
2344 | 2474 | validateSession(); |
2345 | 2475 | |
2346 | - if (empty($topic)) |
|
2347 | - fatal_lang_error('topic_gone', false); |
|
2476 | + if (empty($topic)) { |
|
2477 | + fatal_lang_error('topic_gone', false); |
|
2478 | + } |
|
2348 | 2479 | |
2349 | 2480 | loadLanguage('Post'); |
2350 | 2481 | loadTemplate('Post'); |
@@ -2371,8 +2502,9 @@ discard block |
||
2371 | 2502 | global $txt, $context, $topic, $board_info, $smcFunc; |
2372 | 2503 | |
2373 | 2504 | $groups = array_merge($board_info['groups'], array(1)); |
2374 | - foreach ($groups as $id => $group) |
|
2375 | - $groups[$id] = (int) $group; |
|
2505 | + foreach ($groups as $id => $group) { |
|
2506 | + $groups[$id] = (int) $group; |
|
2507 | + } |
|
2376 | 2508 | |
2377 | 2509 | $context['groups'] = array(); |
2378 | 2510 | if (in_array(0, $groups)) |
@@ -2415,8 +2547,9 @@ discard block |
||
2415 | 2547 | 'group_list' => $groups, |
2416 | 2548 | ) |
2417 | 2549 | ); |
2418 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2419 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2550 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2551 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2552 | + } |
|
2420 | 2553 | $smcFunc['db_free_result']($request); |
2421 | 2554 | |
2422 | 2555 | // Get the subject of the topic we're about to announce. |
@@ -2458,16 +2591,19 @@ discard block |
||
2458 | 2591 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2459 | 2592 | $groups = array_merge($board_info['groups'], array(1)); |
2460 | 2593 | |
2461 | - if (isset($_POST['membergroups'])) |
|
2462 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2594 | + if (isset($_POST['membergroups'])) { |
|
2595 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2596 | + } |
|
2463 | 2597 | |
2464 | 2598 | // Check whether at least one membergroup was selected. |
2465 | - if (empty($_POST['who'])) |
|
2466 | - fatal_lang_error('no_membergroup_selected'); |
|
2599 | + if (empty($_POST['who'])) { |
|
2600 | + fatal_lang_error('no_membergroup_selected'); |
|
2601 | + } |
|
2467 | 2602 | |
2468 | 2603 | // Make sure all membergroups are integers and can access the board of the announcement. |
2469 | - foreach ($_POST['who'] as $id => $mg) |
|
2470 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2604 | + foreach ($_POST['who'] as $id => $mg) { |
|
2605 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2606 | + } |
|
2471 | 2607 | |
2472 | 2608 | // Get the topic subject and censor it. |
2473 | 2609 | $request = $smcFunc['db_query']('', ' |
@@ -2513,12 +2649,13 @@ discard block |
||
2513 | 2649 | if ($smcFunc['db_num_rows']($request) == 0) |
2514 | 2650 | { |
2515 | 2651 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2516 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2517 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2518 | - elseif (!empty($_REQUEST['goback'])) |
|
2519 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2520 | - else |
|
2521 | - redirectexit('board=' . $board . '.0'); |
|
2652 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2653 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2654 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2655 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2656 | + } else { |
|
2657 | + redirectexit('board=' . $board . '.0'); |
|
2658 | + } |
|
2522 | 2659 | } |
2523 | 2660 | |
2524 | 2661 | $announcements = array(); |
@@ -2537,8 +2674,9 @@ discard block |
||
2537 | 2674 | foreach ($rows as $row) |
2538 | 2675 | { |
2539 | 2676 | // Force them to have it? |
2540 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2541 | - continue; |
|
2677 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2678 | + continue; |
|
2679 | + } |
|
2542 | 2680 | |
2543 | 2681 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2544 | 2682 | |
@@ -2566,8 +2704,9 @@ discard block |
||
2566 | 2704 | } |
2567 | 2705 | |
2568 | 2706 | // For each language send a different mail - low priority... |
2569 | - foreach ($announcements as $lang => $mail) |
|
2570 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2707 | + foreach ($announcements as $lang => $mail) { |
|
2708 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2709 | + } |
|
2571 | 2710 | |
2572 | 2711 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2573 | 2712 | |
@@ -2577,9 +2716,10 @@ discard block |
||
2577 | 2716 | $context['sub_template'] = 'announcement_send'; |
2578 | 2717 | |
2579 | 2718 | // Go back to the correct language for the user ;). |
2580 | - if (!empty($modSettings['userLanguage'])) |
|
2581 | - loadLanguage('Post'); |
|
2582 | -} |
|
2719 | + if (!empty($modSettings['userLanguage'])) { |
|
2720 | + loadLanguage('Post'); |
|
2721 | + } |
|
2722 | + } |
|
2583 | 2723 | |
2584 | 2724 | /** |
2585 | 2725 | * Get the topic for display purposes. |
@@ -2592,12 +2732,13 @@ discard block |
||
2592 | 2732 | { |
2593 | 2733 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2594 | 2734 | |
2595 | - if (isset($_REQUEST['xml'])) |
|
2596 | - $limit = ' |
|
2735 | + if (isset($_REQUEST['xml'])) { |
|
2736 | + $limit = ' |
|
2597 | 2737 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2598 | - else |
|
2599 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2738 | + } else { |
|
2739 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2600 | 2740 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2741 | + } |
|
2601 | 2742 | |
2602 | 2743 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2603 | 2744 | $request = $smcFunc['db_query']('', ' |
@@ -2635,8 +2776,9 @@ discard block |
||
2635 | 2776 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2636 | 2777 | ); |
2637 | 2778 | |
2638 | - if (!empty($context['new_replies'])) |
|
2639 | - $context['new_replies']--; |
|
2779 | + if (!empty($context['new_replies'])) { |
|
2780 | + $context['new_replies']--; |
|
2781 | + } |
|
2640 | 2782 | } |
2641 | 2783 | $smcFunc['db_free_result']($request); |
2642 | 2784 | } |
@@ -2653,8 +2795,9 @@ discard block |
||
2653 | 2795 | global $sourcedir, $smcFunc; |
2654 | 2796 | |
2655 | 2797 | loadLanguage('Post'); |
2656 | - if (!isset($_REQUEST['xml'])) |
|
2657 | - loadTemplate('Post'); |
|
2798 | + if (!isset($_REQUEST['xml'])) { |
|
2799 | + loadTemplate('Post'); |
|
2800 | + } |
|
2658 | 2801 | |
2659 | 2802 | include_once($sourcedir . '/Subs-Post.php'); |
2660 | 2803 | |
@@ -2685,8 +2828,9 @@ discard block |
||
2685 | 2828 | $smcFunc['db_free_result']($request); |
2686 | 2829 | |
2687 | 2830 | $context['sub_template'] = 'quotefast'; |
2688 | - if (!empty($row)) |
|
2689 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2831 | + if (!empty($row)) { |
|
2832 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2833 | + } |
|
2690 | 2834 | |
2691 | 2835 | if (!empty($can_view_post)) |
2692 | 2836 | { |
@@ -2719,8 +2863,9 @@ discard block |
||
2719 | 2863 | } |
2720 | 2864 | |
2721 | 2865 | // Remove any nested quotes. |
2722 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2723 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2866 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2867 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2868 | + } |
|
2724 | 2869 | |
2725 | 2870 | $lb = "\n"; |
2726 | 2871 | |
@@ -2746,14 +2891,14 @@ discard block |
||
2746 | 2891 | 'time' => '', |
2747 | 2892 | ), |
2748 | 2893 | ); |
2749 | - } |
|
2750 | - else |
|
2751 | - $context['quote'] = array( |
|
2894 | + } else { |
|
2895 | + $context['quote'] = array( |
|
2752 | 2896 | 'xml' => '', |
2753 | 2897 | 'mozilla' => '', |
2754 | 2898 | 'text' => '', |
2755 | 2899 | ); |
2756 | -} |
|
2900 | + } |
|
2901 | + } |
|
2757 | 2902 | |
2758 | 2903 | /** |
2759 | 2904 | * Used to edit the body or subject of a message inline |
@@ -2765,8 +2910,9 @@ discard block |
||
2765 | 2910 | global $user_info, $context, $smcFunc, $language, $board_info; |
2766 | 2911 | |
2767 | 2912 | // We have to have a topic! |
2768 | - if (empty($topic)) |
|
2769 | - obExit(false); |
|
2913 | + if (empty($topic)) { |
|
2914 | + obExit(false); |
|
2915 | + } |
|
2770 | 2916 | |
2771 | 2917 | checkSession('get'); |
2772 | 2918 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2792,31 +2938,35 @@ discard block |
||
2792 | 2938 | 'guest_id' => 0, |
2793 | 2939 | ) |
2794 | 2940 | ); |
2795 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2796 | - fatal_lang_error('no_board', false); |
|
2941 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2942 | + fatal_lang_error('no_board', false); |
|
2943 | + } |
|
2797 | 2944 | $row = $smcFunc['db_fetch_assoc']($request); |
2798 | 2945 | $smcFunc['db_free_result']($request); |
2799 | 2946 | |
2800 | 2947 | // Change either body or subject requires permissions to modify messages. |
2801 | 2948 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2802 | 2949 | { |
2803 | - if (!empty($row['locked'])) |
|
2804 | - isAllowedTo('moderate_board'); |
|
2950 | + if (!empty($row['locked'])) { |
|
2951 | + isAllowedTo('moderate_board'); |
|
2952 | + } |
|
2805 | 2953 | |
2806 | 2954 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2807 | 2955 | { |
2808 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2809 | - fatal_lang_error('modify_post_time_passed', false); |
|
2810 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2811 | - isAllowedTo('modify_replies'); |
|
2812 | - else |
|
2813 | - isAllowedTo('modify_own'); |
|
2956 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2957 | + fatal_lang_error('modify_post_time_passed', false); |
|
2958 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2959 | + isAllowedTo('modify_replies'); |
|
2960 | + } else { |
|
2961 | + isAllowedTo('modify_own'); |
|
2962 | + } |
|
2814 | 2963 | } |
2815 | 2964 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2816 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2817 | - isAllowedTo('modify_replies'); |
|
2818 | - else |
|
2819 | - isAllowedTo('modify_any'); |
|
2965 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2966 | + isAllowedTo('modify_replies'); |
|
2967 | + } else { |
|
2968 | + isAllowedTo('modify_any'); |
|
2969 | + } |
|
2820 | 2970 | |
2821 | 2971 | // Only log this action if it wasn't your message. |
2822 | 2972 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2828,10 +2978,10 @@ discard block |
||
2828 | 2978 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2829 | 2979 | |
2830 | 2980 | // Maximum number of characters. |
2831 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2832 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2833 | - } |
|
2834 | - elseif (isset($_POST['subject'])) |
|
2981 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2982 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2983 | + } |
|
2984 | + } elseif (isset($_POST['subject'])) |
|
2835 | 2985 | { |
2836 | 2986 | $post_errors[] = 'no_subject'; |
2837 | 2987 | unset($_POST['subject']); |
@@ -2843,13 +2993,11 @@ discard block |
||
2843 | 2993 | { |
2844 | 2994 | $post_errors[] = 'no_message'; |
2845 | 2995 | unset($_POST['message']); |
2846 | - } |
|
2847 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2996 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2848 | 2997 | { |
2849 | 2998 | $post_errors[] = 'long_message'; |
2850 | 2999 | unset($_POST['message']); |
2851 | - } |
|
2852 | - else |
|
3000 | + } else |
|
2853 | 3001 | { |
2854 | 3002 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2855 | 3003 | |
@@ -2865,31 +3013,34 @@ discard block |
||
2865 | 3013 | |
2866 | 3014 | if (isset($_POST['lock'])) |
2867 | 3015 | { |
2868 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2869 | - unset($_POST['lock']); |
|
2870 | - elseif (!allowedTo('lock_any')) |
|
3016 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
3017 | + unset($_POST['lock']); |
|
3018 | + } elseif (!allowedTo('lock_any')) |
|
2871 | 3019 | { |
2872 | - if ($row['locked'] == 1) |
|
2873 | - unset($_POST['lock']); |
|
2874 | - else |
|
2875 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3020 | + if ($row['locked'] == 1) { |
|
3021 | + unset($_POST['lock']); |
|
3022 | + } else { |
|
3023 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
3024 | + } |
|
3025 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
3026 | + unset($_POST['lock']); |
|
3027 | + } else { |
|
3028 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2876 | 3029 | } |
2877 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2878 | - unset($_POST['lock']); |
|
2879 | - else |
|
2880 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2881 | 3030 | } |
2882 | 3031 | |
2883 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2884 | - unset($_POST['sticky']); |
|
3032 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
3033 | + unset($_POST['sticky']); |
|
3034 | + } |
|
2885 | 3035 | |
2886 | 3036 | if (isset($_POST['modify_reason'])) |
2887 | 3037 | { |
2888 | 3038 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2889 | 3039 | |
2890 | 3040 | // Maximum number of characters. |
2891 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2892 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3041 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
3042 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
3043 | + } |
|
2893 | 3044 | } |
2894 | 3045 | |
2895 | 3046 | if (empty($post_errors)) |
@@ -2926,8 +3077,9 @@ discard block |
||
2926 | 3077 | } |
2927 | 3078 | } |
2928 | 3079 | // If nothing was changed there's no need to add an entry to the moderation log. |
2929 | - else |
|
2930 | - $moderationAction = false; |
|
3080 | + else { |
|
3081 | + $moderationAction = false; |
|
3082 | + } |
|
2931 | 3083 | |
2932 | 3084 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2933 | 3085 | |
@@ -2945,9 +3097,9 @@ discard block |
||
2945 | 3097 | // Get the proper (default language) response prefix first. |
2946 | 3098 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2947 | 3099 | { |
2948 | - if ($language === $user_info['language']) |
|
2949 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2950 | - else |
|
3100 | + if ($language === $user_info['language']) { |
|
3101 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3102 | + } else |
|
2951 | 3103 | { |
2952 | 3104 | loadLanguage('index', $language, false); |
2953 | 3105 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2969,8 +3121,9 @@ discard block |
||
2969 | 3121 | ); |
2970 | 3122 | } |
2971 | 3123 | |
2972 | - if (!empty($moderationAction)) |
|
2973 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3124 | + if (!empty($moderationAction)) { |
|
3125 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3126 | + } |
|
2974 | 3127 | } |
2975 | 3128 | |
2976 | 3129 | if (isset($_REQUEST['xml'])) |
@@ -3011,8 +3164,7 @@ discard block |
||
3011 | 3164 | ); |
3012 | 3165 | |
3013 | 3166 | censorText($context['message']['subject']); |
3014 | - } |
|
3015 | - else |
|
3167 | + } else |
|
3016 | 3168 | { |
3017 | 3169 | $context['message'] = array( |
3018 | 3170 | 'id' => $row['id_msg'], |
@@ -3024,15 +3176,16 @@ discard block |
||
3024 | 3176 | loadLanguage('Errors'); |
3025 | 3177 | foreach ($post_errors as $post_error) |
3026 | 3178 | { |
3027 | - if ($post_error == 'long_message') |
|
3028 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3029 | - else |
|
3030 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3179 | + if ($post_error == 'long_message') { |
|
3180 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3181 | + } else { |
|
3182 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3183 | + } |
|
3031 | 3184 | } |
3032 | 3185 | } |
3186 | + } else { |
|
3187 | + obExit(false); |
|
3188 | + } |
|
3033 | 3189 | } |
3034 | - else |
|
3035 | - obExit(false); |
|
3036 | -} |
|
3037 | 3190 | |
3038 | 3191 | ?> |
3039 | 3192 | \ No newline at end of file |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
301 | 305 | $context['default_list'] = 'moderation_log_list'; |
302 | 306 | |
303 | 307 | // If a hook has changed this, respect it. |
304 | - if (!empty($moderation_menu_name)) |
|
305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
306 | - elseif (isset($context['moderation_menu_name'])) |
|
307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | + if (!empty($moderation_menu_name)) { |
|
309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
311 | 315 | ); |
312 | -} |
|
316 | + } |
|
317 | + } |
|
313 | 318 | |
314 | 319 | /** |
315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
413 | 418 | // Add on some of the column stuff info |
414 | 419 | if (!empty($row['id_board'])) |
415 | 420 | { |
416 | - if ($row['action'] == 'move') |
|
417 | - $row['extra']['board_to'] = $row['id_board']; |
|
418 | - else |
|
419 | - $row['extra']['board'] = $row['id_board']; |
|
421 | + if ($row['action'] == 'move') { |
|
422 | + $row['extra']['board_to'] = $row['id_board']; |
|
423 | + } else { |
|
424 | + $row['extra']['board'] = $row['id_board']; |
|
425 | + } |
|
420 | 426 | } |
421 | 427 | |
422 | - if (!empty($row['id_topic'])) |
|
423 | - $row['extra']['topic'] = $row['id_topic']; |
|
424 | - if (!empty($row['id_msg'])) |
|
425 | - $row['extra']['message'] = $row['id_msg']; |
|
428 | + if (!empty($row['id_topic'])) { |
|
429 | + $row['extra']['topic'] = $row['id_topic']; |
|
430 | + } |
|
431 | + if (!empty($row['id_msg'])) { |
|
432 | + $row['extra']['message'] = $row['id_msg']; |
|
433 | + } |
|
426 | 434 | |
427 | 435 | // Is this associated with a topic? |
428 | - if (isset($row['extra']['topic'])) |
|
429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
430 | - if (isset($row['extra']['new_topic'])) |
|
431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
436 | + if (isset($row['extra']['topic'])) { |
|
437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
438 | + } |
|
439 | + if (isset($row['extra']['new_topic'])) { |
|
440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
441 | + } |
|
432 | 442 | |
433 | 443 | // How about a member? |
434 | 444 | if (isset($row['extra']['member'])) |
435 | 445 | { |
436 | 446 | // Guests don't have names! |
437 | - if (empty($row['extra']['member'])) |
|
438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
439 | - else |
|
447 | + if (empty($row['extra']['member'])) { |
|
448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
449 | + } else |
|
440 | 450 | { |
441 | 451 | // Try to find it... |
442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
444 | 454 | } |
445 | 455 | |
446 | 456 | // Associated with a board? |
447 | - if (isset($row['extra']['board_to'])) |
|
448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
449 | - if (isset($row['extra']['board_from'])) |
|
450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
451 | - if (isset($row['extra']['board'])) |
|
452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
457 | + if (isset($row['extra']['board_to'])) { |
|
458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
459 | + } |
|
460 | + if (isset($row['extra']['board_from'])) { |
|
461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
462 | + } |
|
463 | + if (isset($row['extra']['board'])) { |
|
464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
465 | + } |
|
453 | 466 | |
454 | 467 | // A message? |
455 | - if (isset($row['extra']['message'])) |
|
456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
468 | + if (isset($row['extra']['message'])) { |
|
469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
470 | + } |
|
457 | 471 | |
458 | 472 | // IP Info? |
459 | - if (isset($row['extra']['ip_range'])) |
|
460 | - if ($seeIP) |
|
473 | + if (isset($row['extra']['ip_range'])) { |
|
474 | + if ($seeIP) |
|
461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
462 | - else |
|
463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
476 | + } else { |
|
477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
478 | + } |
|
464 | 479 | |
465 | 480 | // Email? |
466 | - if (isset($row['extra']['email'])) |
|
467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
481 | + if (isset($row['extra']['email'])) { |
|
482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
483 | + } |
|
468 | 484 | |
469 | 485 | // Bans are complex. |
470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
471 | 487 | { |
472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
474 | - if (isset($row['extra'][$type])) |
|
489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
490 | + if (isset($row['extra'][$type])) |
|
475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
492 | + } |
|
476 | 493 | } |
477 | 494 | |
478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
508 | 525 | foreach ($boards[$row['id_board']] as $action) |
509 | 526 | { |
510 | 527 | // Make the board number into a link - dealing with moving too. |
511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | } |
519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
547 | 565 | ); |
548 | 566 | |
549 | 567 | // Make the topic number into a link - dealing with splitting too. |
550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
572 | + } |
|
554 | 573 | } |
555 | 574 | } |
556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
583 | 602 | ); |
584 | 603 | |
585 | 604 | // Make the message number into a link. |
586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
607 | + } |
|
588 | 608 | } |
589 | 609 | } |
590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
624 | 644 | foreach ($entries as $k => $entry) |
625 | 645 | { |
626 | 646 | // Make any message info links so its easier to go find that message. |
627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
649 | + } |
|
629 | 650 | |
630 | 651 | // Mark up any deleted members, topics and boards. |
631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
655 | + } |
|
634 | 656 | |
635 | 657 | if (isset($entry['extra']['report'])) |
636 | 658 | { |
637 | 659 | // Member profile reports go in a different area |
638 | - if (stristr($entry['action'], 'user_report')) |
|
639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
640 | - else |
|
641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
660 | + if (stristr($entry['action'], 'user_report')) { |
|
661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
662 | + } else { |
|
663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
664 | + } |
|
642 | 665 | } |
643 | 666 | |
644 | - if (empty($entries[$k]['action_text'])) |
|
645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
667 | + if (empty($entries[$k]['action_text'])) { |
|
668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
669 | + } |
|
646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
647 | 671 | function ($matches) use ($entries, $k) |
648 | 672 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -106,8 +107,9 @@ discard block |
||
106 | 107 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
107 | 108 | |
108 | 109 | // We do not want to output debug information here. |
109 | - if ($this->_js) |
|
110 | - $db_show_debug = false; |
|
110 | + if ($this->_js) { |
|
111 | + $db_show_debug = false; |
|
112 | + } |
|
111 | 113 | } |
112 | 114 | |
113 | 115 | /** |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | $call = $this->_sa; |
142 | 144 | |
143 | 145 | // Guest can only view likes. |
144 | - if ($call != 'view') |
|
145 | - is_not_guest(); |
|
146 | + if ($call != 'view') { |
|
147 | + is_not_guest(); |
|
148 | + } |
|
146 | 149 | |
147 | 150 | checkSession('get'); |
148 | 151 | |
@@ -180,15 +183,17 @@ discard block |
||
180 | 183 | global $smcFunc, $modSettings; |
181 | 184 | |
182 | 185 | // This feature is currently disable. |
183 | - if (empty($modSettings['enable_likes'])) |
|
184 | - return $this->_error = 'like_disable'; |
|
186 | + if (empty($modSettings['enable_likes'])) { |
|
187 | + return $this->_error = 'like_disable'; |
|
188 | + } |
|
185 | 189 | |
186 | 190 | // Zerothly, they did indicate some kind of content to like, right? |
187 | 191 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
188 | 192 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
189 | 193 | |
190 | - if ($this->_type == '' || $this->_content <= 0) |
|
191 | - return $this->_error = 'cannot_'; |
|
194 | + if ($this->_type == '' || $this->_content <= 0) { |
|
195 | + return $this->_error = 'cannot_'; |
|
196 | + } |
|
192 | 197 | |
193 | 198 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
194 | 199 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -207,12 +212,14 @@ discard block |
||
207 | 212 | 'msg' => $this->_content, |
208 | 213 | ) |
209 | 214 | ); |
210 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
211 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
215 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
216 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + } |
|
212 | 218 | |
213 | 219 | $smcFunc['db_free_result']($request); |
214 | - if (empty($this->_idTopic)) |
|
215 | - return $this->_error = 'cannot_'; |
|
220 | + if (empty($this->_idTopic)) { |
|
221 | + return $this->_error = 'cannot_'; |
|
222 | + } |
|
216 | 223 | |
217 | 224 | // So we know what topic it's in and more importantly we know the user can see it. |
218 | 225 | // If we're not viewing, we need some info set up. |
@@ -221,9 +228,7 @@ discard block |
||
221 | 228 | $this->_validLikes['redirect'] = 'topic=' . $this->_idTopic . '.msg' . $this->_content . '#msg' . $this->_content; |
222 | 229 | |
223 | 230 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
224 | - } |
|
225 | - |
|
226 | - else |
|
231 | + } else |
|
227 | 232 | { |
228 | 233 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
229 | 234 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -241,8 +246,9 @@ discard block |
||
241 | 246 | if ($result !== false) |
242 | 247 | { |
243 | 248 | // Match the type with what we already have. |
244 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
245 | - return $this->_error = 'not_valid_like_type'; |
|
249 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
250 | + return $this->_error = 'not_valid_like_type'; |
|
251 | + } |
|
246 | 252 | |
247 | 253 | // Fill out the rest. |
248 | 254 | $this->_type = $result['type']; |
@@ -253,13 +259,15 @@ discard block |
||
253 | 259 | } |
254 | 260 | } |
255 | 261 | |
256 | - if (!$found) |
|
257 | - return $this->_error = 'cannot_'; |
|
262 | + if (!$found) { |
|
263 | + return $this->_error = 'cannot_'; |
|
264 | + } |
|
258 | 265 | } |
259 | 266 | |
260 | 267 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
261 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
262 | - return $this->_error = $this->_validLikes['can_like']; |
|
268 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
269 | + return $this->_error = $this->_validLikes['can_like']; |
|
270 | + } |
|
263 | 271 | } |
264 | 272 | |
265 | 273 | /** |
@@ -284,8 +292,9 @@ discard block |
||
284 | 292 | ); |
285 | 293 | |
286 | 294 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
287 | - if ($this->_sa == __FUNCTION__) |
|
288 | - $this->_data = __FUNCTION__; |
|
295 | + if ($this->_sa == __FUNCTION__) { |
|
296 | + $this->_data = __FUNCTION__; |
|
297 | + } |
|
289 | 298 | } |
290 | 299 | |
291 | 300 | /** |
@@ -315,8 +324,8 @@ discard block |
||
315 | 324 | |
316 | 325 | // Add a background task to process sending alerts. |
317 | 326 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
318 | - if ($this->_type == 'msg') |
|
319 | - $smcFunc['db_insert']('insert', |
|
327 | + if ($this->_type == 'msg') { |
|
328 | + $smcFunc['db_insert']('insert', |
|
320 | 329 | '{db_prefix}background_tasks', |
321 | 330 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
322 | 331 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', $smcFunc['json_encode'](array( |
@@ -328,10 +337,12 @@ discard block |
||
328 | 337 | )), 0), |
329 | 338 | array('id_task') |
330 | 339 | ); |
340 | + } |
|
331 | 341 | |
332 | 342 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
333 | - if ($this->_sa == __FUNCTION__) |
|
334 | - $this->_data = __FUNCTION__; |
|
343 | + if ($this->_sa == __FUNCTION__) { |
|
344 | + $this->_data = __FUNCTION__; |
|
345 | + } |
|
335 | 346 | } |
336 | 347 | |
337 | 348 | /** |
@@ -357,8 +368,9 @@ discard block |
||
357 | 368 | $smcFunc['db_free_result']($request); |
358 | 369 | |
359 | 370 | // If you want to call this directly, fill out _data property too. |
360 | - if ($this->_sa == __FUNCTION__) |
|
361 | - $this->_data = $this->_numLikes; |
|
371 | + if ($this->_sa == __FUNCTION__) { |
|
372 | + $this->_data = $this->_numLikes; |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | |
364 | 376 | /** |
@@ -371,8 +383,9 @@ discard block |
||
371 | 383 | global $smcFunc; |
372 | 384 | |
373 | 385 | // Safety first! |
374 | - if (empty($this->_type) || empty($this->_content)) |
|
375 | - return $this->_error = 'cannot_'; |
|
386 | + if (empty($this->_type) || empty($this->_content)) { |
|
387 | + return $this->_error = 'cannot_'; |
|
388 | + } |
|
376 | 389 | |
377 | 390 | // Do we already like this? |
378 | 391 | $request = $smcFunc['db_query']('', ' |
@@ -390,26 +403,28 @@ discard block |
||
390 | 403 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
391 | 404 | $smcFunc['db_free_result']($request); |
392 | 405 | |
393 | - if ($this->_alreadyLiked) |
|
394 | - $this->delete(); |
|
395 | - |
|
396 | - else |
|
397 | - $this->insert(); |
|
406 | + if ($this->_alreadyLiked) { |
|
407 | + $this->delete(); |
|
408 | + } else { |
|
409 | + $this->insert(); |
|
410 | + } |
|
398 | 411 | |
399 | 412 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
400 | 413 | $this->_count(); |
401 | 414 | |
402 | 415 | // Update the likes count for messages. |
403 | - if ($this->_type == 'msg') |
|
404 | - $this->msgIssueLike(); |
|
416 | + if ($this->_type == 'msg') { |
|
417 | + $this->msgIssueLike(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Any callbacks? |
407 | 421 | elseif (!empty($this->_validLikes['callback'])) |
408 | 422 | { |
409 | 423 | $call = call_helper($this->_validLikes['callback'], true); |
410 | 424 | |
411 | - if (!empty($call)) |
|
412 | - call_user_func_array($call, array($this)); |
|
425 | + if (!empty($call)) { |
|
426 | + call_user_func_array($call, array($this)); |
|
427 | + } |
|
413 | 428 | } |
414 | 429 | |
415 | 430 | // Sometimes there might be other things that need updating after we do this like. |
@@ -418,8 +433,9 @@ discard block |
||
418 | 433 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
419 | 434 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
420 | 435 | // in integrate_valid_likes where it absolutely has to exist. |
421 | - if (!empty($this->_validLikes['flush_cache'])) |
|
422 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
436 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
437 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
438 | + } |
|
423 | 439 | |
424 | 440 | // All done, start building the data to pass as response. |
425 | 441 | $this->_data = array( |
@@ -442,8 +458,9 @@ discard block |
||
442 | 458 | { |
443 | 459 | global $smcFunc; |
444 | 460 | |
445 | - if ($this->_type !== 'msg') |
|
446 | - return; |
|
461 | + if ($this->_type !== 'msg') { |
|
462 | + return; |
|
463 | + } |
|
447 | 464 | |
448 | 465 | $smcFunc['db_query']('', ' |
449 | 466 | UPDATE {db_prefix}messages |
@@ -484,8 +501,9 @@ discard block |
||
484 | 501 | 'like_type' => $this->_type, |
485 | 502 | ) |
486 | 503 | ); |
487 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
488 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
504 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
505 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
506 | + } |
|
489 | 507 | |
490 | 508 | // Now to get member data, including avatars and so on. |
491 | 509 | $members = array_keys($context['likers']); |
@@ -493,8 +511,9 @@ discard block |
||
493 | 511 | if (count($loaded) != count($members)) |
494 | 512 | { |
495 | 513 | $members = array_diff($members, $loaded); |
496 | - foreach ($members as $not_loaded) |
|
497 | - unset ($context['likers'][$not_loaded]); |
|
514 | + foreach ($members as $not_loaded) { |
|
515 | + unset ($context['likers'][$not_loaded]); |
|
516 | + } |
|
498 | 517 | } |
499 | 518 | |
500 | 519 | foreach ($context['likers'] as $liker => $dummy) |
@@ -536,12 +555,14 @@ discard block |
||
536 | 555 | global $context, $txt; |
537 | 556 | |
538 | 557 | // Don't do anything if someone else has already take care of the response. |
539 | - if (!$this->_setResponse) |
|
540 | - return; |
|
558 | + if (!$this->_setResponse) { |
|
559 | + return; |
|
560 | + } |
|
541 | 561 | |
542 | 562 | // Want a json response huh? |
543 | - if ($this->_validLikes['json']) |
|
544 | - return $this->jsonResponse(); |
|
563 | + if ($this->_validLikes['json']) { |
|
564 | + return $this->jsonResponse(); |
|
565 | + } |
|
545 | 566 | |
546 | 567 | // Set everything up for display. |
547 | 568 | loadTemplate('Likes'); |
@@ -551,8 +572,9 @@ discard block |
||
551 | 572 | if ($this->_error) |
552 | 573 | { |
553 | 574 | // If this is a generic error, set it up good. |
554 | - if ($this->_error == 'cannot_') |
|
555 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
575 | + if ($this->_error == 'cannot_') { |
|
576 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
577 | + } |
|
556 | 578 | |
557 | 579 | // Is this request coming from an ajax call? |
558 | 580 | if ($this->_js) |
@@ -562,8 +584,9 @@ discard block |
||
562 | 584 | } |
563 | 585 | |
564 | 586 | // Nope? then just do a redirect to whatever URL was provided. |
565 | - else |
|
566 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
587 | + else { |
|
588 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
589 | + } |
|
567 | 590 | |
568 | 591 | return; |
569 | 592 | } |
@@ -572,8 +595,9 @@ discard block |
||
572 | 595 | else |
573 | 596 | { |
574 | 597 | // Not an ajax request so send the user back to the previous location or the main page. |
575 | - if (!$this->_js) |
|
576 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
598 | + if (!$this->_js) { |
|
599 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
600 | + } |
|
577 | 601 | |
578 | 602 | // These fine gentlemen all share the same template. |
579 | 603 | $generic = array('delete', 'insert', '_count'); |
@@ -606,8 +630,9 @@ discard block |
||
606 | 630 | // If there is an error, send it. |
607 | 631 | if ($this->_error) |
608 | 632 | { |
609 | - if ($this->_error == 'cannot_') |
|
610 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
633 | + if ($this->_error == 'cannot_') { |
|
634 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
635 | + } |
|
611 | 636 | |
612 | 637 | $print['error'] = $this->_error; |
613 | 638 | } |
@@ -643,33 +668,36 @@ discard block |
||
643 | 668 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
644 | 669 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
645 | 670 | |
646 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
647 | - $_GET['verse'] = '4:16'; |
|
671 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
672 | + $_GET['verse'] = '4:16'; |
|
673 | + } |
|
648 | 674 | |
649 | - if ($_GET['verse'] == '2:18') |
|
650 | - echo ' |
|
675 | + if ($_GET['verse'] == '2:18') { |
|
676 | + echo ' |
|
651 | 677 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
652 | - elseif ($_GET['verse'] == '4:16') |
|
653 | - echo ' |
|
678 | + } elseif ($_GET['verse'] == '4:16') { |
|
679 | + echo ' |
|
654 | 680 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
655 | - elseif ($_GET['verse'] == '22:1-2') |
|
656 | - echo ' |
|
681 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
682 | + echo ' |
|
657 | 683 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
658 | 684 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
685 | + } |
|
659 | 686 | |
660 | 687 | echo ' |
661 | 688 | </div> |
662 | 689 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
663 | 690 | |
664 | - if ($_GET['verse'] == '2:18') |
|
665 | - echo ' |
|
691 | + if ($_GET['verse'] == '2:18') { |
|
692 | + echo ' |
|
666 | 693 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
667 | - elseif ($_GET['verse'] == '4:16') |
|
668 | - echo ' |
|
694 | + } elseif ($_GET['verse'] == '4:16') { |
|
695 | + echo ' |
|
669 | 696 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
670 | - elseif ($_GET['verse'] == '22:1-2') |
|
671 | - echo ' |
|
697 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
698 | + echo ' |
|
672 | 699 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
700 | + } |
|
673 | 701 | |
674 | 702 | echo ' |
675 | 703 | </div> |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Interface cache_api_interface |
@@ -182,8 +183,9 @@ discard block |
||
182 | 183 | { |
183 | 184 | global $cache_enable; |
184 | 185 | |
185 | - if ($test) |
|
186 | - return true; |
|
186 | + if ($test) { |
|
187 | + return true; |
|
188 | + } |
|
187 | 189 | return !empty($cache_enable); |
188 | 190 | } |
189 | 191 | |
@@ -202,18 +204,20 @@ discard block |
||
202 | 204 | global $boardurl, $cachedir; |
203 | 205 | |
204 | 206 | // Find a valid good file to do mtime checks on. |
205 | - if (file_exists($cachedir . '/' . 'index.php')) |
|
206 | - $filemtime = $cachedir . '/' . 'index.php'; |
|
207 | - elseif (is_dir($cachedir . '/')) |
|
208 | - $filemtime = $cachedir . '/'; |
|
209 | - else |
|
210 | - $filemtime = $boardurl . '/index.php'; |
|
207 | + if (file_exists($cachedir . '/' . 'index.php')) { |
|
208 | + $filemtime = $cachedir . '/' . 'index.php'; |
|
209 | + } elseif (is_dir($cachedir . '/')) { |
|
210 | + $filemtime = $cachedir . '/'; |
|
211 | + } else { |
|
212 | + $filemtime = $boardurl . '/index.php'; |
|
213 | + } |
|
211 | 214 | |
212 | 215 | // Set the default if no prefix was specified. |
213 | - if (empty($prefix)) |
|
214 | - $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
215 | - else |
|
216 | - $this->prefix = $prefix; |
|
216 | + if (empty($prefix)) { |
|
217 | + $this->prefix = md5($boardurl . filemtime($filemtime)) . '-SMF-'; |
|
218 | + } else { |
|
219 | + $this->prefix = $prefix; |
|
220 | + } |
|
217 | 221 | |
218 | 222 | return true; |
219 | 223 | } |
@@ -276,8 +280,9 @@ discard block |
||
276 | 280 | |
277 | 281 | // Invalidate cache, to be sure! |
278 | 282 | // ... as long as index.php can be modified, anyway. |
279 | - if (is_writable($cachedir . '/' . 'index.php')) |
|
280 | - @touch($cachedir . '/' . 'index.php'); |
|
283 | + if (is_writable($cachedir . '/' . 'index.php')) { |
|
284 | + @touch($cachedir . '/' . 'index.php'); |
|
285 | + } |
|
281 | 286 | |
282 | 287 | return true; |
283 | 288 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Retrieve a list and several other statistics of the users currently online. |
@@ -45,8 +46,9 @@ discard block |
||
45 | 46 | } |
46 | 47 | |
47 | 48 | // Not allowed sort method? Bang! Error! |
48 | - elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) |
|
49 | - trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
49 | + elseif (!in_array($membersOnlineOptions['sort'], $allowed_sort_options)) { |
|
50 | + trigger_error('Sort method for getMembersOnlineStats() function is not allowed', E_USER_NOTICE); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Initialize the array that'll be returned later on. |
52 | 54 | $membersOnlineStats = array( |
@@ -63,8 +65,9 @@ discard block |
||
63 | 65 | // Get any spiders if enabled. |
64 | 66 | $spiders = array(); |
65 | 67 | $spider_finds = array(); |
66 | - if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) |
|
67 | - $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
68 | + if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) { |
|
69 | + $spiders = $smcFunc['json_decode']($modSettings['spider_name_cache'], true); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | // Load the users online right now. |
70 | 73 | $request = $smcFunc['db_query']('', ' |
@@ -92,9 +95,7 @@ discard block |
||
92 | 95 | $membersOnlineStats['num_guests']++; |
93 | 96 | |
94 | 97 | continue; |
95 | - } |
|
96 | - |
|
97 | - elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | + } elseif (empty($row['show_online']) && empty($membersOnlineOptions['show_hidden'])) |
|
98 | 99 | { |
99 | 100 | // Just increase the stats and don't add this hidden user to any list. |
100 | 101 | $membersOnlineStats['num_users_hidden']++; |
@@ -102,10 +103,11 @@ discard block |
||
102 | 103 | } |
103 | 104 | |
104 | 105 | // Some basic color coding... |
105 | - if (!empty($row['online_color'])) |
|
106 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
107 | - else |
|
108 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
106 | + if (!empty($row['online_color'])) { |
|
107 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
108 | + } else { |
|
109 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
110 | + } |
|
109 | 111 | |
110 | 112 | // Buddies get counted and highlighted. |
111 | 113 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
@@ -132,8 +134,8 @@ discard block |
||
132 | 134 | $membersOnlineStats['list_users_online'][$row[$membersOnlineOptions['sort']] . '_' . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
133 | 135 | |
134 | 136 | // Store all distinct (primary) membergroups that are shown. |
135 | - if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) |
|
136 | - $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | + if (!isset($membersOnlineStats['online_groups'][$row['id_group']])) { |
|
138 | + $membersOnlineStats['online_groups'][$row['id_group']] = array( |
|
137 | 139 | 'id' => $row['id_group'], |
138 | 140 | 'name' => $row['group_name'], |
139 | 141 | 'color' => $row['online_color'], |
@@ -141,6 +143,7 @@ discard block |
||
141 | 143 | 'type' => $row['group_type'], |
142 | 144 | 'parent' => $row['id_parent'], |
143 | 145 | ); |
146 | + } |
|
144 | 147 | } |
145 | 148 | $smcFunc['db_free_result']($request); |
146 | 149 | |
@@ -201,11 +204,12 @@ discard block |
||
201 | 204 | $settingsToUpdate = array(); |
202 | 205 | |
203 | 206 | // More members on now than ever were? Update it! |
204 | - if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) |
|
205 | - $settingsToUpdate = array( |
|
207 | + if (!isset($modSettings['mostOnline']) || $total_users_online >= $modSettings['mostOnline']) { |
|
208 | + $settingsToUpdate = array( |
|
206 | 209 | 'mostOnline' => $total_users_online, |
207 | 210 | 'mostDate' => time() |
208 | 211 | ); |
212 | + } |
|
209 | 213 | |
210 | 214 | $date = strftime('%Y-%m-%d', forum_time(false)); |
211 | 215 | |
@@ -237,8 +241,9 @@ discard block |
||
237 | 241 | { |
238 | 242 | list ($modSettings['mostOnlineToday']) = $smcFunc['db_fetch_row']($request); |
239 | 243 | |
240 | - if ($total_users_online > $modSettings['mostOnlineToday']) |
|
241 | - trackStats(array('most_on' => $total_users_online)); |
|
244 | + if ($total_users_online > $modSettings['mostOnlineToday']) { |
|
245 | + trackStats(array('most_on' => $total_users_online)); |
|
246 | + } |
|
242 | 247 | |
243 | 248 | $total_users_online = max($total_users_online, $modSettings['mostOnlineToday']); |
244 | 249 | } |
@@ -255,8 +260,9 @@ discard block |
||
255 | 260 | $settingsToUpdate['mostOnlineToday'] = $total_users_online; |
256 | 261 | } |
257 | 262 | |
258 | - if (!empty($settingsToUpdate)) |
|
259 | - updateSettings($settingsToUpdate); |
|
260 | -} |
|
263 | + if (!empty($settingsToUpdate)) { |
|
264 | + updateSettings($settingsToUpdate); |
|
265 | + } |
|
266 | + } |
|
261 | 267 | |
262 | 268 | ?> |
263 | 269 | \ No newline at end of file |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | echo ' |
74 | 74 | <div class="main_container"> |
75 | - <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '','" id="category_', $category['id'], '"> |
|
75 | + <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '', '" id="category_', $category['id'], '"> |
|
76 | 76 | <h3 class="catbg">'; |
77 | 77 | |
78 | 78 | // If this category even can collapse, show a link to collapse it. |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | foreach ($board['children'] as $child) |
248 | 248 | { |
249 | 249 | if (!$child['is_redirect']) |
250 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
250 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
251 | 251 | else |
252 | 252 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
253 | 253 |
@@ -31,9 +31,10 @@ discard block |
||
31 | 31 | echo ' |
32 | 32 | <ul id="smf_slider" class="roundframe">'; |
33 | 33 | |
34 | - foreach ($context['news_lines'] as $news) |
|
35 | - echo ' |
|
34 | + foreach ($context['news_lines'] as $news) { |
|
35 | + echo ' |
|
36 | 36 | <li>', $news, '</li>'; |
37 | + } |
|
37 | 38 | |
38 | 39 | echo ' |
39 | 40 | </ul> |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | foreach ($context['categories'] as $category) |
66 | 67 | { |
67 | 68 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
68 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
69 | - continue; |
|
69 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
70 | + continue; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | echo ' |
72 | 74 | <div class="main_container"> |
@@ -74,9 +76,10 @@ discard block |
||
74 | 76 | <h3 class="catbg">'; |
75 | 77 | |
76 | 78 | // If this category even can collapse, show a link to collapse it. |
77 | - if ($category['can_collapse']) |
|
78 | - echo ' |
|
79 | + if ($category['can_collapse']) { |
|
80 | + echo ' |
|
79 | 81 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
82 | + } |
|
80 | 83 | |
81 | 84 | echo ' |
82 | 85 | ', $category['link'], ' |
@@ -106,10 +109,11 @@ discard block |
||
106 | 109 | </div>'; |
107 | 110 | |
108 | 111 | // Won't somebody think of the children! |
109 | - if (function_exists('template_bi_' . $board['type'] . '_children')) |
|
110 | - call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
111 | - else |
|
112 | - template_bi_board_children($board); |
|
112 | + if (function_exists('template_bi_' . $board['type'] . '_children')) { |
|
113 | + call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
114 | + } else { |
|
115 | + template_bi_board_children($board); |
|
116 | + } |
|
113 | 117 | |
114 | 118 | echo ' |
115 | 119 | </div><!-- #board_[id] -->'; |
@@ -124,12 +128,13 @@ discard block |
||
124 | 128 | </div><!-- #boardindex_table -->'; |
125 | 129 | |
126 | 130 | // Show the mark all as read button? |
127 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
128 | - echo ' |
|
131 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
132 | + echo ' |
|
129 | 133 | <div class="mark_read"> |
130 | 134 | ', template_button_strip($context['mark_read_button'], 'right'), ' |
131 | 135 | </div>'; |
132 | -} |
|
136 | + } |
|
137 | + } |
|
133 | 138 | |
134 | 139 | /** |
135 | 140 | * Outputs the board icon for a standard board. |
@@ -173,18 +178,20 @@ discard block |
||
173 | 178 | </a>'; |
174 | 179 | |
175 | 180 | // Has it outstanding posts for approval? |
176 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
177 | - echo ' |
|
181 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
182 | + echo ' |
|
178 | 183 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
184 | + } |
|
179 | 185 | |
180 | 186 | echo ' |
181 | 187 | <p class="board_description">', $board['description'], '</p>'; |
182 | 188 | |
183 | 189 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
184 | - if (!empty($board['link_moderators'])) |
|
185 | - echo ' |
|
190 | + if (!empty($board['link_moderators'])) { |
|
191 | + echo ' |
|
186 | 192 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
187 | -} |
|
193 | + } |
|
194 | + } |
|
188 | 195 | |
189 | 196 | /** |
190 | 197 | * Outputs the board stats for a standard board. |
@@ -225,10 +232,11 @@ discard block |
||
225 | 232 | */ |
226 | 233 | function template_bi_board_lastpost($board) |
227 | 234 | { |
228 | - if (!empty($board['last_post']['id'])) |
|
229 | - echo ' |
|
235 | + if (!empty($board['last_post']['id'])) { |
|
236 | + echo ' |
|
230 | 237 | <p>', $board['last_post']['last_post_message'], '</p>'; |
231 | -} |
|
238 | + } |
|
239 | + } |
|
232 | 240 | |
233 | 241 | /** |
234 | 242 | * Outputs the board children for a standard board. |
@@ -248,14 +256,16 @@ discard block |
||
248 | 256 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
249 | 257 | foreach ($board['children'] as $child) |
250 | 258 | { |
251 | - if (!$child['is_redirect']) |
|
252 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
253 | - else |
|
254 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
259 | + if (!$child['is_redirect']) { |
|
260 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
261 | + } else { |
|
262 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
263 | + } |
|
255 | 264 | |
256 | 265 | // Has it posts awaiting approval? |
257 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
258 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
266 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
267 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
268 | + } |
|
259 | 269 | |
260 | 270 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
261 | 271 | } |
@@ -282,8 +292,9 @@ discard block |
||
282 | 292 | { |
283 | 293 | global $context, $options, $txt; |
284 | 294 | |
285 | - if (empty($context['info_center'])) |
|
286 | - return; |
|
295 | + if (empty($context['info_center'])) { |
|
296 | + return; |
|
297 | + } |
|
287 | 298 | |
288 | 299 | // Here's where the "Info Center" starts... |
289 | 300 | echo ' |
@@ -383,14 +394,15 @@ discard block |
||
383 | 394 | /* Each post in latest_posts has: |
384 | 395 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
385 | 396 | subject, short_subject (shortened with...), time, link, and href. */ |
386 | - foreach ($context['latest_posts'] as $post) |
|
387 | - echo ' |
|
397 | + foreach ($context['latest_posts'] as $post) { |
|
398 | + echo ' |
|
388 | 399 | <tr class="windowbg"> |
389 | 400 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
390 | 401 | <td class="recentposter">', $post['poster']['link'], '</td> |
391 | 402 | <td class="recentboard">', $post['board']['link'], '</td> |
392 | 403 | <td class="recenttime">', $post['time'], '</td> |
393 | 404 | </tr>'; |
405 | + } |
|
394 | 406 | echo ' |
395 | 407 | </table>'; |
396 | 408 | } |
@@ -414,11 +426,12 @@ discard block |
||
414 | 426 | </div>'; |
415 | 427 | |
416 | 428 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P |
417 | - if (!empty($context['calendar_holidays'])) |
|
418 | - echo ' |
|
429 | + if (!empty($context['calendar_holidays'])) { |
|
430 | + echo ' |
|
419 | 431 | <p class="inline holiday"> |
420 | 432 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), ' |
421 | 433 | </p>'; |
434 | + } |
|
422 | 435 | |
423 | 436 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
424 | 437 | if (!empty($context['calendar_birthdays'])) |
@@ -428,9 +441,10 @@ discard block |
||
428 | 441 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
429 | 442 | |
430 | 443 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
431 | - foreach ($context['calendar_birthdays'] as $member) |
|
432 | - echo ' |
|
444 | + foreach ($context['calendar_birthdays'] as $member) { |
|
445 | + echo ' |
|
433 | 446 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
447 | + } |
|
434 | 448 | |
435 | 449 | echo ' |
436 | 450 | </p>'; |
@@ -445,9 +459,10 @@ discard block |
||
445 | 459 | |
446 | 460 | // Each event in calendar_events should have: |
447 | 461 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
448 | - foreach ($context['calendar_events'] as $event) |
|
449 | - echo ' |
|
462 | + foreach ($context['calendar_events'] as $event) { |
|
463 | + echo ' |
|
450 | 464 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
465 | + } |
|
451 | 466 | echo ' |
452 | 467 | </p>'; |
453 | 468 | } |
@@ -493,17 +508,21 @@ discard block |
||
493 | 508 | // Handle hidden users and buddies. |
494 | 509 | $bracketList = array(); |
495 | 510 | |
496 | - if ($context['show_buddies']) |
|
497 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
511 | + if ($context['show_buddies']) { |
|
512 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
513 | + } |
|
498 | 514 | |
499 | - if (!empty($context['num_spiders'])) |
|
500 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
515 | + if (!empty($context['num_spiders'])) { |
|
516 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
517 | + } |
|
501 | 518 | |
502 | - if (!empty($context['num_users_hidden'])) |
|
503 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
519 | + if (!empty($context['num_users_hidden'])) { |
|
520 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
521 | + } |
|
504 | 522 | |
505 | - if (!empty($bracketList)) |
|
506 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
523 | + if (!empty($bracketList)) { |
|
524 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
525 | + } |
|
507 | 526 | |
508 | 527 | echo $context['show_who'] ? '</a>' : '', ' |
509 | 528 | |
@@ -517,9 +536,10 @@ discard block |
||
517 | 536 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
518 | 537 | |
519 | 538 | // Showing membergroups? |
520 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
521 | - echo ' |
|
539 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
540 | + echo ' |
|
522 | 541 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
542 | + } |
|
523 | 543 | } |
524 | 544 | |
525 | 545 | echo ' |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Main dispatcher. This function checks permissions and passes control through to the relevant section. |
@@ -245,8 +246,9 @@ discard block |
||
245 | 246 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
246 | 247 | { |
247 | 248 | // Private PM/email subjects and similar shouldn't be shown in the mailbox area. |
248 | - if (!empty($row['private'])) |
|
249 | - $row['subject'] = $txt['personal_message']; |
|
249 | + if (!empty($row['private'])) { |
|
250 | + $row['subject'] = $txt['personal_message']; |
|
251 | + } |
|
250 | 252 | |
251 | 253 | $mails[] = $row; |
252 | 254 | } |
@@ -300,8 +302,9 @@ discard block |
||
300 | 302 | $element = substr($key, strrpos($key, '_') + 1); |
301 | 303 | $processedBirthdayEmails[$index][$element] = $value; |
302 | 304 | } |
303 | - foreach ($processedBirthdayEmails as $index => $dummy) |
|
304 | - $emails[$index] = $index; |
|
305 | + foreach ($processedBirthdayEmails as $index => $dummy) { |
|
306 | + $emails[$index] = $index; |
|
307 | + } |
|
305 | 308 | |
306 | 309 | $config_vars = array( |
307 | 310 | // Mail queue stuff, this rocks ;) |
@@ -322,8 +325,9 @@ discard block |
||
322 | 325 | |
323 | 326 | call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); |
324 | 327 | |
325 | - if ($return_config) |
|
326 | - return $config_vars; |
|
328 | + if ($return_config) { |
|
329 | + return $config_vars; |
|
330 | + } |
|
327 | 331 | |
328 | 332 | // Saving? |
329 | 333 | if (isset($_GET['save'])) |
@@ -398,9 +402,9 @@ discard block |
||
398 | 402 | ); |
399 | 403 | list ($_GET['te']) = $smcFunc['db_fetch_row']($request); |
400 | 404 | $smcFunc['db_free_result']($request); |
405 | + } else { |
|
406 | + $_GET['te'] = (int) $_GET['te']; |
|
401 | 407 | } |
402 | - else |
|
403 | - $_GET['te'] = (int) $_GET['te']; |
|
404 | 408 | |
405 | 409 | $_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0; |
406 | 410 | |
@@ -424,12 +428,14 @@ discard block |
||
424 | 428 | |
425 | 429 | // Try get more time... |
426 | 430 | @set_time_limit(600); |
427 | - if (function_exists('apache_reset_timeout')) |
|
428 | - @apache_reset_timeout(); |
|
431 | + if (function_exists('apache_reset_timeout')) { |
|
432 | + @apache_reset_timeout(); |
|
433 | + } |
|
429 | 434 | |
430 | 435 | // Have we already used our maximum time? |
431 | - if ((time() - $time_start) < 5) |
|
432 | - return; |
|
436 | + if ((time() - $time_start) < 5) { |
|
437 | + return; |
|
438 | + } |
|
433 | 439 | |
434 | 440 | $context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
435 | 441 | $context['page_title'] = $txt['not_done_title']; |
@@ -459,8 +465,9 @@ discard block |
||
459 | 465 | { |
460 | 466 | global $txt; |
461 | 467 | |
462 | - if ($time_diff < 0) |
|
463 | - $time_diff = 0; |
|
468 | + if ($time_diff < 0) { |
|
469 | + $time_diff = 0; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | // Just do a bit of an if fest... |
466 | 473 | if ($time_diff > 86400) |
@@ -481,8 +488,9 @@ discard block |
||
481 | 488 | return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes); |
482 | 489 | } |
483 | 490 | // Otherwise must be second |
484 | - else |
|
485 | - return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
486 | -} |
|
491 | + else { |
|
492 | + return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff); |
|
493 | + } |
|
494 | + } |
|
487 | 495 | |
488 | 496 | ?> |
489 | 497 | \ No newline at end of file |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $table = str_replace('{db_prefix}', $db_prefix, $table); |
93 | 93 | |
94 | - $pg_tables = array('pg_catalog','information_schema'); |
|
94 | + $pg_tables = array('pg_catalog', 'information_schema'); |
|
95 | 95 | |
96 | 96 | $request = $smcFunc['db_query']('', ' |
97 | 97 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | global $db_connection; |
291 | 291 | static $ver; |
292 | 292 | |
293 | - if(!empty($ver)) |
|
293 | + if (!empty($ver)) |
|
294 | 294 | return $ver; |
295 | 295 | |
296 | 296 | $ver = pg_version($db_connection)['server']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -33,7 +34,8 @@ discard block |
||
33 | 34 | 'db_get_vendor' => 'smf_db_get_vendor', |
34 | 35 | 'db_allow_persistent' => 'smf_db_allow_persistent', |
35 | 36 | ); |
36 | -} |
|
37 | + } |
|
38 | + } |
|
37 | 39 | |
38 | 40 | /** |
39 | 41 | * Backup $table to $backup_table. |
@@ -49,13 +51,14 @@ discard block |
||
49 | 51 | |
50 | 52 | // Do we need to drop it first? |
51 | 53 | $tables = smf_db_list_tables(false, $backup_table); |
52 | - if (!empty($tables)) |
|
53 | - $smcFunc['db_query']('', ' |
|
54 | + if (!empty($tables)) { |
|
55 | + $smcFunc['db_query']('', ' |
|
54 | 56 | DROP TABLE {raw:backup_table}', |
55 | 57 | array( |
56 | 58 | 'backup_table' => $backup_table, |
57 | 59 | ) |
58 | 60 | ); |
61 | + } |
|
59 | 62 | |
60 | 63 | /** |
61 | 64 | * @todo Should we create backups of sequences as well? |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | ) |
119 | 122 | ); |
120 | 123 | |
121 | - if (!$request) |
|
122 | - return -1; |
|
124 | + if (!$request) { |
|
125 | + return -1; |
|
126 | + } |
|
123 | 127 | |
124 | 128 | $request = $smcFunc['db_query']('', ' |
125 | 129 | SELECT pg_relation_size(C.oid) AS "size" |
@@ -137,11 +141,12 @@ discard block |
||
137 | 141 | $row = $smcFunc['db_fetch_assoc']($request); |
138 | 142 | $smcFunc['db_free_result']($request); |
139 | 143 | |
140 | - if (isset($row['size'])) |
|
141 | - return ($old_size - $row['size']) / 1024; |
|
142 | - else |
|
143 | - return 0; |
|
144 | -} |
|
144 | + if (isset($row['size'])) { |
|
145 | + return ($old_size - $row['size']) / 1024; |
|
146 | + } else { |
|
147 | + return 0; |
|
148 | + } |
|
149 | + } |
|
145 | 150 | |
146 | 151 | /** |
147 | 152 | * This function lists all tables in the database. |
@@ -168,8 +173,9 @@ discard block |
||
168 | 173 | ); |
169 | 174 | |
170 | 175 | $tables = array(); |
171 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
172 | - $tables[] = $row[0]; |
|
176 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
177 | + $tables[] = $row[0]; |
|
178 | + } |
|
173 | 179 | $smcFunc['db_free_result']($request); |
174 | 180 | |
175 | 181 | return $tables; |
@@ -210,12 +216,14 @@ discard block |
||
210 | 216 | ); |
211 | 217 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
212 | 218 | { |
213 | - if ($row['data_type'] == 'character varying') |
|
214 | - $row['data_type'] = 'varchar'; |
|
215 | - elseif ($row['data_type'] == 'character') |
|
216 | - $row['data_type'] = 'char'; |
|
217 | - if ($row['character_maximum_length']) |
|
218 | - $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
219 | + if ($row['data_type'] == 'character varying') { |
|
220 | + $row['data_type'] = 'varchar'; |
|
221 | + } elseif ($row['data_type'] == 'character') { |
|
222 | + $row['data_type'] = 'char'; |
|
223 | + } |
|
224 | + if ($row['character_maximum_length']) { |
|
225 | + $row['data_type'] .= '(' . $row['character_maximum_length'] . ')'; |
|
226 | + } |
|
219 | 227 | |
220 | 228 | // Make the CREATE for this column. |
221 | 229 | $schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : ''); |
@@ -266,13 +274,14 @@ discard block |
||
266 | 274 | { |
267 | 275 | if ($row['is_primary']) |
268 | 276 | { |
269 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
270 | - continue; |
|
277 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
278 | + continue; |
|
279 | + } |
|
271 | 280 | |
272 | 281 | $index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");'; |
282 | + } else { |
|
283 | + $index_create .= $crlf . $row['inddef'] . ';'; |
|
273 | 284 | } |
274 | - else |
|
275 | - $index_create .= $crlf . $row['inddef'] . ';'; |
|
276 | 285 | } |
277 | 286 | $smcFunc['db_free_result']($result); |
278 | 287 | |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | global $db_connection; |
292 | 301 | static $ver; |
293 | 302 | |
294 | - if(!empty($ver)) |
|
295 | - return $ver; |
|
303 | + if(!empty($ver)) { |
|
304 | + return $ver; |
|
305 | + } |
|
296 | 306 | |
297 | 307 | $ver = pg_version($db_connection)['server']; |
298 | 308 | |
@@ -317,10 +327,11 @@ discard block |
||
317 | 327 | function smf_db_allow_persistent() |
318 | 328 | { |
319 | 329 | $value = ini_get('pgsql.allow_persistent'); |
320 | - if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') |
|
321 | - return true; |
|
322 | - else |
|
323 | - return false; |
|
324 | -} |
|
330 | + if (strtolower($value) == 'on' || strtolower($value) == 'true' || $value == '1') { |
|
331 | + return true; |
|
332 | + } else { |
|
333 | + return false; |
|
334 | + } |
|
335 | + } |
|
325 | 336 | |
326 | 337 | ?> |
327 | 338 | \ No newline at end of file |