@@ -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 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '1004-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '1004-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '1004-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '1004-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
882 | 921 | if ($context['user']['is_owner']) |
883 | 922 | { |
884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
924 | + } else { |
|
925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
885 | 926 | } |
886 | - else |
|
887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
888 | 927 | |
889 | 928 | // Arrays of all the changes - makes things easier. |
890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
895 | 934 | 'ignore_boards', |
896 | 935 | ); |
897 | 936 | |
898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
899 | - $_POST['ignore_brd'] = array(); |
|
937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
938 | + $_POST['ignore_brd'] = array(); |
|
939 | + } |
|
900 | 940 | |
901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
902 | 942 | if (isset($_POST['ignore_brd'])) |
903 | 943 | { |
904 | - if (!is_array($_POST['ignore_brd'])) |
|
905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
944 | + if (!is_array($_POST['ignore_brd'])) { |
|
945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
946 | + } |
|
906 | 947 | |
907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
908 | 949 | { |
909 | 950 | $d = (int) $d; |
910 | - if ($d != 0) |
|
911 | - $_POST['ignore_brd'][$k] = $d; |
|
912 | - else |
|
913 | - unset($_POST['ignore_brd'][$k]); |
|
951 | + if ($d != 0) { |
|
952 | + $_POST['ignore_brd'][$k] = $d; |
|
953 | + } else { |
|
954 | + unset($_POST['ignore_brd'][$k]); |
|
955 | + } |
|
914 | 956 | } |
915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
924 | 966 | //makeAvatarChanges($memID, $post_errors); |
925 | 967 | |
926 | - if (!empty($_REQUEST['sa'])) |
|
927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
968 | + if (!empty($_REQUEST['sa'])) { |
|
969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
970 | + } |
|
928 | 971 | |
929 | - foreach ($profile_bools as $var) |
|
930 | - if (isset($_POST[$var])) |
|
972 | + foreach ($profile_bools as $var) { |
|
973 | + if (isset($_POST[$var])) |
|
931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
932 | - foreach ($profile_ints as $var) |
|
933 | - if (isset($_POST[$var])) |
|
975 | + } |
|
976 | + foreach ($profile_ints as $var) { |
|
977 | + if (isset($_POST[$var])) |
|
934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
935 | - foreach ($profile_floats as $var) |
|
936 | - if (isset($_POST[$var])) |
|
979 | + } |
|
980 | + foreach ($profile_floats as $var) { |
|
981 | + if (isset($_POST[$var])) |
|
937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
938 | - foreach ($profile_strings as $var) |
|
939 | - if (isset($_POST[$var])) |
|
983 | + } |
|
984 | + foreach ($profile_strings as $var) { |
|
985 | + if (isset($_POST[$var])) |
|
940 | 986 | $profile_vars[$var] = $_POST[$var]; |
987 | + } |
|
941 | 988 | } |
942 | 989 | } |
943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
971 | 1018 | ); |
972 | 1019 | |
973 | 1020 | // Can't change reserved vars. |
974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
975 | - fatal_lang_error('no_access', false); |
|
1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1022 | + fatal_lang_error('no_access', false); |
|
1023 | + } |
|
976 | 1024 | |
977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
984 | 1032 | ) |
985 | 1033 | ); |
986 | 1034 | $custom_fields = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $custom_fields[] = $row['col_name']; |
|
1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1036 | + $custom_fields[] = $row['col_name']; |
|
1037 | + } |
|
989 | 1038 | $smcFunc['db_free_result']($request); |
990 | 1039 | |
991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
994 | 1043 | { |
995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
996 | 1045 | { |
997 | - if (in_array($opt, $custom_fields)) |
|
998 | - continue; |
|
1046 | + if (in_array($opt, $custom_fields)) { |
|
1047 | + continue; |
|
1048 | + } |
|
999 | 1049 | |
1000 | 1050 | // These need to be controlled. |
1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1002 | - $val = max(0, min($val, 50)); |
|
1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1052 | + $val = max(0, min($val, 50)); |
|
1053 | + } |
|
1003 | 1054 | // We don't set this per theme anymore. |
1004 | - elseif ($opt == 'allow_no_censored') |
|
1005 | - continue; |
|
1055 | + elseif ($opt == 'allow_no_censored') { |
|
1056 | + continue; |
|
1057 | + } |
|
1006 | 1058 | |
1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1008 | 1060 | } |
1009 | 1061 | } |
1010 | 1062 | |
1011 | 1063 | $erase_options = array(); |
1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1014 | 1066 | { |
1015 | 1067 | if (in_array($opt, $custom_fields)) |
1016 | 1068 | continue; |
1069 | + } |
|
1017 | 1070 | |
1018 | 1071 | // These need to be controlled. |
1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1020 | - $val = max(0, min($val, 50)); |
|
1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1073 | + $val = max(0, min($val, 50)); |
|
1074 | + } |
|
1021 | 1075 | // Only let admins and owners change the censor. |
1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1023 | - continue; |
|
1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1077 | + continue; |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
1056 | 1111 | |
1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1059 | - foreach ($themes as $t) |
|
1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1114 | + foreach ($themes as $t) { |
|
1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1116 | + } |
|
1061 | 1117 | } |
1062 | 1118 | } |
1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1077 | 1133 | { |
1078 | 1134 | // Make sure only integers are deleted. |
1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1137 | + } |
|
1081 | 1138 | |
1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
1096 | 1153 | // We are editing topic notifications...... |
1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1098 | 1155 | { |
1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1158 | + } |
|
1101 | 1159 | |
1102 | 1160 | // Make sure there are no zeros left. |
1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
1111 | 1169 | 'selected_member' => $memID, |
1112 | 1170 | ) |
1113 | 1171 | ); |
1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1174 | + } |
|
1116 | 1175 | } |
1117 | 1176 | |
1118 | 1177 | // We are removing topic preferences |
1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1120 | 1179 | { |
1121 | 1180 | $prefs = array(); |
1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
1183 | + } |
|
1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
1125 | 1185 | } |
1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1129 | 1189 | { |
1130 | 1190 | $prefs = array(); |
1131 | - foreach ($_POST['notify_boards'] as $board) |
|
1132 | - $prefs[] = 'board_notify_' . $board; |
|
1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
1192 | + $prefs[] = 'board_notify_' . $board; |
|
1193 | + } |
|
1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
1134 | 1195 | } |
1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
1150 | 1211 | |
1151 | 1212 | $errors = array(); |
1152 | 1213 | |
1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1216 | + } |
|
1155 | 1217 | |
1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1157 | 1219 | |
@@ -1176,26 +1238,29 @@ discard block |
||
1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1178 | 1240 | */ |
1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1180 | - continue; |
|
1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1242 | + continue; |
|
1243 | + } |
|
1181 | 1244 | |
1182 | 1245 | // Validate the user data. |
1183 | - if ($row['field_type'] == 'check') |
|
1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1246 | + if ($row['field_type'] == 'check') { |
|
1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1186 | 1249 | { |
1187 | 1250 | $value = $row['default_value']; |
1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1190 | 1253 | $value = $v; |
1254 | + } |
|
1191 | 1255 | } |
1192 | 1256 | // Otherwise some form of text! |
1193 | 1257 | else |
1194 | 1258 | { |
1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1196 | 1260 | |
1197 | - if ($row['field_length']) |
|
1198 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1261 | + if ($row['field_length']) { |
|
1262 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1263 | + } |
|
1199 | 1264 | |
1200 | 1265 | // Any masks? |
1201 | 1266 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
@@ -1204,36 +1269,34 @@ discard block |
||
1204 | 1269 | $valueReference = un_htmlspecialchars($value); |
1205 | 1270 | |
1206 | 1271 | // Try and avoid some checks. '0' could be a valid non-empty value. |
1207 | - if (empty($value) && !is_numeric($value)) |
|
1208 | - $value = ''; |
|
1272 | + if (empty($value) && !is_numeric($value)) { |
|
1273 | + $value = ''; |
|
1274 | + } |
|
1209 | 1275 | |
1210 | 1276 | if ($row['mask'] == 'nohtml' && ($valueReference != strip_tags($valueReference) || $value != filter_var($value, FILTER_SANITIZE_STRING) || preg_match('/<(.+?)[\s]*\/?[\s]*>/si', $valueReference))) |
1211 | 1277 | { |
1212 | - if ($returnErrors) |
|
1213 | - $errors[] = 'custom_field_nohtml_fail'; |
|
1214 | - |
|
1215 | - else |
|
1216 | - $value = ''; |
|
1217 | - } |
|
1218 | - elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1278 | + if ($returnErrors) { |
|
1279 | + $errors[] = 'custom_field_nohtml_fail'; |
|
1280 | + } else { |
|
1281 | + $value = ''; |
|
1282 | + } |
|
1283 | + } elseif ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
1219 | 1284 | { |
1220 | - if ($returnErrors) |
|
1221 | - $errors[] = 'custom_field_mail_fail'; |
|
1222 | - |
|
1223 | - else |
|
1224 | - $value = ''; |
|
1225 | - } |
|
1226 | - elseif ($row['mask'] == 'number') |
|
1285 | + if ($returnErrors) { |
|
1286 | + $errors[] = 'custom_field_mail_fail'; |
|
1287 | + } else { |
|
1288 | + $value = ''; |
|
1289 | + } |
|
1290 | + } elseif ($row['mask'] == 'number') |
|
1227 | 1291 | { |
1228 | 1292 | $value = (int) $value; |
1229 | - } |
|
1230 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1293 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1231 | 1294 | { |
1232 | - if ($returnErrors) |
|
1233 | - $errors[] = 'custom_field_regex_fail'; |
|
1234 | - |
|
1235 | - else |
|
1236 | - $value = ''; |
|
1295 | + if ($returnErrors) { |
|
1296 | + $errors[] = 'custom_field_regex_fail'; |
|
1297 | + } else { |
|
1298 | + $value = ''; |
|
1299 | + } |
|
1237 | 1300 | } |
1238 | 1301 | |
1239 | 1302 | unset($valueReference); |
@@ -1261,8 +1324,9 @@ discard block |
||
1261 | 1324 | |
1262 | 1325 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1263 | 1326 | |
1264 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1265 | - $errors = array_merge($errors, $hook_errors); |
|
1327 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1328 | + $errors = array_merge($errors, $hook_errors); |
|
1329 | + } |
|
1266 | 1330 | |
1267 | 1331 | // Make those changes! |
1268 | 1332 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1280,9 +1344,10 @@ discard block |
||
1280 | 1344 | } |
1281 | 1345 | } |
1282 | 1346 | |
1283 | - if ($returnErrors) |
|
1284 | - return $errors; |
|
1285 | -} |
|
1347 | + if ($returnErrors) { |
|
1348 | + return $errors; |
|
1349 | + } |
|
1350 | + } |
|
1286 | 1351 | |
1287 | 1352 | /** |
1288 | 1353 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1294,8 +1359,9 @@ discard block |
||
1294 | 1359 | global $context, $txt, $modSettings; |
1295 | 1360 | |
1296 | 1361 | // Do a quick check to ensure people aren't getting here illegally! |
1297 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1298 | - fatal_lang_error('no_access', false); |
|
1362 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1363 | + fatal_lang_error('no_access', false); |
|
1364 | + } |
|
1299 | 1365 | |
1300 | 1366 | // Can we email the user direct? |
1301 | 1367 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1325,9 +1391,10 @@ discard block |
||
1325 | 1391 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1326 | 1392 | $call = call_helper($subActions[$context['list_area']][0], true); |
1327 | 1393 | |
1328 | - if (!empty($call)) |
|
1329 | - call_user_func($call, $memID); |
|
1330 | -} |
|
1394 | + if (!empty($call)) { |
|
1395 | + call_user_func($call, $memID); |
|
1396 | + } |
|
1397 | + } |
|
1331 | 1398 | |
1332 | 1399 | /** |
1333 | 1400 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1341,9 +1408,10 @@ discard block |
||
1341 | 1408 | |
1342 | 1409 | // For making changes! |
1343 | 1410 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1344 | - foreach ($buddiesArray as $k => $dummy) |
|
1345 | - if ($dummy == '') |
|
1411 | + foreach ($buddiesArray as $k => $dummy) { |
|
1412 | + if ($dummy == '') |
|
1346 | 1413 | unset($buddiesArray[$k]); |
1414 | + } |
|
1347 | 1415 | |
1348 | 1416 | // Removing a buddy? |
1349 | 1417 | if (isset($_GET['remove'])) |
@@ -1355,10 +1423,11 @@ discard block |
||
1355 | 1423 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1356 | 1424 | |
1357 | 1425 | // Heh, I'm lazy, do it the easy way... |
1358 | - foreach ($buddiesArray as $key => $buddy) |
|
1359 | - if ($buddy == (int) $_GET['remove']) |
|
1426 | + foreach ($buddiesArray as $key => $buddy) { |
|
1427 | + if ($buddy == (int) $_GET['remove']) |
|
1360 | 1428 | { |
1361 | 1429 | unset($buddiesArray[$key]); |
1430 | + } |
|
1362 | 1431 | $_SESSION['prf-save'] = true; |
1363 | 1432 | } |
1364 | 1433 | |
@@ -1368,8 +1437,7 @@ discard block |
||
1368 | 1437 | |
1369 | 1438 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1370 | 1439 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1371 | - } |
|
1372 | - elseif (isset($_POST['new_buddy'])) |
|
1440 | + } elseif (isset($_POST['new_buddy'])) |
|
1373 | 1441 | { |
1374 | 1442 | checkSession(); |
1375 | 1443 | |
@@ -1382,8 +1450,9 @@ discard block |
||
1382 | 1450 | { |
1383 | 1451 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1384 | 1452 | |
1385 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1386 | - unset($new_buddies[$k]); |
|
1453 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1454 | + unset($new_buddies[$k]); |
|
1455 | + } |
|
1387 | 1456 | } |
1388 | 1457 | |
1389 | 1458 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1403,16 +1472,18 @@ discard block |
||
1403 | 1472 | ) |
1404 | 1473 | ); |
1405 | 1474 | |
1406 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1407 | - $_SESSION['prf-save'] = true; |
|
1475 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1476 | + $_SESSION['prf-save'] = true; |
|
1477 | + } |
|
1408 | 1478 | |
1409 | 1479 | // Add the new member to the buddies array. |
1410 | 1480 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1411 | 1481 | { |
1412 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1413 | - continue; |
|
1414 | - else |
|
1415 | - $buddiesArray[] = (int) $row['id_member']; |
|
1482 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1483 | + continue; |
|
1484 | + } else { |
|
1485 | + $buddiesArray[] = (int) $row['id_member']; |
|
1486 | + } |
|
1416 | 1487 | } |
1417 | 1488 | $smcFunc['db_free_result']($request); |
1418 | 1489 | |
@@ -1442,18 +1513,20 @@ discard block |
||
1442 | 1513 | |
1443 | 1514 | $context['custom_pf'] = array(); |
1444 | 1515 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1445 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1446 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1516 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1517 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1447 | 1518 | $context['custom_pf'][$row['col_name']] = array( |
1448 | 1519 | 'label' => $row['field_name'], |
1449 | 1520 | 'type' => $row['field_type'], |
1450 | 1521 | 'bbc' => !empty($row['bbc']), |
1451 | 1522 | 'enclose' => $row['enclose'], |
1452 | 1523 | ); |
1524 | + } |
|
1453 | 1525 | |
1454 | 1526 | // Gotta disable the gender option. |
1455 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') |
|
1456 | - unset($context['custom_pf']['cust_gender']); |
|
1527 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'None') { |
|
1528 | + unset($context['custom_pf']['cust_gender']); |
|
1529 | + } |
|
1457 | 1530 | |
1458 | 1531 | $smcFunc['db_free_result']($request); |
1459 | 1532 | |
@@ -1470,8 +1543,9 @@ discard block |
||
1470 | 1543 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1471 | 1544 | ) |
1472 | 1545 | ); |
1473 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1474 | - $buddies[] = $row['id_member']; |
|
1546 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1547 | + $buddies[] = $row['id_member']; |
|
1548 | + } |
|
1475 | 1549 | $smcFunc['db_free_result']($result); |
1476 | 1550 | } |
1477 | 1551 | |
@@ -1499,30 +1573,32 @@ discard block |
||
1499 | 1573 | continue; |
1500 | 1574 | } |
1501 | 1575 | |
1502 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1503 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1504 | - |
|
1505 | - elseif ($column['type'] == 'check') |
|
1506 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1576 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1577 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1578 | + } elseif ($column['type'] == 'check') { |
|
1579 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1580 | + } |
|
1507 | 1581 | |
1508 | 1582 | // Enclosing the user input within some other text? |
1509 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1510 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1583 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1584 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1511 | 1585 | '{SCRIPTURL}' => $scripturl, |
1512 | 1586 | '{IMAGES_URL}' => $settings['images_url'], |
1513 | 1587 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1514 | 1588 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1515 | 1589 | )); |
1590 | + } |
|
1516 | 1591 | } |
1517 | 1592 | } |
1518 | 1593 | } |
1519 | 1594 | |
1520 | 1595 | if (isset($_SESSION['prf-save'])) |
1521 | 1596 | { |
1522 | - if ($_SESSION['prf-save'] === true) |
|
1523 | - $context['saved_successful'] = true; |
|
1524 | - else |
|
1525 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1597 | + if ($_SESSION['prf-save'] === true) { |
|
1598 | + $context['saved_successful'] = true; |
|
1599 | + } else { |
|
1600 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1601 | + } |
|
1526 | 1602 | |
1527 | 1603 | unset($_SESSION['prf-save']); |
1528 | 1604 | } |
@@ -1542,9 +1618,10 @@ discard block |
||
1542 | 1618 | |
1543 | 1619 | // For making changes! |
1544 | 1620 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1545 | - foreach ($ignoreArray as $k => $dummy) |
|
1546 | - if ($dummy == '') |
|
1621 | + foreach ($ignoreArray as $k => $dummy) { |
|
1622 | + if ($dummy == '') |
|
1547 | 1623 | unset($ignoreArray[$k]); |
1624 | + } |
|
1548 | 1625 | |
1549 | 1626 | // Removing a member from the ignore list? |
1550 | 1627 | if (isset($_GET['remove'])) |
@@ -1554,10 +1631,11 @@ discard block |
||
1554 | 1631 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1555 | 1632 | |
1556 | 1633 | // Heh, I'm lazy, do it the easy way... |
1557 | - foreach ($ignoreArray as $key => $id_remove) |
|
1558 | - if ($id_remove == (int) $_GET['remove']) |
|
1634 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1635 | + if ($id_remove == (int) $_GET['remove']) |
|
1559 | 1636 | { |
1560 | 1637 | unset($ignoreArray[$key]); |
1638 | + } |
|
1561 | 1639 | $_SESSION['prf-save'] = true; |
1562 | 1640 | } |
1563 | 1641 | |
@@ -1567,8 +1645,7 @@ discard block |
||
1567 | 1645 | |
1568 | 1646 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1569 | 1647 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1570 | - } |
|
1571 | - elseif (isset($_POST['new_ignore'])) |
|
1648 | + } elseif (isset($_POST['new_ignore'])) |
|
1572 | 1649 | { |
1573 | 1650 | checkSession(); |
1574 | 1651 | // Prepare the string for extraction... |
@@ -1580,8 +1657,9 @@ discard block |
||
1580 | 1657 | { |
1581 | 1658 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1582 | 1659 | |
1583 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1584 | - unset($new_entries[$k]); |
|
1660 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1661 | + unset($new_entries[$k]); |
|
1662 | + } |
|
1585 | 1663 | } |
1586 | 1664 | |
1587 | 1665 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1599,16 +1677,18 @@ discard block |
||
1599 | 1677 | ) |
1600 | 1678 | ); |
1601 | 1679 | |
1602 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1603 | - $_SESSION['prf-save'] = true; |
|
1680 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1681 | + $_SESSION['prf-save'] = true; |
|
1682 | + } |
|
1604 | 1683 | |
1605 | 1684 | // Add the new member to the buddies array. |
1606 | 1685 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1607 | 1686 | { |
1608 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1609 | - continue; |
|
1610 | - else |
|
1611 | - $ignoreArray[] = (int) $row['id_member']; |
|
1687 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1688 | + continue; |
|
1689 | + } else { |
|
1690 | + $ignoreArray[] = (int) $row['id_member']; |
|
1691 | + } |
|
1612 | 1692 | } |
1613 | 1693 | $smcFunc['db_free_result']($request); |
1614 | 1694 | |
@@ -1637,8 +1717,9 @@ discard block |
||
1637 | 1717 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1638 | 1718 | ) |
1639 | 1719 | ); |
1640 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1641 | - $ignored[] = $row['id_member']; |
|
1720 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1721 | + $ignored[] = $row['id_member']; |
|
1722 | + } |
|
1642 | 1723 | $smcFunc['db_free_result']($result); |
1643 | 1724 | } |
1644 | 1725 | |
@@ -1657,10 +1738,11 @@ discard block |
||
1657 | 1738 | |
1658 | 1739 | if (isset($_SESSION['prf-save'])) |
1659 | 1740 | { |
1660 | - if ($_SESSION['prf-save'] === true) |
|
1661 | - $context['saved_successful'] = true; |
|
1662 | - else |
|
1663 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1741 | + if ($_SESSION['prf-save'] === true) { |
|
1742 | + $context['saved_successful'] = true; |
|
1743 | + } else { |
|
1744 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1745 | + } |
|
1664 | 1746 | |
1665 | 1747 | unset($_SESSION['prf-save']); |
1666 | 1748 | } |
@@ -1676,8 +1758,9 @@ discard block |
||
1676 | 1758 | global $context, $txt; |
1677 | 1759 | |
1678 | 1760 | loadThemeOptions($memID); |
1679 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1680 | - loadCustomFields($memID, 'account'); |
|
1761 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1762 | + loadCustomFields($memID, 'account'); |
|
1763 | + } |
|
1681 | 1764 | |
1682 | 1765 | $context['sub_template'] = 'edit_options'; |
1683 | 1766 | $context['page_desc'] = $txt['account_info']; |
@@ -1704,8 +1787,9 @@ discard block |
||
1704 | 1787 | global $context, $txt; |
1705 | 1788 | |
1706 | 1789 | loadThemeOptions($memID); |
1707 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1708 | - loadCustomFields($memID, 'forumprofile'); |
|
1790 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1791 | + loadCustomFields($memID, 'forumprofile'); |
|
1792 | + } |
|
1709 | 1793 | |
1710 | 1794 | $context['sub_template'] = 'edit_options'; |
1711 | 1795 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1738,18 +1822,21 @@ discard block |
||
1738 | 1822 | $dirs = array(); |
1739 | 1823 | $files = array(); |
1740 | 1824 | |
1741 | - if (!$dir) |
|
1742 | - return array(); |
|
1825 | + if (!$dir) { |
|
1826 | + return array(); |
|
1827 | + } |
|
1743 | 1828 | |
1744 | 1829 | while ($line = $dir->read()) |
1745 | 1830 | { |
1746 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1747 | - continue; |
|
1831 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1832 | + continue; |
|
1833 | + } |
|
1748 | 1834 | |
1749 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1750 | - $dirs[] = $line; |
|
1751 | - else |
|
1752 | - $files[] = $line; |
|
1835 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1836 | + $dirs[] = $line; |
|
1837 | + } else { |
|
1838 | + $files[] = $line; |
|
1839 | + } |
|
1753 | 1840 | } |
1754 | 1841 | $dir->close(); |
1755 | 1842 | |
@@ -1770,14 +1857,15 @@ discard block |
||
1770 | 1857 | foreach ($dirs as $line) |
1771 | 1858 | { |
1772 | 1859 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1773 | - if (!empty($tmp)) |
|
1774 | - $result[] = array( |
|
1860 | + if (!empty($tmp)) { |
|
1861 | + $result[] = array( |
|
1775 | 1862 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1776 | 1863 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1777 | 1864 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1778 | 1865 | 'is_dir' => true, |
1779 | 1866 | 'files' => $tmp |
1780 | 1867 | ); |
1868 | + } |
|
1781 | 1869 | unset($tmp); |
1782 | 1870 | } |
1783 | 1871 | |
@@ -1787,8 +1875,9 @@ discard block |
||
1787 | 1875 | $extension = substr(strrchr($line, '.'), 1); |
1788 | 1876 | |
1789 | 1877 | // Make sure it is an image. |
1790 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1791 | - continue; |
|
1878 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1879 | + continue; |
|
1880 | + } |
|
1792 | 1881 | |
1793 | 1882 | $result[] = array( |
1794 | 1883 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1796,8 +1885,9 @@ discard block |
||
1796 | 1885 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1797 | 1886 | 'is_dir' => false |
1798 | 1887 | ); |
1799 | - if ($level == 1) |
|
1800 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1888 | + if ($level == 1) { |
|
1889 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1890 | + } |
|
1801 | 1891 | } |
1802 | 1892 | |
1803 | 1893 | return $result; |
@@ -1819,8 +1909,9 @@ discard block |
||
1819 | 1909 | call_integration_hook('integrate_theme_options'); |
1820 | 1910 | |
1821 | 1911 | loadThemeOptions($memID); |
1822 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1823 | - loadCustomFields($memID, 'theme'); |
|
1912 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1913 | + loadCustomFields($memID, 'theme'); |
|
1914 | + } |
|
1824 | 1915 | |
1825 | 1916 | $context['sub_template'] = 'edit_options'; |
1826 | 1917 | $context['page_desc'] = $txt['theme_info']; |
@@ -1874,16 +1965,19 @@ discard block |
||
1874 | 1965 | { |
1875 | 1966 | global $txt, $context, $modSettings, $smcFunc, $sourcedir; |
1876 | 1967 | |
1877 | - if (!isset($context['token_check'])) |
|
1878 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1968 | + if (!isset($context['token_check'])) { |
|
1969 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1970 | + } |
|
1879 | 1971 | |
1880 | 1972 | is_not_guest(); |
1881 | - if (!$context['user']['is_owner']) |
|
1882 | - isAllowedTo('profile_extra_any'); |
|
1973 | + if (!$context['user']['is_owner']) { |
|
1974 | + isAllowedTo('profile_extra_any'); |
|
1975 | + } |
|
1883 | 1976 | |
1884 | 1977 | // Set the post action if we're coming from the profile... |
1885 | - if (!isset($context['action'])) |
|
1886 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1978 | + if (!isset($context['action'])) { |
|
1979 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1980 | + } |
|
1887 | 1981 | |
1888 | 1982 | // What options are set |
1889 | 1983 | loadThemeOptions($memID); |
@@ -1970,28 +2064,34 @@ discard block |
||
1970 | 2064 | ); |
1971 | 2065 | |
1972 | 2066 | // There are certain things that are disabled at the group level. |
1973 | - if (empty($modSettings['cal_enabled'])) |
|
1974 | - unset($alert_types['calendar']); |
|
2067 | + if (empty($modSettings['cal_enabled'])) { |
|
2068 | + unset($alert_types['calendar']); |
|
2069 | + } |
|
1975 | 2070 | |
1976 | 2071 | // Disable paid subscriptions at group level if they're disabled |
1977 | - if (empty($modSettings['paid_enabled'])) |
|
1978 | - unset($alert_types['paidsubs']); |
|
2072 | + if (empty($modSettings['paid_enabled'])) { |
|
2073 | + unset($alert_types['paidsubs']); |
|
2074 | + } |
|
1979 | 2075 | |
1980 | 2076 | // Disable membergroup requests at group level if they're disabled |
1981 | - if (empty($modSettings['show_group_membership'])) |
|
1982 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2077 | + if (empty($modSettings['show_group_membership'])) { |
|
2078 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2079 | + } |
|
1983 | 2080 | |
1984 | 2081 | // Disable mentions if they're disabled |
1985 | - if (empty($modSettings['enable_mentions'])) |
|
1986 | - unset($alert_types['msg']['msg_mention']); |
|
2082 | + if (empty($modSettings['enable_mentions'])) { |
|
2083 | + unset($alert_types['msg']['msg_mention']); |
|
2084 | + } |
|
1987 | 2085 | |
1988 | 2086 | // Disable likes if they're disabled |
1989 | - if (empty($modSettings['enable_likes'])) |
|
1990 | - unset($alert_types['msg']['msg_like']); |
|
2087 | + if (empty($modSettings['enable_likes'])) { |
|
2088 | + unset($alert_types['msg']['msg_like']); |
|
2089 | + } |
|
1991 | 2090 | |
1992 | 2091 | // Disable buddy requests if they're disabled |
1993 | - if (empty($modSettings['enable_buddylist'])) |
|
1994 | - unset($alert_types['members']['buddy_request']); |
|
2092 | + if (empty($modSettings['enable_buddylist'])) { |
|
2093 | + unset($alert_types['members']['buddy_request']); |
|
2094 | + } |
|
1995 | 2095 | |
1996 | 2096 | // Now, now, we could pass this through global but we should really get into the habit of |
1997 | 2097 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -2019,15 +2119,17 @@ discard block |
||
2019 | 2119 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
2020 | 2120 | } |
2021 | 2121 | |
2022 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
2023 | - unset($alert_types['members']['request_group']); |
|
2122 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2123 | + unset($alert_types['members']['request_group']); |
|
2124 | + } |
|
2024 | 2125 | |
2025 | 2126 | foreach ($alert_types as $group => $items) |
2026 | 2127 | { |
2027 | 2128 | foreach ($items as $alert_key => $alert_value) |
2028 | 2129 | { |
2029 | - if (!isset($alert_value['permission'])) |
|
2030 | - continue; |
|
2130 | + if (!isset($alert_value['permission'])) { |
|
2131 | + continue; |
|
2132 | + } |
|
2031 | 2133 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2032 | 2134 | { |
2033 | 2135 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2035,12 +2137,14 @@ discard block |
||
2035 | 2137 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2036 | 2138 | } |
2037 | 2139 | |
2038 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2039 | - unset ($alert_types[$group][$alert_key]); |
|
2140 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2141 | + unset ($alert_types[$group][$alert_key]); |
|
2142 | + } |
|
2040 | 2143 | } |
2041 | 2144 | |
2042 | - if (empty($alert_types[$group])) |
|
2043 | - unset ($alert_types[$group]); |
|
2145 | + if (empty($alert_types[$group])) { |
|
2146 | + unset ($alert_types[$group]); |
|
2147 | + } |
|
2044 | 2148 | } |
2045 | 2149 | } |
2046 | 2150 | |
@@ -2072,9 +2176,9 @@ discard block |
||
2072 | 2176 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2073 | 2177 | break; |
2074 | 2178 | case 'select': |
2075 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2076 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2077 | - else |
|
2179 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2180 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2181 | + } else |
|
2078 | 2182 | { |
2079 | 2183 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2080 | 2184 | $keys = array_keys($this_option['opts']); |
@@ -2094,23 +2198,28 @@ discard block |
||
2094 | 2198 | $this_value = 0; |
2095 | 2199 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2096 | 2200 | { |
2097 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2098 | - $this_value |= $bitvalue; |
|
2201 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2202 | + $this_value |= $bitvalue; |
|
2203 | + } |
|
2204 | + } |
|
2205 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2206 | + $update_prefs[$item_key] = $this_value; |
|
2099 | 2207 | } |
2100 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2101 | - $update_prefs[$item_key] = $this_value; |
|
2102 | 2208 | } |
2103 | 2209 | } |
2104 | 2210 | |
2105 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2106 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2211 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2212 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2213 | + } |
|
2107 | 2214 | |
2108 | - if (!empty($_POST['notify_announcements'])) |
|
2109 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2215 | + if (!empty($_POST['notify_announcements'])) { |
|
2216 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2217 | + } |
|
2110 | 2218 | |
2111 | 2219 | setNotifyPrefs((int) $memID, $update_prefs); |
2112 | - foreach ($update_prefs as $pref => $value) |
|
2113 | - $context['alert_prefs'][$pref] = $value; |
|
2220 | + foreach ($update_prefs as $pref => $value) { |
|
2221 | + $context['alert_prefs'][$pref] = $value; |
|
2222 | + } |
|
2114 | 2223 | |
2115 | 2224 | makeNotificationChanges($memID); |
2116 | 2225 | |
@@ -2140,8 +2249,9 @@ discard block |
||
2140 | 2249 | |
2141 | 2250 | // Now we're all set up. |
2142 | 2251 | is_not_guest(); |
2143 | - if (!$context['user']['is_owner']) |
|
2144 | - fatal_error('no_access'); |
|
2252 | + if (!$context['user']['is_owner']) { |
|
2253 | + fatal_error('no_access'); |
|
2254 | + } |
|
2145 | 2255 | |
2146 | 2256 | checkSession('get'); |
2147 | 2257 | |
@@ -2173,8 +2283,9 @@ discard block |
||
2173 | 2283 | { |
2174 | 2284 | global $smcFunc; |
2175 | 2285 | |
2176 | - if (empty($toMark) || empty($memID)) |
|
2177 | - return false; |
|
2286 | + if (empty($toMark) || empty($memID)) { |
|
2287 | + return false; |
|
2288 | + } |
|
2178 | 2289 | |
2179 | 2290 | $toMark = (array) $toMark; |
2180 | 2291 | |
@@ -2208,8 +2319,9 @@ discard block |
||
2208 | 2319 | { |
2209 | 2320 | global $smcFunc; |
2210 | 2321 | |
2211 | - if (empty($toDelete)) |
|
2212 | - return false; |
|
2322 | + if (empty($toDelete)) { |
|
2323 | + return false; |
|
2324 | + } |
|
2213 | 2325 | |
2214 | 2326 | $toDelete = (array) $toDelete; |
2215 | 2327 | |
@@ -2244,8 +2356,9 @@ discard block |
||
2244 | 2356 | { |
2245 | 2357 | global $smcFunc; |
2246 | 2358 | |
2247 | - if (empty($memID)) |
|
2248 | - return false; |
|
2359 | + if (empty($memID)) { |
|
2360 | + return false; |
|
2361 | + } |
|
2249 | 2362 | |
2250 | 2363 | $request = $smcFunc['db_query']('', ' |
2251 | 2364 | SELECT id_alert |
@@ -2322,8 +2435,9 @@ discard block |
||
2322 | 2435 | { |
2323 | 2436 | $link = $topic['link']; |
2324 | 2437 | |
2325 | - if ($topic['new']) |
|
2326 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2438 | + if ($topic['new']) { |
|
2439 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2440 | + } |
|
2327 | 2441 | |
2328 | 2442 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2329 | 2443 | |
@@ -2474,8 +2588,9 @@ discard block |
||
2474 | 2588 | { |
2475 | 2589 | $link = $board['link']; |
2476 | 2590 | |
2477 | - if ($board['new']) |
|
2478 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2591 | + if ($board['new']) { |
|
2592 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2593 | + } |
|
2479 | 2594 | |
2480 | 2595 | return $link; |
2481 | 2596 | }, |
@@ -2675,8 +2790,8 @@ discard block |
||
2675 | 2790 | ) |
2676 | 2791 | ); |
2677 | 2792 | $notification_boards = array(); |
2678 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2679 | - $notification_boards[] = array( |
|
2793 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2794 | + $notification_boards[] = array( |
|
2680 | 2795 | 'id' => $row['id_board'], |
2681 | 2796 | 'name' => $row['name'], |
2682 | 2797 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2684,6 +2799,7 @@ discard block |
||
2684 | 2799 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2685 | 2800 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2686 | 2801 | ); |
2802 | + } |
|
2687 | 2803 | $smcFunc['db_free_result']($request); |
2688 | 2804 | |
2689 | 2805 | return $notification_boards; |
@@ -2698,17 +2814,18 @@ discard block |
||
2698 | 2814 | { |
2699 | 2815 | global $context, $options, $cur_profile, $smcFunc; |
2700 | 2816 | |
2701 | - if (isset($_POST['default_options'])) |
|
2702 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2817 | + if (isset($_POST['default_options'])) { |
|
2818 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2819 | + } |
|
2703 | 2820 | |
2704 | 2821 | if ($context['user']['is_owner']) |
2705 | 2822 | { |
2706 | 2823 | $context['member']['options'] = $options; |
2707 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2708 | - foreach ($_POST['options'] as $k => $v) |
|
2824 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2825 | + foreach ($_POST['options'] as $k => $v) |
|
2709 | 2826 | $context['member']['options'][$k] = $v; |
2710 | - } |
|
2711 | - else |
|
2827 | + } |
|
2828 | + } else |
|
2712 | 2829 | { |
2713 | 2830 | $request = $smcFunc['db_query']('', ' |
2714 | 2831 | SELECT id_member, variable, value |
@@ -2729,8 +2846,9 @@ discard block |
||
2729 | 2846 | continue; |
2730 | 2847 | } |
2731 | 2848 | |
2732 | - if (isset($_POST['options'][$row['variable']])) |
|
2733 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2849 | + if (isset($_POST['options'][$row['variable']])) { |
|
2850 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2851 | + } |
|
2734 | 2852 | $context['member']['options'][$row['variable']] = $row['value']; |
2735 | 2853 | } |
2736 | 2854 | $smcFunc['db_free_result']($request); |
@@ -2738,8 +2856,9 @@ discard block |
||
2738 | 2856 | // Load up the default theme options for any missing. |
2739 | 2857 | foreach ($temp as $k => $v) |
2740 | 2858 | { |
2741 | - if (!isset($context['member']['options'][$k])) |
|
2742 | - $context['member']['options'][$k] = $v; |
|
2859 | + if (!isset($context['member']['options'][$k])) { |
|
2860 | + $context['member']['options'][$k] = $v; |
|
2861 | + } |
|
2743 | 2862 | } |
2744 | 2863 | } |
2745 | 2864 | } |
@@ -2754,8 +2873,9 @@ discard block |
||
2754 | 2873 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2755 | 2874 | |
2756 | 2875 | // Have the admins enabled this option? |
2757 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2758 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2876 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2877 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2878 | + } |
|
2759 | 2879 | |
2760 | 2880 | // Find all the boards this user is allowed to see. |
2761 | 2881 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2775,12 +2895,13 @@ discard block |
||
2775 | 2895 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2776 | 2896 | { |
2777 | 2897 | // This category hasn't been set up yet.. |
2778 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2779 | - $context['categories'][$row['id_cat']] = array( |
|
2898 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2899 | + $context['categories'][$row['id_cat']] = array( |
|
2780 | 2900 | 'id' => $row['id_cat'], |
2781 | 2901 | 'name' => $row['cat_name'], |
2782 | 2902 | 'boards' => array() |
2783 | 2903 | ); |
2904 | + } |
|
2784 | 2905 | |
2785 | 2906 | // Set this board up, and let the template know when it's a child. (indent them..) |
2786 | 2907 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2810,18 +2931,20 @@ discard block |
||
2810 | 2931 | } |
2811 | 2932 | |
2812 | 2933 | $max_boards = ceil(count($temp_boards) / 2); |
2813 | - if ($max_boards == 1) |
|
2814 | - $max_boards = 2; |
|
2934 | + if ($max_boards == 1) { |
|
2935 | + $max_boards = 2; |
|
2936 | + } |
|
2815 | 2937 | |
2816 | 2938 | // Now, alternate them so they can be shown left and right ;). |
2817 | 2939 | $context['board_columns'] = array(); |
2818 | 2940 | for ($i = 0; $i < $max_boards; $i++) |
2819 | 2941 | { |
2820 | 2942 | $context['board_columns'][] = $temp_boards[$i]; |
2821 | - if (isset($temp_boards[$i + $max_boards])) |
|
2822 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2823 | - else |
|
2824 | - $context['board_columns'][] = array(); |
|
2943 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2944 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2945 | + } else { |
|
2946 | + $context['board_columns'][] = array(); |
|
2947 | + } |
|
2825 | 2948 | } |
2826 | 2949 | |
2827 | 2950 | loadThemeOptions($memID); |
@@ -2890,8 +3013,9 @@ discard block |
||
2890 | 3013 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2891 | 3014 | { |
2892 | 3015 | // We should skip the administrator group if they don't have the admin_forum permission! |
2893 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2894 | - continue; |
|
3016 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
3017 | + continue; |
|
3018 | + } |
|
2895 | 3019 | |
2896 | 3020 | $context['member_groups'][$row['id_group']] = array( |
2897 | 3021 | 'id' => $row['id_group'], |
@@ -2937,16 +3061,17 @@ discard block |
||
2937 | 3061 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2938 | 3062 | // Warning message for signature image limits? |
2939 | 3063 | $context['signature_warning'] = ''; |
2940 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2941 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2942 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2943 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3064 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3065 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3066 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3067 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3068 | + } |
|
2944 | 3069 | |
2945 | 3070 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2946 | 3071 | |
2947 | - if (empty($context['do_preview'])) |
|
2948 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2949 | - else |
|
3072 | + if (empty($context['do_preview'])) { |
|
3073 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3074 | + } else |
|
2950 | 3075 | { |
2951 | 3076 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2952 | 3077 | $validation = profileValidateSignature($signature); |
@@ -2956,8 +3081,9 @@ discard block |
||
2956 | 3081 | $context['post_errors'] = array(); |
2957 | 3082 | } |
2958 | 3083 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2959 | - if ($validation !== true && $validation !== false) |
|
2960 | - $context['post_errors'][] = $validation; |
|
3084 | + if ($validation !== true && $validation !== false) { |
|
3085 | + $context['post_errors'][] = $validation; |
|
3086 | + } |
|
2961 | 3087 | |
2962 | 3088 | censorText($context['member']['signature']); |
2963 | 3089 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2967,8 +3093,9 @@ discard block |
||
2967 | 3093 | } |
2968 | 3094 | |
2969 | 3095 | // Load the spell checker? |
2970 | - if ($context['show_spellchecking']) |
|
2971 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3096 | + if ($context['show_spellchecking']) { |
|
3097 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3098 | + } |
|
2972 | 3099 | |
2973 | 3100 | return true; |
2974 | 3101 | } |
@@ -3002,8 +3129,7 @@ discard block |
||
3002 | 3129 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
3003 | 3130 | ); |
3004 | 3131 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
3005 | - } |
|
3006 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3132 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3007 | 3133 | { |
3008 | 3134 | $context['member']['avatar'] += array( |
3009 | 3135 | 'choice' => 'upload', |
@@ -3013,33 +3139,34 @@ discard block |
||
3013 | 3139 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
3014 | 3140 | } |
3015 | 3141 | // Use "avatar_original" here so we show what the user entered even if the image proxy is enabled |
3016 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
3017 | - $context['member']['avatar'] += array( |
|
3142 | + elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3143 | + $context['member']['avatar'] += array( |
|
3018 | 3144 | 'choice' => 'external', |
3019 | 3145 | 'server_pic' => 'blank.png', |
3020 | 3146 | 'external' => $cur_profile['avatar_original'] |
3021 | 3147 | ); |
3022 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
3023 | - $context['member']['avatar'] += array( |
|
3148 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3149 | + $context['member']['avatar'] += array( |
|
3024 | 3150 | 'choice' => 'server_stored', |
3025 | 3151 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3026 | 3152 | 'external' => 'http://' |
3027 | 3153 | ); |
3028 | - else |
|
3029 | - $context['member']['avatar'] += array( |
|
3154 | + } else { |
|
3155 | + $context['member']['avatar'] += array( |
|
3030 | 3156 | 'choice' => 'none', |
3031 | 3157 | 'server_pic' => 'blank.png', |
3032 | 3158 | 'external' => 'http://' |
3033 | 3159 | ); |
3160 | + } |
|
3034 | 3161 | |
3035 | 3162 | // Get a list of all the avatars. |
3036 | 3163 | if ($context['member']['avatar']['allow_server_stored']) |
3037 | 3164 | { |
3038 | 3165 | $context['avatar_list'] = array(); |
3039 | 3166 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3167 | + } else { |
|
3168 | + $context['avatars'] = array(); |
|
3040 | 3169 | } |
3041 | - else |
|
3042 | - $context['avatars'] = array(); |
|
3043 | 3170 | |
3044 | 3171 | // Second level selected avatar... |
3045 | 3172 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3068,19 +3195,22 @@ discard block |
||
3068 | 3195 | ) |
3069 | 3196 | ); |
3070 | 3197 | $protected_groups = array(1); |
3071 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3072 | - $protected_groups[] = $row['id_group']; |
|
3198 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3199 | + $protected_groups[] = $row['id_group']; |
|
3200 | + } |
|
3073 | 3201 | $smcFunc['db_free_result']($request); |
3074 | 3202 | |
3075 | 3203 | $protected_groups = array_unique($protected_groups); |
3076 | 3204 | } |
3077 | 3205 | |
3078 | 3206 | // The account page allows the change of your id_group - but not to a protected group! |
3079 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3080 | - $value = (int) $value; |
|
3207 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3208 | + $value = (int) $value; |
|
3209 | + } |
|
3081 | 3210 | // ... otherwise it's the old group sir. |
3082 | - else |
|
3083 | - $value = $old_profile['id_group']; |
|
3211 | + else { |
|
3212 | + $value = $old_profile['id_group']; |
|
3213 | + } |
|
3084 | 3214 | |
3085 | 3215 | // Find the additional membergroups (if any) |
3086 | 3216 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3089,16 +3219,18 @@ discard block |
||
3089 | 3219 | foreach ($_POST['additional_groups'] as $group_id) |
3090 | 3220 | { |
3091 | 3221 | $group_id = (int) $group_id; |
3092 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3093 | - $additional_groups[] = $group_id; |
|
3222 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3223 | + $additional_groups[] = $group_id; |
|
3224 | + } |
|
3094 | 3225 | } |
3095 | 3226 | |
3096 | 3227 | // Put the protected groups back in there if you don't have permission to take them away. |
3097 | 3228 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3098 | 3229 | foreach ($old_additional_groups as $group_id) |
3099 | 3230 | { |
3100 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3101 | - $additional_groups[] = $group_id; |
|
3231 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3232 | + $additional_groups[] = $group_id; |
|
3233 | + } |
|
3102 | 3234 | } |
3103 | 3235 | |
3104 | 3236 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3130,18 +3262,20 @@ discard block |
||
3130 | 3262 | list ($another) = $smcFunc['db_fetch_row']($request); |
3131 | 3263 | $smcFunc['db_free_result']($request); |
3132 | 3264 | |
3133 | - if (empty($another)) |
|
3134 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3265 | + if (empty($another)) { |
|
3266 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3267 | + } |
|
3135 | 3268 | } |
3136 | 3269 | } |
3137 | 3270 | |
3138 | 3271 | // If we are changing group status, update permission cache as necessary. |
3139 | 3272 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3140 | 3273 | { |
3141 | - if ($context['user']['is_owner']) |
|
3142 | - $_SESSION['mc']['time'] = 0; |
|
3143 | - else |
|
3144 | - updateSettings(array('settings_updated' => time())); |
|
3274 | + if ($context['user']['is_owner']) { |
|
3275 | + $_SESSION['mc']['time'] = 0; |
|
3276 | + } else { |
|
3277 | + updateSettings(array('settings_updated' => time())); |
|
3278 | + } |
|
3145 | 3279 | } |
3146 | 3280 | |
3147 | 3281 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3162,8 +3296,9 @@ discard block |
||
3162 | 3296 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3163 | 3297 | |
3164 | 3298 | $memID = $context['id_member']; |
3165 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3166 | - return false; |
|
3299 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3300 | + return false; |
|
3301 | + } |
|
3167 | 3302 | |
3168 | 3303 | require_once($sourcedir . '/ManageAttachments.php'); |
3169 | 3304 | |
@@ -3174,8 +3309,9 @@ discard block |
||
3174 | 3309 | $downloadedExternalAvatar = false; |
3175 | 3310 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3176 | 3311 | { |
3177 | - if (!is_writable($uploadDir)) |
|
3178 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3312 | + if (!is_writable($uploadDir)) { |
|
3313 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3314 | + } |
|
3179 | 3315 | |
3180 | 3316 | require_once($sourcedir . '/Subs-Package.php'); |
3181 | 3317 | |
@@ -3219,19 +3355,18 @@ discard block |
||
3219 | 3355 | |
3220 | 3356 | // Get rid of their old avatar. (if uploaded.) |
3221 | 3357 | removeAttachments(array('id_member' => $memID)); |
3222 | - } |
|
3223 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3358 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3224 | 3359 | { |
3225 | 3360 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3226 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3227 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3228 | - else |
|
3229 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3361 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3362 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3363 | + } else { |
|
3364 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3365 | + } |
|
3230 | 3366 | |
3231 | 3367 | // Get rid of their old avatar. (if uploaded.) |
3232 | 3368 | removeAttachments(array('id_member' => $memID)); |
3233 | - } |
|
3234 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3369 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3235 | 3370 | { |
3236 | 3371 | // We need these clean... |
3237 | 3372 | $cur_profile['id_attach'] = 0; |
@@ -3243,11 +3378,13 @@ discard block |
||
3243 | 3378 | |
3244 | 3379 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3245 | 3380 | |
3246 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3247 | - $profile_vars['avatar'] = ''; |
|
3381 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3382 | + $profile_vars['avatar'] = ''; |
|
3383 | + } |
|
3248 | 3384 | // Trying to make us do something we'll regret? |
3249 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3250 | - return 'bad_avatar_invalid_url'; |
|
3385 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3386 | + return 'bad_avatar_invalid_url'; |
|
3387 | + } |
|
3251 | 3388 | // Should we check dimensions? |
3252 | 3389 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3253 | 3390 | { |
@@ -3257,9 +3394,9 @@ discard block |
||
3257 | 3394 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3258 | 3395 | { |
3259 | 3396 | // Houston, we have a problem. The avatar is too large!! |
3260 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3261 | - return 'bad_avatar_too_large'; |
|
3262 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3397 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3398 | + return 'bad_avatar_too_large'; |
|
3399 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3263 | 3400 | { |
3264 | 3401 | // @todo remove this if appropriate |
3265 | 3402 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3269,26 +3406,27 @@ discard block |
||
3269 | 3406 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3270 | 3407 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3271 | 3408 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3409 | + } else { |
|
3410 | + return 'bad_avatar'; |
|
3272 | 3411 | } |
3273 | - else |
|
3274 | - return 'bad_avatar'; |
|
3275 | 3412 | } |
3276 | 3413 | } |
3277 | 3414 | } |
3278 | - } |
|
3279 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3415 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3280 | 3416 | { |
3281 | 3417 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3282 | 3418 | { |
3283 | 3419 | // Get the dimensions of the image. |
3284 | 3420 | if (!$downloadedExternalAvatar) |
3285 | 3421 | { |
3286 | - if (!is_writable($uploadDir)) |
|
3287 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3422 | + if (!is_writable($uploadDir)) { |
|
3423 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3424 | + } |
|
3288 | 3425 | |
3289 | 3426 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3290 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3291 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3427 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3428 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3429 | + } |
|
3292 | 3430 | |
3293 | 3431 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3294 | 3432 | } |
@@ -3401,17 +3539,19 @@ discard block |
||
3401 | 3539 | $profile_vars['avatar'] = ''; |
3402 | 3540 | |
3403 | 3541 | // Delete any temporary file. |
3404 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3405 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3542 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3543 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3544 | + } |
|
3406 | 3545 | } |
3407 | 3546 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3408 | - else |
|
3547 | + else { |
|
3548 | + $profile_vars['avatar'] = ''; |
|
3549 | + } |
|
3550 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3551 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3552 | + } else { |
|
3409 | 3553 | $profile_vars['avatar'] = ''; |
3410 | 3554 | } |
3411 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3412 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3413 | - else |
|
3414 | - $profile_vars['avatar'] = ''; |
|
3415 | 3555 | |
3416 | 3556 | // Setup the profile variables so it shows things right on display! |
3417 | 3557 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3459,9 +3599,9 @@ discard block |
||
3459 | 3599 | $smiley_parsed = $unparsed_signature; |
3460 | 3600 | parsesmileys($smiley_parsed); |
3461 | 3601 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3462 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3463 | - return 'signature_allow_smileys'; |
|
3464 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3602 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3603 | + return 'signature_allow_smileys'; |
|
3604 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3465 | 3605 | { |
3466 | 3606 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3467 | 3607 | return 'signature_max_smileys'; |
@@ -3474,14 +3614,15 @@ discard block |
||
3474 | 3614 | { |
3475 | 3615 | $limit_broke = 0; |
3476 | 3616 | // Attempt to allow all sizes of abuse, so to speak. |
3477 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3478 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3479 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3480 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3481 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3482 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3483 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3484 | - $limit_broke = 'large'; |
|
3617 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3618 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3619 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3620 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3621 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3622 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3623 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3624 | + $limit_broke = 'large'; |
|
3625 | + } |
|
3485 | 3626 | |
3486 | 3627 | if ($limit_broke) |
3487 | 3628 | { |
@@ -3523,24 +3664,26 @@ discard block |
||
3523 | 3664 | $width = -1; $height = -1; |
3524 | 3665 | |
3525 | 3666 | // Does it have predefined restraints? Width first. |
3526 | - if ($matches[6][$key]) |
|
3527 | - $matches[2][$key] = $matches[6][$key]; |
|
3667 | + if ($matches[6][$key]) { |
|
3668 | + $matches[2][$key] = $matches[6][$key]; |
|
3669 | + } |
|
3528 | 3670 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3529 | 3671 | { |
3530 | 3672 | $width = $sig_limits[5]; |
3531 | 3673 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3674 | + } elseif ($matches[2][$key]) { |
|
3675 | + $width = $matches[2][$key]; |
|
3532 | 3676 | } |
3533 | - elseif ($matches[2][$key]) |
|
3534 | - $width = $matches[2][$key]; |
|
3535 | 3677 | // ... and height. |
3536 | 3678 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3537 | 3679 | { |
3538 | 3680 | $height = $sig_limits[6]; |
3539 | - if ($width != -1) |
|
3540 | - $width = $width * ($height / $matches[4][$key]); |
|
3681 | + if ($width != -1) { |
|
3682 | + $width = $width * ($height / $matches[4][$key]); |
|
3683 | + } |
|
3684 | + } elseif ($matches[4][$key]) { |
|
3685 | + $height = $matches[4][$key]; |
|
3541 | 3686 | } |
3542 | - elseif ($matches[4][$key]) |
|
3543 | - $height = $matches[4][$key]; |
|
3544 | 3687 | |
3545 | 3688 | // If the dimensions are still not fixed - we need to check the actual image. |
3546 | 3689 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3558,21 +3701,24 @@ discard block |
||
3558 | 3701 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3559 | 3702 | { |
3560 | 3703 | $height = $sig_limits[6]; |
3561 | - if ($width == -1) |
|
3562 | - $width = $sizes[0]; |
|
3704 | + if ($width == -1) { |
|
3705 | + $width = $sizes[0]; |
|
3706 | + } |
|
3563 | 3707 | $width = $width * ($height / $sizes[1]); |
3708 | + } elseif ($width != -1) { |
|
3709 | + $height = $sizes[1]; |
|
3564 | 3710 | } |
3565 | - elseif ($width != -1) |
|
3566 | - $height = $sizes[1]; |
|
3567 | 3711 | } |
3568 | 3712 | } |
3569 | 3713 | |
3570 | 3714 | // Did we come up with some changes? If so remake the string. |
3571 | - if ($width != -1 || $height != -1) |
|
3572 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3715 | + if ($width != -1 || $height != -1) { |
|
3716 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3717 | + } |
|
3718 | + } |
|
3719 | + if (!empty($replaces)) { |
|
3720 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3573 | 3721 | } |
3574 | - if (!empty($replaces)) |
|
3575 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3576 | 3722 | } |
3577 | 3723 | } |
3578 | 3724 | |
@@ -3616,10 +3762,12 @@ discard block |
||
3616 | 3762 | $email = strtr($email, array(''' => '\'')); |
3617 | 3763 | |
3618 | 3764 | // Check the name and email for validity. |
3619 | - if (trim($email) == '') |
|
3620 | - return 'no_email'; |
|
3621 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3622 | - return 'bad_email'; |
|
3765 | + if (trim($email) == '') { |
|
3766 | + return 'no_email'; |
|
3767 | + } |
|
3768 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3769 | + return 'bad_email'; |
|
3770 | + } |
|
3623 | 3771 | |
3624 | 3772 | // Email addresses should be and stay unique. |
3625 | 3773 | $request = $smcFunc['db_query']('', ' |
@@ -3634,8 +3782,9 @@ discard block |
||
3634 | 3782 | ) |
3635 | 3783 | ); |
3636 | 3784 | |
3637 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3638 | - return 'email_taken'; |
|
3785 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3786 | + return 'email_taken'; |
|
3787 | + } |
|
3639 | 3788 | $smcFunc['db_free_result']($request); |
3640 | 3789 | |
3641 | 3790 | return true; |
@@ -3648,8 +3797,9 @@ discard block |
||
3648 | 3797 | { |
3649 | 3798 | global $modSettings, $context, $cur_profile; |
3650 | 3799 | |
3651 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3652 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3800 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3801 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3802 | + } |
|
3653 | 3803 | |
3654 | 3804 | loadUserSettings(); |
3655 | 3805 | writeLog(); |
@@ -3665,8 +3815,9 @@ discard block |
||
3665 | 3815 | require_once($sourcedir . '/Subs-Post.php'); |
3666 | 3816 | |
3667 | 3817 | // Shouldn't happen but just in case. |
3668 | - if (empty($profile_vars['email_address'])) |
|
3669 | - return; |
|
3818 | + if (empty($profile_vars['email_address'])) { |
|
3819 | + return; |
|
3820 | + } |
|
3670 | 3821 | |
3671 | 3822 | $replacements = array( |
3672 | 3823 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3689,8 +3840,9 @@ discard block |
||
3689 | 3840 | $_SESSION['log_time'] = 0; |
3690 | 3841 | $_SESSION['login_' . $cookiename] = $smcFunc['json_encode'](array(0, '', 0)); |
3691 | 3842 | |
3692 | - if (isset($_COOKIE[$cookiename])) |
|
3693 | - $_COOKIE[$cookiename] = ''; |
|
3843 | + if (isset($_COOKIE[$cookiename])) { |
|
3844 | + $_COOKIE[$cookiename] = ''; |
|
3845 | + } |
|
3694 | 3846 | |
3695 | 3847 | loadUserSettings(); |
3696 | 3848 | |
@@ -3723,11 +3875,13 @@ discard block |
||
3723 | 3875 | $groups[] = $curMember['id_group']; |
3724 | 3876 | |
3725 | 3877 | // Ensure the query doesn't croak! |
3726 | - if (empty($groups)) |
|
3727 | - $groups = array(0); |
|
3878 | + if (empty($groups)) { |
|
3879 | + $groups = array(0); |
|
3880 | + } |
|
3728 | 3881 | // Just to be sure... |
3729 | - foreach ($groups as $k => $v) |
|
3730 | - $groups[$k] = (int) $v; |
|
3882 | + foreach ($groups as $k => $v) { |
|
3883 | + $groups[$k] = (int) $v; |
|
3884 | + } |
|
3731 | 3885 | |
3732 | 3886 | // Get all the membergroups they can join. |
3733 | 3887 | $request = $smcFunc['db_query']('', ' |
@@ -3757,12 +3911,14 @@ discard block |
||
3757 | 3911 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3758 | 3912 | { |
3759 | 3913 | // Can they edit their primary group? |
3760 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3761 | - $context['can_edit_primary'] = true; |
|
3914 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3915 | + $context['can_edit_primary'] = true; |
|
3916 | + } |
|
3762 | 3917 | |
3763 | 3918 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3764 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3765 | - continue; |
|
3919 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3920 | + continue; |
|
3921 | + } |
|
3766 | 3922 | |
3767 | 3923 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3768 | 3924 | 'id' => $row['id_group'], |
@@ -3791,13 +3947,15 @@ discard block |
||
3791 | 3947 | ); |
3792 | 3948 | |
3793 | 3949 | // No changing primary one unless you have enough groups! |
3794 | - if (count($context['groups']['member']) < 2) |
|
3795 | - $context['can_edit_primary'] = false; |
|
3950 | + if (count($context['groups']['member']) < 2) { |
|
3951 | + $context['can_edit_primary'] = false; |
|
3952 | + } |
|
3796 | 3953 | |
3797 | 3954 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3798 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3799 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3800 | -} |
|
3955 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3956 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3957 | + } |
|
3958 | + } |
|
3801 | 3959 | |
3802 | 3960 | /** |
3803 | 3961 | * This function actually makes all the group changes |
@@ -3812,10 +3970,12 @@ discard block |
||
3812 | 3970 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3813 | 3971 | |
3814 | 3972 | // Let's be extra cautious... |
3815 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3816 | - isAllowedTo('manage_membergroups'); |
|
3817 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3818 | - fatal_lang_error('no_access', false); |
|
3973 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3974 | + isAllowedTo('manage_membergroups'); |
|
3975 | + } |
|
3976 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3977 | + fatal_lang_error('no_access', false); |
|
3978 | + } |
|
3819 | 3979 | |
3820 | 3980 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3821 | 3981 | |
@@ -3834,8 +3994,9 @@ discard block |
||
3834 | 3994 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3835 | 3995 | |
3836 | 3996 | // Sanity check!! |
3837 | - if ($group_id == 1) |
|
3838 | - isAllowedTo('admin_forum'); |
|
3997 | + if ($group_id == 1) { |
|
3998 | + isAllowedTo('admin_forum'); |
|
3999 | + } |
|
3839 | 4000 | // Protected groups too! |
3840 | 4001 | else |
3841 | 4002 | { |
@@ -3852,8 +4013,9 @@ discard block |
||
3852 | 4013 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3853 | 4014 | $smcFunc['db_free_result']($request); |
3854 | 4015 | |
3855 | - if ($is_protected == 1) |
|
3856 | - isAllowedTo('admin_forum'); |
|
4016 | + if ($is_protected == 1) { |
|
4017 | + isAllowedTo('admin_forum'); |
|
4018 | + } |
|
3857 | 4019 | } |
3858 | 4020 | |
3859 | 4021 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3875,36 +4037,43 @@ discard block |
||
3875 | 4037 | $group_name = $row['group_name']; |
3876 | 4038 | |
3877 | 4039 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3878 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3879 | - fatal_lang_error('no_access', false); |
|
4040 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4041 | + fatal_lang_error('no_access', false); |
|
4042 | + } |
|
3880 | 4043 | // What about leaving a requestable group we are not a member of? |
3881 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3882 | - fatal_lang_error('no_access', false); |
|
3883 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3884 | - fatal_lang_error('no_access', false); |
|
4044 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4045 | + fatal_lang_error('no_access', false); |
|
4046 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4047 | + fatal_lang_error('no_access', false); |
|
4048 | + } |
|
3885 | 4049 | |
3886 | 4050 | // We can't change the primary group if this is hidden! |
3887 | - if ($row['hidden'] == 2) |
|
3888 | - $canChangePrimary = false; |
|
4051 | + if ($row['hidden'] == 2) { |
|
4052 | + $canChangePrimary = false; |
|
4053 | + } |
|
3889 | 4054 | } |
3890 | 4055 | |
3891 | 4056 | // If this is their old primary, can we change it? |
3892 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3893 | - $canChangePrimary = 1; |
|
4057 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4058 | + $canChangePrimary = 1; |
|
4059 | + } |
|
3894 | 4060 | |
3895 | 4061 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3896 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3897 | - $canChangePrimary = false; |
|
4062 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4063 | + $canChangePrimary = false; |
|
4064 | + } |
|
3898 | 4065 | |
3899 | 4066 | // If this is the one we are acting on, can we even act? |
3900 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3901 | - $canChangePrimary = false; |
|
4067 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4068 | + $canChangePrimary = false; |
|
4069 | + } |
|
3902 | 4070 | } |
3903 | 4071 | $smcFunc['db_free_result']($request); |
3904 | 4072 | |
3905 | 4073 | // Didn't find the target? |
3906 | - if (!$foundTarget) |
|
3907 | - fatal_lang_error('no_access', false); |
|
4074 | + if (!$foundTarget) { |
|
4075 | + fatal_lang_error('no_access', false); |
|
4076 | + } |
|
3908 | 4077 | |
3909 | 4078 | // Final security check, don't allow users to promote themselves to admin. |
3910 | 4079 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3924,8 +4093,9 @@ discard block |
||
3924 | 4093 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3925 | 4094 | $smcFunc['db_free_result']($request); |
3926 | 4095 | |
3927 | - if ($disallow) |
|
3928 | - isAllowedTo('admin_forum'); |
|
4096 | + if ($disallow) { |
|
4097 | + isAllowedTo('admin_forum'); |
|
4098 | + } |
|
3929 | 4099 | } |
3930 | 4100 | |
3931 | 4101 | // If we're requesting, add the note then return. |
@@ -3943,8 +4113,9 @@ discard block |
||
3943 | 4113 | 'status_open' => 0, |
3944 | 4114 | ) |
3945 | 4115 | ); |
3946 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3947 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4116 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4117 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4118 | + } |
|
3948 | 4119 | $smcFunc['db_free_result']($request); |
3949 | 4120 | |
3950 | 4121 | // Log the request. |
@@ -3978,10 +4149,11 @@ discard block |
||
3978 | 4149 | // Are we leaving? |
3979 | 4150 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3980 | 4151 | { |
3981 | - if ($old_profile['id_group'] == $group_id) |
|
3982 | - $newPrimary = 0; |
|
3983 | - else |
|
3984 | - unset($addGroups[$group_id]); |
|
4152 | + if ($old_profile['id_group'] == $group_id) { |
|
4153 | + $newPrimary = 0; |
|
4154 | + } else { |
|
4155 | + unset($addGroups[$group_id]); |
|
4156 | + } |
|
3985 | 4157 | } |
3986 | 4158 | // ... if not, must be joining. |
3987 | 4159 | else |
@@ -3989,36 +4161,42 @@ discard block |
||
3989 | 4161 | // Can we change the primary, and do we want to? |
3990 | 4162 | if ($canChangePrimary) |
3991 | 4163 | { |
3992 | - if ($old_profile['id_group'] != 0) |
|
3993 | - $addGroups[$old_profile['id_group']] = -1; |
|
4164 | + if ($old_profile['id_group'] != 0) { |
|
4165 | + $addGroups[$old_profile['id_group']] = -1; |
|
4166 | + } |
|
3994 | 4167 | $newPrimary = $group_id; |
3995 | 4168 | } |
3996 | 4169 | // Otherwise it's an additional group... |
3997 | - else |
|
3998 | - $addGroups[$group_id] = -1; |
|
4170 | + else { |
|
4171 | + $addGroups[$group_id] = -1; |
|
4172 | + } |
|
3999 | 4173 | } |
4000 | 4174 | } |
4001 | 4175 | // Finally, we must be setting the primary. |
4002 | 4176 | elseif ($canChangePrimary) |
4003 | 4177 | { |
4004 | - if ($old_profile['id_group'] != 0) |
|
4005 | - $addGroups[$old_profile['id_group']] = -1; |
|
4006 | - if (isset($addGroups[$group_id])) |
|
4007 | - unset($addGroups[$group_id]); |
|
4178 | + if ($old_profile['id_group'] != 0) { |
|
4179 | + $addGroups[$old_profile['id_group']] = -1; |
|
4180 | + } |
|
4181 | + if (isset($addGroups[$group_id])) { |
|
4182 | + unset($addGroups[$group_id]); |
|
4183 | + } |
|
4008 | 4184 | $newPrimary = $group_id; |
4009 | 4185 | } |
4010 | 4186 | |
4011 | 4187 | // Finally, we can make the changes! |
4012 | - foreach ($addGroups as $id => $dummy) |
|
4013 | - if (empty($id)) |
|
4188 | + foreach ($addGroups as $id => $dummy) { |
|
4189 | + if (empty($id)) |
|
4014 | 4190 | unset($addGroups[$id]); |
4191 | + } |
|
4015 | 4192 | $addGroups = implode(',', array_flip($addGroups)); |
4016 | 4193 | |
4017 | 4194 | // Ensure that we don't cache permissions if the group is changing. |
4018 | - if ($context['user']['is_owner']) |
|
4019 | - $_SESSION['mc']['time'] = 0; |
|
4020 | - else |
|
4021 | - updateSettings(array('settings_updated' => time())); |
|
4195 | + if ($context['user']['is_owner']) { |
|
4196 | + $_SESSION['mc']['time'] = 0; |
|
4197 | + } else { |
|
4198 | + updateSettings(array('settings_updated' => time())); |
|
4199 | + } |
|
4022 | 4200 | |
4023 | 4201 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
4024 | 4202 | |
@@ -4041,8 +4219,9 @@ discard block |
||
4041 | 4219 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4042 | 4220 | { |
4043 | 4221 | // Check to ensure we're forcing SSL for authentication |
4044 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
4045 | - fatal_lang_error('login_ssl_required'); |
|
4222 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
4223 | + fatal_lang_error('login_ssl_required'); |
|
4224 | + } |
|
4046 | 4225 | |
4047 | 4226 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4048 | 4227 | // we do not want too much AJAX to confuse them. |
@@ -4079,8 +4258,7 @@ discard block |
||
4079 | 4258 | $context['sub_template'] = 'tfasetup_backup'; |
4080 | 4259 | |
4081 | 4260 | return; |
4082 | - } |
|
4083 | - else |
|
4261 | + } else |
|
4084 | 4262 | { |
4085 | 4263 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4086 | 4264 | $context['tfa_error'] = !$valid_code; |
@@ -4088,8 +4266,7 @@ discard block |
||
4088 | 4266 | $context['tfa_pass_value'] = $_POST['passwd']; |
4089 | 4267 | $context['tfa_value'] = $_POST['tfa_code']; |
4090 | 4268 | } |
4091 | - } |
|
4092 | - else |
|
4269 | + } else |
|
4093 | 4270 | { |
4094 | 4271 | $totp = new \TOTP\Auth(); |
4095 | 4272 | $secret = $totp->generateCode(); |
@@ -4099,17 +4276,16 @@ discard block |
||
4099 | 4276 | } |
4100 | 4277 | |
4101 | 4278 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4102 | - } |
|
4103 | - elseif (isset($_REQUEST['disable'])) |
|
4279 | + } elseif (isset($_REQUEST['disable'])) |
|
4104 | 4280 | { |
4105 | 4281 | updateMemberData($memID, array( |
4106 | 4282 | 'tfa_secret' => '', |
4107 | 4283 | 'tfa_backup' => '', |
4108 | 4284 | )); |
4109 | 4285 | redirectexit('action=profile;area=account;u=' . $memID); |
4286 | + } else { |
|
4287 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4288 | + } |
|
4110 | 4289 | } |
4111 | - else |
|
4112 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4113 | -} |
|
4114 | 4290 | |
4115 | 4291 | ?> |
4116 | 4292 | \ No newline at end of file |
@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -581,13 +593,13 @@ discard block |
||
581 | 593 | ) |
582 | 594 | ); |
583 | 595 | $context['theme_options'] = array(); |
584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
598 | + } |
|
586 | 599 | $smcFunc['db_free_result']($request); |
587 | 600 | |
588 | 601 | $context['theme_options_reset'] = false; |
589 | - } |
|
590 | - else |
|
602 | + } else |
|
591 | 603 | { |
592 | 604 | $context['theme_options'] = array(); |
593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,30 +608,32 @@ discard block |
||
596 | 608 | foreach ($context['options'] as $i => $setting) |
597 | 609 | { |
598 | 610 | // Just skip separators |
599 | - if (!is_array($setting)) |
|
600 | - continue; |
|
611 | + if (!is_array($setting)) { |
|
612 | + continue; |
|
613 | + } |
|
601 | 614 | |
602 | 615 | // Is this disabled? |
603 | 616 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
604 | 617 | { |
605 | 618 | unset($context['options'][$i]); |
606 | 619 | continue; |
607 | - } |
|
608 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
620 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
609 | 621 | { |
610 | 622 | unset($context['options'][$i]); |
611 | 623 | continue; |
612 | 624 | } |
613 | 625 | |
614 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
615 | - $context['options'][$i]['type'] = 'checkbox'; |
|
616 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
617 | - $context['options'][$i]['type'] = 'number'; |
|
618 | - elseif ($setting['type'] == 'string') |
|
619 | - $context['options'][$i]['type'] = 'text'; |
|
626 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
627 | + $context['options'][$i]['type'] = 'checkbox'; |
|
628 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
629 | + $context['options'][$i]['type'] = 'number'; |
|
630 | + } elseif ($setting['type'] == 'string') { |
|
631 | + $context['options'][$i]['type'] = 'text'; |
|
632 | + } |
|
620 | 633 | |
621 | - if (isset($setting['options'])) |
|
622 | - $context['options'][$i]['type'] = 'list'; |
|
634 | + if (isset($setting['options'])) { |
|
635 | + $context['options'][$i]['type'] = 'list'; |
|
636 | + } |
|
623 | 637 | |
624 | 638 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
625 | 639 | } |
@@ -644,8 +658,9 @@ discard block |
||
644 | 658 | { |
645 | 659 | global $txt, $context, $settings, $modSettings, $smcFunc; |
646 | 660 | |
647 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
648 | - return ThemeAdmin(); |
|
661 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
662 | + return ThemeAdmin(); |
|
663 | + } |
|
649 | 664 | |
650 | 665 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
651 | 666 | |
@@ -656,8 +671,9 @@ discard block |
||
656 | 671 | isAllowedTo('admin_forum'); |
657 | 672 | |
658 | 673 | // Validate inputs/user. |
659 | - if (empty($_GET['th'])) |
|
660 | - fatal_lang_error('no_theme', false); |
|
674 | + if (empty($_GET['th'])) { |
|
675 | + fatal_lang_error('no_theme', false); |
|
676 | + } |
|
661 | 677 | |
662 | 678 | // Fetch the smiley sets... |
663 | 679 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -665,8 +681,9 @@ discard block |
||
665 | 681 | $context['smiley_sets'] = array( |
666 | 682 | '' => $txt['smileys_no_default'] |
667 | 683 | ); |
668 | - foreach ($sets as $i => $set) |
|
669 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
684 | + foreach ($sets as $i => $set) { |
|
685 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
686 | + } |
|
670 | 687 | |
671 | 688 | $old_id = $settings['theme_id']; |
672 | 689 | $old_settings = $settings; |
@@ -691,8 +708,9 @@ discard block |
||
691 | 708 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
692 | 709 | { |
693 | 710 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
694 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
695 | - eval('global $settings;' . $matches[0]); |
|
711 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
712 | + eval('global $settings;' . $matches[0]); |
|
713 | + } |
|
696 | 714 | } |
697 | 715 | |
698 | 716 | // Let mods hook into the theme settings. |
@@ -704,37 +722,45 @@ discard block |
||
704 | 722 | checkSession(); |
705 | 723 | validateToken('admin-sts'); |
706 | 724 | |
707 | - if (empty($_POST['options'])) |
|
708 | - $_POST['options'] = array(); |
|
709 | - if (empty($_POST['default_options'])) |
|
710 | - $_POST['default_options'] = array(); |
|
725 | + if (empty($_POST['options'])) { |
|
726 | + $_POST['options'] = array(); |
|
727 | + } |
|
728 | + if (empty($_POST['default_options'])) { |
|
729 | + $_POST['default_options'] = array(); |
|
730 | + } |
|
711 | 731 | |
712 | 732 | // Make sure items are cast correctly. |
713 | 733 | foreach ($context['theme_settings'] as $item) |
714 | 734 | { |
715 | 735 | // Disregard this item if this is just a separator. |
716 | - if (!is_array($item)) |
|
717 | - continue; |
|
736 | + if (!is_array($item)) { |
|
737 | + continue; |
|
738 | + } |
|
718 | 739 | |
719 | 740 | foreach (array('options', 'default_options') as $option) |
720 | 741 | { |
721 | - if (!isset($_POST[$option][$item['id']])) |
|
722 | - continue; |
|
742 | + if (!isset($_POST[$option][$item['id']])) { |
|
743 | + continue; |
|
744 | + } |
|
723 | 745 | // Checkbox. |
724 | - elseif (empty($item['type'])) |
|
725 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
746 | + elseif (empty($item['type'])) { |
|
747 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
748 | + } |
|
726 | 749 | // Number |
727 | - elseif ($item['type'] == 'number') |
|
728 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
750 | + elseif ($item['type'] == 'number') { |
|
751 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
752 | + } |
|
729 | 753 | } |
730 | 754 | } |
731 | 755 | |
732 | 756 | // Set up the sql query. |
733 | 757 | $inserts = array(); |
734 | - foreach ($_POST['options'] as $opt => $val) |
|
735 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
736 | - foreach ($_POST['default_options'] as $opt => $val) |
|
737 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
758 | + foreach ($_POST['options'] as $opt => $val) { |
|
759 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
760 | + } |
|
761 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
762 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
763 | + } |
|
738 | 764 | // If we're actually inserting something.. |
739 | 765 | if (!empty($inserts)) |
740 | 766 | { |
@@ -760,8 +786,9 @@ discard block |
||
760 | 786 | |
761 | 787 | foreach ($settings as $setting => $dummy) |
762 | 788 | { |
763 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
764 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
789 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
790 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
791 | + } |
|
765 | 792 | } |
766 | 793 | |
767 | 794 | $context['settings'] = $context['theme_settings']; |
@@ -770,18 +797,21 @@ discard block |
||
770 | 797 | foreach ($context['settings'] as $i => $setting) |
771 | 798 | { |
772 | 799 | // Separators are dummies, so leave them alone. |
773 | - if (!is_array($setting)) |
|
774 | - continue; |
|
800 | + if (!is_array($setting)) { |
|
801 | + continue; |
|
802 | + } |
|
775 | 803 | |
776 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
777 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
778 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
779 | - $context['settings'][$i]['type'] = 'number'; |
|
780 | - elseif ($setting['type'] == 'string') |
|
781 | - $context['settings'][$i]['type'] = 'text'; |
|
804 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
805 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
806 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
807 | + $context['settings'][$i]['type'] = 'number'; |
|
808 | + } elseif ($setting['type'] == 'string') { |
|
809 | + $context['settings'][$i]['type'] = 'text'; |
|
810 | + } |
|
782 | 811 | |
783 | - if (isset($setting['options'])) |
|
784 | - $context['settings'][$i]['type'] = 'list'; |
|
812 | + if (isset($setting['options'])) { |
|
813 | + $context['settings'][$i]['type'] = 'list'; |
|
814 | + } |
|
785 | 815 | |
786 | 816 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
787 | 817 | } |
@@ -834,8 +864,9 @@ discard block |
||
834 | 864 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
835 | 865 | |
836 | 866 | // You can't delete the default theme! |
837 | - if ($themeID == 1) |
|
838 | - fatal_lang_error('no_access', false); |
|
867 | + if ($themeID == 1) { |
|
868 | + fatal_lang_error('no_access', false); |
|
869 | + } |
|
839 | 870 | |
840 | 871 | $theme_info = get_single_theme($themeID); |
841 | 872 | |
@@ -843,8 +874,9 @@ discard block |
||
843 | 874 | remove_theme($themeID); |
844 | 875 | |
845 | 876 | // And remove all its files and folders too. |
846 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
847 | - remove_dir($theme_info['theme_dir']); |
|
877 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
878 | + remove_dir($theme_info['theme_dir']); |
|
879 | + } |
|
848 | 880 | |
849 | 881 | // Go back to the list page. |
850 | 882 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -869,12 +901,14 @@ discard block |
||
869 | 901 | $enableThemes = explode(',', $modSettings['enableThemes']); |
870 | 902 | |
871 | 903 | // Are we disabling it? |
872 | - if (isset($_GET['disabled'])) |
|
873 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
904 | + if (isset($_GET['disabled'])) { |
|
905 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
906 | + } |
|
874 | 907 | |
875 | 908 | // Nope? then enable it! |
876 | - else |
|
877 | - $enableThemes[] = (string) $themeID; |
|
909 | + else { |
|
910 | + $enableThemes[] = (string) $themeID; |
|
911 | + } |
|
878 | 912 | |
879 | 913 | // Update the setting. |
880 | 914 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -909,18 +943,21 @@ discard block |
||
909 | 943 | |
910 | 944 | $_SESSION['id_theme'] = 0; |
911 | 945 | |
912 | - if (isset($_GET['id'])) |
|
913 | - $_GET['th'] = $_GET['id']; |
|
946 | + if (isset($_GET['id'])) { |
|
947 | + $_GET['th'] = $_GET['id']; |
|
948 | + } |
|
914 | 949 | |
915 | 950 | // Saving a variant cause JS doesn't work - pretend it did ;) |
916 | 951 | if (isset($_POST['save'])) |
917 | 952 | { |
918 | 953 | // Which theme? |
919 | - foreach ($_POST['save'] as $k => $v) |
|
920 | - $_GET['th'] = (int) $k; |
|
954 | + foreach ($_POST['save'] as $k => $v) { |
|
955 | + $_GET['th'] = (int) $k; |
|
956 | + } |
|
921 | 957 | |
922 | - if (isset($_POST['vrt'][$k])) |
|
923 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
958 | + if (isset($_POST['vrt'][$k])) { |
|
959 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
960 | + } |
|
924 | 961 | } |
925 | 962 | |
926 | 963 | // Have we made a decision, or are we just browsing? |
@@ -998,8 +1035,9 @@ discard block |
||
998 | 1035 | else |
999 | 1036 | { |
1000 | 1037 | // The forum's default theme is always 0 and we |
1001 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
1002 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1038 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1039 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1040 | + } |
|
1003 | 1041 | |
1004 | 1042 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
1005 | 1043 | |
@@ -1013,8 +1051,9 @@ discard block |
||
1013 | 1051 | ); |
1014 | 1052 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1015 | 1053 | |
1016 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1017 | - $_SESSION['id_variant'] = 0; |
|
1054 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1055 | + $_SESSION['id_variant'] = 0; |
|
1056 | + } |
|
1018 | 1057 | } |
1019 | 1058 | |
1020 | 1059 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1083,12 +1122,13 @@ discard block |
||
1083 | 1122 | ); |
1084 | 1123 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1085 | 1124 | { |
1086 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1087 | - $context['available_themes'][$row['id_theme']] = array( |
|
1125 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1126 | + $context['available_themes'][$row['id_theme']] = array( |
|
1088 | 1127 | 'id' => $row['id_theme'], |
1089 | 1128 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1090 | 1129 | 'num_users' => 0 |
1091 | 1130 | ); |
1131 | + } |
|
1092 | 1132 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1093 | 1133 | } |
1094 | 1134 | $smcFunc['db_free_result']($request); |
@@ -1101,9 +1141,9 @@ discard block |
||
1101 | 1141 | 'num_users' => 0 |
1102 | 1142 | ); |
1103 | 1143 | $guest_theme = 0; |
1144 | + } else { |
|
1145 | + $guest_theme = $modSettings['theme_guests']; |
|
1104 | 1146 | } |
1105 | - else |
|
1106 | - $guest_theme = $modSettings['theme_guests']; |
|
1107 | 1147 | |
1108 | 1148 | $request = $smcFunc['db_query']('', ' |
1109 | 1149 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1116,15 +1156,17 @@ discard block |
||
1116 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1117 | 1157 | { |
1118 | 1158 | // Figure out which theme it is they are REALLY using. |
1119 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1120 | - $row['id_theme'] = $guest_theme; |
|
1121 | - elseif (empty($modSettings['theme_allow'])) |
|
1122 | - $row['id_theme'] = $guest_theme; |
|
1159 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1160 | + $row['id_theme'] = $guest_theme; |
|
1161 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1162 | + $row['id_theme'] = $guest_theme; |
|
1163 | + } |
|
1123 | 1164 | |
1124 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1125 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1126 | - else |
|
1127 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1165 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1166 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1167 | + } else { |
|
1168 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1169 | + } |
|
1128 | 1170 | } |
1129 | 1171 | $smcFunc['db_free_result']($request); |
1130 | 1172 | |
@@ -1143,8 +1185,9 @@ discard block |
||
1143 | 1185 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1144 | 1186 | ) |
1145 | 1187 | ); |
1146 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1147 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1188 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1189 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1190 | + } |
|
1148 | 1191 | $smcFunc['db_free_result']($request); |
1149 | 1192 | } |
1150 | 1193 | |
@@ -1155,17 +1198,18 @@ discard block |
||
1155 | 1198 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1156 | 1199 | { |
1157 | 1200 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1158 | - if ($id_theme == 0) |
|
1159 | - continue; |
|
1201 | + if ($id_theme == 0) { |
|
1202 | + continue; |
|
1203 | + } |
|
1160 | 1204 | |
1161 | 1205 | // The thumbnail needs the correct path. |
1162 | 1206 | $settings['images_url'] = &$theme_data['images_url']; |
1163 | 1207 | |
1164 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1165 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1166 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1167 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1168 | - else |
|
1208 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1209 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1210 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1211 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1212 | + } else |
|
1169 | 1213 | { |
1170 | 1214 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1171 | 1215 | $txt['theme_description'] = ''; |
@@ -1190,15 +1234,17 @@ discard block |
||
1190 | 1234 | loadLanguage('Settings'); |
1191 | 1235 | |
1192 | 1236 | $context['available_themes'][$id_theme]['variants'] = array(); |
1193 | - foreach ($settings['theme_variants'] as $variant) |
|
1194 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1237 | + foreach ($settings['theme_variants'] as $variant) { |
|
1238 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1195 | 1239 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1196 | 1240 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1197 | 1241 | ); |
1242 | + } |
|
1198 | 1243 | |
1199 | 1244 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1200 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1201 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1245 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1246 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1247 | + } |
|
1202 | 1248 | |
1203 | 1249 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1204 | 1250 | // Allow themes to override the text. |
@@ -1214,8 +1260,9 @@ discard block |
||
1214 | 1260 | // As long as we're not doing the default theme... |
1215 | 1261 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1216 | 1262 | { |
1217 | - if ($guest_theme != 0) |
|
1218 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1263 | + if ($guest_theme != 0) { |
|
1264 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1265 | + } |
|
1219 | 1266 | |
1220 | 1267 | $context['available_themes'][0]['id'] = 0; |
1221 | 1268 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1264,14 +1311,16 @@ discard block |
||
1264 | 1311 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1265 | 1312 | |
1266 | 1313 | // Got any info from the specific form? |
1267 | - if (!isset($_POST['save_' . $action])) |
|
1268 | - fatal_lang_error('theme_install_no_action', false); |
|
1314 | + if (!isset($_POST['save_' . $action])) { |
|
1315 | + fatal_lang_error('theme_install_no_action', false); |
|
1316 | + } |
|
1269 | 1317 | |
1270 | 1318 | validateToken('admin-t-' . $action); |
1271 | 1319 | |
1272 | 1320 | // Hopefully the themes directory is writable, or we might have a problem. |
1273 | - if (!is_writable($themedir)) |
|
1274 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1321 | + if (!is_writable($themedir)) { |
|
1322 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1323 | + } |
|
1275 | 1324 | |
1276 | 1325 | // Call the function and handle the result. |
1277 | 1326 | $result = $subActions[$action](); |
@@ -1286,9 +1335,10 @@ discard block |
||
1286 | 1335 | } |
1287 | 1336 | |
1288 | 1337 | // Nope, show a nice error. |
1289 | - else |
|
1290 | - fatal_lang_error('theme_install_no_action', false); |
|
1291 | -} |
|
1338 | + else { |
|
1339 | + fatal_lang_error('theme_install_no_action', false); |
|
1340 | + } |
|
1341 | + } |
|
1292 | 1342 | |
1293 | 1343 | /** |
1294 | 1344 | * Installs a theme from a theme package. |
@@ -1304,8 +1354,9 @@ discard block |
||
1304 | 1354 | $dirtemp = $themedir . '/temp'; |
1305 | 1355 | |
1306 | 1356 | // Make sure the temp dir doesn't already exist |
1307 | - if (file_exists($dirtemp)) |
|
1308 | - remove_dir($dirtemp); |
|
1357 | + if (file_exists($dirtemp)) { |
|
1358 | + remove_dir($dirtemp); |
|
1359 | + } |
|
1309 | 1360 | |
1310 | 1361 | // Create the temp dir. |
1311 | 1362 | mkdir($dirtemp, 0777); |
@@ -1317,17 +1368,20 @@ discard block |
||
1317 | 1368 | smf_chmod($dirtemp, '0755'); |
1318 | 1369 | |
1319 | 1370 | // How about now? |
1320 | - if (!is_writable($dirtemp)) |
|
1321 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1371 | + if (!is_writable($dirtemp)) { |
|
1372 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1373 | + } |
|
1322 | 1374 | } |
1323 | 1375 | |
1324 | 1376 | // This happens when the admin session is gone and the user has to login again. |
1325 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1326 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1377 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1378 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1379 | + } |
|
1327 | 1380 | |
1328 | 1381 | // Another error check layer, something went wrong with the upload. |
1329 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1330 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1382 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1383 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1384 | + } |
|
1331 | 1385 | |
1332 | 1386 | // Get the theme's name. |
1333 | 1387 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1358,11 +1412,10 @@ discard block |
||
1358 | 1412 | |
1359 | 1413 | // return all the info. |
1360 | 1414 | return $context['to_install']; |
1415 | + } else { |
|
1416 | + fatal_lang_error('theme_install_error_title', false); |
|
1417 | + } |
|
1361 | 1418 | } |
1362 | - |
|
1363 | - else |
|
1364 | - fatal_lang_error('theme_install_error_title', false); |
|
1365 | -} |
|
1366 | 1419 | |
1367 | 1420 | /** |
1368 | 1421 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1376,15 +1429,17 @@ discard block |
||
1376 | 1429 | global $forum_version; |
1377 | 1430 | |
1378 | 1431 | // There's gotta be something to work with. |
1379 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1380 | - fatal_lang_error('theme_install_error_title', false); |
|
1432 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1433 | + fatal_lang_error('theme_install_error_title', false); |
|
1434 | + } |
|
1381 | 1435 | |
1382 | 1436 | // Get a cleaner version. |
1383 | 1437 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1384 | 1438 | |
1385 | 1439 | // Is there a theme already named like this? |
1386 | - if (file_exists($themedir . '/' . $name)) |
|
1387 | - fatal_lang_error('theme_install_already_dir', false); |
|
1440 | + if (file_exists($themedir . '/' . $name)) { |
|
1441 | + fatal_lang_error('theme_install_already_dir', false); |
|
1442 | + } |
|
1388 | 1443 | |
1389 | 1444 | // This is a brand new theme so set all possible values. |
1390 | 1445 | $context['to_install'] = array( |
@@ -1404,8 +1459,9 @@ discard block |
||
1404 | 1459 | |
1405 | 1460 | // Buy some time. |
1406 | 1461 | @set_time_limit(600); |
1407 | - if (function_exists('apache_reset_timeout')) |
|
1408 | - @apache_reset_timeout(); |
|
1462 | + if (function_exists('apache_reset_timeout')) { |
|
1463 | + @apache_reset_timeout(); |
|
1464 | + } |
|
1409 | 1465 | |
1410 | 1466 | // Create subdirectories for css and javascript files. |
1411 | 1467 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1441,12 +1497,13 @@ discard block |
||
1441 | 1497 | |
1442 | 1498 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1443 | 1499 | { |
1444 | - if ($row['variable'] == 'theme_templates') |
|
1445 | - $theme_templates = $row['value']; |
|
1446 | - elseif ($row['variable'] == 'theme_layers') |
|
1447 | - $theme_layers = $row['value']; |
|
1448 | - else |
|
1449 | - continue; |
|
1500 | + if ($row['variable'] == 'theme_templates') { |
|
1501 | + $theme_templates = $row['value']; |
|
1502 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1503 | + $theme_layers = $row['value']; |
|
1504 | + } else { |
|
1505 | + continue; |
|
1506 | + } |
|
1450 | 1507 | } |
1451 | 1508 | |
1452 | 1509 | $smcFunc['db_free_result']($request); |
@@ -1505,12 +1562,14 @@ discard block |
||
1505 | 1562 | global $themedir, $themeurl, $context; |
1506 | 1563 | |
1507 | 1564 | // Cannot use the theme dir as a theme dir. |
1508 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1509 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1565 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1566 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1567 | + } |
|
1510 | 1568 | |
1511 | 1569 | // Check is there is "something" on the dir. |
1512 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1513 | - fatal_lang_error('theme_install_error', false); |
|
1570 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1571 | + fatal_lang_error('theme_install_error', false); |
|
1572 | + } |
|
1514 | 1573 | |
1515 | 1574 | $name = basename($_REQUEST['theme_dir']); |
1516 | 1575 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1554,24 +1613,27 @@ discard block |
||
1554 | 1613 | } |
1555 | 1614 | |
1556 | 1615 | // Any special layers? |
1557 | - if (isset($settings['catch_action']['layers'])) |
|
1558 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1616 | + if (isset($settings['catch_action']['layers'])) { |
|
1617 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1618 | + } |
|
1559 | 1619 | |
1560 | 1620 | // Any function to call? |
1561 | 1621 | if (isset($settings['catch_action']['function'])) |
1562 | 1622 | { |
1563 | 1623 | $hook = $settings['catch_action']['function']; |
1564 | 1624 | |
1565 | - if (!isset($settings['catch_action']['filename'])) |
|
1566 | - $settings['catch_action']['filename'] = ''; |
|
1625 | + if (!isset($settings['catch_action']['filename'])) { |
|
1626 | + $settings['catch_action']['filename'] = ''; |
|
1627 | + } |
|
1567 | 1628 | |
1568 | 1629 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1569 | 1630 | call_integration_hook('integrate_wrap_action'); |
1570 | 1631 | } |
1571 | 1632 | // And finally, the main sub template ;). |
1572 | - if (isset($settings['catch_action']['sub_template'])) |
|
1573 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1574 | -} |
|
1633 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1634 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1635 | + } |
|
1636 | + } |
|
1575 | 1637 | |
1576 | 1638 | /** |
1577 | 1639 | * Set an option via javascript. |
@@ -1590,12 +1652,14 @@ discard block |
||
1590 | 1652 | checkSession('get'); |
1591 | 1653 | |
1592 | 1654 | // This good-for-nothing pixel is being used to keep the session alive. |
1593 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1594 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1655 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1656 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1657 | + } |
|
1595 | 1658 | |
1596 | 1659 | // Sorry, guests can't go any further than this. |
1597 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1598 | - obExit(false); |
|
1660 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1661 | + obExit(false); |
|
1662 | + } |
|
1599 | 1663 | |
1600 | 1664 | $reservedVars = array( |
1601 | 1665 | 'actual_theme_url', |
@@ -1618,8 +1682,9 @@ discard block |
||
1618 | 1682 | ); |
1619 | 1683 | |
1620 | 1684 | // Can't change reserved vars. |
1621 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1622 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1685 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1686 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1687 | + } |
|
1623 | 1688 | |
1624 | 1689 | // Use a specific theme? |
1625 | 1690 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1635,8 +1700,9 @@ discard block |
||
1635 | 1700 | { |
1636 | 1701 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1637 | 1702 | // New thingy... |
1638 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1639 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1703 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1704 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1705 | + } |
|
1640 | 1706 | |
1641 | 1707 | // Change the value to be something nice, |
1642 | 1708 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1666,8 +1732,9 @@ discard block |
||
1666 | 1732 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1667 | 1733 | |
1668 | 1734 | // @todo Should this be removed? |
1669 | - if (isset($_REQUEST['preview'])) |
|
1670 | - die('die() with fire'); |
|
1735 | + if (isset($_REQUEST['preview'])) { |
|
1736 | + die('die() with fire'); |
|
1737 | + } |
|
1671 | 1738 | |
1672 | 1739 | isAllowedTo('admin_forum'); |
1673 | 1740 | loadTemplate('Themes'); |
@@ -1681,11 +1748,11 @@ discard block |
||
1681 | 1748 | foreach ($context['themes'] as $key => $theme) |
1682 | 1749 | { |
1683 | 1750 | // There has to be a Settings template! |
1684 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1685 | - unset($context['themes'][$key]); |
|
1686 | - |
|
1687 | - else |
|
1688 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1751 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1752 | + unset($context['themes'][$key]); |
|
1753 | + } else { |
|
1754 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1755 | + } |
|
1689 | 1756 | } |
1690 | 1757 | |
1691 | 1758 | $context['sub_template'] = 'edit_list'; |
@@ -1700,22 +1767,24 @@ discard block |
||
1700 | 1767 | $context['theme_id'] = $currentTheme['id']; |
1701 | 1768 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1702 | 1769 | |
1703 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1704 | - fatal_lang_error('theme_edit_missing', false); |
|
1770 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1771 | + fatal_lang_error('theme_edit_missing', false); |
|
1772 | + } |
|
1705 | 1773 | |
1706 | 1774 | if (!isset($_REQUEST['filename'])) |
1707 | 1775 | { |
1708 | 1776 | if (isset($_GET['directory'])) |
1709 | 1777 | { |
1710 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1711 | - $_GET['directory'] = ''; |
|
1712 | - else |
|
1778 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1779 | + $_GET['directory'] = ''; |
|
1780 | + } else |
|
1713 | 1781 | { |
1714 | 1782 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1715 | 1783 | |
1716 | 1784 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1717 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1718 | - $_GET['directory'] = ''; |
|
1785 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1786 | + $_GET['directory'] = ''; |
|
1787 | + } |
|
1719 | 1788 | } |
1720 | 1789 | } |
1721 | 1790 | |
@@ -1734,37 +1803,39 @@ discard block |
||
1734 | 1803 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1735 | 1804 | 'size' => '', |
1736 | 1805 | )); |
1806 | + } else { |
|
1807 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1737 | 1808 | } |
1738 | - else |
|
1739 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1740 | 1809 | |
1741 | 1810 | $context['sub_template'] = 'edit_browse'; |
1742 | 1811 | |
1743 | 1812 | return; |
1744 | - } |
|
1745 | - else |
|
1813 | + } else |
|
1746 | 1814 | { |
1747 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1748 | - $_REQUEST['filename'] = ''; |
|
1749 | - else |
|
1815 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1816 | + $_REQUEST['filename'] = ''; |
|
1817 | + } else |
|
1750 | 1818 | { |
1751 | 1819 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1752 | 1820 | |
1753 | 1821 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1754 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1755 | - $_REQUEST['filename'] = ''; |
|
1822 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1823 | + $_REQUEST['filename'] = ''; |
|
1824 | + } |
|
1756 | 1825 | } |
1757 | 1826 | |
1758 | - if (empty($_REQUEST['filename'])) |
|
1759 | - fatal_lang_error('theme_edit_missing', false); |
|
1827 | + if (empty($_REQUEST['filename'])) { |
|
1828 | + fatal_lang_error('theme_edit_missing', false); |
|
1829 | + } |
|
1760 | 1830 | } |
1761 | 1831 | |
1762 | 1832 | if (isset($_POST['save'])) |
1763 | 1833 | { |
1764 | 1834 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1765 | 1835 | { |
1766 | - if (is_array($_POST['entire_file'])) |
|
1767 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1836 | + if (is_array($_POST['entire_file'])) { |
|
1837 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1838 | + } |
|
1768 | 1839 | |
1769 | 1840 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1770 | 1841 | |
@@ -1776,10 +1847,11 @@ discard block |
||
1776 | 1847 | fclose($fp); |
1777 | 1848 | |
1778 | 1849 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1779 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1780 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1781 | - else |
|
1782 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1850 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1851 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1852 | + } else { |
|
1853 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1854 | + } |
|
1783 | 1855 | } |
1784 | 1856 | |
1785 | 1857 | if (!isset($error_file)) |
@@ -1800,10 +1872,11 @@ discard block |
||
1800 | 1872 | $context['sub_template'] = 'edit_file'; |
1801 | 1873 | |
1802 | 1874 | // Recycle the submitted data. |
1803 | - if (is_array($_POST['entire_file'])) |
|
1804 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1805 | - else |
|
1806 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1875 | + if (is_array($_POST['entire_file'])) { |
|
1876 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1877 | + } else { |
|
1878 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1879 | + } |
|
1807 | 1880 | |
1808 | 1881 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1809 | 1882 | |
@@ -1826,17 +1899,17 @@ discard block |
||
1826 | 1899 | $context['sub_template'] = 'edit_style'; |
1827 | 1900 | |
1828 | 1901 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1829 | - } |
|
1830 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1902 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1831 | 1903 | { |
1832 | 1904 | $context['sub_template'] = 'edit_template'; |
1833 | 1905 | |
1834 | - if (!isset($error_file)) |
|
1835 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1836 | - else |
|
1906 | + if (!isset($error_file)) { |
|
1907 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1908 | + } else |
|
1837 | 1909 | { |
1838 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1839 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1910 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1911 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1912 | + } |
|
1840 | 1913 | $file_data = file($error_file); |
1841 | 1914 | unlink($error_file); |
1842 | 1915 | } |
@@ -1850,8 +1923,9 @@ discard block |
||
1850 | 1923 | // Try to format the functions a little nicer... |
1851 | 1924 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1852 | 1925 | |
1853 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1854 | - unset($context['file_parts'][$j]); |
|
1926 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1927 | + unset($context['file_parts'][$j]); |
|
1928 | + } |
|
1855 | 1929 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1856 | 1930 | } |
1857 | 1931 | |
@@ -1860,8 +1934,7 @@ discard block |
||
1860 | 1934 | } |
1861 | 1935 | |
1862 | 1936 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1863 | - } |
|
1864 | - else |
|
1937 | + } else |
|
1865 | 1938 | { |
1866 | 1939 | $context['sub_template'] = 'edit_file'; |
1867 | 1940 | |
@@ -1887,8 +1960,9 @@ discard block |
||
1887 | 1960 | |
1888 | 1961 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1889 | 1962 | |
1890 | - if (empty($_GET['th'])) |
|
1891 | - fatal_lang_error('theme_install_invalid_id'); |
|
1963 | + if (empty($_GET['th'])) { |
|
1964 | + fatal_lang_error('theme_install_invalid_id'); |
|
1965 | + } |
|
1892 | 1966 | |
1893 | 1967 | // Get the theme info. |
1894 | 1968 | $theme = get_single_theme($_GET['th']); |
@@ -1896,25 +1970,24 @@ discard block |
||
1896 | 1970 | |
1897 | 1971 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1898 | 1972 | { |
1899 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1900 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1901 | - |
|
1902 | - else |
|
1903 | - fatal_lang_error('no_access', false); |
|
1973 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1974 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1975 | + } else { |
|
1976 | + fatal_lang_error('no_access', false); |
|
1977 | + } |
|
1904 | 1978 | |
1905 | 1979 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1906 | 1980 | fwrite($fp, file_get_contents($filename)); |
1907 | 1981 | fclose($fp); |
1908 | 1982 | |
1909 | 1983 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1910 | - } |
|
1911 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1984 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1912 | 1985 | { |
1913 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1914 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1915 | - |
|
1916 | - else |
|
1917 | - fatal_lang_error('no_access', false); |
|
1986 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1987 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1988 | + } else { |
|
1989 | + fatal_lang_error('no_access', false); |
|
1990 | + } |
|
1918 | 1991 | |
1919 | 1992 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1920 | 1993 | fwrite($fp, file_get_contents($filename)); |
@@ -1929,16 +2002,18 @@ discard block |
||
1929 | 2002 | $dir = dir($settings['default_theme_dir']); |
1930 | 2003 | while ($entry = $dir->read()) |
1931 | 2004 | { |
1932 | - if (substr($entry, -13) == '.template.php') |
|
1933 | - $templates[] = substr($entry, 0, -13); |
|
2005 | + if (substr($entry, -13) == '.template.php') { |
|
2006 | + $templates[] = substr($entry, 0, -13); |
|
2007 | + } |
|
1934 | 2008 | } |
1935 | 2009 | $dir->close(); |
1936 | 2010 | |
1937 | 2011 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1938 | 2012 | while ($entry = $dir->read()) |
1939 | 2013 | { |
1940 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1941 | - $lang_files[] = $matches[1]; |
|
2014 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2015 | + $lang_files[] = $matches[1]; |
|
2016 | + } |
|
1942 | 2017 | } |
1943 | 2018 | $dir->close(); |
1944 | 2019 | |
@@ -1946,21 +2021,23 @@ discard block |
||
1946 | 2021 | natcasesort($lang_files); |
1947 | 2022 | |
1948 | 2023 | $context['available_templates'] = array(); |
1949 | - foreach ($templates as $template) |
|
1950 | - $context['available_templates'][$template] = array( |
|
2024 | + foreach ($templates as $template) { |
|
2025 | + $context['available_templates'][$template] = array( |
|
1951 | 2026 | 'filename' => $template . '.template.php', |
1952 | 2027 | 'value' => $template, |
1953 | 2028 | 'already_exists' => false, |
1954 | 2029 | 'can_copy' => is_writable($theme['theme_dir']), |
1955 | 2030 | ); |
2031 | + } |
|
1956 | 2032 | $context['available_language_files'] = array(); |
1957 | - foreach ($lang_files as $file) |
|
1958 | - $context['available_language_files'][$file] = array( |
|
2033 | + foreach ($lang_files as $file) { |
|
2034 | + $context['available_language_files'][$file] = array( |
|
1959 | 2035 | 'filename' => $file . '.php', |
1960 | 2036 | 'value' => $file, |
1961 | 2037 | 'already_exists' => false, |
1962 | 2038 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1963 | 2039 | ); |
2040 | + } |
|
1964 | 2041 | |
1965 | 2042 | $dir = dir($theme['theme_dir']); |
1966 | 2043 | while ($entry = $dir->read()) |