@@ -12,5 +12,6 @@ |
||
12 | 12 | header('Location: ' . $boardurl); |
13 | 13 | } |
14 | 14 | // Can't find it... just forget it. |
15 | -else |
|
16 | - exit; |
|
17 | 15 | \ No newline at end of file |
16 | +else { |
|
17 | + exit; |
|
18 | +} |
@@ -50,31 +50,42 @@ discard block |
||
50 | 50 | { |
51 | 51 | // Maybe someone is paranoid or mistakenly misconfigured the param? Give them at least 5 minutes. |
52 | 52 | if ($modSettings['admin_session_lifetime'] < 5) |
53 | - $refreshTime = 5; |
|
53 | + { |
|
54 | + $refreshTime = 5; |
|
55 | + } |
|
54 | 56 | |
55 | 57 | // A whole day should be more than enough.. |
56 | 58 | elseif ($modSettings['admin_session_lifetime'] > 14400) |
57 | - $refreshTime = 14400; |
|
59 | + { |
|
60 | + $refreshTime = 14400; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | // We are between our internal min and max. Let's keep the board owner's value. |
60 | - else |
|
61 | - $refreshTime = $modSettings['admin_session_lifetime']; |
|
64 | + else { |
|
65 | + $refreshTime = $modSettings['admin_session_lifetime']; |
|
66 | + } |
|
62 | 67 | } |
63 | 68 | |
64 | 69 | // If we're using XML give an additional ten minutes grace as an admin can't log on in XML mode. |
65 | 70 | if (isset($_GET['xml'])) |
66 | - $refreshTime += 10; |
|
71 | + { |
|
72 | + $refreshTime += 10; |
|
73 | + } |
|
67 | 74 | |
68 | 75 | $refreshTime = $refreshTime * 60; |
69 | 76 | |
70 | 77 | // Is the security option off? |
71 | 78 | // @todo remove the exception (means update the db as well) |
72 | 79 | if (!empty($modSettings['securityDisable' . ($type != 'admin' ? '_' . $type : '')])) |
73 | - return true; |
|
80 | + { |
|
81 | + return true; |
|
82 | + } |
|
74 | 83 | |
75 | 84 | // If their admin or moderator session hasn't expired yet, let it pass, let the admin session trump a moderation one as well |
76 | 85 | if ((!empty($_SESSION[$type . '_time']) && $_SESSION[$type . '_time'] + $refreshTime >= time()) || (!empty($_SESSION['admin_time']) && $_SESSION['admin_time'] + $refreshTime >= time())) |
77 | - return true; |
|
86 | + { |
|
87 | + return true; |
|
88 | + } |
|
78 | 89 | |
79 | 90 | require_once(SUBSDIR . '/Auth.subs.php'); |
80 | 91 | |
@@ -88,14 +99,18 @@ discard block |
||
88 | 99 | if (isset($_POST[$type . '_hash_pass']) && strlen($_POST[$type . '_hash_pass']) === 64) |
89 | 100 | { |
90 | 101 | if (checkPassword($type, true)) |
91 | - return true; |
|
102 | + { |
|
103 | + return true; |
|
104 | + } |
|
92 | 105 | } |
93 | 106 | |
94 | 107 | // Posting the password... check it. |
95 | 108 | if (isset($_POST[$type . '_pass']) && str_replace('*', '', $_POST[$type . '_pass']) !== '') |
96 | 109 | { |
97 | 110 | if (checkPassword($type)) |
98 | - return true; |
|
111 | + { |
|
112 | + return true; |
|
113 | + } |
|
99 | 114 | } |
100 | 115 | } |
101 | 116 | |
@@ -114,13 +129,19 @@ discard block |
||
114 | 129 | |
115 | 130 | // Better be sure to remember the real referer |
116 | 131 | if (empty($_SESSION['request_referer'])) |
117 | - $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; |
|
132 | + { |
|
133 | + $_SESSION['request_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; |
|
134 | + } |
|
118 | 135 | elseif (empty($_POST)) |
119 | - unset($_SESSION['request_referer']); |
|
136 | + { |
|
137 | + unset($_SESSION['request_referer']); |
|
138 | + } |
|
120 | 139 | |
121 | 140 | // Need to type in a password for that, man. |
122 | 141 | if (!isset($_GET['xml'])) |
123 | - adminLogin($type); |
|
142 | + { |
|
143 | + adminLogin($type); |
|
144 | + } |
|
124 | 145 | |
125 | 146 | return 'session_verify_fail'; |
126 | 147 | } |
@@ -178,7 +199,9 @@ discard block |
||
178 | 199 | |
179 | 200 | // Luckily, this person isn't a guest. |
180 | 201 | if (isset($user_info['is_guest']) && !$user_info['is_guest']) |
181 | - return true; |
|
202 | + { |
|
203 | + return true; |
|
204 | + } |
|
182 | 205 | |
183 | 206 | // People always worry when they see people doing things they aren't actually doing... |
184 | 207 | $_GET['action'] = ''; |
@@ -188,11 +211,15 @@ discard block |
||
188 | 211 | |
189 | 212 | // Just die. |
190 | 213 | if (isset($_REQUEST['xml']) || !$is_fatal) |
191 | - obExit(false); |
|
214 | + { |
|
215 | + obExit(false); |
|
216 | + } |
|
192 | 217 | |
193 | 218 | // Attempt to detect if they came from dlattach. |
194 | 219 | if (ELK != 'SSI' && empty($context['theme_loaded'])) |
195 | - loadTheme(); |
|
220 | + { |
|
221 | + loadTheme(); |
|
222 | + } |
|
196 | 223 | |
197 | 224 | // Never redirect to an attachment |
198 | 225 | if (validLoginUrl($_SERVER['REQUEST_URL'])) |
@@ -210,7 +237,9 @@ discard block |
||
210 | 237 | redirectexit('action=login'); |
211 | 238 | } |
212 | 239 | elseif (isset($_GET['api'])) |
213 | - return false; |
|
240 | + { |
|
241 | + return false; |
|
242 | + } |
|
214 | 243 | else |
215 | 244 | { |
216 | 245 | loadTemplate('Login'); |
@@ -251,7 +280,9 @@ discard block |
||
251 | 280 | |
252 | 281 | // You cannot be banned if you are an admin - doesn't help if you log out. |
253 | 282 | if ($user_info['is_admin']) |
254 | - return; |
|
283 | + { |
|
284 | + return; |
|
285 | + } |
|
255 | 286 | |
256 | 287 | // Only check the ban every so often. (to reduce load.) |
257 | 288 | if ($forceCheck || !isset($_SESSION['ban']) || empty($modSettings['banLastUpdated']) || ($_SESSION['ban']['last_checked'] < $modSettings['banLastUpdated']) || $_SESSION['ban']['id_member'] != $user_info['id'] || $_SESSION['ban']['ip'] != $user_info['ip'] || $_SESSION['ban']['ip2'] != $user_info['ip2'] || (isset($user_info['email'], $_SESSION['ban']['email']) && $_SESSION['ban']['email'] != $user_info['email'])) |
@@ -273,7 +304,9 @@ discard block |
||
273 | 304 | foreach (array('ip', 'ip2') as $ip_number) |
274 | 305 | { |
275 | 306 | if ($ip_number == 'ip2' && $user_info['ip2'] == $user_info['ip']) |
276 | - continue; |
|
307 | + { |
|
308 | + continue; |
|
309 | + } |
|
277 | 310 | $ban_query[] = constructBanQueryIP($user_info[$ip_number]); |
278 | 311 | |
279 | 312 | // IP was valid, maybe there's also a hostname... |
@@ -329,10 +362,14 @@ discard block |
||
329 | 362 | $_SESSION['ban'][$restriction]['reason'] = $row['reason']; |
330 | 363 | $_SESSION['ban'][$restriction]['ids'][] = $row['id_ban']; |
331 | 364 | if (!isset($_SESSION['ban']['expire_time']) || ($_SESSION['ban']['expire_time'] != 0 && ($row['expire_time'] == 0 || $row['expire_time'] > $_SESSION['ban']['expire_time']))) |
332 | - $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
365 | + { |
|
366 | + $_SESSION['ban']['expire_time'] = $row['expire_time']; |
|
367 | + } |
|
333 | 368 | |
334 | 369 | if (!$user_info['is_guest'] && $restriction == 'cannot_access' && ($row['id_member'] == $user_info['id'] || $row['email_address'] == $user_info['email'])) |
335 | - $flag_is_activated = true; |
|
370 | + { |
|
371 | + $flag_is_activated = true; |
|
372 | + } |
|
336 | 373 | } |
337 | 374 | } |
338 | 375 | } |
@@ -341,7 +378,9 @@ discard block |
||
341 | 378 | |
342 | 379 | // Mark the cannot_access and cannot_post bans as being 'hit'. |
343 | 380 | if (isset($_SESSION['ban']['cannot_access']) || isset($_SESSION['ban']['cannot_post']) || isset($_SESSION['ban']['cannot_login'])) |
344 | - log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
381 | + { |
|
382 | + log_ban(array_merge(isset($_SESSION['ban']['cannot_access']) ? $_SESSION['ban']['cannot_access']['ids'] : array(), isset($_SESSION['ban']['cannot_post']) ? $_SESSION['ban']['cannot_post']['ids'] : array(), isset($_SESSION['ban']['cannot_login']) ? $_SESSION['ban']['cannot_login']['ids'] : array())); |
|
383 | + } |
|
345 | 384 | |
346 | 385 | // If for whatever reason the is_activated flag seems wrong, do a little work to clear it up. |
347 | 386 | if ($user_info['id'] && (($user_settings['is_activated'] >= 10 && !$flag_is_activated) |
@@ -357,7 +396,9 @@ discard block |
||
357 | 396 | { |
358 | 397 | $bans = explode(',', $_COOKIE[$cookiename . '_']); |
359 | 398 | foreach ($bans as $key => $value) |
360 | - $bans[$key] = (int) $value; |
|
399 | + { |
|
400 | + $bans[$key] = (int) $value; |
|
401 | + } |
|
361 | 402 | |
362 | 403 | $db->fetchQueryCallback(' |
363 | 404 | SELECT bi.id_ban, bg.reason |
@@ -478,8 +519,10 @@ discard block |
||
478 | 519 | |
479 | 520 | // Fix up the banning permissions. |
480 | 521 | if (isset($user_info['permissions'])) |
481 | - banPermissions(); |
|
482 | -} |
|
522 | + { |
|
523 | + banPermissions(); |
|
524 | + } |
|
525 | + } |
|
483 | 526 | |
484 | 527 | /** |
485 | 528 | * Fix permissions according to ban status. |
@@ -498,7 +541,9 @@ discard block |
||
498 | 541 | |
499 | 542 | // Somehow they got here, at least take away all permissions... |
500 | 543 | if (isset($_SESSION['ban']['cannot_access'])) |
501 | - $user_info['permissions'] = array(); |
|
544 | + { |
|
545 | + $user_info['permissions'] = array(); |
|
546 | + } |
|
502 | 547 | // Okay, well, you can watch, but don't touch a thing. |
503 | 548 | elseif (isset($_SESSION['ban']['cannot_post']) || (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $user_info['warning'])) |
504 | 549 | { |
@@ -543,9 +588,12 @@ discard block |
||
543 | 588 | foreach ($permission_change as $old => $new) |
544 | 589 | { |
545 | 590 | if (!in_array($old, $user_info['permissions'])) |
546 | - unset($permission_change[$old]); |
|
547 | - else |
|
548 | - $user_info['permissions'][] = $new; |
|
591 | + { |
|
592 | + unset($permission_change[$old]); |
|
593 | + } |
|
594 | + else { |
|
595 | + $user_info['permissions'][] = $new; |
|
596 | + } |
|
549 | 597 | } |
550 | 598 | $user_info['permissions'] = array_diff($user_info['permissions'], array_keys($permission_change)); |
551 | 599 | } |
@@ -553,7 +601,9 @@ discard block |
||
553 | 601 | // @todo Find a better place to call this? Needs to be after permissions loaded! |
554 | 602 | // Finally, some bits we cache in the session because it saves queries. |
555 | 603 | if (isset($_SESSION['mc']) && $_SESSION['mc']['time'] > $modSettings['settings_updated'] && $_SESSION['mc']['id'] == $user_info['id']) |
556 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
604 | + { |
|
605 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
606 | + } |
|
557 | 607 | else |
558 | 608 | { |
559 | 609 | require_once(SUBSDIR . '/Auth.subs.php'); |
@@ -574,9 +624,10 @@ discard block |
||
574 | 624 | require_once(SUBSDIR . '/Moderation.subs.php'); |
575 | 625 | recountOpenReports(true, allowedTo('admin_forum')); |
576 | 626 | } |
577 | - else |
|
578 | - $context['open_mod_reports'] = 0; |
|
579 | -} |
|
627 | + else { |
|
628 | + $context['open_mod_reports'] = 0; |
|
629 | + } |
|
630 | + } |
|
580 | 631 | |
581 | 632 | /** |
582 | 633 | * Log a ban in the database. |
@@ -598,7 +649,9 @@ discard block |
||
598 | 649 | |
599 | 650 | // Don't log web accelerators, it's very confusing... |
600 | 651 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
601 | - return; |
|
652 | + { |
|
653 | + return; |
|
654 | + } |
|
602 | 655 | |
603 | 656 | $db->insert('', |
604 | 657 | '{db_prefix}log_banned', |
@@ -609,7 +662,8 @@ discard block |
||
609 | 662 | |
610 | 663 | // One extra point for these bans. |
611 | 664 | if (!empty($ban_ids)) |
612 | - $db->query('', ' |
|
665 | + { |
|
666 | + $db->query('', ' |
|
613 | 667 | UPDATE {db_prefix}ban_items |
614 | 668 | SET hits = hits + 1 |
615 | 669 | WHERE id_ban IN ({array_int:ban_ids})', |
@@ -617,7 +671,8 @@ discard block |
||
617 | 671 | 'ban_ids' => $ban_ids, |
618 | 672 | ) |
619 | 673 | ); |
620 | -} |
|
674 | + } |
|
675 | + } |
|
621 | 676 | |
622 | 677 | /** |
623 | 678 | * Checks if a given email address might be banned. |
@@ -642,7 +697,9 @@ discard block |
||
642 | 697 | |
643 | 698 | // Can't ban an empty email |
644 | 699 | if (empty($email) || trim($email) == '') |
645 | - return; |
|
700 | + { |
|
701 | + return; |
|
702 | + } |
|
646 | 703 | |
647 | 704 | // Let's start with the bans based on your IP/hostname/memberID... |
648 | 705 | $ban_ids = isset($_SESSION['ban'][$restriction]) ? $_SESSION['ban'][$restriction]['ids'] : array(); |
@@ -724,14 +781,18 @@ discard block |
||
724 | 781 | { |
725 | 782 | $check = isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null); |
726 | 783 | if ($check !== $_SESSION['session_value']) |
727 | - $error = 'session_timeout'; |
|
784 | + { |
|
785 | + $error = 'session_timeout'; |
|
786 | + } |
|
728 | 787 | } |
729 | 788 | // How about $_GET['sesc']? |
730 | 789 | elseif ($type === 'get') |
731 | 790 | { |
732 | 791 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : null); |
733 | 792 | if ($check !== $_SESSION['session_value']) |
734 | - $error = 'session_verify_fail'; |
|
793 | + { |
|
794 | + $error = 'session_verify_fail'; |
|
795 | + } |
|
735 | 796 | } |
736 | 797 | // Or can it be in either? |
737 | 798 | elseif ($type == 'request') |
@@ -739,30 +800,40 @@ discard block |
||
739 | 800 | $check = isset($_GET[$_SESSION['session_var']]) ? $_GET[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_GET['sesc']) ? $_GET['sesc'] : (isset($_POST[$_SESSION['session_var']]) ? $_POST[$_SESSION['session_var']] : (empty($modSettings['strictSessionCheck']) && isset($_POST['sc']) ? $_POST['sc'] : null))); |
740 | 801 | |
741 | 802 | if ($check !== $_SESSION['session_value']) |
742 | - $error = 'session_verify_fail'; |
|
803 | + { |
|
804 | + $error = 'session_verify_fail'; |
|
805 | + } |
|
743 | 806 | } |
744 | 807 | |
745 | 808 | // Verify that they aren't changing user agents on us - that could be bad. |
746 | 809 | if ((!isset($_SESSION['USER_AGENT']) || $_SESSION['USER_AGENT'] != $req->user_agent()) && empty($modSettings['disableCheckUA'])) |
747 | - $error = 'session_verify_fail'; |
|
810 | + { |
|
811 | + $error = 'session_verify_fail'; |
|
812 | + } |
|
748 | 813 | |
749 | 814 | // Make sure a page with session check requirement is not being prefetched. |
750 | 815 | stop_prefetching(); |
751 | 816 | |
752 | 817 | // Check the referring site - it should be the same server at least! |
753 | 818 | if (isset($_SESSION['request_referer'])) |
754 | - $referrer_url = $_SESSION['request_referer']; |
|
755 | - else |
|
756 | - $referrer_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; |
|
819 | + { |
|
820 | + $referrer_url = $_SESSION['request_referer']; |
|
821 | + } |
|
822 | + else { |
|
823 | + $referrer_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; |
|
824 | + } |
|
757 | 825 | |
758 | 826 | $referrer = @parse_url($referrer_url); |
759 | 827 | |
760 | 828 | if (!empty($referrer['host'])) |
761 | 829 | { |
762 | 830 | if (strpos($_SERVER['HTTP_HOST'], ':') !== false) |
763 | - $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
764 | - else |
|
765 | - $real_host = $_SERVER['HTTP_HOST']; |
|
831 | + { |
|
832 | + $real_host = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], ':')); |
|
833 | + } |
|
834 | + else { |
|
835 | + $real_host = $_SERVER['HTTP_HOST']; |
|
836 | + } |
|
766 | 837 | |
767 | 838 | $parsed_url = parse_url($boardurl); |
768 | 839 | |
@@ -770,13 +841,19 @@ discard block |
||
770 | 841 | if (!empty($modSettings['globalCookies'])) |
771 | 842 | { |
772 | 843 | if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
773 | - $parsed_url['host'] = $parts[1]; |
|
844 | + { |
|
845 | + $parsed_url['host'] = $parts[1]; |
|
846 | + } |
|
774 | 847 | |
775 | 848 | if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $referrer['host'], $parts) == 1) |
776 | - $referrer['host'] = $parts[1]; |
|
849 | + { |
|
850 | + $referrer['host'] = $parts[1]; |
|
851 | + } |
|
777 | 852 | |
778 | 853 | if (preg_match('~(?:[^\.]+\.)?([^\.]{3,}\..+)\z~i', $real_host, $parts) == 1) |
779 | - $real_host = $parts[1]; |
|
854 | + { |
|
855 | + $real_host = $parts[1]; |
|
856 | + } |
|
780 | 857 | } |
781 | 858 | |
782 | 859 | // Okay: referrer must either match parsed_url or real_host. |
@@ -798,7 +875,9 @@ discard block |
||
798 | 875 | |
799 | 876 | // Everything is ok, return an empty string. |
800 | 877 | if (!isset($error)) |
801 | - return ''; |
|
878 | + { |
|
879 | + return ''; |
|
880 | + } |
|
802 | 881 | // A session error occurred, show the error. |
803 | 882 | elseif ($is_fatal) |
804 | 883 | { |
@@ -808,12 +887,14 @@ discard block |
||
808 | 887 | header('HTTP/1.1 403 Forbidden - Session timeout'); |
809 | 888 | die; |
810 | 889 | } |
811 | - else |
|
812 | - throw new Elk_Exception($error, isset($log_error) ? 'user' : false, isset($sprintf) ? $sprintf : array()); |
|
890 | + else { |
|
891 | + throw new Elk_Exception($error, isset($log_error) ? 'user' : false, isset($sprintf) ? $sprintf : array()); |
|
892 | + } |
|
813 | 893 | } |
814 | 894 | // A session error occurred, return the error to the calling function. |
815 | - else |
|
816 | - return $error; |
|
895 | + else { |
|
896 | + return $error; |
|
897 | + } |
|
817 | 898 | |
818 | 899 | // We really should never fall through here, for very important reasons. Let's make sure. |
819 | 900 | trigger_error('Hacking attempt...', E_USER_ERROR); |
@@ -887,12 +968,15 @@ discard block |
||
887 | 968 | |
888 | 969 | return $return; |
889 | 970 | } |
890 | - else |
|
891 | - return ''; |
|
971 | + else { |
|
972 | + return ''; |
|
973 | + } |
|
892 | 974 | } |
893 | 975 | |
894 | 976 | if (!isset($_SESSION['token'][$token_index])) |
895 | - return false; |
|
977 | + { |
|
978 | + return false; |
|
979 | + } |
|
896 | 980 | |
897 | 981 | // We need the user agent and client IP |
898 | 982 | $req = request(); |
@@ -921,7 +1005,9 @@ discard block |
||
921 | 1005 | createToken($action, $type); |
922 | 1006 | |
923 | 1007 | if ($fatal) |
924 | - throw new Elk_Exception('token_verify_fail', false); |
|
1008 | + { |
|
1009 | + throw new Elk_Exception('token_verify_fail', false); |
|
1010 | + } |
|
925 | 1011 | } |
926 | 1012 | // You don't get a new token |
927 | 1013 | else |
@@ -951,18 +1037,25 @@ discard block |
||
951 | 1037 | { |
952 | 1038 | // We appreciate cleaning up after yourselves. |
953 | 1039 | if (!isset($_SESSION['token'])) |
954 | - return; |
|
1040 | + { |
|
1041 | + return; |
|
1042 | + } |
|
955 | 1043 | |
956 | 1044 | // Clean up tokens, trying to give enough time still. |
957 | 1045 | foreach ($_SESSION['token'] as $key => $data) |
958 | 1046 | { |
959 | 1047 | if (!empty($suffix)) |
960 | - $force = $complete || strpos($key, $suffix); |
|
961 | - else |
|
962 | - $force = $complete; |
|
1048 | + { |
|
1049 | + $force = $complete || strpos($key, $suffix); |
|
1050 | + } |
|
1051 | + else { |
|
1052 | + $force = $complete; |
|
1053 | + } |
|
963 | 1054 | |
964 | 1055 | if ($data[2] + 10800 < time() || $force) |
965 | - unset($_SESSION['token'][$key]); |
|
1056 | + { |
|
1057 | + unset($_SESSION['token'][$key]); |
|
1058 | + } |
|
966 | 1059 | } |
967 | 1060 | } |
968 | 1061 | |
@@ -988,7 +1081,9 @@ discard block |
||
988 | 1081 | global $context; |
989 | 1082 | |
990 | 1083 | if (!isset($_SESSION['forms'])) |
991 | - $_SESSION['forms'] = array(); |
|
1084 | + { |
|
1085 | + $_SESSION['forms'] = array(); |
|
1086 | + } |
|
992 | 1087 | |
993 | 1088 | // Register a form number and store it in the session stack. (use this on the page that has the form.) |
994 | 1089 | if ($action == 'register') |
@@ -996,13 +1091,17 @@ discard block |
||
996 | 1091 | $tokenizer = new Token_Hash(); |
997 | 1092 | $context['form_sequence_number'] = ''; |
998 | 1093 | while (empty($context['form_sequence_number']) || in_array($context['form_sequence_number'], $_SESSION['forms'])) |
999 | - $context['form_sequence_number'] = $tokenizer->generate_hash(); |
|
1094 | + { |
|
1095 | + $context['form_sequence_number'] = $tokenizer->generate_hash(); |
|
1096 | + } |
|
1000 | 1097 | } |
1001 | 1098 | // Check whether the submitted number can be found in the session. |
1002 | 1099 | elseif ($action == 'check') |
1003 | 1100 | { |
1004 | 1101 | if (!isset($_REQUEST['seqnum'])) |
1005 | - return true; |
|
1102 | + { |
|
1103 | + return true; |
|
1104 | + } |
|
1006 | 1105 | elseif (!in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
1007 | 1106 | { |
1008 | 1107 | // Mark this one as used |
@@ -1010,16 +1109,23 @@ discard block |
||
1010 | 1109 | return true; |
1011 | 1110 | } |
1012 | 1111 | elseif ($is_fatal) |
1013 | - throw new Elk_Exception('error_form_already_submitted', false); |
|
1014 | - else |
|
1015 | - return false; |
|
1112 | + { |
|
1113 | + throw new Elk_Exception('error_form_already_submitted', false); |
|
1114 | + } |
|
1115 | + else { |
|
1116 | + return false; |
|
1117 | + } |
|
1016 | 1118 | } |
1017 | 1119 | // Don't check, just free the stack number. |
1018 | 1120 | elseif ($action == 'free' && isset($_REQUEST['seqnum']) && in_array($_REQUEST['seqnum'], $_SESSION['forms'])) |
1019 | - $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
1121 | + { |
|
1122 | + $_SESSION['forms'] = array_diff($_SESSION['forms'], array($_REQUEST['seqnum'])); |
|
1123 | + } |
|
1020 | 1124 | elseif ($action != 'free') |
1021 | - trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
1022 | -} |
|
1125 | + { |
|
1126 | + trigger_error('checkSubmitOnce(): Invalid action \'' . $action . '\'', E_USER_WARNING); |
|
1127 | + } |
|
1128 | + } |
|
1023 | 1129 | |
1024 | 1130 | /** |
1025 | 1131 | * This function checks whether the user is allowed to do permission. (ie. post_new.) |
@@ -1042,35 +1148,49 @@ discard block |
||
1042 | 1148 | |
1043 | 1149 | // You're always allowed to do nothing. (unless you're a working man, MR. LAZY :P!) |
1044 | 1150 | if (empty($permission)) |
1045 | - return true; |
|
1151 | + { |
|
1152 | + return true; |
|
1153 | + } |
|
1046 | 1154 | |
1047 | 1155 | // You're never allowed to do something if your data hasn't been loaded yet! |
1048 | 1156 | if (empty($user_info) || !isset($user_info['permissions'])) |
1049 | - return false; |
|
1157 | + { |
|
1158 | + return false; |
|
1159 | + } |
|
1050 | 1160 | |
1051 | 1161 | // Administrators are supermen :P. |
1052 | 1162 | if ($user_info['is_admin']) |
1053 | - return true; |
|
1163 | + { |
|
1164 | + return true; |
|
1165 | + } |
|
1054 | 1166 | |
1055 | 1167 | // Make sure permission is a valid array |
1056 | 1168 | if (!is_array($permission)) |
1057 | - $permission = array($permission); |
|
1169 | + { |
|
1170 | + $permission = array($permission); |
|
1171 | + } |
|
1058 | 1172 | |
1059 | 1173 | // Are we checking the _current_ board, or some other boards? |
1060 | 1174 | if ($boards === null) |
1061 | 1175 | { |
1062 | 1176 | if (empty($user_info['permissions'])) |
1063 | - return false; |
|
1177 | + { |
|
1178 | + return false; |
|
1179 | + } |
|
1064 | 1180 | |
1065 | 1181 | // Check if they can do it, you aren't allowed, by default. |
1066 | 1182 | return count(array_intersect($permission, $user_info['permissions'])) !== 0 ? true : false; |
1067 | 1183 | } |
1068 | 1184 | |
1069 | 1185 | if (!is_array($boards)) |
1070 | - $boards = array($boards); |
|
1186 | + { |
|
1187 | + $boards = array($boards); |
|
1188 | + } |
|
1071 | 1189 | |
1072 | 1190 | if (empty($user_info['groups'])) |
1073 | - return false; |
|
1191 | + { |
|
1192 | + return false; |
|
1193 | + } |
|
1074 | 1194 | |
1075 | 1195 | $request = $db->query('', ' |
1076 | 1196 | SELECT MIN(bp.add_deny) AS add_deny |
@@ -1093,11 +1213,15 @@ discard block |
||
1093 | 1213 | |
1094 | 1214 | // Make sure they can do it on all of the boards. |
1095 | 1215 | if ($db->num_rows($request) != count($boards)) |
1096 | - return false; |
|
1216 | + { |
|
1217 | + return false; |
|
1218 | + } |
|
1097 | 1219 | |
1098 | 1220 | $result = true; |
1099 | 1221 | while ($row = $db->fetch_assoc($request)) |
1100 | - $result &= !empty($row['add_deny']); |
|
1222 | + { |
|
1223 | + $result &= !empty($row['add_deny']); |
|
1224 | + } |
|
1101 | 1225 | $db->free_result($request); |
1102 | 1226 | |
1103 | 1227 | // If the query returned 1, they can do it... otherwise, they can't. |
@@ -1163,8 +1287,10 @@ discard block |
||
1163 | 1287 | // If you're doing something on behalf of some "heavy" permissions, validate your session. |
1164 | 1288 | // (take out the heavy permissions, and if you can't do anything but those, you need a validated session.) |
1165 | 1289 | if (!allowedTo(array_diff($permission, $heavy_permissions), $boards)) |
1166 | - validateSession(); |
|
1167 | -} |
|
1290 | + { |
|
1291 | + validateSession(); |
|
1292 | + } |
|
1293 | + } |
|
1168 | 1294 | |
1169 | 1295 | /** |
1170 | 1296 | * Return the boards a user has a certain (board) permission on. (array(0) if all.) |
@@ -1188,7 +1314,9 @@ discard block |
||
1188 | 1314 | |
1189 | 1315 | // Arrays are nice, most of the time. |
1190 | 1316 | if (!is_array($permissions)) |
1191 | - $permissions = array($permissions); |
|
1317 | + { |
|
1318 | + $permissions = array($permissions); |
|
1319 | + } |
|
1192 | 1320 | |
1193 | 1321 | /* |
1194 | 1322 | * Set $simple to true to use this function in compatibility mode |
@@ -1201,12 +1329,16 @@ discard block |
||
1201 | 1329 | if ($user_info['is_admin']) |
1202 | 1330 | { |
1203 | 1331 | if ($simple) |
1204 | - return array(0); |
|
1332 | + { |
|
1333 | + return array(0); |
|
1334 | + } |
|
1205 | 1335 | else |
1206 | 1336 | { |
1207 | 1337 | $boards = array(); |
1208 | 1338 | foreach ($permissions as $permission) |
1209 | - $boards[$permission] = array(0); |
|
1339 | + { |
|
1340 | + $boards[$permission] = array(0); |
|
1341 | + } |
|
1210 | 1342 | |
1211 | 1343 | return $boards; |
1212 | 1344 | } |
@@ -1238,29 +1370,39 @@ discard block |
||
1238 | 1370 | if ($simple) |
1239 | 1371 | { |
1240 | 1372 | if (empty($row['add_deny'])) |
1241 | - $deny_boards[] = $row['id_board']; |
|
1242 | - else |
|
1243 | - $boards[] = $row['id_board']; |
|
1373 | + { |
|
1374 | + $deny_boards[] = $row['id_board']; |
|
1375 | + } |
|
1376 | + else { |
|
1377 | + $boards[] = $row['id_board']; |
|
1378 | + } |
|
1244 | 1379 | } |
1245 | 1380 | else |
1246 | 1381 | { |
1247 | 1382 | if (empty($row['add_deny'])) |
1248 | - $deny_boards[$row['permission']][] = $row['id_board']; |
|
1249 | - else |
|
1250 | - $boards[$row['permission']][] = $row['id_board']; |
|
1383 | + { |
|
1384 | + $deny_boards[$row['permission']][] = $row['id_board']; |
|
1385 | + } |
|
1386 | + else { |
|
1387 | + $boards[$row['permission']][] = $row['id_board']; |
|
1388 | + } |
|
1251 | 1389 | } |
1252 | 1390 | } |
1253 | 1391 | $db->free_result($request); |
1254 | 1392 | |
1255 | 1393 | if ($simple) |
1256 | - $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1394 | + { |
|
1395 | + $boards = array_unique(array_values(array_diff($boards, $deny_boards))); |
|
1396 | + } |
|
1257 | 1397 | else |
1258 | 1398 | { |
1259 | 1399 | foreach ($permissions as $permission) |
1260 | 1400 | { |
1261 | 1401 | // Never had it to start with |
1262 | 1402 | if (empty($boards[$permission])) |
1263 | - $boards[$permission] = array(); |
|
1403 | + { |
|
1404 | + $boards[$permission] = array(); |
|
1405 | + } |
|
1264 | 1406 | else |
1265 | 1407 | { |
1266 | 1408 | // Or it may have been removed |
@@ -1304,16 +1446,25 @@ discard block |
||
1304 | 1446 | // Otherwise: no_through_forum. (don't show it but allow emailing the member) |
1305 | 1447 | |
1306 | 1448 | if ($user_info['is_guest'] || isset($_SESSION['ban']['cannot_post'])) |
1307 | - return 'no'; |
|
1449 | + { |
|
1450 | + return 'no'; |
|
1451 | + } |
|
1308 | 1452 | elseif ((!$user_info['is_guest'] && $user_info['id'] == $userProfile_id && !$userProfile_hideEmail)) |
1309 | - return 'yes_permission_override'; |
|
1453 | + { |
|
1454 | + return 'yes_permission_override'; |
|
1455 | + } |
|
1310 | 1456 | elseif (allowedTo('moderate_forum')) |
1311 | - return 'yes_permission_override'; |
|
1457 | + { |
|
1458 | + return 'yes_permission_override'; |
|
1459 | + } |
|
1312 | 1460 | elseif ($userProfile_hideEmail) |
1313 | - return 'no'; |
|
1314 | - else |
|
1315 | - return 'no_through_forum'; |
|
1316 | -} |
|
1461 | + { |
|
1462 | + return 'no'; |
|
1463 | + } |
|
1464 | + else { |
|
1465 | + return 'no_through_forum'; |
|
1466 | + } |
|
1467 | + } |
|
1317 | 1468 | |
1318 | 1469 | /** |
1319 | 1470 | * This function attempts to protect from carrying out specific actions repeatedly. |
@@ -1352,9 +1503,12 @@ discard block |
||
1352 | 1503 | |
1353 | 1504 | // Moderators are free... |
1354 | 1505 | if (!allowedTo('moderate_board')) |
1355 | - $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1356 | - else |
|
1357 | - $timeLimit = 2; |
|
1506 | + { |
|
1507 | + $timeLimit = isset($timeOverrides[$error_type]) ? $timeOverrides[$error_type] : $modSettings['spamWaitTime']; |
|
1508 | + } |
|
1509 | + else { |
|
1510 | + $timeLimit = 2; |
|
1511 | + } |
|
1358 | 1512 | |
1359 | 1513 | // Delete old entries... |
1360 | 1514 | $db->query('', ' |
@@ -1383,8 +1537,9 @@ discard block |
||
1383 | 1537 | { |
1384 | 1538 | throw new Elk_Exception($error_type . '_WaitTime_broken', false, array($timeLimit)); |
1385 | 1539 | } |
1386 | - else |
|
1387 | - return $timeLimit; |
|
1540 | + else { |
|
1541 | + return $timeLimit; |
|
1542 | + } |
|
1388 | 1543 | } |
1389 | 1544 | |
1390 | 1545 | // They haven't posted within the limit. |
@@ -1403,10 +1558,14 @@ discard block |
||
1403 | 1558 | function secureDirectory($path, $allow_localhost = false, $files = '*') |
1404 | 1559 | { |
1405 | 1560 | if (empty($path)) |
1406 | - return 'empty_path'; |
|
1561 | + { |
|
1562 | + return 'empty_path'; |
|
1563 | + } |
|
1407 | 1564 | |
1408 | 1565 | if (!is_writable($path)) |
1409 | - return 'path_not_writable'; |
|
1566 | + { |
|
1567 | + return 'path_not_writable'; |
|
1568 | + } |
|
1410 | 1569 | |
1411 | 1570 | $directoryname = basename($path); |
1412 | 1571 | |
@@ -1419,7 +1578,9 @@ discard block |
||
1419 | 1578 | RemoveHandler .php .php3 .phtml .cgi .fcgi .pl .fpl .shtml'; |
1420 | 1579 | |
1421 | 1580 | if (file_exists($path . '/.htaccess')) |
1422 | - $errors[] = 'htaccess_exists'; |
|
1581 | + { |
|
1582 | + $errors[] = 'htaccess_exists'; |
|
1583 | + } |
|
1423 | 1584 | else |
1424 | 1585 | { |
1425 | 1586 | $fh = @fopen($path . '/.htaccess', 'w'); |
@@ -1434,7 +1595,9 @@ discard block |
||
1434 | 1595 | } |
1435 | 1596 | |
1436 | 1597 | if (file_exists($path . '/index.php')) |
1437 | - $errors[] = 'index-php_exists'; |
|
1598 | + { |
|
1599 | + $errors[] = 'index-php_exists'; |
|
1600 | + } |
|
1438 | 1601 | else |
1439 | 1602 | { |
1440 | 1603 | $fh = @fopen($path . '/index.php', 'w'); |
@@ -1462,10 +1625,13 @@ discard block |
||
1462 | 1625 | } |
1463 | 1626 | |
1464 | 1627 | if (!empty($errors)) |
1465 | - return $errors; |
|
1466 | - else |
|
1467 | - return true; |
|
1468 | -} |
|
1628 | + { |
|
1629 | + return $errors; |
|
1630 | + } |
|
1631 | + else { |
|
1632 | + return true; |
|
1633 | + } |
|
1634 | + } |
|
1469 | 1635 | |
1470 | 1636 | /** |
1471 | 1637 | * Helper function that puts together a ban query for a given ip |
@@ -1496,16 +1662,19 @@ discard block |
||
1496 | 1662 | } |
1497 | 1663 | // Check if we have a valid IPv4 address. |
1498 | 1664 | elseif (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $fullip, $ip_parts) == 1) |
1499 | - $ban_query = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1) |
|
1665 | + { |
|
1666 | + $ban_query = '((' . $ip_parts[1] . ' BETWEEN bi.ip_low1 AND bi.ip_high1) |
|
1500 | 1667 | AND (' . $ip_parts[2] . ' BETWEEN bi.ip_low2 AND bi.ip_high2) |
1501 | 1668 | AND (' . $ip_parts[3] . ' BETWEEN bi.ip_low3 AND bi.ip_high3) |
1502 | 1669 | AND (' . $ip_parts[4] . ' BETWEEN bi.ip_low4 AND bi.ip_high4))'; |
1670 | + } |
|
1503 | 1671 | // We use '255.255.255.255' for 'unknown' since it's not valid anyway. |
1504 | - else |
|
1505 | - $ban_query = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255 |
|
1672 | + else { |
|
1673 | + $ban_query = '(bi.ip_low1 = 255 AND bi.ip_high1 = 255 |
|
1506 | 1674 | AND bi.ip_low2 = 255 AND bi.ip_high2 = 255 |
1507 | 1675 | AND bi.ip_low3 = 255 AND bi.ip_high3 = 255 |
1508 | 1676 | AND bi.ip_low4 = 255 AND bi.ip_high4 = 255)'; |
1677 | + } |
|
1509 | 1678 | |
1510 | 1679 | return $ban_query; |
1511 | 1680 | } |
@@ -1533,11 +1702,17 @@ discard block |
||
1533 | 1702 | if (!$user_info['is_guest']) |
1534 | 1703 | { |
1535 | 1704 | if (!empty($user_info['is_moderator']) || !empty($user_info['is_admin'])) |
1536 | - $bb_run = false; |
|
1705 | + { |
|
1706 | + $bb_run = false; |
|
1707 | + } |
|
1537 | 1708 | elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] < 0) |
1538 | - $bb_run = false; |
|
1709 | + { |
|
1710 | + $bb_run = false; |
|
1711 | + } |
|
1539 | 1712 | elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] > 0 && ($user_info['posts'] > $modSettings['badbehavior_postcount_wl'])) |
1540 | - $bb_run = false; |
|
1713 | + { |
|
1714 | + $bb_run = false; |
|
1715 | + } |
|
1541 | 1716 | } |
1542 | 1717 | |
1543 | 1718 | // Put on the sanitary gloves, its time for a patdown ! |
@@ -1574,7 +1749,9 @@ discard block |
||
1574 | 1749 | setLoginCookie(-3600, 0); |
1575 | 1750 | |
1576 | 1751 | if (isset($_SESSION['login_' . $cookiename])) |
1577 | - unset($_SESSION['login_' . $cookiename]); |
|
1752 | + { |
|
1753 | + unset($_SESSION['login_' . $cookiename]); |
|
1754 | + } |
|
1578 | 1755 | |
1579 | 1756 | // We need a member! |
1580 | 1757 | if (!$id_member) |
@@ -1592,7 +1769,9 @@ discard block |
||
1592 | 1769 | |
1593 | 1770 | // Right, have we got a flood value? |
1594 | 1771 | if ($password_flood_value !== false) |
1595 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
1772 | + { |
|
1773 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
1774 | + } |
|
1596 | 1775 | |
1597 | 1776 | // Timestamp invalid or non-existent? |
1598 | 1777 | if (empty($number_tries) || $time_stamp < (time() - 10)) |
@@ -1606,7 +1785,9 @@ discard block |
||
1606 | 1785 | |
1607 | 1786 | // Broken the law? |
1608 | 1787 | if ($number_tries > 5) |
1609 | - throw new Elk_Exception('login_threshold_brute_fail', 'critical'); |
|
1788 | + { |
|
1789 | + throw new Elk_Exception('login_threshold_brute_fail', 'critical'); |
|
1790 | + } |
|
1610 | 1791 | |
1611 | 1792 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
1612 | 1793 | require_once(SUBSDIR . '/Members.subs.php'); |
@@ -1625,13 +1806,19 @@ discard block |
||
1625 | 1806 | $option = 'SAMEORIGIN'; |
1626 | 1807 | |
1627 | 1808 | if (is_null($override) && !empty($modSettings['frame_security'])) |
1628 | - $option = $modSettings['frame_security']; |
|
1809 | + { |
|
1810 | + $option = $modSettings['frame_security']; |
|
1811 | + } |
|
1629 | 1812 | elseif (in_array($override, array('SAMEORIGIN', 'DENY'))) |
1630 | - $option = $override; |
|
1813 | + { |
|
1814 | + $option = $override; |
|
1815 | + } |
|
1631 | 1816 | |
1632 | 1817 | // Don't bother setting the header if we have disabled it. |
1633 | 1818 | if ($option == 'DISABLE') |
1634 | - return; |
|
1819 | + { |
|
1820 | + return; |
|
1821 | + } |
|
1635 | 1822 | |
1636 | 1823 | // Finally set it. |
1637 | 1824 | header('X-Frame-Options: ' . $option); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | WHERE |
320 | 320 | (' . implode(' OR ', $ban_query) . ')', |
321 | 321 | $ban_query_vars, |
322 | - function ($row) use($user_info, $restrictions, &$flag_is_activated) |
|
322 | + function($row) use($user_info, $restrictions, &$flag_is_activated) |
|
323 | 323 | { |
324 | 324 | // Store every type of ban that applies to you in your session. |
325 | 325 | foreach ($restrictions as $restriction) |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | 'ban_list' => $bans, |
373 | 373 | 'current_time' => time(), |
374 | 374 | ), |
375 | - function ($row) |
|
375 | + function($row) |
|
376 | 376 | { |
377 | 377 | $_SESSION['ban']['cannot_access']['ids'][] = $row['id_ban']; |
378 | 378 | $_SESSION['ban']['cannot_access']['reason'] = $row['reason']; |
@@ -179,14 +179,19 @@ discard block |
||
179 | 179 | // Just in case we have a legacy IPv4 address. |
180 | 180 | // @ TODO: Convert to IPv6. |
181 | 181 | if (filter_var($this->_client_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false) |
182 | - $this->_client_ip = 'unknown'; |
|
182 | + { |
|
183 | + $this->_client_ip = 'unknown'; |
|
184 | + } |
|
185 | + } |
|
186 | + else { |
|
187 | + $this->_client_ip = $_SERVER['REMOTE_ADDR']; |
|
183 | 188 | } |
184 | - else |
|
185 | - $this->_client_ip = $_SERVER['REMOTE_ADDR']; |
|
186 | 189 | |
187 | 190 | // Final check |
188 | 191 | if ($this->_client_ip == 'unknown') |
189 | - $this->_client_ip = ''; |
|
192 | + { |
|
193 | + $this->_client_ip = ''; |
|
194 | + } |
|
190 | 195 | } |
191 | 196 | |
192 | 197 | /** |
@@ -204,18 +209,24 @@ discard block |
||
204 | 209 | if (strtok($_SERVER['HTTP_X_FORWARDED_FOR'], '.') != strtok($_SERVER['HTTP_CLIENT_IP'], '.') |
205 | 210 | && '.' . strtok($_SERVER['HTTP_X_FORWARDED_FOR'], '.') == strrchr($_SERVER['HTTP_CLIENT_IP'], '.') |
206 | 211 | && (preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown)~', $_SERVER['HTTP_X_FORWARDED_FOR']) == 0 || preg_match('~^((0|10|172\.(1[6-9]|2[0-9]|3[01])|192\.168|255|127)\.|unknown)~', $this->_client_ip) != 0)) |
207 | - $this->_ban_ip = implode('.', array_reverse(explode('.', $_SERVER['HTTP_CLIENT_IP']))); |
|
208 | - else |
|
209 | - $this->_ban_ip = $_SERVER['HTTP_CLIENT_IP']; |
|
212 | + { |
|
213 | + $this->_ban_ip = implode('.', array_reverse(explode('.', $_SERVER['HTTP_CLIENT_IP']))); |
|
214 | + } |
|
215 | + else { |
|
216 | + $this->_ban_ip = $_SERVER['HTTP_CLIENT_IP']; |
|
217 | + } |
|
210 | 218 | } |
211 | 219 | |
212 | 220 | if (!empty($_SERVER['HTTP_CLIENT_IP']) && (preg_match('~^' . $this->_local_ip_pattern . '~', $_SERVER['HTTP_CLIENT_IP']) == 0 || preg_match('~^' . $this->_local_ip_pattern . '~', $this->_client_ip) != 0)) |
213 | 221 | { |
214 | 222 | // Since they are in different blocks, it's probably reversed. |
215 | 223 | if (strtok($this->_client_ip, '.') != strtok($_SERVER['HTTP_CLIENT_IP'], '.')) |
216 | - $this->_ban_ip = implode('.', array_reverse(explode('.', $_SERVER['HTTP_CLIENT_IP']))); |
|
217 | - else |
|
218 | - $this->_ban_ip = $_SERVER['HTTP_CLIENT_IP']; |
|
224 | + { |
|
225 | + $this->_ban_ip = implode('.', array_reverse(explode('.', $_SERVER['HTTP_CLIENT_IP']))); |
|
226 | + } |
|
227 | + else { |
|
228 | + $this->_ban_ip = $_SERVER['HTTP_CLIENT_IP']; |
|
229 | + } |
|
219 | 230 | } |
220 | 231 | elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
221 | 232 | { |
@@ -229,7 +240,9 @@ discard block |
||
229 | 240 | { |
230 | 241 | // Make sure it's in a valid range... |
231 | 242 | if (preg_match('~^' . $this->_local_ip_pattern . '~', $ip) != 0 && preg_match('~^' . $this->_local_ip_pattern . '~', $this->_client_ip) == 0) |
232 | - continue; |
|
243 | + { |
|
244 | + continue; |
|
245 | + } |
|
233 | 246 | |
234 | 247 | // Otherwise, we've got an IP! |
235 | 248 | $this->_ban_ip = trim($ip); |
@@ -238,12 +251,16 @@ discard block |
||
238 | 251 | } |
239 | 252 | // Otherwise just use the only one. |
240 | 253 | elseif (preg_match('~^' . $this->_local_ip_pattern . '~', $_SERVER['HTTP_X_FORWARDED_FOR']) == 0 || preg_match('~^' . $this->_local_ip_pattern . '~', $this->_client_ip) != 0) |
241 | - $this->_ban_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
254 | + { |
|
255 | + $this->_ban_ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
|
256 | + } |
|
242 | 257 | } |
243 | 258 | |
244 | 259 | // Some final checking. |
245 | 260 | if (filter_var($this->_ban_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false && !isValidIPv6($this->_ban_ip)) |
246 | - $this->_ban_ip = ''; |
|
261 | + { |
|
262 | + $this->_ban_ip = ''; |
|
263 | + } |
|
247 | 264 | } |
248 | 265 | |
249 | 266 | /** |
@@ -264,14 +281,20 @@ discard block |
||
264 | 281 | |
265 | 282 | // There should be a $_REQUEST['start'], some at least. If you need to default to other than 0, use $_GET['start']. |
266 | 283 | if (empty($_REQUEST['start']) || $_REQUEST['start'] < 0 || (int) $_REQUEST['start'] > 2147473647) |
267 | - $_REQUEST['start'] = 0; |
|
284 | + { |
|
285 | + $_REQUEST['start'] = 0; |
|
286 | + } |
|
268 | 287 | |
269 | 288 | // The action needs to be a string, too. |
270 | 289 | if (isset($_REQUEST['action'])) |
271 | - $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
290 | + { |
|
291 | + $_REQUEST['action'] = (string) $_REQUEST['action']; |
|
292 | + } |
|
272 | 293 | |
273 | 294 | if (isset($_GET['action'])) |
274 | - $_GET['action'] = (string) $_GET['action']; |
|
295 | + { |
|
296 | + $_GET['action'] = (string) $_GET['action']; |
|
297 | + } |
|
275 | 298 | |
276 | 299 | $this->_xml = (isset($_SERVER['X_REQUESTED_WITH']) && $_SERVER['X_REQUESTED_WITH'] == 'XMLHttpRequest') || isset($_REQUEST['xml']); |
277 | 300 | } |
@@ -290,10 +313,14 @@ discard block |
||
290 | 313 | |
291 | 314 | // If we have ?board=3/10, that's... board=3, start=10! (old, compatible links.) |
292 | 315 | if (strpos($_REQUEST['board'], '/') !== false) |
293 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
316 | + { |
|
317 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('/', $_REQUEST['board']); |
|
318 | + } |
|
294 | 319 | // Or perhaps we have... ?board=1.0... |
295 | 320 | elseif (strpos($_REQUEST['board'], '.') !== false) |
296 | - list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
321 | + { |
|
322 | + list ($_REQUEST['board'], $_REQUEST['start']) = explode('.', $_REQUEST['board']); |
|
323 | + } |
|
297 | 324 | |
298 | 325 | // $board and $_REQUEST['start'] are always numbers. |
299 | 326 | $board = (int) $_REQUEST['board']; |
@@ -303,8 +330,9 @@ discard block |
||
303 | 330 | $_GET['board'] = $board; |
304 | 331 | } |
305 | 332 | // None? We still need *something*, and it'd better be a number |
306 | - else |
|
307 | - $board = 0; |
|
333 | + else { |
|
334 | + $board = 0; |
|
335 | + } |
|
308 | 336 | |
309 | 337 | return $board; |
310 | 338 | } |
@@ -318,7 +346,9 @@ discard block |
||
318 | 346 | { |
319 | 347 | // Look for threadid, old YaBB SE links have those. Just read it as a topic. |
320 | 348 | if (isset($_REQUEST['threadid']) && !isset($_REQUEST['topic'])) |
321 | - $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
349 | + { |
|
350 | + $_REQUEST['topic'] = $_REQUEST['threadid']; |
|
351 | + } |
|
322 | 352 | |
323 | 353 | if (isset($_REQUEST['topic'])) |
324 | 354 | { |
@@ -327,10 +357,14 @@ discard block |
||
327 | 357 | |
328 | 358 | // It might come as ?topic=1/15, from an old, SMF beta style link |
329 | 359 | if (strpos($_REQUEST['topic'], '/') !== false) |
330 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
360 | + { |
|
361 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('/', $_REQUEST['topic']); |
|
362 | + } |
|
331 | 363 | // Or it might come as ?topic=1.15. |
332 | 364 | elseif (strpos($_REQUEST['topic'], '.') !== false) |
333 | - list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
365 | + { |
|
366 | + list ($_REQUEST['topic'], $_REQUEST['start']) = explode('.', $_REQUEST['topic']); |
|
367 | + } |
|
334 | 368 | |
335 | 369 | // $topic and $_REQUEST['start'] are numbers, numbers I say. |
336 | 370 | $topic = (int) $_REQUEST['topic']; |
@@ -342,8 +376,9 @@ discard block |
||
342 | 376 | $_GET['topic'] = $topic; |
343 | 377 | } |
344 | 378 | // No topic? Well, set something, and that something is 0. |
345 | - else |
|
346 | - $topic = 0; |
|
379 | + else { |
|
380 | + $topic = 0; |
|
381 | + } |
|
347 | 382 | |
348 | 383 | return $topic; |
349 | 384 | } |
@@ -389,11 +424,16 @@ discard block |
||
389 | 424 | |
390 | 425 | // Make sure we know the URL of the current request. |
391 | 426 | if (empty($_SERVER['REQUEST_URI'])) |
392 | - $_SERVER['REQUEST_URL'] = $this->_scripturl . (!empty($this->_server_query_string) ? '?' . $this->_server_query_string : ''); |
|
427 | + { |
|
428 | + $_SERVER['REQUEST_URL'] = $this->_scripturl . (!empty($this->_server_query_string) ? '?' . $this->_server_query_string : ''); |
|
429 | + } |
|
393 | 430 | elseif (preg_match('~^([^/]+//[^/]+)~', $this->_scripturl, $match) == 1) |
394 | - $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
395 | - else |
|
396 | - $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
431 | + { |
|
432 | + $_SERVER['REQUEST_URL'] = $match[1] . $_SERVER['REQUEST_URI']; |
|
433 | + } |
|
434 | + else { |
|
435 | + $_SERVER['REQUEST_URL'] = $_SERVER['REQUEST_URI']; |
|
436 | + } |
|
397 | 437 | } |
398 | 438 | |
399 | 439 | /** |
@@ -420,7 +460,9 @@ discard block |
||
420 | 460 | |
421 | 461 | // Get the correct query string. It may be in an environment variable... |
422 | 462 | if (!isset($_SERVER['QUERY_STRING'])) |
423 | - $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
463 | + { |
|
464 | + $_SERVER['QUERY_STRING'] = getenv('QUERY_STRING'); |
|
465 | + } |
|
424 | 466 | |
425 | 467 | // It seems that sticking a URL after the query string is mighty common, well, it's evil - don't. |
426 | 468 | if (strpos($_SERVER['QUERY_STRING'], 'http') === 0) |
@@ -443,20 +485,26 @@ discard block |
||
443 | 485 | private function _checkNumericKeys() |
444 | 486 | { |
445 | 487 | if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS'])) |
446 | - throw new Elk_Exception('Invalid request variable.', false); |
|
488 | + { |
|
489 | + throw new Elk_Exception('Invalid request variable.', false); |
|
490 | + } |
|
447 | 491 | |
448 | 492 | // Same goes for numeric keys. |
449 | 493 | foreach (array_merge(array_keys($_POST), array_keys($_GET), array_keys($_FILES)) as $key) |
450 | 494 | { |
451 | 495 | if (is_numeric($key)) |
452 | - throw new Elk_Exception('Numeric request keys are invalid.', false); |
|
496 | + { |
|
497 | + throw new Elk_Exception('Numeric request keys are invalid.', false); |
|
498 | + } |
|
453 | 499 | } |
454 | 500 | |
455 | 501 | // Numeric keys in cookies are less of a problem. Just unset those. |
456 | 502 | foreach ($_COOKIE as $key => $value) |
457 | 503 | { |
458 | 504 | if (is_numeric($key)) |
459 | - unset($_COOKIE[$key]); |
|
505 | + { |
|
506 | + unset($_COOKIE[$key]); |
|
507 | + } |
|
460 | 508 | } |
461 | 509 | } |
462 | 510 | |
@@ -471,11 +519,15 @@ discard block |
||
471 | 519 | { |
472 | 520 | // Reject magic_quotes_sybase='on'. |
473 | 521 | if (ini_get('magic_quotes_sybase') || strtolower(ini_get('magic_quotes_sybase')) == 'on') |
474 | - throw new Elk_Exception('magic_quotes_sybase=on was detected: your host is using an unsecure PHP configuration, deprecated and removed in current versions. Please upgrade PHP.', false); |
|
522 | + { |
|
523 | + throw new Elk_Exception('magic_quotes_sybase=on was detected: your host is using an unsecure PHP configuration, deprecated and removed in current versions. Please upgrade PHP.', false); |
|
524 | + } |
|
475 | 525 | |
476 | 526 | // Reject magic_quotes_gpc='on'. |
477 | 527 | if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() != 0) |
478 | - throw new Elk_Exception('magic_quotes_gpc=on was detected: your host is using an unsecure PHP configuration, deprecated and removed in current versions. Please upgrade PHP.', false); |
|
528 | + { |
|
529 | + throw new Elk_Exception('magic_quotes_gpc=on was detected: your host is using an unsecure PHP configuration, deprecated and removed in current versions. Please upgrade PHP.', false); |
|
530 | + } |
|
479 | 531 | } |
480 | 532 | } |
481 | 533 | |
@@ -496,7 +548,9 @@ discard block |
||
496 | 548 | |
497 | 549 | // Some german webmailers need a decoded string, so let's decode the string for sa=activate and action=reminder |
498 | 550 | if (strpos($this->_server_query_string, 'activate') !== false || strpos($this->_server_query_string, 'reminder') !== false) |
499 | - $this->_server_query_string = urldecode($this->_server_query_string); |
|
551 | + { |
|
552 | + $this->_server_query_string = urldecode($this->_server_query_string); |
|
553 | + } |
|
500 | 554 | |
501 | 555 | // Replace ';' with '&' and '&something&' with '&something=&'. (this is done for compatibility...) |
502 | 556 | parse_str(preg_replace('/&(\w+)(?=&|$)/', '&$1=', strtr($this->_server_query_string, array(';?' => '&', ';' => '&', '%00' => '', "\0" => ''))), $_GET); |
@@ -518,7 +572,9 @@ discard block |
||
518 | 572 | { |
519 | 573 | list ($key, $val) = array_pad(explode('=', $temp[$i], 2), 2, ''); |
520 | 574 | if (!isset($_GET[$key])) |
521 | - $_GET[$key] = $val; |
|
575 | + { |
|
576 | + $_GET[$key] = $val; |
|
577 | + } |
|
522 | 578 | } |
523 | 579 | } |
524 | 580 | |
@@ -542,9 +598,12 @@ discard block |
||
542 | 598 | { |
543 | 599 | // Remove the .html, assuming there is one. |
544 | 600 | if (substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '.'), 4) === '.htm') |
545 | - $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
546 | - else |
|
547 | - $request = $_SERVER['REQUEST_URI']; |
|
601 | + { |
|
602 | + $request = substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '.')); |
|
603 | + } |
|
604 | + else { |
|
605 | + $request = $_SERVER['REQUEST_URI']; |
|
606 | + } |
|
548 | 607 | |
549 | 608 | // Replace 'index.php/a,b,c/d/e,f' with 'a=b,c&d=&e=f' and parse it into $_GET. |
550 | 609 | if (strpos($request, basename($this->_scripturl) . '/') !== false) |
@@ -563,7 +622,9 @@ discard block |
||
563 | 622 | public static function instance() |
564 | 623 | { |
565 | 624 | if (self::$_req === null) |
566 | - self::$_req = new Request(); |
|
625 | + { |
|
626 | + self::$_req = new Request(); |
|
627 | + } |
|
567 | 628 | |
568 | 629 | return self::$_req; |
569 | 630 | } |
@@ -129,9 +129,13 @@ discard block |
||
129 | 129 | { |
130 | 130 | // POSTing some data perhaps? |
131 | 131 | if (!empty($post_data) && is_array($post_data)) |
132 | - $this->_post_data = $this->_buildPostData($post_data); |
|
132 | + { |
|
133 | + $this->_post_data = $this->_buildPostData($post_data); |
|
134 | + } |
|
133 | 135 | elseif (!empty($post_data)) |
134 | - $this->_post_data = trim($post_data); |
|
136 | + { |
|
137 | + $this->_post_data = trim($post_data); |
|
138 | + } |
|
135 | 139 | |
136 | 140 | // Set the options and get it |
137 | 141 | $this->_setOptions(); |
@@ -154,9 +158,12 @@ discard block |
||
154 | 158 | { |
155 | 159 | // We do have a url I hope |
156 | 160 | if ($url == '') |
157 | - return false; |
|
158 | - else |
|
159 | - $this->_options[CURLOPT_URL] = $url; |
|
161 | + { |
|
162 | + return false; |
|
163 | + } |
|
164 | + else { |
|
165 | + $this->_options[CURLOPT_URL] = $url; |
|
166 | + } |
|
160 | 167 | |
161 | 168 | // If we have not already been redirected, set it up so we can |
162 | 169 | if (!$redirect) |
@@ -242,9 +249,12 @@ discard block |
||
242 | 249 | |
243 | 250 | // Just return a specified area or the entire result? |
244 | 251 | if ($area == '') |
245 | - return $this->_response[$max_result]; |
|
246 | - else |
|
247 | - return isset($this->_response[$max_result][$area]) ? $this->_response[$max_result][$area] : $this->_response[$max_result]; |
|
252 | + { |
|
253 | + return $this->_response[$max_result]; |
|
254 | + } |
|
255 | + else { |
|
256 | + return isset($this->_response[$max_result][$area]) ? $this->_response[$max_result][$area] : $this->_response[$max_result]; |
|
257 | + } |
|
248 | 258 | } |
249 | 259 | |
250 | 260 | /** |
@@ -260,7 +270,9 @@ discard block |
||
260 | 270 | public function result_raw($response_number = '') |
261 | 271 | { |
262 | 272 | if (!is_numeric($response_number)) |
263 | - return $this->_response; |
|
273 | + { |
|
274 | + return $this->_response; |
|
275 | + } |
|
264 | 276 | else |
265 | 277 | { |
266 | 278 | $response_number = min($response_number, count($this->_response) - 1); |
@@ -292,8 +304,9 @@ discard block |
||
292 | 304 | |
293 | 305 | return implode('&', $postvars); |
294 | 306 | } |
295 | - else |
|
296 | - return $post_data; |
|
307 | + else { |
|
308 | + return $post_data; |
|
309 | + } |
|
297 | 310 | } |
298 | 311 | |
299 | 312 | /** |
@@ -318,8 +331,9 @@ discard block |
||
318 | 331 | $vals = array_merge($this->default_options, $this->_user_options); |
319 | 332 | $this->_options = array_combine($keys, $vals); |
320 | 333 | } |
321 | - else |
|
322 | - $this->_options = $this->default_options; |
|
334 | + else { |
|
335 | + $this->_options = $this->default_options; |
|
336 | + } |
|
323 | 337 | |
324 | 338 | // POST data options, here we don't allow any override |
325 | 339 | if (!empty($this->_post_data)) |
@@ -363,7 +377,9 @@ discard block |
||
363 | 377 | |
364 | 378 | // Set proper headers only |
365 | 379 | if (isset($temp[0]) && isset($temp[1])) |
366 | - $this->_headers[strtolower($temp[0])] = trim($temp[1]); |
|
380 | + { |
|
381 | + $this->_headers[strtolower($temp[0])] = trim($temp[1]); |
|
382 | + } |
|
367 | 383 | |
368 | 384 | // Return the length of what was *passed* unless you want a Failed writing header error ;) |
369 | 385 | return strlen($header); |
@@ -338,7 +338,9 @@ |
||
338 | 338 | $this->_file_name = $this->_surname; |
339 | 339 | |
340 | 340 | if (!empty($this->_current_namespace)) |
341 | - $this->_file_name = $this->_current_namespace . '/' . $this->_file_name; |
|
341 | + { |
|
342 | + $this->_file_name = $this->_current_namespace . '/' . $this->_file_name; |
|
343 | + } |
|
342 | 344 | |
343 | 345 | // validate the file since it can vary |
344 | 346 | if (stream_resolve_include_path($this->_file_name . '.class.php')) |
@@ -271,12 +271,17 @@ discard block |
||
271 | 271 | |
272 | 272 | // If the method is coded in, use it |
273 | 273 | if (!empty($this->actionArray[$this->action][1])) |
274 | - $this->_function_name = $this->actionArray[$this->action][1]; |
|
274 | + { |
|
275 | + $this->_function_name = $this->actionArray[$this->action][1]; |
|
276 | + } |
|
275 | 277 | // Otherwise fall back to naming patterns |
276 | 278 | elseif (!empty($this->subAction) && preg_match('~^\w+$~', $this->subAction)) |
277 | - $this->_function_name = 'action_' . $this->subAction; |
|
278 | - else |
|
279 | - $this->_function_name = 'action_index'; |
|
279 | + { |
|
280 | + $this->_function_name = 'action_' . $this->subAction; |
|
281 | + } |
|
282 | + else { |
|
283 | + $this->_function_name = 'action_index'; |
|
284 | + } |
|
280 | 285 | } |
281 | 286 | // Fall back to naming patterns. |
282 | 287 | // addons can use any of them, and it should Just Work (tm). |
@@ -286,9 +291,12 @@ discard block |
||
286 | 291 | // sa=upload => action_upload() |
287 | 292 | $this->_controller_name = ucfirst($this->action) . '_Controller'; |
288 | 293 | if (isset($this->subAction) && preg_match('~^\w+$~', $this->subAction) && empty($this->area)) |
289 | - $this->_function_name = 'action_' . $this->subAction; |
|
290 | - else |
|
291 | - $this->_function_name = 'action_index'; |
|
294 | + { |
|
295 | + $this->_function_name = 'action_' . $this->subAction; |
|
296 | + } |
|
297 | + else { |
|
298 | + $this->_function_name = 'action_index'; |
|
299 | + } |
|
292 | 300 | } |
293 | 301 | |
294 | 302 | // The file and function weren't found yet? |
@@ -305,7 +313,9 @@ discard block |
||
305 | 313 | } |
306 | 314 | |
307 | 315 | if (isset($_REQUEST['api'])) |
308 | - $this->_function_name .= '_api'; |
|
316 | + { |
|
317 | + $this->_function_name .= '_api'; |
|
318 | + } |
|
309 | 319 | |
310 | 320 | // 3, 2, ... and go |
311 | 321 | if (class_exists($this->_controller_name)) |
@@ -74,10 +74,14 @@ discard block |
||
74 | 74 | self::$_autosave_enabled = !empty($modSettings['drafts_autosave_enabled']); |
75 | 75 | |
76 | 76 | if (!empty($modSettings['drafts_autosave_frequency'])) |
77 | - self::$_autosave_frequency = (int) $modSettings['drafts_autosave_frequency'] * 1000; |
|
77 | + { |
|
78 | + self::$_autosave_frequency = (int) $modSettings['drafts_autosave_frequency'] * 1000; |
|
79 | + } |
|
78 | 80 | |
79 | 81 | if (!empty($modSettings['draft_subject_length'])) |
80 | - self::$_subject_length = (int) $modSettings['draft_subject_length']; |
|
82 | + { |
|
83 | + self::$_subject_length = (int) $modSettings['draft_subject_length']; |
|
84 | + } |
|
81 | 85 | |
82 | 86 | self::$_drafts_save = allowedTo('post_draft'); |
83 | 87 | |
@@ -142,9 +146,13 @@ discard block |
||
142 | 146 | if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) |
143 | 147 | { |
144 | 148 | if (!isset($editorOptions['plugin_addons'])) |
145 | - $editorOptions['plugin_addons'] = array(); |
|
149 | + { |
|
150 | + $editorOptions['plugin_addons'] = array(); |
|
151 | + } |
|
146 | 152 | if (!isset($editorOptions['plugin_options'])) |
147 | - $editorOptions['plugin_options'] = array(); |
|
153 | + { |
|
154 | + $editorOptions['plugin_options'] = array(); |
|
155 | + } |
|
148 | 156 | |
149 | 157 | // @todo remove |
150 | 158 | $context['drafts_autosave_frequency'] = self::$_autosave_frequency; |
@@ -167,7 +175,9 @@ discard block |
||
167 | 175 | $context['shortcuts_text'] = $txt['shortcuts_drafts']; |
168 | 176 | |
169 | 177 | if (!isset($editorOptions['buttons'])) |
170 | - $editorOptions['buttons'] = array(); |
|
178 | + { |
|
179 | + $editorOptions['buttons'] = array(); |
|
180 | + } |
|
171 | 181 | |
172 | 182 | $editorOptions['buttons'][] = array( |
173 | 183 | 'name' => 'save_draft', |
@@ -176,7 +186,9 @@ discard block |
||
176 | 186 | ); |
177 | 187 | |
178 | 188 | if (!empty($context['drafts'])) |
179 | - $template_layers->add('load_drafts', 100); |
|
189 | + { |
|
190 | + $template_layers->add('load_drafts', 100); |
|
191 | + } |
|
180 | 192 | } |
181 | 193 | } |
182 | 194 | |
@@ -188,7 +200,9 @@ discard block |
||
188 | 200 | { |
189 | 201 | // Drafts enabled and needed? |
190 | 202 | if (isset($_POST['save_draft']) || isset($_POST['id_draft'])) |
191 | - require_once(SUBSDIR . '/Drafts.subs.php'); |
|
203 | + { |
|
204 | + require_once(SUBSDIR . '/Drafts.subs.php'); |
|
205 | + } |
|
192 | 206 | } |
193 | 207 | |
194 | 208 | /** |
@@ -254,7 +268,9 @@ discard block |
||
254 | 268 | |
255 | 269 | // If we had a draft for this, its time to remove it since it was just posted |
256 | 270 | if (!empty($_POST['id_draft'])) |
257 | - deleteDrafts($_POST['id_draft'], $user_info['id']); |
|
271 | + { |
|
272 | + deleteDrafts($_POST['id_draft'], $user_info['id']); |
|
273 | + } |
|
258 | 274 | } |
259 | 275 | |
260 | 276 | /** |
@@ -278,7 +294,9 @@ discard block |
||
278 | 294 | |
279 | 295 | // Need a member |
280 | 296 | if (empty($member_id)) |
281 | - return false; |
|
297 | + { |
|
298 | + return false; |
|
299 | + } |
|
282 | 300 | |
283 | 301 | // We haz drafts |
284 | 302 | loadLanguage('Drafts'); |
@@ -286,7 +304,9 @@ discard block |
||
286 | 304 | |
287 | 305 | // has a specific draft has been selected? Load it up if there is not already a message already in the editor |
288 | 306 | if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) |
289 | - $this->_loading_draft = loadDraft((int) $_REQUEST['id_draft'], 0, true, true); |
|
307 | + { |
|
308 | + $this->_loading_draft = loadDraft((int) $_REQUEST['id_draft'], 0, true, true); |
|
309 | + } |
|
290 | 310 | |
291 | 311 | // load all the drafts for this user that meet the criteria |
292 | 312 | $order = 'poster_time DESC'; |
@@ -46,14 +46,17 @@ discard block |
||
46 | 46 | self::$_autosave_enabled = !empty($modSettings['drafts_autosave_enabled']); |
47 | 47 | |
48 | 48 | if (!empty($modSettings['drafts_autosave_frequency'])) |
49 | - self::$_autosave_frequency = (int) $modSettings['drafts_autosave_frequency'] * 1000; |
|
49 | + { |
|
50 | + self::$_autosave_frequency = (int) $modSettings['drafts_autosave_frequency'] * 1000; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | return array( |
52 | 54 | array('prepare_context', array('Drafts_Display_Module', 'prepare_context'), array('use_quick_reply', 'editorOptions', 'board')), |
53 | 55 | ); |
54 | 56 | } |
55 | - else |
|
56 | - return array(); |
|
57 | + else { |
|
58 | + return array(); |
|
59 | + } |
|
57 | 60 | } |
58 | 61 | |
59 | 62 | /** |
@@ -89,9 +92,13 @@ discard block |
||
89 | 92 | if (!empty($options['use_editor_quick_reply'])) |
90 | 93 | { |
91 | 94 | if (!isset($editorOptions['plugin_addons'])) |
92 | - $editorOptions['plugin_addons'] = array(); |
|
95 | + { |
|
96 | + $editorOptions['plugin_addons'] = array(); |
|
97 | + } |
|
93 | 98 | if (!isset($editorOptions['plugin_options'])) |
94 | - $editorOptions['plugin_options'] = array(); |
|
99 | + { |
|
100 | + $editorOptions['plugin_options'] = array(); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | // @todo remove |
97 | 104 | $context['drafts_autosave_frequency'] = self::$_autosave_frequency; |
@@ -112,9 +119,13 @@ discard block |
||
112 | 119 | $context['shortcuts_text'] = $txt['shortcuts_drafts']; |
113 | 120 | |
114 | 121 | if (!isset($editorOptions['buttons'])) |
115 | - $editorOptions['buttons'] = array(); |
|
122 | + { |
|
123 | + $editorOptions['buttons'] = array(); |
|
124 | + } |
|
116 | 125 | if (!isset($editorOptions['hidden_fields'])) |
117 | - $editorOptions['hidden_fields'] = array(); |
|
126 | + { |
|
127 | + $editorOptions['hidden_fields'] = array(); |
|
128 | + } |
|
118 | 129 | |
119 | 130 | $editorOptions['buttons'][] = array( |
120 | 131 | 'name' => 'save_draft', |
@@ -36,8 +36,9 @@ discard block |
||
36 | 36 | array('pre_load', array('Drafts_Profile_Module', 'pre_load'), array('post_errors')), |
37 | 37 | ); |
38 | 38 | } |
39 | - else |
|
40 | - return array(); |
|
39 | + else { |
|
40 | + return array(); |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | /** |
@@ -70,6 +71,8 @@ discard block |
||
70 | 71 | public function pre_load($post_errors) |
71 | 72 | { |
72 | 73 | if (empty($post_errors)) |
73 | - loadLanguage('Drafts'); |
|
74 | + { |
|
75 | + loadLanguage('Drafts'); |
|
76 | + } |
|
74 | 77 | } |
75 | 78 | } |
76 | 79 | \ No newline at end of file |