@@ -53,14 +53,15 @@ discard block |
||
53 | 53 | foreach ($context['smileys'] as $location => $smileyRows) |
54 | 54 | { |
55 | 55 | $countLocations--; |
56 | - if ($location == 'postform') |
|
57 | - echo ' |
|
56 | + if ($location == 'postform') { |
|
57 | + echo ' |
|
58 | 58 | dropdown: |
59 | 59 | {'; |
60 | - elseif ($location == 'popup') |
|
61 | - echo ' |
|
60 | + } elseif ($location == 'popup') { |
|
61 | + echo ' |
|
62 | 62 | popup: |
63 | 63 | {'; |
64 | + } |
|
64 | 65 | |
65 | 66 | $numRows = count($smileyRows); |
66 | 67 | |
@@ -68,25 +69,27 @@ discard block |
||
68 | 69 | $emptyPlaceholder = 0; |
69 | 70 | foreach ($smileyRows as $smileyRow) |
70 | 71 | { |
71 | - foreach ($smileyRow['smileys'] as $smiley) |
|
72 | - echo ' |
|
72 | + foreach ($smileyRow['smileys'] as $smiley) { |
|
73 | + echo ' |
|
73 | 74 | ', JavaScriptEscape($smiley['code']), ': ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), empty($smiley['isLast']) ? ',' : ''; |
75 | + } |
|
74 | 76 | |
75 | - if (empty($smileyRow['isLast']) && $numRows != 1) |
|
76 | - echo ', |
|
77 | + if (empty($smileyRow['isLast']) && $numRows != 1) { |
|
78 | + echo ', |
|
77 | 79 | \'-', $emptyPlaceholder++, '\': \'\','; |
80 | + } |
|
78 | 81 | } |
79 | 82 | echo ' |
80 | 83 | }', $countLocations != 0 ? ',' : ''; |
81 | 84 | } |
82 | 85 | echo ' |
83 | 86 | }'; |
84 | - } |
|
85 | - else |
|
86 | - echo ', |
|
87 | + } else { |
|
88 | + echo ', |
|
87 | 89 | emoticons: |
88 | 90 | {}, |
89 | 91 | emoticonsEnabled:false'; |
92 | + } |
|
90 | 93 | |
91 | 94 | if ($context['show_bbc'] && $bbcContainer !== null) |
92 | 95 | { |
@@ -100,15 +103,16 @@ discard block |
||
100 | 103 | |
101 | 104 | $count_tags--; |
102 | 105 | |
103 | - if (!empty($count_tags)) |
|
104 | - echo '||'; |
|
106 | + if (!empty($count_tags)) { |
|
107 | + echo '||'; |
|
108 | + } |
|
105 | 109 | } |
106 | 110 | |
107 | 111 | echo '",'; |
108 | - } |
|
109 | - else |
|
110 | - echo ', |
|
112 | + } else { |
|
113 | + echo ', |
|
111 | 114 | toolbar: "",'; |
115 | + } |
|
112 | 116 | |
113 | 117 | echo ' |
114 | 118 | }); |
@@ -150,42 +154,47 @@ discard block |
||
150 | 154 | |
151 | 155 | $tempTab = $context['tabindex']; |
152 | 156 | |
153 | - if (!empty($context['drafts_pm_save'])) |
|
154 | - $tempTab++; |
|
155 | - elseif (!empty($context['drafts_save'])) |
|
156 | - $tempTab++; |
|
157 | - elseif ($editor_context['preview_type']) |
|
158 | - $tempTab++; |
|
159 | - elseif ($context['show_spellchecking']) |
|
160 | - $tempTab++; |
|
157 | + if (!empty($context['drafts_pm_save'])) { |
|
158 | + $tempTab++; |
|
159 | + } elseif (!empty($context['drafts_save'])) { |
|
160 | + $tempTab++; |
|
161 | + } elseif ($editor_context['preview_type']) { |
|
162 | + $tempTab++; |
|
163 | + } elseif ($context['show_spellchecking']) { |
|
164 | + $tempTab++; |
|
165 | + } |
|
161 | 166 | |
162 | 167 | $tempTab++; |
163 | 168 | $context['tabindex'] = $tempTab; |
164 | 169 | |
165 | - if (!empty($context['drafts_pm_save'])) |
|
166 | - echo ' |
|
170 | + if (!empty($context['drafts_pm_save'])) { |
|
171 | + echo ' |
|
167 | 172 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="submitThisOnce(this);" accesskey="d" class="button"> |
168 | 173 | <input type="hidden" id="id_pm_draft" name="id_pm_draft" value="', empty($context['id_pm_draft']) ? 0 : $context['id_pm_draft'], '">'; |
174 | + } |
|
169 | 175 | |
170 | - if (!empty($context['drafts_save'])) |
|
171 | - echo ' |
|
176 | + if (!empty($context['drafts_save'])) { |
|
177 | + echo ' |
|
172 | 178 | <input type="submit" name="save_draft" value="', $txt['draft_save'], '" tabindex="', --$tempTab, '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" class="button"> |
173 | 179 | <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">'; |
180 | + } |
|
174 | 181 | |
175 | - if ($context['show_spellchecking']) |
|
176 | - echo ' |
|
182 | + if ($context['show_spellchecking']) { |
|
183 | + echo ' |
|
177 | 184 | <input type="button" value="', $txt['spell_check'], '" tabindex="', --$tempTab, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button">'; |
185 | + } |
|
178 | 186 | |
179 | - if ($editor_context['preview_type']) |
|
180 | - echo ' |
|
187 | + if ($editor_context['preview_type']) { |
|
188 | + echo ' |
|
181 | 189 | <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', --$tempTab, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button">'; |
190 | + } |
|
182 | 191 | |
183 | 192 | echo ' |
184 | 193 | <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">'; |
185 | 194 | |
186 | 195 | // Load in the PM autosaver if it's enabled |
187 | - if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) |
|
188 | - echo ' |
|
196 | + if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave'])) { |
|
197 | + echo ' |
|
189 | 198 | <span class="righttext padding" style="display: block"> |
190 | 199 | <span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span> |
191 | 200 | <span id="draft_lastautosave" ></span> |
@@ -203,10 +212,11 @@ discard block |
||
203 | 212 | iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), ' |
204 | 213 | }); |
205 | 214 | </script>'; |
215 | + } |
|
206 | 216 | |
207 | 217 | // Start an instance of the auto saver if its enabled |
208 | - if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) |
|
209 | - echo ' |
|
218 | + if (!empty($context['drafts_save']) && !empty($context['drafts_autosave'])) { |
|
219 | + echo ' |
|
210 | 220 | <span class="righttext padding" style="display: block"> |
211 | 221 | <span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span> |
212 | 222 | <span id="draft_lastautosave" ></span> |
@@ -223,7 +233,8 @@ discard block |
||
223 | 233 | iFreq: ', $context['drafts_autosave_frequency'], ' |
224 | 234 | }); |
225 | 235 | </script>'; |
226 | -} |
|
236 | + } |
|
237 | + } |
|
227 | 238 | |
228 | 239 | /** |
229 | 240 | * This template displays a verification form |
@@ -240,51 +251,57 @@ discard block |
||
240 | 251 | $verify_context = &$context['controls']['verification'][$verify_id]; |
241 | 252 | |
242 | 253 | // Keep track of where we are. |
243 | - if (empty($verify_context['tracking']) || $reset) |
|
244 | - $verify_context['tracking'] = 0; |
|
254 | + if (empty($verify_context['tracking']) || $reset) { |
|
255 | + $verify_context['tracking'] = 0; |
|
256 | + } |
|
245 | 257 | |
246 | 258 | // How many items are there to display in total. |
247 | 259 | $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0); |
248 | 260 | |
249 | 261 | // If we've gone too far, stop. |
250 | - if ($verify_context['tracking'] > $total_items) |
|
251 | - return false; |
|
262 | + if ($verify_context['tracking'] > $total_items) { |
|
263 | + return false; |
|
264 | + } |
|
252 | 265 | |
253 | 266 | // Loop through each item to show them. |
254 | 267 | for ($i = 0; $i < $total_items; $i++) |
255 | 268 | { |
256 | 269 | // If we're after a single item only show it if we're in the right place. |
257 | - if ($display_type == 'single' && $verify_context['tracking'] != $i) |
|
258 | - continue; |
|
270 | + if ($display_type == 'single' && $verify_context['tracking'] != $i) { |
|
271 | + continue; |
|
272 | + } |
|
259 | 273 | |
260 | - if ($display_type != 'single') |
|
261 | - echo ' |
|
274 | + if ($display_type != 'single') { |
|
275 | + echo ' |
|
262 | 276 | <div id="verification_control_', $i, '" class="verification_control">'; |
277 | + } |
|
263 | 278 | |
264 | 279 | // Display empty field, but only if we have one, and it's the first time. |
265 | - if ($verify_context['empty_field'] && empty($i)) |
|
266 | - echo ' |
|
280 | + if ($verify_context['empty_field'] && empty($i)) { |
|
281 | + echo ' |
|
267 | 282 | <div class="smalltext vv_special"> |
268 | 283 | ', $txt['visual_verification_hidden'], ': |
269 | 284 | <input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value=""> |
270 | 285 | </div>'; |
286 | + } |
|
271 | 287 | |
272 | 288 | // Do the actual stuff |
273 | 289 | if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha'])) |
274 | 290 | { |
275 | 291 | if ($verify_context['show_visual']) |
276 | 292 | { |
277 | - if ($context['use_graphic_library']) |
|
278 | - echo ' |
|
293 | + if ($context['use_graphic_library']) { |
|
294 | + echo ' |
|
279 | 295 | <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">'; |
280 | - else |
|
281 | - echo ' |
|
296 | + } else { |
|
297 | + echo ' |
|
282 | 298 | <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1"> |
283 | 299 | <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2"> |
284 | 300 | <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3"> |
285 | 301 | <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4"> |
286 | 302 | <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5"> |
287 | 303 | <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">'; |
304 | + } |
|
288 | 305 | |
289 | 306 | echo ' |
290 | 307 | <div class="smalltext" style="margin: 4px 0 8px 0;"> |
@@ -302,8 +319,7 @@ discard block |
||
302 | 319 | <br> |
303 | 320 | <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl='.$lang.'"></script>'; |
304 | 321 | } |
305 | - } |
|
306 | - else |
|
322 | + } else |
|
307 | 323 | { |
308 | 324 | // Where in the question array is this question? |
309 | 325 | $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; |
@@ -315,21 +331,24 @@ discard block |
||
315 | 331 | </div>'; |
316 | 332 | } |
317 | 333 | |
318 | - if ($display_type != 'single') |
|
319 | - echo ' |
|
334 | + if ($display_type != 'single') { |
|
335 | + echo ' |
|
320 | 336 | </div><!-- #verification_control_[i] -->'; |
337 | + } |
|
321 | 338 | |
322 | 339 | // If we were displaying just one and we did it, break. |
323 | - if ($display_type == 'single' && $verify_context['tracking'] == $i) |
|
324 | - break; |
|
340 | + if ($display_type == 'single' && $verify_context['tracking'] == $i) { |
|
341 | + break; |
|
342 | + } |
|
325 | 343 | } |
326 | 344 | |
327 | 345 | // Assume we found something, always. |
328 | 346 | $verify_context['tracking']++; |
329 | 347 | |
330 | 348 | // Tell something displaying piecemeal to keep going. |
331 | - if ($display_type == 'single') |
|
332 | - return true; |
|
333 | -} |
|
349 | + if ($display_type == 'single') { |
|
350 | + return true; |
|
351 | + } |
|
352 | + } |
|
334 | 353 | |
335 | 354 | ?> |
336 | 355 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -245,16 +253,18 @@ discard block |
||
245 | 253 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
246 | 254 | $alerts[$id_alert] = $row; |
247 | 255 | |
248 | - if (!empty($row['sender_id'])) |
|
249 | - $senders[] = $row['sender_id']; |
|
256 | + if (!empty($row['sender_id'])) { |
|
257 | + $senders[] = $row['sender_id']; |
|
258 | + } |
|
250 | 259 | } |
251 | 260 | $smcFunc['db_free_result']($request); |
252 | 261 | |
253 | 262 | if($withSender) |
254 | 263 | { |
255 | 264 | $senders = loadMemberData($senders); |
256 | - foreach ($senders as $member) |
|
257 | - loadMemberContext($member); |
|
265 | + foreach ($senders as $member) { |
|
266 | + loadMemberContext($member); |
|
267 | + } |
|
258 | 268 | } |
259 | 269 | |
260 | 270 | // Now go through and actually make with the text. |
@@ -269,12 +279,15 @@ discard block |
||
269 | 279 | $msgs = array(); |
270 | 280 | foreach ($alerts as $id_alert => $alert) |
271 | 281 | { |
272 | - if (isset($alert['extra']['board'])) |
|
273 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
274 | - if (isset($alert['extra']['topic'])) |
|
275 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
276 | - if ($alert['content_type'] == 'msg') |
|
277 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
282 | + if (isset($alert['extra']['board'])) { |
|
283 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
284 | + } |
|
285 | + if (isset($alert['extra']['topic'])) { |
|
286 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
287 | + } |
|
288 | + if ($alert['content_type'] == 'msg') { |
|
289 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
290 | + } |
|
278 | 291 | } |
279 | 292 | |
280 | 293 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -289,8 +302,9 @@ discard block |
||
289 | 302 | 'boards' => array_keys($boards), |
290 | 303 | ) |
291 | 304 | ); |
292 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
293 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
305 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
306 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
307 | + } |
|
294 | 308 | } |
295 | 309 | if (!empty($topics)) |
296 | 310 | { |
@@ -305,8 +319,9 @@ discard block |
||
305 | 319 | 'topics' => array_keys($topics), |
306 | 320 | ) |
307 | 321 | ); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
322 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
323 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
324 | + } |
|
310 | 325 | } |
311 | 326 | if (!empty($msgs)) |
312 | 327 | { |
@@ -321,44 +336,51 @@ discard block |
||
321 | 336 | 'msgs' => array_keys($msgs), |
322 | 337 | ) |
323 | 338 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
340 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
341 | + } |
|
326 | 342 | } |
327 | 343 | |
328 | 344 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
329 | 345 | foreach ($alerts as $id_alert => $alert) |
330 | 346 | { |
331 | - if (!empty($alert['text'])) |
|
332 | - continue; |
|
333 | - if (isset($alert['extra']['board'])) |
|
334 | - if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
347 | + if (!empty($alert['text'])) { |
|
348 | + continue; |
|
349 | + } |
|
350 | + if (isset($alert['extra']['board'])) { |
|
351 | + if ($boards[$alert['extra']['board']] == $txt['board_na']) |
|
335 | 352 | { |
336 | 353 | unset($alerts[$id_alert]); |
354 | + } |
|
337 | 355 | continue; |
356 | + } else { |
|
357 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
338 | 358 | } |
339 | - else |
|
340 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
341 | - if (isset($alert['extra']['topic'])) |
|
342 | - if ($alert['extra']['topic'] == $txt['topic_na']) |
|
359 | + if (isset($alert['extra']['topic'])) { |
|
360 | + if ($alert['extra']['topic'] == $txt['topic_na']) |
|
343 | 361 | { |
344 | 362 | unset($alerts[$id_alert]); |
363 | + } |
|
345 | 364 | continue; |
365 | + } else { |
|
366 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
346 | 367 | } |
347 | - else |
|
348 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
349 | - if ($alert['content_type'] == 'msg') |
|
350 | - if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
368 | + if ($alert['content_type'] == 'msg') { |
|
369 | + if ($msgs[$alert['content_id']] == $txt['topic_na']) |
|
351 | 370 | { |
352 | 371 | unset($alerts[$id_alert]); |
372 | + } |
|
353 | 373 | continue; |
374 | + } else { |
|
375 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
354 | 376 | } |
355 | - else |
|
356 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
357 | - if ($alert['content_type'] == 'profile') |
|
358 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
377 | + if ($alert['content_type'] == 'profile') { |
|
378 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
379 | + } |
|
359 | 380 | |
360 | - if (!empty($memberContext[$alert['sender_id']])) |
|
361 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
381 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
382 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
383 | + } |
|
362 | 384 | |
363 | 385 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
364 | 386 | if (isset($txt[$string])) |
@@ -446,11 +468,11 @@ discard block |
||
446 | 468 | checkSession('request'); |
447 | 469 | |
448 | 470 | // Call it! |
449 | - if ($action == 'remove') |
|
450 | - alert_delete($toMark, $memID); |
|
451 | - |
|
452 | - else |
|
453 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
471 | + if ($action == 'remove') { |
|
472 | + alert_delete($toMark, $memID); |
|
473 | + } else { |
|
474 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
475 | + } |
|
454 | 476 | |
455 | 477 | // Set a nice update message. |
456 | 478 | $_SESSION['update_message'] = true; |
@@ -500,23 +522,27 @@ discard block |
||
500 | 522 | ); |
501 | 523 | |
502 | 524 | // Set the page title |
503 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
504 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
505 | - else |
|
506 | - $context['page_title'] = $txt['showPosts']; |
|
525 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
526 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
527 | + } else { |
|
528 | + $context['page_title'] = $txt['showPosts']; |
|
529 | + } |
|
507 | 530 | |
508 | 531 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
509 | 532 | |
510 | 533 | // Is the load average too high to allow searching just now? |
511 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
512 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
534 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
535 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
536 | + } |
|
513 | 537 | |
514 | 538 | // If we're specifically dealing with attachments use that function! |
515 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
516 | - return showAttachments($memID); |
|
539 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
540 | + return showAttachments($memID); |
|
541 | + } |
|
517 | 542 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
518 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
519 | - return showUnwatched($memID); |
|
543 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
544 | + return showUnwatched($memID); |
|
545 | + } |
|
520 | 546 | |
521 | 547 | // Are we just viewing topics? |
522 | 548 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -539,27 +565,30 @@ discard block |
||
539 | 565 | $smcFunc['db_free_result']($request); |
540 | 566 | |
541 | 567 | // Trying to remove a message that doesn't exist. |
542 | - if (empty($info)) |
|
543 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
568 | + if (empty($info)) { |
|
569 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
570 | + } |
|
544 | 571 | |
545 | 572 | // We can be lazy, since removeMessage() will check the permissions for us. |
546 | 573 | require_once($sourcedir . '/RemoveTopic.php'); |
547 | 574 | removeMessage((int) $_GET['delete']); |
548 | 575 | |
549 | 576 | // Add it to the mod log. |
550 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
551 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
577 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
578 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
579 | + } |
|
552 | 580 | |
553 | 581 | // Back to... where we are now ;). |
554 | 582 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
555 | 583 | } |
556 | 584 | |
557 | 585 | // Default to 10. |
558 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
559 | - $_REQUEST['viewscount'] = '10'; |
|
586 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
587 | + $_REQUEST['viewscount'] = '10'; |
|
588 | + } |
|
560 | 589 | |
561 | - if ($context['is_topics']) |
|
562 | - $request = $smcFunc['db_query']('', ' |
|
590 | + if ($context['is_topics']) { |
|
591 | + $request = $smcFunc['db_query']('', ' |
|
563 | 592 | SELECT COUNT(*) |
564 | 593 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
565 | 594 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -572,8 +601,8 @@ discard block |
||
572 | 601 | 'board' => $board, |
573 | 602 | ) |
574 | 603 | ); |
575 | - else |
|
576 | - $request = $smcFunc['db_query']('', ' |
|
604 | + } else { |
|
605 | + $request = $smcFunc['db_query']('', ' |
|
577 | 606 | SELECT COUNT(*) |
578 | 607 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
579 | 608 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -586,6 +615,7 @@ discard block |
||
586 | 615 | 'board' => $board, |
587 | 616 | ) |
588 | 617 | ); |
618 | + } |
|
589 | 619 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
590 | 620 | $smcFunc['db_free_result']($request); |
591 | 621 | |
@@ -606,10 +636,11 @@ discard block |
||
606 | 636 | |
607 | 637 | $range_limit = ''; |
608 | 638 | |
609 | - if ($context['is_topics']) |
|
610 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
611 | - else |
|
612 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
639 | + if ($context['is_topics']) { |
|
640 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
641 | + } else { |
|
642 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
643 | + } |
|
613 | 644 | |
614 | 645 | $maxIndex = $maxPerPage; |
615 | 646 | |
@@ -635,9 +666,9 @@ discard block |
||
635 | 666 | { |
636 | 667 | $margin *= 5; |
637 | 668 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
669 | + } else { |
|
670 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
638 | 671 | } |
639 | - else |
|
640 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
641 | 672 | } |
642 | 673 | |
643 | 674 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -669,8 +700,7 @@ discard block |
||
669 | 700 | 'max' => $maxIndex, |
670 | 701 | ) |
671 | 702 | ); |
672 | - } |
|
673 | - else |
|
703 | + } else |
|
674 | 704 | { |
675 | 705 | $request = $smcFunc['db_query']('', ' |
676 | 706 | SELECT |
@@ -699,8 +729,9 @@ discard block |
||
699 | 729 | } |
700 | 730 | |
701 | 731 | // Make sure we quit this loop. |
702 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') |
|
703 | - break; |
|
732 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') { |
|
733 | + break; |
|
734 | + } |
|
704 | 735 | $looped = true; |
705 | 736 | $range_limit = ''; |
706 | 737 | } |
@@ -744,19 +775,21 @@ discard block |
||
744 | 775 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
745 | 776 | ); |
746 | 777 | |
747 | - if ($user_info['id'] == $row['id_member_started']) |
|
748 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
778 | + if ($user_info['id'] == $row['id_member_started']) { |
|
779 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
780 | + } |
|
749 | 781 | $board_ids['any'][$row['id_board']][] = $counter; |
750 | 782 | } |
751 | 783 | $smcFunc['db_free_result']($request); |
752 | 784 | |
753 | 785 | // All posts were retrieved in reverse order, get them right again. |
754 | - if ($reverse) |
|
755 | - $context['posts'] = array_reverse($context['posts'], true); |
|
786 | + if ($reverse) { |
|
787 | + $context['posts'] = array_reverse($context['posts'], true); |
|
788 | + } |
|
756 | 789 | |
757 | 790 | // These are all the permissions that are different from board to board.. |
758 | - if ($context['is_topics']) |
|
759 | - $permissions = array( |
|
791 | + if ($context['is_topics']) { |
|
792 | + $permissions = array( |
|
760 | 793 | 'own' => array( |
761 | 794 | 'post_reply_own' => 'can_reply', |
762 | 795 | ), |
@@ -764,8 +797,8 @@ discard block |
||
764 | 797 | 'post_reply_any' => 'can_reply', |
765 | 798 | ) |
766 | 799 | ); |
767 | - else |
|
768 | - $permissions = array( |
|
800 | + } else { |
|
801 | + $permissions = array( |
|
769 | 802 | 'own' => array( |
770 | 803 | 'post_reply_own' => 'can_reply', |
771 | 804 | 'delete_own' => 'can_delete', |
@@ -775,6 +808,7 @@ discard block |
||
775 | 808 | 'delete_any' => 'can_delete', |
776 | 809 | ) |
777 | 810 | ); |
811 | + } |
|
778 | 812 | |
779 | 813 | // For every permission in the own/any lists... |
780 | 814 | foreach ($permissions as $type => $list) |
@@ -785,19 +819,22 @@ discard block |
||
785 | 819 | $boards = boardsAllowedTo($permission); |
786 | 820 | |
787 | 821 | // Hmm, they can do it on all boards, can they? |
788 | - if (!empty($boards) && $boards[0] == 0) |
|
789 | - $boards = array_keys($board_ids[$type]); |
|
822 | + if (!empty($boards) && $boards[0] == 0) { |
|
823 | + $boards = array_keys($board_ids[$type]); |
|
824 | + } |
|
790 | 825 | |
791 | 826 | // Now go through each board they can do the permission on. |
792 | 827 | foreach ($boards as $board_id) |
793 | 828 | { |
794 | 829 | // There aren't any posts displayed from this board. |
795 | - if (!isset($board_ids[$type][$board_id])) |
|
796 | - continue; |
|
830 | + if (!isset($board_ids[$type][$board_id])) { |
|
831 | + continue; |
|
832 | + } |
|
797 | 833 | |
798 | 834 | // Set the permission to true ;). |
799 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
800 | - $context['posts'][$counter][$allowed] = true; |
|
835 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
836 | + $context['posts'][$counter][$allowed] = true; |
|
837 | + } |
|
801 | 838 | } |
802 | 839 | } |
803 | 840 | } |
@@ -828,8 +865,9 @@ discard block |
||
828 | 865 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
829 | 866 | |
830 | 867 | // Make sure we can't actually see anything... |
831 | - if (empty($boardsAllowed)) |
|
832 | - $boardsAllowed = array(-1); |
|
868 | + if (empty($boardsAllowed)) { |
|
869 | + $boardsAllowed = array(-1); |
|
870 | + } |
|
833 | 871 | |
834 | 872 | require_once($sourcedir . '/Subs-List.php'); |
835 | 873 | |
@@ -980,8 +1018,8 @@ discard block |
||
980 | 1018 | ) |
981 | 1019 | ); |
982 | 1020 | $attachments = array(); |
983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
984 | - $attachments[] = array( |
|
1021 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1022 | + $attachments[] = array( |
|
985 | 1023 | 'id' => $row['id_attach'], |
986 | 1024 | 'filename' => $row['filename'], |
987 | 1025 | 'downloads' => $row['downloads'], |
@@ -993,6 +1031,7 @@ discard block |
||
993 | 1031 | 'board_name' => $row['name'], |
994 | 1032 | 'approved' => $row['approved'], |
995 | 1033 | ); |
1034 | + } |
|
996 | 1035 | |
997 | 1036 | $smcFunc['db_free_result']($request); |
998 | 1037 | |
@@ -1047,8 +1086,9 @@ discard block |
||
1047 | 1086 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1048 | 1087 | |
1049 | 1088 | // Only the owner can see the list (if the function is enabled of course) |
1050 | - if ($user_info['id'] != $memID) |
|
1051 | - return; |
|
1089 | + if ($user_info['id'] != $memID) { |
|
1090 | + return; |
|
1091 | + } |
|
1052 | 1092 | |
1053 | 1093 | require_once($sourcedir . '/Subs-List.php'); |
1054 | 1094 | |
@@ -1194,8 +1234,9 @@ discard block |
||
1194 | 1234 | ); |
1195 | 1235 | |
1196 | 1236 | $topics = array(); |
1197 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1198 | - $topics[] = $row['id_topic']; |
|
1237 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1238 | + $topics[] = $row['id_topic']; |
|
1239 | + } |
|
1199 | 1240 | |
1200 | 1241 | $smcFunc['db_free_result']($request); |
1201 | 1242 | |
@@ -1215,8 +1256,9 @@ discard block |
||
1215 | 1256 | 'topics' => $topics, |
1216 | 1257 | ) |
1217 | 1258 | ); |
1218 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1219 | - $topicsInfo[] = $row; |
|
1259 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1260 | + $topicsInfo[] = $row; |
|
1261 | + } |
|
1220 | 1262 | $smcFunc['db_free_result']($request); |
1221 | 1263 | } |
1222 | 1264 | |
@@ -1264,8 +1306,9 @@ discard block |
||
1264 | 1306 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1265 | 1307 | |
1266 | 1308 | // Is the load average too high to allow searching just now? |
1267 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1268 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1309 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1310 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1311 | + } |
|
1269 | 1312 | |
1270 | 1313 | // General user statistics. |
1271 | 1314 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1408,11 +1451,13 @@ discard block |
||
1408 | 1451 | } |
1409 | 1452 | $smcFunc['db_free_result']($result); |
1410 | 1453 | |
1411 | - if ($maxPosts > 0) |
|
1412 | - for ($hour = 0; $hour < 24; $hour++) |
|
1454 | + if ($maxPosts > 0) { |
|
1455 | + for ($hour = 0; |
|
1456 | + } |
|
1457 | + $hour < 24; $hour++) |
|
1413 | 1458 | { |
1414 | - if (!isset($context['posts_by_time'][$hour])) |
|
1415 | - $context['posts_by_time'][$hour] = array( |
|
1459 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1460 | + $context['posts_by_time'][$hour] = array( |
|
1416 | 1461 | 'hour' => $hour, |
1417 | 1462 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1418 | 1463 | 'posts' => 0, |
@@ -1420,7 +1465,7 @@ discard block |
||
1420 | 1465 | 'relative_percent' => 0, |
1421 | 1466 | 'is_last' => $hour == 23, |
1422 | 1467 | ); |
1423 | - else |
|
1468 | + } else |
|
1424 | 1469 | { |
1425 | 1470 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1426 | 1471 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1453,8 +1498,9 @@ discard block |
||
1453 | 1498 | |
1454 | 1499 | foreach ($subActions as $sa => $action) |
1455 | 1500 | { |
1456 | - if (!allowedTo($action[2])) |
|
1457 | - unset($subActions[$sa]); |
|
1501 | + if (!allowedTo($action[2])) { |
|
1502 | + unset($subActions[$sa]); |
|
1503 | + } |
|
1458 | 1504 | } |
1459 | 1505 | |
1460 | 1506 | // Create the tabs for the template. |
@@ -1472,15 +1518,18 @@ discard block |
||
1472 | 1518 | ); |
1473 | 1519 | |
1474 | 1520 | // Moderation must be on to track edits. |
1475 | - if (empty($modSettings['userlog_enabled'])) |
|
1476 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1521 | + if (empty($modSettings['userlog_enabled'])) { |
|
1522 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1523 | + } |
|
1477 | 1524 | |
1478 | 1525 | // Group requests must be active to show it... |
1479 | - if (empty($modSettings['show_group_membership'])) |
|
1480 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1526 | + if (empty($modSettings['show_group_membership'])) { |
|
1527 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1528 | + } |
|
1481 | 1529 | |
1482 | - if (empty($subActions)) |
|
1483 | - fatal_lang_error('no_access', false); |
|
1530 | + if (empty($subActions)) { |
|
1531 | + fatal_lang_error('no_access', false); |
|
1532 | + } |
|
1484 | 1533 | |
1485 | 1534 | $keys = array_keys($subActions); |
1486 | 1535 | $default = array_shift($keys); |
@@ -1493,9 +1542,10 @@ discard block |
||
1493 | 1542 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1494 | 1543 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1495 | 1544 | |
1496 | - if (!empty($call)) |
|
1497 | - call_user_func($call, $memID); |
|
1498 | -} |
|
1545 | + if (!empty($call)) { |
|
1546 | + call_user_func($call, $memID); |
|
1547 | + } |
|
1548 | + } |
|
1499 | 1549 | |
1500 | 1550 | /** |
1501 | 1551 | * Handles tracking a user's activity |
@@ -1511,8 +1561,9 @@ discard block |
||
1511 | 1561 | isAllowedTo('moderate_forum'); |
1512 | 1562 | |
1513 | 1563 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1514 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1515 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1564 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1565 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1566 | + } |
|
1516 | 1567 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1517 | 1568 | |
1518 | 1569 | // Set the options for the list component. |
@@ -1679,8 +1730,9 @@ discard block |
||
1679 | 1730 | ) |
1680 | 1731 | ); |
1681 | 1732 | $message_members = array(); |
1682 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1683 | - $message_members[] = $row['id_member']; |
|
1733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1734 | + $message_members[] = $row['id_member']; |
|
1735 | + } |
|
1684 | 1736 | $smcFunc['db_free_result']($request); |
1685 | 1737 | |
1686 | 1738 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1695,8 +1747,9 @@ discard block |
||
1695 | 1747 | 'ip_list' => $ips, |
1696 | 1748 | ) |
1697 | 1749 | ); |
1698 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1699 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1750 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1751 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1752 | + } |
|
1700 | 1753 | $smcFunc['db_free_result']($request); |
1701 | 1754 | } |
1702 | 1755 | |
@@ -1710,8 +1763,9 @@ discard block |
||
1710 | 1763 | 'ip_list' => $ips, |
1711 | 1764 | ) |
1712 | 1765 | ); |
1713 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1714 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1766 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1767 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1768 | + } |
|
1715 | 1769 | $smcFunc['db_free_result']($request); |
1716 | 1770 | } |
1717 | 1771 | } |
@@ -1771,8 +1825,8 @@ discard block |
||
1771 | 1825 | )) |
1772 | 1826 | ); |
1773 | 1827 | $error_messages = array(); |
1774 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1775 | - $error_messages[] = array( |
|
1828 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1829 | + $error_messages[] = array( |
|
1776 | 1830 | 'ip' => inet_dtop($row['ip']), |
1777 | 1831 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1778 | 1832 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1780,6 +1834,7 @@ discard block |
||
1780 | 1834 | 'time' => timeformat($row['log_time']), |
1781 | 1835 | 'timestamp' => forum_time(true, $row['log_time']), |
1782 | 1836 | ); |
1837 | + } |
|
1783 | 1838 | $smcFunc['db_free_result']($request); |
1784 | 1839 | |
1785 | 1840 | return $error_messages; |
@@ -1842,8 +1897,8 @@ discard block |
||
1842 | 1897 | )) |
1843 | 1898 | ); |
1844 | 1899 | $messages = array(); |
1845 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1846 | - $messages[] = array( |
|
1900 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1901 | + $messages[] = array( |
|
1847 | 1902 | 'ip' => inet_dtop($row['poster_ip']), |
1848 | 1903 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1849 | 1904 | 'board' => array( |
@@ -1856,6 +1911,7 @@ discard block |
||
1856 | 1911 | 'time' => timeformat($row['poster_time']), |
1857 | 1912 | 'timestamp' => forum_time(true, $row['poster_time']) |
1858 | 1913 | ); |
1914 | + } |
|
1859 | 1915 | $smcFunc['db_free_result']($request); |
1860 | 1916 | |
1861 | 1917 | return $messages; |
@@ -1882,19 +1938,20 @@ discard block |
||
1882 | 1938 | $context['sub_template'] = 'trackIP'; |
1883 | 1939 | $context['page_title'] = $txt['profile']; |
1884 | 1940 | $context['base_url'] = $scripturl . '?action=trackip'; |
1885 | - } |
|
1886 | - else |
|
1941 | + } else |
|
1887 | 1942 | { |
1888 | 1943 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1889 | 1944 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1890 | 1945 | } |
1891 | 1946 | |
1892 | 1947 | // Searching? |
1893 | - if (isset($_REQUEST['searchip'])) |
|
1894 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1948 | + if (isset($_REQUEST['searchip'])) { |
|
1949 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1950 | + } |
|
1895 | 1951 | |
1896 | - if (isValidIP($context['ip']) === false) |
|
1897 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1952 | + if (isValidIP($context['ip']) === false) { |
|
1953 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1954 | + } |
|
1898 | 1955 | |
1899 | 1956 | //mysql didn't support like search with varbinary |
1900 | 1957 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1902,8 +1959,9 @@ discard block |
||
1902 | 1959 | $ip_var = $context['ip']; |
1903 | 1960 | $ip_string = '= {inet:ip_address}'; |
1904 | 1961 | |
1905 | - if (empty($context['tracking_area'])) |
|
1906 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1962 | + if (empty($context['tracking_area'])) { |
|
1963 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1964 | + } |
|
1907 | 1965 | |
1908 | 1966 | $request = $smcFunc['db_query']('', ' |
1909 | 1967 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1914,8 +1972,9 @@ discard block |
||
1914 | 1972 | ) |
1915 | 1973 | ); |
1916 | 1974 | $context['ips'] = array(); |
1917 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1918 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1975 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1976 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1977 | + } |
|
1919 | 1978 | $smcFunc['db_free_result']($request); |
1920 | 1979 | |
1921 | 1980 | ksort($context['ips']); |
@@ -2144,8 +2203,9 @@ discard block |
||
2144 | 2203 | foreach ($context['whois_servers'] as $whois) |
2145 | 2204 | { |
2146 | 2205 | // Strip off the "decimal point" and anything following... |
2147 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2148 | - $context['auto_whois_server'] = $whois; |
|
2206 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2207 | + $context['auto_whois_server'] = $whois; |
|
2208 | + } |
|
2149 | 2209 | } |
2150 | 2210 | } |
2151 | 2211 | } |
@@ -2162,10 +2222,11 @@ discard block |
||
2162 | 2222 | // Gonna want this for the list. |
2163 | 2223 | require_once($sourcedir . '/Subs-List.php'); |
2164 | 2224 | |
2165 | - if ($memID == 0) |
|
2166 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2167 | - else |
|
2168 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2225 | + if ($memID == 0) { |
|
2226 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2227 | + } else { |
|
2228 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2229 | + } |
|
2169 | 2230 | |
2170 | 2231 | // Start with the user messages. |
2171 | 2232 | $listOptions = array( |
@@ -2275,12 +2336,13 @@ discard block |
||
2275 | 2336 | ) |
2276 | 2337 | ); |
2277 | 2338 | $logins = array(); |
2278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2279 | - $logins[] = array( |
|
2339 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2340 | + $logins[] = array( |
|
2280 | 2341 | 'time' => timeformat($row['time']), |
2281 | 2342 | 'ip' => inet_dtop($row['ip']), |
2282 | 2343 | 'ip2' => inet_dtop($row['ip2']), |
2283 | 2344 | ); |
2345 | + } |
|
2284 | 2346 | $smcFunc['db_free_result']($request); |
2285 | 2347 | |
2286 | 2348 | return $logins; |
@@ -2305,11 +2367,12 @@ discard block |
||
2305 | 2367 | ) |
2306 | 2368 | ); |
2307 | 2369 | $context['custom_field_titles'] = array(); |
2308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2309 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2370 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2371 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2310 | 2372 | 'title' => $row['field_name'], |
2311 | 2373 | 'parse_bbc' => $row['bbc'], |
2312 | 2374 | ); |
2375 | + } |
|
2313 | 2376 | $smcFunc['db_free_result']($request); |
2314 | 2377 | |
2315 | 2378 | // Set the options for the error lists. |
@@ -2448,19 +2511,22 @@ discard block |
||
2448 | 2511 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2449 | 2512 | { |
2450 | 2513 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2451 | - if (!empty($extra['applicator'])) |
|
2452 | - $members[] = $extra['applicator']; |
|
2514 | + if (!empty($extra['applicator'])) { |
|
2515 | + $members[] = $extra['applicator']; |
|
2516 | + } |
|
2453 | 2517 | |
2454 | 2518 | // Work out what the name of the action is. |
2455 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2456 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2457 | - elseif (isset($txt[$row['action']])) |
|
2458 | - $action_text = $txt[$row['action']]; |
|
2519 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2520 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2521 | + } elseif (isset($txt[$row['action']])) { |
|
2522 | + $action_text = $txt[$row['action']]; |
|
2523 | + } |
|
2459 | 2524 | // Custom field? |
2460 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2461 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2462 | - else |
|
2463 | - $action_text = $row['action']; |
|
2525 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2526 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2527 | + } else { |
|
2528 | + $action_text = $row['action']; |
|
2529 | + } |
|
2464 | 2530 | |
2465 | 2531 | // Parse BBC? |
2466 | 2532 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2492,13 +2558,15 @@ discard block |
||
2492 | 2558 | ) |
2493 | 2559 | ); |
2494 | 2560 | $members = array(); |
2495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2496 | - $members[$row['id_member']] = $row['real_name']; |
|
2561 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2562 | + $members[$row['id_member']] = $row['real_name']; |
|
2563 | + } |
|
2497 | 2564 | $smcFunc['db_free_result']($request); |
2498 | 2565 | |
2499 | - foreach ($edits as $key => $value) |
|
2500 | - if (isset($members[$value['id_member']])) |
|
2566 | + foreach ($edits as $key => $value) { |
|
2567 | + if (isset($members[$value['id_member']])) |
|
2501 | 2568 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2569 | + } |
|
2502 | 2570 | } |
2503 | 2571 | |
2504 | 2572 | return $edits; |
@@ -2699,10 +2767,11 @@ discard block |
||
2699 | 2767 | $context['board'] = $board; |
2700 | 2768 | |
2701 | 2769 | // Determine which groups this user is in. |
2702 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2703 | - $curGroups = array(); |
|
2704 | - else |
|
2705 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2770 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2771 | + $curGroups = array(); |
|
2772 | + } else { |
|
2773 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2774 | + } |
|
2706 | 2775 | $curGroups[] = $user_profile[$memID]['id_group']; |
2707 | 2776 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2708 | 2777 | |
@@ -2722,28 +2791,30 @@ discard block |
||
2722 | 2791 | $context['no_access_boards'] = array(); |
2723 | 2792 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2724 | 2793 | { |
2725 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2726 | - $context['no_access_boards'][] = array( |
|
2794 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2795 | + $context['no_access_boards'][] = array( |
|
2727 | 2796 | 'id' => $row['id_board'], |
2728 | 2797 | 'name' => $row['name'], |
2729 | 2798 | 'is_last' => false, |
2730 | 2799 | ); |
2731 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2732 | - $context['boards'][$row['id_board']] = array( |
|
2800 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2801 | + $context['boards'][$row['id_board']] = array( |
|
2733 | 2802 | 'id' => $row['id_board'], |
2734 | 2803 | 'name' => $row['name'], |
2735 | 2804 | 'selected' => $board == $row['id_board'], |
2736 | 2805 | 'profile' => $row['id_profile'], |
2737 | 2806 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2738 | 2807 | ); |
2808 | + } |
|
2739 | 2809 | } |
2740 | 2810 | $smcFunc['db_free_result']($request); |
2741 | 2811 | |
2742 | 2812 | require_once($sourcedir . '/Subs-Boards.php'); |
2743 | 2813 | sortBoards($context['boards']); |
2744 | 2814 | |
2745 | - if (!empty($context['no_access_boards'])) |
|
2746 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2815 | + if (!empty($context['no_access_boards'])) { |
|
2816 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2817 | + } |
|
2747 | 2818 | |
2748 | 2819 | $context['member']['permissions'] = array( |
2749 | 2820 | 'general' => array(), |
@@ -2752,8 +2823,9 @@ discard block |
||
2752 | 2823 | |
2753 | 2824 | // If you're an admin we know you can do everything, we might as well leave. |
2754 | 2825 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2755 | - if ($context['member']['has_all_permissions']) |
|
2756 | - return; |
|
2826 | + if ($context['member']['has_all_permissions']) { |
|
2827 | + return; |
|
2828 | + } |
|
2757 | 2829 | |
2758 | 2830 | $denied = array(); |
2759 | 2831 | |
@@ -2772,21 +2844,24 @@ discard block |
||
2772 | 2844 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2773 | 2845 | { |
2774 | 2846 | // We don't know about this permission, it doesn't exist :P. |
2775 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2776 | - continue; |
|
2847 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2848 | + continue; |
|
2849 | + } |
|
2777 | 2850 | |
2778 | - if (empty($row['add_deny'])) |
|
2779 | - $denied[] = $row['permission']; |
|
2851 | + if (empty($row['add_deny'])) { |
|
2852 | + $denied[] = $row['permission']; |
|
2853 | + } |
|
2780 | 2854 | |
2781 | 2855 | // Permissions that end with _own or _any consist of two parts. |
2782 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2783 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2784 | - else |
|
2785 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2856 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2857 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2858 | + } else { |
|
2859 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2860 | + } |
|
2786 | 2861 | |
2787 | 2862 | // Add this permission if it doesn't exist yet. |
2788 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2789 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2863 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2864 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2790 | 2865 | 'id' => $row['permission'], |
2791 | 2866 | 'groups' => array( |
2792 | 2867 | 'allowed' => array(), |
@@ -2796,6 +2871,7 @@ discard block |
||
2796 | 2871 | 'is_denied' => false, |
2797 | 2872 | 'is_global' => true, |
2798 | 2873 | ); |
2874 | + } |
|
2799 | 2875 | |
2800 | 2876 | // Add the membergroup to either the denied or the allowed groups. |
2801 | 2877 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2829,18 +2905,20 @@ discard block |
||
2829 | 2905 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2830 | 2906 | { |
2831 | 2907 | // We don't know about this permission, it doesn't exist :P. |
2832 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2833 | - continue; |
|
2908 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2909 | + continue; |
|
2910 | + } |
|
2834 | 2911 | |
2835 | 2912 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2836 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2837 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2838 | - else |
|
2839 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2913 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2914 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2915 | + } else { |
|
2916 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2917 | + } |
|
2840 | 2918 | |
2841 | 2919 | // Create the structure for this permission. |
2842 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2843 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2920 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2921 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2844 | 2922 | 'id' => $row['permission'], |
2845 | 2923 | 'groups' => array( |
2846 | 2924 | 'allowed' => array(), |
@@ -2850,6 +2928,7 @@ discard block |
||
2850 | 2928 | 'is_denied' => false, |
2851 | 2929 | 'is_global' => empty($board), |
2852 | 2930 | ); |
2931 | + } |
|
2853 | 2932 | |
2854 | 2933 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2855 | 2934 | |
@@ -2868,8 +2947,9 @@ discard block |
||
2868 | 2947 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2869 | 2948 | |
2870 | 2949 | // Firstly, can we actually even be here? |
2871 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2872 | - fatal_lang_error('no_access', false); |
|
2950 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2951 | + fatal_lang_error('no_access', false); |
|
2952 | + } |
|
2873 | 2953 | |
2874 | 2954 | // Make sure things which are disabled stay disabled. |
2875 | 2955 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2956,9 +3036,10 @@ discard block |
||
2956 | 3036 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2957 | 3037 | ); |
2958 | 3038 | $context['current_level'] = 0; |
2959 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2960 | - if ($context['member']['warning'] >= $limit) |
|
3039 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3040 | + if ($context['member']['warning'] >= $limit) |
|
2961 | 3041 | $context['current_level'] = $limit; |
2962 | -} |
|
3042 | + } |
|
3043 | + } |
|
2963 | 3044 | |
2964 | 3045 | ?> |
2965 | 3046 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | 'messages', 'moderator_groups', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
54 | 55 | 'pm_labeled_messages', 'pm_labels', 'pm_recipients', 'pm_rules', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
55 | 56 | 'spiders', 'subscriptions', 'themes', 'topics', 'user_alerts', 'user_alerts_prefs', 'user_drafts', 'user_likes'); |
56 | - foreach ($reservedTables as $k => $table_name) |
|
57 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
57 | + foreach ($reservedTables as $k => $table_name) { |
|
58 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | // We in turn may need the extra stuff. |
60 | 62 | db_extend('extra'); |
@@ -107,8 +109,9 @@ discard block |
||
107 | 109 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
108 | 110 | |
109 | 111 | // First - no way do we touch SMF tables. |
110 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
111 | - return false; |
|
112 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
113 | + return false; |
|
114 | + } |
|
112 | 115 | |
113 | 116 | // Log that we'll want to remove this on uninstall. |
114 | 117 | $db_package_log[] = array('remove_table', $table_name); |
@@ -118,9 +121,9 @@ discard block |
||
118 | 121 | if (in_array($full_table_name, $tables)) |
119 | 122 | { |
120 | 123 | // This is a sad day... drop the table? If not, return false (error) by default. |
121 | - if ($if_exists == 'overwrite') |
|
122 | - $smcFunc['db_drop_table']($table_name); |
|
123 | - else if ($if_exists == 'update') |
|
124 | + if ($if_exists == 'overwrite') { |
|
125 | + $smcFunc['db_drop_table']($table_name); |
|
126 | + } else if ($if_exists == 'update') |
|
124 | 127 | { |
125 | 128 | $smcFunc['db_drop_table']($table_name.'_old'); |
126 | 129 | $smcFunc['db_transaction']('begin'); |
@@ -132,47 +135,51 @@ discard block |
||
132 | 135 | ) |
133 | 136 | ); |
134 | 137 | $old_table_exists = true; |
138 | + } else { |
|
139 | + return $if_exists == 'ignore'; |
|
135 | 140 | } |
136 | - else |
|
137 | - return $if_exists == 'ignore'; |
|
138 | 141 | } |
139 | 142 | |
140 | 143 | // If we've got this far - good news - no table exists. We can build our own! |
141 | - if (!$db_trans) |
|
142 | - $smcFunc['db_transaction']('begin'); |
|
144 | + if (!$db_trans) { |
|
145 | + $smcFunc['db_transaction']('begin'); |
|
146 | + } |
|
143 | 147 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
144 | 148 | foreach ($columns as $column) |
145 | 149 | { |
146 | 150 | // If we have an auto increment do it! |
147 | 151 | if (!empty($column['auto'])) |
148 | 152 | { |
149 | - if (!$old_table_exists) |
|
150 | - $smcFunc['db_query']('', ' |
|
153 | + if (!$old_table_exists) { |
|
154 | + $smcFunc['db_query']('', ' |
|
151 | 155 | DROP SEQUENCE IF EXISTS ' . $table_name . '_seq', |
152 | 156 | array( |
153 | 157 | 'security_override' => true, |
154 | 158 | ) |
155 | 159 | ); |
160 | + } |
|
156 | 161 | |
157 | - if (!$old_table_exists) |
|
158 | - $smcFunc['db_query']('', ' |
|
162 | + if (!$old_table_exists) { |
|
163 | + $smcFunc['db_query']('', ' |
|
159 | 164 | CREATE SEQUENCE ' . $table_name . '_seq', |
160 | 165 | array( |
161 | 166 | 'security_override' => true, |
162 | 167 | ) |
163 | 168 | ); |
169 | + } |
|
164 | 170 | $default = 'default nextval(\'' . $table_name . '_seq\')'; |
171 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
172 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
173 | + } else { |
|
174 | + $default = ''; |
|
165 | 175 | } |
166 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
167 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
168 | - else |
|
169 | - $default = ''; |
|
170 | 176 | |
171 | 177 | // Sort out the size... |
172 | 178 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
173 | 179 | list ($type, $size) = $smcFunc['db_calculate_type']($column['type'], $column['size']); |
174 | - if ($size !== null) |
|
175 | - $type = $type . '(' . $size . ')'; |
|
180 | + if ($size !== null) { |
|
181 | + $type = $type . '(' . $size . ')'; |
|
182 | + } |
|
176 | 183 | |
177 | 184 | // Now just put it together! |
178 | 185 | $table_query .= "\n\t\"" . $column['name'] . '" ' . $type . ' ' . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default . ','; |
@@ -185,19 +192,21 @@ discard block |
||
185 | 192 | $columns = implode(',', $index['columns']); |
186 | 193 | |
187 | 194 | // Primary goes in the table... |
188 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
189 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
190 | - else |
|
195 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
196 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
197 | + } else |
|
191 | 198 | { |
192 | - if (empty($index['name'])) |
|
193 | - $index['name'] = implode('_', $index['columns']); |
|
199 | + if (empty($index['name'])) { |
|
200 | + $index['name'] = implode('_', $index['columns']); |
|
201 | + } |
|
194 | 202 | $index_queries[] = 'CREATE ' . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $table_name . '_' . $index['name'] . ' ON ' . $table_name . ' (' . $columns . ')'; |
195 | 203 | } |
196 | 204 | } |
197 | 205 | |
198 | 206 | // No trailing commas! |
199 | - if (substr($table_query, -1) == ',') |
|
200 | - $table_query = substr($table_query, 0, -1); |
|
207 | + if (substr($table_query, -1) == ',') { |
|
208 | + $table_query = substr($table_query, 0, -1); |
|
209 | + } |
|
201 | 210 | |
202 | 211 | $table_query .= ')'; |
203 | 212 | |
@@ -242,18 +251,20 @@ discard block |
||
242 | 251 | } |
243 | 252 | |
244 | 253 | // And the indexes... |
245 | - foreach ($index_queries as $query) |
|
246 | - $smcFunc['db_query']('', $query, |
|
254 | + foreach ($index_queries as $query) { |
|
255 | + $smcFunc['db_query']('', $query, |
|
247 | 256 | array( |
248 | 257 | 'security_override' => true, |
249 | 258 | ) |
250 | 259 | ); |
260 | + } |
|
251 | 261 | |
252 | 262 | // Go, go power rangers! |
253 | 263 | $smcFunc['db_transaction']('commit'); |
254 | 264 | |
255 | - if ($old_table_exists) |
|
256 | - $smcFunc['db_drop_table']($table_name . '_old'); |
|
265 | + if ($old_table_exists) { |
|
266 | + $smcFunc['db_drop_table']($table_name . '_old'); |
|
267 | + } |
|
257 | 268 | |
258 | 269 | return true; |
259 | 270 | } |
@@ -278,8 +289,9 @@ discard block |
||
278 | 289 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
279 | 290 | |
280 | 291 | // God no - dropping one of these = bad. |
281 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
282 | - return false; |
|
292 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
293 | + return false; |
|
294 | + } |
|
283 | 295 | |
284 | 296 | // Does it exist? |
285 | 297 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -337,21 +349,24 @@ discard block |
||
337 | 349 | |
338 | 350 | // Does it exist - if so don't add it again! |
339 | 351 | $columns = $smcFunc['db_list_columns']($table_name, false); |
340 | - foreach ($columns as $column) |
|
341 | - if ($column == $column_info['name']) |
|
352 | + foreach ($columns as $column) { |
|
353 | + if ($column == $column_info['name']) |
|
342 | 354 | { |
343 | 355 | // If we're going to overwrite then use change column. |
344 | 356 | if ($if_exists == 'update') |
345 | 357 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
346 | - else |
|
347 | - return false; |
|
358 | + } |
|
359 | + else { |
|
360 | + return false; |
|
361 | + } |
|
348 | 362 | } |
349 | 363 | |
350 | 364 | // Get the specifics... |
351 | 365 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
352 | 366 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
353 | - if ($size !== null) |
|
354 | - $type = $type . '(' . $size . ')'; |
|
367 | + if ($size !== null) { |
|
368 | + $type = $type . '(' . $size . ')'; |
|
369 | + } |
|
355 | 370 | |
356 | 371 | // Now add the thing! |
357 | 372 | $query = ' |
@@ -366,11 +381,12 @@ discard block |
||
366 | 381 | // If there's more attributes they need to be done via a change on PostgreSQL. |
367 | 382 | unset($column_info['type'], $column_info['size']); |
368 | 383 | |
369 | - if (count($column_info) != 1) |
|
370 | - return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
371 | - else |
|
372 | - return true; |
|
373 | -} |
|
384 | + if (count($column_info) != 1) { |
|
385 | + return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
|
386 | + } else { |
|
387 | + return true; |
|
388 | + } |
|
389 | + } |
|
374 | 390 | |
375 | 391 | /** |
376 | 392 | * Removes a column. |
@@ -389,8 +405,8 @@ discard block |
||
389 | 405 | |
390 | 406 | // Does it exist? |
391 | 407 | $columns = $smcFunc['db_list_columns']($table_name, true); |
392 | - foreach ($columns as $column) |
|
393 | - if ($column['name'] == $column_name) |
|
408 | + foreach ($columns as $column) { |
|
409 | + if ($column['name'] == $column_name) |
|
394 | 410 | { |
395 | 411 | // If there is an auto we need remove it! |
396 | 412 | if ($column['auto']) |
@@ -400,6 +416,7 @@ discard block |
||
400 | 416 | 'security_override' => true, |
401 | 417 | ) |
402 | 418 | ); |
419 | + } |
|
403 | 420 | |
404 | 421 | $smcFunc['db_query']('', ' |
405 | 422 | ALTER TABLE ' . $table_name . ' |
@@ -433,13 +450,15 @@ discard block |
||
433 | 450 | // Check it does exist! |
434 | 451 | $columns = $smcFunc['db_list_columns']($table_name, true); |
435 | 452 | $old_info = null; |
436 | - foreach ($columns as $column) |
|
437 | - if ($column['name'] == $old_column) |
|
453 | + foreach ($columns as $column) { |
|
454 | + if ($column['name'] == $old_column) |
|
438 | 455 | $old_info = $column; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Nothing? |
441 | - if ($old_info == null) |
|
442 | - return false; |
|
459 | + if ($old_info == null) { |
|
460 | + return false; |
|
461 | + } |
|
443 | 462 | |
444 | 463 | // Now we check each bit individually and ALTER as required. |
445 | 464 | if (isset($column_info['name']) && $column_info['name'] != $old_column) |
@@ -496,8 +515,9 @@ discard block |
||
496 | 515 | { |
497 | 516 | $column_info['size'] = isset($column_info['size']) && is_numeric($column_info['size']) ? $column_info['size'] : null; |
498 | 517 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
499 | - if ($size !== null) |
|
500 | - $type = $type . '(' . $size . ')'; |
|
518 | + if ($size !== null) { |
|
519 | + $type = $type . '(' . $size . ')'; |
|
520 | + } |
|
501 | 521 | |
502 | 522 | // The alter is a pain. |
503 | 523 | $smcFunc['db_transaction']('begin'); |
@@ -598,21 +618,23 @@ discard block |
||
598 | 618 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
599 | 619 | |
600 | 620 | // No columns = no index. |
601 | - if (empty($index_info['columns'])) |
|
602 | - return false; |
|
621 | + if (empty($index_info['columns'])) { |
|
622 | + return false; |
|
623 | + } |
|
603 | 624 | $columns = implode(',', $index_info['columns']); |
604 | 625 | |
605 | 626 | // No name - make it up! |
606 | 627 | if (empty($index_info['name'])) |
607 | 628 | { |
608 | 629 | // No need for primary. |
609 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
610 | - $index_info['name'] = ''; |
|
611 | - else |
|
612 | - $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
630 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
631 | + $index_info['name'] = ''; |
|
632 | + } else { |
|
633 | + $index_info['name'] = $table_name . implode('_', $index_info['columns']); |
|
634 | + } |
|
635 | + } else { |
|
636 | + $index_info['name'] = $table_name . $index_info['name']; |
|
613 | 637 | } |
614 | - else |
|
615 | - $index_info['name'] = $table_name . $index_info['name']; |
|
616 | 638 | |
617 | 639 | // Log that we are going to want to remove this! |
618 | 640 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -625,10 +647,11 @@ discard block |
||
625 | 647 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
626 | 648 | { |
627 | 649 | // If we want to overwrite simply remove the current one then continue. |
628 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
629 | - return false; |
|
630 | - else |
|
631 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
650 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
651 | + return false; |
|
652 | + } else { |
|
653 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
654 | + } |
|
632 | 655 | } |
633 | 656 | } |
634 | 657 | |
@@ -642,8 +665,7 @@ discard block |
||
642 | 665 | 'security_override' => true, |
643 | 666 | ) |
644 | 667 | ); |
645 | - } |
|
646 | - else |
|
668 | + } else |
|
647 | 669 | { |
648 | 670 | $smcFunc['db_query']('', ' |
649 | 671 | CREATE ' . (isset($index_info['type']) && $index_info['type'] == 'unique' ? 'UNIQUE' : '') . ' INDEX ' . $index_info['name'] . ' ON ' . $table_name . ' (' . $columns . ')', |
@@ -671,8 +693,9 @@ discard block |
||
671 | 693 | |
672 | 694 | // Better exist! |
673 | 695 | $indexes = $smcFunc['db_list_indexes']($table_name, true); |
674 | - if ($index_name != 'primary') |
|
675 | - $index_name = $table_name . '_' . $index_name; |
|
696 | + if ($index_name != 'primary') { |
|
697 | + $index_name = $table_name . '_' . $index_name; |
|
698 | + } |
|
676 | 699 | |
677 | 700 | foreach ($indexes as $index) |
678 | 701 | { |
@@ -736,8 +759,7 @@ discard block |
||
736 | 759 | 'datetime' => 'timestamp without time zone', |
737 | 760 | 'timestamp' => 'timestamp without time zone', |
738 | 761 | ); |
739 | - } |
|
740 | - else |
|
762 | + } else |
|
741 | 763 | { |
742 | 764 | $types = array( |
743 | 765 | 'character varying' => 'varchar', |
@@ -753,14 +775,16 @@ discard block |
||
753 | 775 | // Got it? Change it! |
754 | 776 | if (isset($types[$type_name])) |
755 | 777 | { |
756 | - if ($type_name == 'tinytext') |
|
757 | - $type_size = 255; |
|
778 | + if ($type_name == 'tinytext') { |
|
779 | + $type_size = 255; |
|
780 | + } |
|
758 | 781 | $type_name = $types[$type_name]; |
759 | 782 | } |
760 | 783 | |
761 | 784 | // Only char fields got size |
762 | - if (strpos($type_name, 'char') === false) |
|
763 | - $type_size = null; |
|
785 | + if (strpos($type_name, 'char') === false) { |
|
786 | + $type_size = null; |
|
787 | + } |
|
764 | 788 | |
765 | 789 | |
766 | 790 | return array($type_name, $type_size); |
@@ -816,8 +840,7 @@ discard block |
||
816 | 840 | if (!$detail) |
817 | 841 | { |
818 | 842 | $columns[] = $row['column_name']; |
819 | - } |
|
820 | - else |
|
843 | + } else |
|
821 | 844 | { |
822 | 845 | $auto = false; |
823 | 846 | // What is the default? |
@@ -825,11 +848,11 @@ discard block |
||
825 | 848 | { |
826 | 849 | $default = null; |
827 | 850 | $auto = true; |
851 | + } elseif (trim($row['column_default']) != '') { |
|
852 | + $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
853 | + } else { |
|
854 | + $default = null; |
|
828 | 855 | } |
829 | - elseif (trim($row['column_default']) != '') |
|
830 | - $default = strpos($row['column_default'], '::') === false ? $row['column_default'] : substr($row['column_default'], 0, strpos($row['column_default'], '::')); |
|
831 | - else |
|
832 | - $default = null; |
|
833 | 856 | |
834 | 857 | // Make the type generic. |
835 | 858 | list ($type, $size) = $smcFunc['db_calculate_type']($row['data_type'], $row['character_maximum_length'], true); |
@@ -880,26 +903,30 @@ discard block |
||
880 | 903 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
881 | 904 | { |
882 | 905 | // Try get the columns that make it up. |
883 | - if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) |
|
884 | - continue; |
|
906 | + if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) { |
|
907 | + continue; |
|
908 | + } |
|
885 | 909 | |
886 | 910 | $columns = explode(',', $matches[1]); |
887 | 911 | |
888 | - if (empty($columns)) |
|
889 | - continue; |
|
912 | + if (empty($columns)) { |
|
913 | + continue; |
|
914 | + } |
|
890 | 915 | |
891 | - foreach ($columns as $k => $v) |
|
892 | - $columns[$k] = trim($v); |
|
916 | + foreach ($columns as $k => $v) { |
|
917 | + $columns[$k] = trim($v); |
|
918 | + } |
|
893 | 919 | |
894 | 920 | // Fix up the name to be consistent cross databases |
895 | - if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) |
|
896 | - $row['name'] = 'PRIMARY'; |
|
897 | - else |
|
898 | - $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
921 | + if (substr($row['name'], -5) == '_pkey' && $row['is_primary'] == 1) { |
|
922 | + $row['name'] = 'PRIMARY'; |
|
923 | + } else { |
|
924 | + $row['name'] = str_replace($table_name . '_', '', $row['name']); |
|
925 | + } |
|
899 | 926 | |
900 | - if (!$detail) |
|
901 | - $indexes[] = $row['name']; |
|
902 | - else |
|
927 | + if (!$detail) { |
|
928 | + $indexes[] = $row['name']; |
|
929 | + } else |
|
903 | 930 | { |
904 | 931 | $indexes[$row['name']] = array( |
905 | 932 | 'name' => $row['name'], |
@@ -28,15 +28,17 @@ discard block |
||
28 | 28 | <form class="login" action="', $context['login_url'], '" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '">'; |
29 | 29 | |
30 | 30 | // Did they make a mistake last time? |
31 | - if (!empty($context['login_errors'])) |
|
32 | - echo ' |
|
31 | + if (!empty($context['login_errors'])) { |
|
32 | + echo ' |
|
33 | 33 | <div class="errorbox">', implode('<br>', $context['login_errors']), '</div> |
34 | 34 | <br>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | // Or perhaps there's some special description for this time? |
37 | - if (isset($context['description'])) |
|
38 | - echo ' |
|
38 | + if (isset($context['description'])) { |
|
39 | + echo ' |
|
39 | 40 | <div class="information">', $context['description'], '</div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Now just get the basic information - username, password, etc. |
42 | 44 | echo ' |
@@ -61,10 +63,11 @@ discard block |
||
61 | 63 | </dd>'; |
62 | 64 | |
63 | 65 | // If they have deleted their account, give them a chance to change their mind. |
64 | - if (isset($context['login_show_undelete'])) |
|
65 | - echo ' |
|
66 | + if (isset($context['login_show_undelete'])) { |
|
67 | + echo ' |
|
66 | 68 | <dt class="alert">', $txt['undelete_account'], ':</dt> |
67 | 69 | <dd><input type="checkbox" name="undelete"></dd>'; |
70 | + } |
|
68 | 71 | |
69 | 72 | echo ' |
70 | 73 | </dl> |
@@ -82,8 +85,8 @@ discard block |
||
82 | 85 | document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus(); |
83 | 86 | }, 150);'; |
84 | 87 | |
85 | - if (!empty($context['from_ajax'])) |
|
86 | - echo ' |
|
88 | + if (!empty($context['from_ajax'])) { |
|
89 | + echo ' |
|
87 | 90 | form = $("#frmLogin"); |
88 | 91 | form.submit(function(e) { |
89 | 92 | e.preventDefault(); |
@@ -116,16 +119,18 @@ discard block |
||
116 | 119 | |
117 | 120 | return false; |
118 | 121 | });'; |
122 | + } |
|
119 | 123 | |
120 | 124 | echo ' |
121 | 125 | </script> |
122 | 126 | </form>'; |
123 | 127 | |
124 | 128 | // It is a long story as to why we have this when we're clearly not going to use it. |
125 | - if (!empty($context['from_ajax'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['from_ajax'])) { |
|
130 | + echo ' |
|
127 | 131 | <br> |
128 | 132 | <a href="javascript:self.close();"></a>'; |
133 | + } |
|
129 | 134 | |
130 | 135 | echo ' |
131 | 136 | </div><!-- .roundframe --> |
@@ -148,11 +153,12 @@ discard block |
||
148 | 153 | </div> |
149 | 154 | <div class="roundframe noup">'; |
150 | 155 | |
151 | - if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) |
|
152 | - echo ' |
|
156 | + if (!empty($context['tfa_error']) || !empty($context['tfa_backup_error'])) { |
|
157 | + echo ' |
|
153 | 158 | <div class="error"> |
154 | 159 | ', $txt['tfa_' . (!empty($context['tfa_error']) ? 'code_' : 'backup_') . 'invalid'], ' |
155 | 160 | </div>'; |
161 | + } |
|
156 | 162 | |
157 | 163 | echo ' |
158 | 164 | <form action="', $context['tfa_url'], '" method="post" id="frmTfa"> |
@@ -181,8 +187,8 @@ discard block |
||
181 | 187 | <script> |
182 | 188 | form = $("#frmTfa");'; |
183 | 189 | |
184 | - if (!empty($context['from_ajax'])) |
|
185 | - echo ' |
|
190 | + if (!empty($context['from_ajax'])) { |
|
191 | + echo ' |
|
186 | 192 | form.submit(function(e) { |
187 | 193 | // If we are submitting backup code, let normal workflow follow since it redirects a couple times into a different page |
188 | 194 | if (form.find("input[name=tfa_backup]:first").val().length > 0) |
@@ -201,6 +207,7 @@ discard block |
||
201 | 207 | |
202 | 208 | return false; |
203 | 209 | });'; |
210 | + } |
|
204 | 211 | |
205 | 212 | echo ' |
206 | 213 | form.find("input[name=backup]").click(function(e) { |
@@ -232,10 +239,11 @@ discard block |
||
232 | 239 | <p class="information centertext"> |
233 | 240 | ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br>'; |
234 | 241 | |
235 | - if ($context['can_register']) |
|
236 | - echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
237 | - else |
|
238 | - echo $txt['login_below']; |
|
242 | + if ($context['can_register']) { |
|
243 | + echo sprintf($txt['login_below_or_register'], $scripturl . '?action=signup', $context['forum_name_html_safe']); |
|
244 | + } else { |
|
245 | + echo $txt['login_below']; |
|
246 | + } |
|
239 | 247 | |
240 | 248 | // And now the login information. |
241 | 249 | echo ' |
@@ -335,9 +343,10 @@ discard block |
||
335 | 343 | </div> |
336 | 344 | <div class="roundframe centertext noup">'; |
337 | 345 | |
338 | - if (!empty($context['incorrect_password'])) |
|
339 | - echo ' |
|
346 | + if (!empty($context['incorrect_password'])) { |
|
347 | + echo ' |
|
340 | 348 | <div class="error">', $txt['admin_incorrect_password'], '</div>'; |
349 | + } |
|
341 | 350 | |
342 | 351 | echo ' |
343 | 352 | <strong>', $txt['password'], ':</strong> |
@@ -378,10 +387,11 @@ discard block |
||
378 | 387 | <dl>'; |
379 | 388 | |
380 | 389 | // You didn't even have an ID? |
381 | - if (empty($context['member_id'])) |
|
382 | - echo ' |
|
390 | + if (empty($context['member_id'])) { |
|
391 | + echo ' |
|
383 | 392 | <dt>', $txt['invalid_activation_username'], ':</dt> |
384 | 393 | <dd><input type="text" name="user" size="30"></dd>'; |
394 | + } |
|
385 | 395 | |
386 | 396 | echo ' |
387 | 397 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
@@ -418,13 +428,14 @@ discard block |
||
418 | 428 | <dd><input type="password" name="passwd" size="30"></dd> |
419 | 429 | </dl>'; |
420 | 430 | |
421 | - if ($context['can_activate']) |
|
422 | - echo ' |
|
431 | + if ($context['can_activate']) { |
|
432 | + echo ' |
|
423 | 433 | <p>', $txt['invalid_activation_known'], '</p> |
424 | 434 | <dl> |
425 | 435 | <dt>', $txt['invalid_activation_retry'], ':</dt> |
426 | 436 | <dd><input type="text" name="code" size="30"></dd> |
427 | 437 | </dl>'; |
438 | + } |
|
428 | 439 | |
429 | 440 | echo ' |
430 | 441 | <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button"></p> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -98,23 +102,26 @@ discard block |
||
98 | 102 | if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) |
99 | 103 | { |
100 | 104 | // First check for 2.1 json-format cookie in $_COOKIE |
101 | - if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) |
|
102 | - list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
105 | + if (isset($_COOKIE[$cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_COOKIE[$cookiename]) === 1) { |
|
106 | + list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // Try checking for 2.1 json-format cookie in $_SESSION |
105 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) |
|
106 | - list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
110 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^{"0":\d+,"1":"[0-9a-f]*","2":\d+~', $_SESSION['login_' . $cookiename]) === 1) { |
|
111 | + list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
|
112 | + } |
|
107 | 113 | |
108 | 114 | // Next, try checking for 2.0 serialized string cookie in $_COOKIE |
109 | - elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) |
|
110 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
115 | + elseif (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_COOKIE[$cookiename]) === 1) { |
|
116 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Last, see if you need to fall back on checking for 2.0 serialized string cookie in $_SESSION |
113 | - elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
115 | - |
|
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
120 | + elseif (isset($_SESSION['login_' . $cookiename]) && preg_match('~^a:[34]:\{i:0;i:\d+;i:1;s:(0|128):"([a-fA-F0-9]{128})?";i:2;[id]:\d+;~', $_SESSION['login_' . $cookiename]) === 1) { |
|
121 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
122 | + } else { |
|
123 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 127 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -134,24 +141,23 @@ discard block |
||
134 | 141 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
135 | 142 | { |
136 | 143 | // Strike! You're outta there! |
137 | - if ($_GET['member'] != $user_info['id']) |
|
138 | - fatal_lang_error('login_cookie_error', false); |
|
144 | + if ($_GET['member'] != $user_info['id']) { |
|
145 | + fatal_lang_error('login_cookie_error', false); |
|
146 | + } |
|
139 | 147 | |
140 | 148 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
141 | 149 | |
142 | 150 | // Some whitelisting for login_url... |
143 | - if (empty($_SESSION['login_url'])) |
|
144 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
145 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
151 | + if (empty($_SESSION['login_url'])) { |
|
152 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
153 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
146 | 154 | { |
147 | 155 | unset ($_SESSION['login_url']); |
148 | 156 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
149 | - } |
|
150 | - elseif (!empty($user_settings['tfa_secret'])) |
|
157 | + } elseif (!empty($user_settings['tfa_secret'])) |
|
151 | 158 | { |
152 | 159 | redirectexit('action=logintfa'); |
153 | - } |
|
154 | - else |
|
160 | + } else |
|
155 | 161 | { |
156 | 162 | // Best not to clutter the session data too much... |
157 | 163 | $temp = $_SESSION['login_url']; |
@@ -162,8 +168,9 @@ discard block |
||
162 | 168 | } |
163 | 169 | |
164 | 170 | // Beyond this point you are assumed to be a guest trying to login. |
165 | - if (!$user_info['is_guest']) |
|
166 | - redirectexit(); |
|
171 | + if (!$user_info['is_guest']) { |
|
172 | + redirectexit(); |
|
173 | + } |
|
167 | 174 | |
168 | 175 | // Are you guessing with a script? |
169 | 176 | checkSession(); |
@@ -171,18 +178,21 @@ discard block |
||
171 | 178 | spamProtection('login'); |
172 | 179 | |
173 | 180 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
174 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
175 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
181 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
182 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
183 | + } |
|
176 | 184 | |
177 | 185 | // Been guessing a lot, haven't we? |
178 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
179 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
186 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
187 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
188 | + } |
|
180 | 189 | |
181 | 190 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
182 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
183 | - $modSettings['cookieTime'] = 3153600; |
|
184 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
185 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
191 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
192 | + $modSettings['cookieTime'] = 3153600; |
|
193 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
194 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
195 | + } |
|
186 | 196 | |
187 | 197 | loadLanguage('Login'); |
188 | 198 | // Load the template stuff. |
@@ -302,8 +312,9 @@ discard block |
||
302 | 312 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
303 | 313 | |
304 | 314 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
305 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
306 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
315 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
316 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
317 | + } |
|
307 | 318 | |
308 | 319 | // phpBB3 users new hashing. We now support it as well ;). |
309 | 320 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -323,27 +334,29 @@ discard block |
||
323 | 334 | // Some common md5 ones. |
324 | 335 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
325 | 336 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
326 | - } |
|
327 | - elseif (strlen($user_settings['passwd']) == 40) |
|
337 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
328 | 338 | { |
329 | 339 | // Maybe they are using a hash from before the password fix. |
330 | 340 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
331 | 341 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
332 | 342 | |
333 | 343 | // BurningBoard3 style of hashing. |
334 | - if (!empty($modSettings['enable_password_conversion'])) |
|
335 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
344 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
345 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
346 | + } |
|
336 | 347 | |
337 | 348 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
338 | 349 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
339 | 350 | { |
340 | 351 | // Try iconv first, for no particular reason. |
341 | - if (function_exists('iconv')) |
|
342 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
352 | + if (function_exists('iconv')) { |
|
353 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
354 | + } |
|
343 | 355 | |
344 | 356 | // Say it aint so, iconv failed! |
345 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
346 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
357 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
358 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
359 | + } |
|
347 | 360 | } |
348 | 361 | } |
349 | 362 | |
@@ -373,8 +386,9 @@ discard block |
||
373 | 386 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
374 | 387 | |
375 | 388 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
376 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
377 | - redirectexit('action=reminder'); |
|
389 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
390 | + redirectexit('action=reminder'); |
|
391 | + } |
|
378 | 392 | // We'll give you another chance... |
379 | 393 | else |
380 | 394 | { |
@@ -385,8 +399,7 @@ discard block |
||
385 | 399 | return; |
386 | 400 | } |
387 | 401 | } |
388 | - } |
|
389 | - elseif (!empty($user_settings['passwd_flood'])) |
|
402 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
390 | 403 | { |
391 | 404 | // Let's be sure they weren't a little hacker. |
392 | 405 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -403,8 +416,9 @@ discard block |
||
403 | 416 | } |
404 | 417 | |
405 | 418 | // Check their activation status. |
406 | - if (!checkActivation()) |
|
407 | - return; |
|
419 | + if (!checkActivation()) { |
|
420 | + return; |
|
421 | + } |
|
408 | 422 | |
409 | 423 | DoLogin(); |
410 | 424 | } |
@@ -416,8 +430,9 @@ discard block |
||
416 | 430 | { |
417 | 431 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
418 | 432 | |
419 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
420 | - fatal_lang_error('no_access', false); |
|
433 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
434 | + fatal_lang_error('no_access', false); |
|
435 | + } |
|
421 | 436 | |
422 | 437 | loadLanguage('Profile'); |
423 | 438 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -425,8 +440,9 @@ discard block |
||
425 | 440 | $member = $context['tfa_member']; |
426 | 441 | |
427 | 442 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
428 | - if (time() - $member['last_login'] < 120) |
|
429 | - fatal_lang_error('tfa_wait', false); |
|
443 | + if (time() - $member['last_login'] < 120) { |
|
444 | + fatal_lang_error('tfa_wait', false); |
|
445 | + } |
|
430 | 446 | |
431 | 447 | $totp = new \TOTP\Auth($member['tfa_secret']); |
432 | 448 | $totp->setRange(1); |
@@ -440,8 +456,9 @@ discard block |
||
440 | 456 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
441 | 457 | { |
442 | 458 | // Check to ensure we're forcing SSL for authentication |
443 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
444 | - fatal_lang_error('login_ssl_required'); |
|
459 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
460 | + fatal_lang_error('login_ssl_required'); |
|
461 | + } |
|
445 | 462 | |
446 | 463 | $code = $_POST['tfa_code']; |
447 | 464 | |
@@ -451,20 +468,19 @@ discard block |
||
451 | 468 | |
452 | 469 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
453 | 470 | redirectexit(); |
454 | - } |
|
455 | - else |
|
471 | + } else |
|
456 | 472 | { |
457 | 473 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
458 | 474 | |
459 | 475 | $context['tfa_error'] = true; |
460 | 476 | $context['tfa_value'] = $_POST['tfa_code']; |
461 | 477 | } |
462 | - } |
|
463 | - elseif (!empty($_POST['tfa_backup'])) |
|
478 | + } elseif (!empty($_POST['tfa_backup'])) |
|
464 | 479 | { |
465 | 480 | // Check to ensure we're forcing SSL for authentication |
466 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
467 | - fatal_lang_error('login_ssl_required'); |
|
481 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
482 | + fatal_lang_error('login_ssl_required'); |
|
483 | + } |
|
468 | 484 | |
469 | 485 | $backup = $_POST['tfa_backup']; |
470 | 486 | |
@@ -478,8 +494,7 @@ discard block |
||
478 | 494 | )); |
479 | 495 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
480 | 496 | redirectexit('action=profile;area=tfasetup;backup'); |
481 | - } |
|
482 | - else |
|
497 | + } else |
|
483 | 498 | { |
484 | 499 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
485 | 500 | |
@@ -502,8 +517,9 @@ discard block |
||
502 | 517 | { |
503 | 518 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
504 | 519 | |
505 | - if (!isset($context['login_errors'])) |
|
506 | - $context['login_errors'] = array(); |
|
520 | + if (!isset($context['login_errors'])) { |
|
521 | + $context['login_errors'] = array(); |
|
522 | + } |
|
507 | 523 | |
508 | 524 | // What is the true activation status of this account? |
509 | 525 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -515,8 +531,9 @@ discard block |
||
515 | 531 | return false; |
516 | 532 | } |
517 | 533 | // Awaiting approval still? |
518 | - elseif ($activation_status == 3) |
|
519 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
534 | + elseif ($activation_status == 3) { |
|
535 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
536 | + } |
|
520 | 537 | // Awaiting deletion, changed their mind? |
521 | 538 | elseif ($activation_status == 4) |
522 | 539 | { |
@@ -524,8 +541,7 @@ discard block |
||
524 | 541 | { |
525 | 542 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
526 | 543 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
527 | - } |
|
528 | - else |
|
544 | + } else |
|
529 | 545 | { |
530 | 546 | $context['disable_login_hashing'] = true; |
531 | 547 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -565,8 +581,9 @@ discard block |
||
565 | 581 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
566 | 582 | |
567 | 583 | // Reset the login threshold. |
568 | - if (isset($_SESSION['failed_login'])) |
|
569 | - unset($_SESSION['failed_login']); |
|
584 | + if (isset($_SESSION['failed_login'])) { |
|
585 | + unset($_SESSION['failed_login']); |
|
586 | + } |
|
570 | 587 | |
571 | 588 | $user_info['is_guest'] = false; |
572 | 589 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -588,16 +605,18 @@ discard block |
||
588 | 605 | 'id_member' => $user_info['id'], |
589 | 606 | ) |
590 | 607 | ); |
591 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
592 | - $_SESSION['first_login'] = true; |
|
593 | - else |
|
594 | - unset($_SESSION['first_login']); |
|
608 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
609 | + $_SESSION['first_login'] = true; |
|
610 | + } else { |
|
611 | + unset($_SESSION['first_login']); |
|
612 | + } |
|
595 | 613 | $smcFunc['db_free_result']($request); |
596 | 614 | |
597 | 615 | // You've logged in, haven't you? |
598 | 616 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
599 | - if (empty($user_settings['tfa_secret'])) |
|
600 | - $update['last_login'] = time(); |
|
617 | + if (empty($user_settings['tfa_secret'])) { |
|
618 | + $update['last_login'] = time(); |
|
619 | + } |
|
601 | 620 | updateMemberData($user_info['id'], $update); |
602 | 621 | |
603 | 622 | // Get rid of the online entry for that old guest.... |
@@ -611,8 +630,8 @@ discard block |
||
611 | 630 | $_SESSION['log_time'] = 0; |
612 | 631 | |
613 | 632 | // Log this entry, only if we have it enabled. |
614 | - if (!empty($modSettings['loginHistoryDays'])) |
|
615 | - $smcFunc['db_insert']('insert', |
|
633 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
634 | + $smcFunc['db_insert']('insert', |
|
616 | 635 | '{db_prefix}member_logins', |
617 | 636 | array( |
618 | 637 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -624,13 +643,15 @@ discard block |
||
624 | 643 | 'id_member', 'time' |
625 | 644 | ) |
626 | 645 | ); |
646 | + } |
|
627 | 647 | |
628 | 648 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
629 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
630 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
631 | - else |
|
632 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
633 | -} |
|
649 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
650 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
651 | + } else { |
|
652 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
653 | + } |
|
654 | + } |
|
634 | 655 | |
635 | 656 | /** |
636 | 657 | * Logs the current user out of their account. |
@@ -646,13 +667,15 @@ discard block |
||
646 | 667 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
647 | 668 | |
648 | 669 | // Make sure they aren't being auto-logged out. |
649 | - if (!$internal) |
|
650 | - checkSession('get'); |
|
670 | + if (!$internal) { |
|
671 | + checkSession('get'); |
|
672 | + } |
|
651 | 673 | |
652 | 674 | require_once($sourcedir . '/Subs-Auth.php'); |
653 | 675 | |
654 | - if (isset($_SESSION['pack_ftp'])) |
|
655 | - $_SESSION['pack_ftp'] = null; |
|
676 | + if (isset($_SESSION['pack_ftp'])) { |
|
677 | + $_SESSION['pack_ftp'] = null; |
|
678 | + } |
|
656 | 679 | |
657 | 680 | // It won't be first login anymore. |
658 | 681 | unset($_SESSION['first_login']); |
@@ -680,8 +703,9 @@ discard block |
||
680 | 703 | |
681 | 704 | // And some other housekeeping while we're at it. |
682 | 705 | $salt = substr(md5(mt_rand()), 0, 4); |
683 | - if (!empty($user_info['id'])) |
|
684 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
706 | + if (!empty($user_info['id'])) { |
|
707 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
708 | + } |
|
685 | 709 | |
686 | 710 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
687 | 711 | { |
@@ -694,14 +718,13 @@ discard block |
||
694 | 718 | // Off to the merry board index we go! |
695 | 719 | if ($redirect) |
696 | 720 | { |
697 | - if (empty($_SESSION['logout_url'])) |
|
698 | - redirectexit('', $context['server']['needs_login_fix']); |
|
699 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
721 | + if (empty($_SESSION['logout_url'])) { |
|
722 | + redirectexit('', $context['server']['needs_login_fix']); |
|
723 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
700 | 724 | { |
701 | 725 | unset ($_SESSION['logout_url']); |
702 | 726 | redirectexit(); |
703 | - } |
|
704 | - else |
|
727 | + } else |
|
705 | 728 | { |
706 | 729 | $temp = $_SESSION['logout_url']; |
707 | 730 | unset($_SESSION['logout_url']); |
@@ -734,8 +757,9 @@ discard block |
||
734 | 757 | function phpBB3_password_check($passwd, $passwd_hash) |
735 | 758 | { |
736 | 759 | // Too long or too short? |
737 | - if (strlen($passwd_hash) != 34) |
|
738 | - return; |
|
760 | + if (strlen($passwd_hash) != 34) { |
|
761 | + return; |
|
762 | + } |
|
739 | 763 | |
740 | 764 | // Range of characters allowed. |
741 | 765 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -746,8 +770,9 @@ discard block |
||
746 | 770 | $salt = substr($passwd_hash, 4, 8); |
747 | 771 | |
748 | 772 | $hash = md5($salt . $passwd, true); |
749 | - for (; $count != 0; --$count) |
|
750 | - $hash = md5($hash . $passwd, true); |
|
773 | + for (; $count != 0; --$count) { |
|
774 | + $hash = md5($hash . $passwd, true); |
|
775 | + } |
|
751 | 776 | |
752 | 777 | $output = substr($passwd_hash, 0, 12); |
753 | 778 | $i = 0; |
@@ -756,21 +781,25 @@ discard block |
||
756 | 781 | $value = ord($hash[$i++]); |
757 | 782 | $output .= $range[$value & 0x3f]; |
758 | 783 | |
759 | - if ($i < 16) |
|
760 | - $value |= ord($hash[$i]) << 8; |
|
784 | + if ($i < 16) { |
|
785 | + $value |= ord($hash[$i]) << 8; |
|
786 | + } |
|
761 | 787 | |
762 | 788 | $output .= $range[($value >> 6) & 0x3f]; |
763 | 789 | |
764 | - if ($i++ >= 16) |
|
765 | - break; |
|
790 | + if ($i++ >= 16) { |
|
791 | + break; |
|
792 | + } |
|
766 | 793 | |
767 | - if ($i < 16) |
|
768 | - $value |= ord($hash[$i]) << 16; |
|
794 | + if ($i < 16) { |
|
795 | + $value |= ord($hash[$i]) << 16; |
|
796 | + } |
|
769 | 797 | |
770 | 798 | $output .= $range[($value >> 12) & 0x3f]; |
771 | 799 | |
772 | - if ($i++ >= 16) |
|
773 | - break; |
|
800 | + if ($i++ >= 16) { |
|
801 | + break; |
|
802 | + } |
|
774 | 803 | |
775 | 804 | $output .= $range[($value >> 18) & 0x3f]; |
776 | 805 | } |
@@ -802,8 +831,9 @@ discard block |
||
802 | 831 | require_once($sourcedir . '/Subs-Auth.php'); |
803 | 832 | setLoginCookie(-3600, 0); |
804 | 833 | |
805 | - if (isset($_SESSION['login_' . $cookiename])) |
|
806 | - unset($_SESSION['login_' . $cookiename]); |
|
834 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
835 | + unset($_SESSION['login_' . $cookiename]); |
|
836 | + } |
|
807 | 837 | } |
808 | 838 | |
809 | 839 | // We need a member! |
@@ -817,8 +847,9 @@ discard block |
||
817 | 847 | } |
818 | 848 | |
819 | 849 | // Right, have we got a flood value? |
820 | - if ($password_flood_value !== false) |
|
821 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
850 | + if ($password_flood_value !== false) { |
|
851 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
852 | + } |
|
822 | 853 | |
823 | 854 | // Timestamp or number of tries invalid? |
824 | 855 | if (empty($number_tries) || empty($time_stamp)) |
@@ -834,15 +865,17 @@ discard block |
||
834 | 865 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
835 | 866 | |
836 | 867 | // They are trying too fast, make them wait longer |
837 | - if ($time_stamp < time() - 10) |
|
838 | - $time_stamp = time(); |
|
868 | + if ($time_stamp < time() - 10) { |
|
869 | + $time_stamp = time(); |
|
870 | + } |
|
839 | 871 | } |
840 | 872 | |
841 | 873 | $number_tries++; |
842 | 874 | |
843 | 875 | // Broken the law? |
844 | - if ($number_tries > 5) |
|
845 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
876 | + if ($number_tries > 5) { |
|
877 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
878 | + } |
|
846 | 879 | |
847 | 880 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
848 | 881 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
566 | 581 | |
567 | 582 | // Sanity check |
568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569 | - continue; |
|
583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
584 | + continue; |
|
585 | + } |
|
570 | 586 | |
571 | 587 | $linked_calendar_event = array( |
572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
615 | 631 | } |
616 | 632 | $smcFunc['db_free_result']($request); |
617 | 633 | |
618 | - if (!empty($context['linked_calendar_events'])) |
|
619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
634 | + if (!empty($context['linked_calendar_events'])) { |
|
635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
636 | + } |
|
620 | 637 | } |
621 | 638 | |
622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
679 | 696 | $smcFunc['db_free_result']($request); |
680 | 697 | |
681 | 698 | // Got we multi choice? |
682 | - if ($pollinfo['max_votes'] > 1) |
|
683 | - $realtotal = $pollinfo['total']; |
|
699 | + if ($pollinfo['max_votes'] > 1) { |
|
700 | + $realtotal = $pollinfo['total']; |
|
701 | + } |
|
684 | 702 | |
685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
694 | 712 | { |
695 | 713 | $guestvoted = explode(',', $guestvoted); |
696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
697 | - break; |
|
714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
715 | + break; |
|
716 | + } |
|
698 | 717 | } |
699 | 718 | // Has the poll been reset since guest voted? |
700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
701 | 720 | { |
702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
703 | 722 | unset($guestinfo[$i]); |
704 | - if (!empty($guestinfo)) |
|
705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
706 | - else |
|
707 | - unset($_COOKIE['guest_poll_vote']); |
|
708 | - } |
|
709 | - else |
|
723 | + if (!empty($guestinfo)) { |
|
724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
725 | + } else { |
|
726 | + unset($_COOKIE['guest_poll_vote']); |
|
727 | + } |
|
728 | + } else |
|
710 | 729 | { |
711 | 730 | // What did they vote for? |
712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
820 | 839 | // Build the poll moderation button array. |
821 | 840 | $context['poll_buttons'] = array(); |
822 | 841 | |
823 | - if ($context['allow_return_vote']) |
|
824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
842 | + if ($context['allow_return_vote']) { |
|
843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
844 | + } |
|
825 | 845 | |
826 | - if ($context['show_view_results_button']) |
|
827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
846 | + if ($context['show_view_results_button']) { |
|
847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
848 | + } |
|
828 | 849 | |
829 | - if ($context['allow_change_vote']) |
|
830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
850 | + if ($context['allow_change_vote']) { |
|
851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
852 | + } |
|
831 | 853 | |
832 | - if ($context['allow_lock_poll']) |
|
833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
854 | + if ($context['allow_lock_poll']) { |
|
855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
856 | + } |
|
834 | 857 | |
835 | - if ($context['allow_edit_poll']) |
|
836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
858 | + if ($context['allow_edit_poll']) { |
|
859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
860 | + } |
|
837 | 861 | |
838 | - if ($context['can_remove_poll']) |
|
839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
862 | + if ($context['can_remove_poll']) { |
|
863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
864 | + } |
|
840 | 865 | |
841 | 866 | // Allow mods to add additional buttons here |
842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -872,9 +897,9 @@ discard block |
||
872 | 897 | { |
873 | 898 | $start_char = 'C'; |
874 | 899 | $page_id = $ascending ? $context['topicinfo']['id_first_msg'] : $context['topicinfo']['id_last_msg']; |
900 | + } else { |
|
901 | + $start_char = null; |
|
875 | 902 | } |
876 | - else |
|
877 | - $start_char = null; |
|
878 | 903 | |
879 | 904 | $limit = $context['messages_per_page']; |
880 | 905 | |
@@ -889,17 +914,17 @@ discard block |
||
889 | 914 | { |
890 | 915 | $ascending_seek = true; |
891 | 916 | $page_operator = $ascending ? '>=' : '<='; |
892 | - } |
|
893 | - else |
|
917 | + } else |
|
894 | 918 | { |
895 | 919 | $ascending_seek = false; |
896 | 920 | $page_operator = $ascending ? '<=' : '>='; |
897 | 921 | } |
898 | 922 | |
899 | - if ($start_char === 'C') |
|
900 | - $limit_seek = $limit; |
|
901 | - else |
|
902 | - $limit_seek = $limit + 1; |
|
923 | + if ($start_char === 'C') { |
|
924 | + $limit_seek = $limit; |
|
925 | + } else { |
|
926 | + $limit_seek = $limit + 1; |
|
927 | + } |
|
903 | 928 | |
904 | 929 | $request = $smcFunc['db_query']('', ' |
905 | 930 | SELECT id_msg, id_member, approved |
@@ -922,21 +947,23 @@ discard block |
||
922 | 947 | $found_msg = false; |
923 | 948 | |
924 | 949 | // Fallback |
925 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
926 | - unset($start_char); |
|
927 | - else |
|
950 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
951 | + unset($start_char); |
|
952 | + } else |
|
928 | 953 | { |
929 | 954 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
930 | 955 | { |
931 | 956 | // Check if the start msg is in our result |
932 | - if ($row['id_msg'] == $page_id) |
|
933 | - $found_msg = true; |
|
957 | + if ($row['id_msg'] == $page_id) { |
|
958 | + $found_msg = true; |
|
959 | + } |
|
934 | 960 | |
935 | 961 | // Skip the the start msg if we not in mode C |
936 | 962 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
937 | 963 | { |
938 | - if (!empty($row['id_member'])) |
|
939 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
964 | + if (!empty($row['id_member'])) { |
|
965 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
966 | + } |
|
940 | 967 | |
941 | 968 | $messages[] = $row['id_msg']; |
942 | 969 | } |
@@ -952,8 +979,9 @@ discard block |
||
952 | 979 | } |
953 | 980 | |
954 | 981 | // Before Page bring in the right order |
955 | - if (!empty($start_char) && $start_char === 'L') |
|
956 | - krsort($messages); |
|
982 | + if (!empty($start_char) && $start_char === 'L') { |
|
983 | + krsort($messages); |
|
984 | + } |
|
957 | 985 | } |
958 | 986 | |
959 | 987 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
989 | 1017 | |
990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
991 | 1019 | { |
992 | - if (!empty($row['id_member'])) |
|
993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
1020 | + if (!empty($row['id_member'])) { |
|
1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
1022 | + } |
|
994 | 1023 | $messages[] = $row['id_msg']; |
995 | 1024 | } |
996 | 1025 | |
997 | 1026 | // Sort the messages into the correct display order |
998 | - if (!$ascending) |
|
999 | - sort($messages); |
|
1027 | + if (!$ascending) { |
|
1028 | + sort($messages); |
|
1029 | + } |
|
1000 | 1030 | } |
1001 | 1031 | |
1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
1017 | 1047 | { |
1018 | 1048 | $mark_at_msg = max($messages); |
1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
1051 | + } |
|
1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
1022 | 1053 | { |
1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1050 | 1081 | { |
1051 | 1082 | // Find if this topic is marked for notification... |
1052 | - if (!empty($row['id_topic'])) |
|
1053 | - $context['is_marked_notify'] = true; |
|
1083 | + if (!empty($row['id_topic'])) { |
|
1084 | + $context['is_marked_notify'] = true; |
|
1085 | + } |
|
1054 | 1086 | |
1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
1072 | 1104 | } |
1073 | 1105 | |
1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
1109 | + } |
|
1077 | 1110 | // Mark board as seen if this is the only new topic. |
1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
1097 | 1130 | $smcFunc['db_free_result']($request); |
1098 | 1131 | |
1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
1100 | - if (empty($numNewTopics)) |
|
1101 | - $_REQUEST['boardseen'] = true; |
|
1102 | - else |
|
1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1133 | + if (empty($numNewTopics)) { |
|
1134 | + $_REQUEST['boardseen'] = true; |
|
1135 | + } else { |
|
1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1137 | + } |
|
1104 | 1138 | } |
1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
1142 | + } |
|
1108 | 1143 | |
1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
1161 | 1196 | $temp = array(); |
1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1163 | 1198 | { |
1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1165 | - continue; |
|
1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1200 | + continue; |
|
1201 | + } |
|
1166 | 1202 | |
1167 | 1203 | $temp[$row['id_attach']] = $row; |
1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
1170 | 1206 | |
1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1209 | + } |
|
1173 | 1210 | } |
1174 | 1211 | $smcFunc['db_free_result']($request); |
1175 | 1212 | |
1176 | 1213 | // This is better than sorting it with the query... |
1177 | 1214 | ksort($temp); |
1178 | 1215 | |
1179 | - foreach ($temp as $row) |
|
1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1216 | + foreach ($temp as $row) { |
|
1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1218 | + } |
|
1181 | 1219 | } |
1182 | 1220 | |
1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
1204 | 1242 | ); |
1205 | 1243 | |
1206 | 1244 | // And the likes |
1207 | - if (!empty($modSettings['enable_likes'])) |
|
1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1245 | + if (!empty($modSettings['enable_likes'])) { |
|
1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1247 | + } |
|
1209 | 1248 | |
1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1252 | + } |
|
1213 | 1253 | |
1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1216 | - if (empty($options['view_newest_first'])) |
|
1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1218 | - else |
|
1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1220 | - } |
|
1221 | - else |
|
1256 | + if (empty($options['view_newest_first'])) { |
|
1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1258 | + } else { |
|
1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1260 | + } |
|
1261 | + } else |
|
1222 | 1262 | { |
1223 | 1263 | $messages_request = false; |
1224 | 1264 | $context['first_message'] = 0; |
@@ -1253,8 +1293,9 @@ discard block |
||
1253 | 1293 | 'can_restore_msg' => 'move_any', |
1254 | 1294 | 'can_like' => 'likes_like', |
1255 | 1295 | ); |
1256 | - foreach ($common_permissions as $contextual => $perm) |
|
1257 | - $context[$contextual] = allowedTo($perm); |
|
1296 | + foreach ($common_permissions as $contextual => $perm) { |
|
1297 | + $context[$contextual] = allowedTo($perm); |
|
1298 | + } |
|
1258 | 1299 | |
1259 | 1300 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1260 | 1301 | $anyown_permissions = array( |
@@ -1267,8 +1308,9 @@ discard block |
||
1267 | 1308 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1268 | 1309 | 'can_view_warning' => 'profile_warning', |
1269 | 1310 | ); |
1270 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1271 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1311 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1312 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1313 | + } |
|
1272 | 1314 | |
1273 | 1315 | if (!$user_info['is_admin'] && $context['can_move'] && !$modSettings['topic_move_any']) |
1274 | 1316 | { |
@@ -1314,8 +1356,9 @@ discard block |
||
1314 | 1356 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1315 | 1357 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1316 | 1358 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1317 | - if (!empty($context['drafts_save'])) |
|
1318 | - loadLanguage('Drafts'); |
|
1359 | + if (!empty($context['drafts_save'])) { |
|
1360 | + loadLanguage('Drafts'); |
|
1361 | + } |
|
1319 | 1362 | |
1320 | 1363 | // When was the last time this topic was replied to? Should we warn them about it? |
1321 | 1364 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1376,26 +1419,31 @@ discard block |
||
1376 | 1419 | // Message icons - customized icons are off? |
1377 | 1420 | $context['icons'] = getMessageIcons($board); |
1378 | 1421 | |
1379 | - if (!empty($context['icons'])) |
|
1380 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1422 | + if (!empty($context['icons'])) { |
|
1423 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1424 | + } |
|
1381 | 1425 | |
1382 | 1426 | // Build the normal button array. |
1383 | 1427 | $context['normal_buttons'] = array(); |
1384 | 1428 | |
1385 | - if ($context['can_reply']) |
|
1386 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1429 | + if ($context['can_reply']) { |
|
1430 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1431 | + } |
|
1387 | 1432 | |
1388 | - if ($context['can_add_poll']) |
|
1389 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1433 | + if ($context['can_add_poll']) { |
|
1434 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1435 | + } |
|
1390 | 1436 | |
1391 | - if ($context['can_mark_unread']) |
|
1392 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1437 | + if ($context['can_mark_unread']) { |
|
1438 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1439 | + } |
|
1393 | 1440 | |
1394 | - if ($context['can_print']) |
|
1395 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1441 | + if ($context['can_print']) { |
|
1442 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1443 | + } |
|
1396 | 1444 | |
1397 | - if ($context['can_set_notify']) |
|
1398 | - $context['normal_buttons']['notify'] = array( |
|
1445 | + if ($context['can_set_notify']) { |
|
1446 | + $context['normal_buttons']['notify'] = array( |
|
1399 | 1447 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1400 | 1448 | 'sub_buttons' => array( |
1401 | 1449 | array( |
@@ -1417,38 +1465,47 @@ discard block |
||
1417 | 1465 | ), |
1418 | 1466 | ), |
1419 | 1467 | ); |
1468 | + } |
|
1420 | 1469 | |
1421 | 1470 | // Build the mod button array |
1422 | 1471 | $context['mod_buttons'] = array(); |
1423 | 1472 | |
1424 | - if ($context['can_move']) |
|
1425 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1473 | + if ($context['can_move']) { |
|
1474 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1475 | + } |
|
1426 | 1476 | |
1427 | - if ($context['can_delete']) |
|
1428 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1477 | + if ($context['can_delete']) { |
|
1478 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1479 | + } |
|
1429 | 1480 | |
1430 | - if ($context['can_lock']) |
|
1431 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1481 | + if ($context['can_lock']) { |
|
1482 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1483 | + } |
|
1432 | 1484 | |
1433 | - if ($context['can_sticky']) |
|
1434 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1485 | + if ($context['can_sticky']) { |
|
1486 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1487 | + } |
|
1435 | 1488 | |
1436 | - if ($context['can_merge']) |
|
1437 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1489 | + if ($context['can_merge']) { |
|
1490 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1491 | + } |
|
1438 | 1492 | |
1439 | - if ($context['calendar_post']) |
|
1440 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1493 | + if ($context['calendar_post']) { |
|
1494 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1495 | + } |
|
1441 | 1496 | |
1442 | 1497 | // Restore topic. eh? No monkey business. |
1443 | - if ($context['can_restore_topic']) |
|
1444 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1498 | + if ($context['can_restore_topic']) { |
|
1499 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1500 | + } |
|
1445 | 1501 | |
1446 | 1502 | // Show a message in case a recently posted message became unapproved. |
1447 | 1503 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1448 | 1504 | |
1449 | 1505 | // Don't want to show this forever... |
1450 | - if ($context['becomesUnapproved']) |
|
1451 | - unset($_SESSION['becomesUnapproved']); |
|
1506 | + if ($context['becomesUnapproved']) { |
|
1507 | + unset($_SESSION['becomesUnapproved']); |
|
1508 | + } |
|
1452 | 1509 | |
1453 | 1510 | // Allow adding new mod buttons easily. |
1454 | 1511 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1457,12 +1514,14 @@ discard block |
||
1457 | 1514 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1458 | 1515 | |
1459 | 1516 | // Load the drafts js file |
1460 | - if ($context['drafts_autosave']) |
|
1461 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1517 | + if ($context['drafts_autosave']) { |
|
1518 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1519 | + } |
|
1462 | 1520 | |
1463 | 1521 | // Spellcheck |
1464 | - if ($context['show_spellchecking']) |
|
1465 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1522 | + if ($context['show_spellchecking']) { |
|
1523 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1524 | + } |
|
1466 | 1525 | |
1467 | 1526 | // topic.js |
1468 | 1527 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1496,16 +1555,19 @@ discard block |
||
1496 | 1555 | static $counter = null; |
1497 | 1556 | |
1498 | 1557 | // If the query returned false, bail. |
1499 | - if ($messages_request == false) |
|
1500 | - return false; |
|
1558 | + if ($messages_request == false) { |
|
1559 | + return false; |
|
1560 | + } |
|
1501 | 1561 | |
1502 | 1562 | // Remember which message this is. (ie. reply #83) |
1503 | - if ($counter === null || $reset) |
|
1504 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1563 | + if ($counter === null || $reset) { |
|
1564 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1565 | + } |
|
1505 | 1566 | |
1506 | 1567 | // Start from the beginning... |
1507 | - if ($reset) |
|
1508 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1568 | + if ($reset) { |
|
1569 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1570 | + } |
|
1509 | 1571 | |
1510 | 1572 | // Attempt to get the next message. |
1511 | 1573 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1519,19 +1581,21 @@ discard block |
||
1519 | 1581 | if (empty($context['icon_sources'])) |
1520 | 1582 | { |
1521 | 1583 | $context['icon_sources'] = array(); |
1522 | - foreach ($context['stable_icons'] as $icon) |
|
1523 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1584 | + foreach ($context['stable_icons'] as $icon) { |
|
1585 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1586 | + } |
|
1524 | 1587 | } |
1525 | 1588 | |
1526 | 1589 | // Message Icon Management... check the images exist. |
1527 | 1590 | if (empty($modSettings['messageIconChecks_disable'])) |
1528 | 1591 | { |
1529 | 1592 | // If the current icon isn't known, then we need to do something... |
1530 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1531 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1593 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1594 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1595 | + } |
|
1596 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1597 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1532 | 1598 | } |
1533 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1534 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1535 | 1599 | |
1536 | 1600 | // If you're a lazy bum, you probably didn't give a subject... |
1537 | 1601 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1556,8 +1620,7 @@ discard block |
||
1556 | 1620 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1557 | 1621 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1558 | 1622 | $memberContext[$message['id_member']]['is_guest'] = true; |
1559 | - } |
|
1560 | - else |
|
1623 | + } else |
|
1561 | 1624 | { |
1562 | 1625 | // Define this here to make things a bit more readable |
1563 | 1626 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1580,8 +1643,9 @@ discard block |
||
1580 | 1643 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1581 | 1644 | |
1582 | 1645 | // If it's in the recycle bin we need to override whatever icon we did have. |
1583 | - if (!empty($board_info['recycle'])) |
|
1584 | - $message['icon'] = 'recycled'; |
|
1646 | + if (!empty($board_info['recycle'])) { |
|
1647 | + $message['icon'] = 'recycled'; |
|
1648 | + } |
|
1585 | 1649 | |
1586 | 1650 | require_once($sourcedir . '/Subs-Attachments.php'); |
1587 | 1651 | |
@@ -1625,32 +1689,36 @@ discard block |
||
1625 | 1689 | } |
1626 | 1690 | |
1627 | 1691 | // Are likes enable? |
1628 | - if (!empty($modSettings['enable_likes'])) |
|
1629 | - $output['likes'] = array( |
|
1692 | + if (!empty($modSettings['enable_likes'])) { |
|
1693 | + $output['likes'] = array( |
|
1630 | 1694 | 'count' => $message['likes'], |
1631 | 1695 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1632 | 1696 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1633 | 1697 | ); |
1698 | + } |
|
1634 | 1699 | |
1635 | 1700 | // Is this user the message author? |
1636 | 1701 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1637 | - if (!empty($output['modified']['name'])) |
|
1638 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1702 | + if (!empty($output['modified']['name'])) { |
|
1703 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1704 | + } |
|
1639 | 1705 | |
1640 | 1706 | // Did they give a reason for editing? |
1641 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1642 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1707 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1708 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1709 | + } |
|
1643 | 1710 | |
1644 | 1711 | // Any custom profile fields? |
1645 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1646 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1712 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1713 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1647 | 1714 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1715 | + } |
|
1648 | 1716 | |
1649 | - if (empty($options['view_newest_first'])) |
|
1650 | - $counter++; |
|
1651 | - |
|
1652 | - else |
|
1653 | - $counter--; |
|
1717 | + if (empty($options['view_newest_first'])) { |
|
1718 | + $counter++; |
|
1719 | + } else { |
|
1720 | + $counter--; |
|
1721 | + } |
|
1654 | 1722 | |
1655 | 1723 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1656 | 1724 | |
@@ -1676,8 +1744,9 @@ discard block |
||
1676 | 1744 | */ |
1677 | 1745 | function approved_attach_sort($a, $b) |
1678 | 1746 | { |
1679 | - if ($a['is_approved'] == $b['is_approved']) |
|
1680 | - return 0; |
|
1747 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1748 | + return 0; |
|
1749 | + } |
|
1681 | 1750 | |
1682 | 1751 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1683 | 1752 | } |
@@ -1694,16 +1763,19 @@ discard block |
||
1694 | 1763 | |
1695 | 1764 | require_once($sourcedir . '/RemoveTopic.php'); |
1696 | 1765 | |
1697 | - if (empty($_REQUEST['msgs'])) |
|
1698 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1766 | + if (empty($_REQUEST['msgs'])) { |
|
1767 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1768 | + } |
|
1699 | 1769 | |
1700 | 1770 | $messages = array(); |
1701 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1702 | - $messages[] = (int) $dummy; |
|
1771 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1772 | + $messages[] = (int) $dummy; |
|
1773 | + } |
|
1703 | 1774 | |
1704 | 1775 | // We are restoring messages. We handle this in another place. |
1705 | - if (isset($_REQUEST['restore_selected'])) |
|
1706 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1776 | + if (isset($_REQUEST['restore_selected'])) { |
|
1777 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1778 | + } |
|
1707 | 1779 | if (isset($_REQUEST['split_selection'])) |
1708 | 1780 | { |
1709 | 1781 | $request = $smcFunc['db_query']('', ' |
@@ -1722,8 +1794,9 @@ discard block |
||
1722 | 1794 | } |
1723 | 1795 | |
1724 | 1796 | // Allowed to delete any message? |
1725 | - if (allowedTo('delete_any')) |
|
1726 | - $allowed_all = true; |
|
1797 | + if (allowedTo('delete_any')) { |
|
1798 | + $allowed_all = true; |
|
1799 | + } |
|
1727 | 1800 | // Allowed to delete replies to their messages? |
1728 | 1801 | elseif (allowedTo('delete_replies')) |
1729 | 1802 | { |
@@ -1740,13 +1813,14 @@ discard block |
||
1740 | 1813 | $smcFunc['db_free_result']($request); |
1741 | 1814 | |
1742 | 1815 | $allowed_all = $starter == $user_info['id']; |
1816 | + } else { |
|
1817 | + $allowed_all = false; |
|
1743 | 1818 | } |
1744 | - else |
|
1745 | - $allowed_all = false; |
|
1746 | 1819 | |
1747 | 1820 | // Make sure they're allowed to delete their own messages, if not any. |
1748 | - if (!$allowed_all) |
|
1749 | - isAllowedTo('delete_own'); |
|
1821 | + if (!$allowed_all) { |
|
1822 | + isAllowedTo('delete_own'); |
|
1823 | + } |
|
1750 | 1824 | |
1751 | 1825 | // Allowed to remove which messages? |
1752 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1766,8 +1840,9 @@ discard block |
||
1766 | 1840 | $messages = array(); |
1767 | 1841 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1768 | 1842 | { |
1769 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1770 | - continue; |
|
1843 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
1844 | + continue; |
|
1845 | + } |
|
1771 | 1846 | |
1772 | 1847 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1773 | 1848 | } |
@@ -1790,17 +1865,20 @@ discard block |
||
1790 | 1865 | foreach ($messages as $message => $info) |
1791 | 1866 | { |
1792 | 1867 | // Just skip the first message - if it's not the last. |
1793 | - if ($message == $first_message && $message != $last_message) |
|
1794 | - continue; |
|
1868 | + if ($message == $first_message && $message != $last_message) { |
|
1869 | + continue; |
|
1870 | + } |
|
1795 | 1871 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
1796 | - elseif ($message == $first_message) |
|
1797 | - $topicGone = true; |
|
1872 | + elseif ($message == $first_message) { |
|
1873 | + $topicGone = true; |
|
1874 | + } |
|
1798 | 1875 | |
1799 | 1876 | removeMessage($message); |
1800 | 1877 | |
1801 | 1878 | // Log this moderation action ;). |
1802 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1803 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1879 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
1880 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1881 | + } |
|
1804 | 1882 | } |
1805 | 1883 | |
1806 | 1884 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding"> |
32 | 32 | ', $context['error_message'], ' |
33 | 33 | </div>'; |
34 | - else |
|
34 | + } else |
|
35 | 35 | { |
36 | 36 | echo ' |
37 | 37 | <div id="fatal_error"> |
@@ -85,21 +85,23 @@ discard block |
||
85 | 85 | |
86 | 86 | $error_types = array(); |
87 | 87 | |
88 | - foreach ($context['error_types'] as $type => $details) |
|
89 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
88 | + foreach ($context['error_types'] as $type => $details) { |
|
89 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
90 | + } |
|
90 | 91 | |
91 | 92 | echo ' |
92 | 93 | ', implode(' | ', $error_types), ' |
93 | 94 | </td> |
94 | 95 | </tr>'; |
95 | 96 | |
96 | - if ($context['has_filter']) |
|
97 | - echo ' |
|
97 | + if ($context['has_filter']) { |
|
98 | + echo ' |
|
98 | 99 | <tr> |
99 | 100 | <td colspan="3" class="windowbg"> |
100 | 101 | <strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
101 | 102 | </td> |
102 | 103 | </tr>'; |
104 | + } |
|
103 | 105 | |
104 | 106 | echo ' |
105 | 107 | <tr> |
@@ -110,11 +112,12 @@ discard block |
||
110 | 112 | </tr>'; |
111 | 113 | |
112 | 114 | // No errors, then show a message |
113 | - if (count($context['errors']) == 0) |
|
114 | - echo ' |
|
115 | + if (count($context['errors']) == 0) { |
|
116 | + echo ' |
|
115 | 117 | <tr class="windowbg"> |
116 | 118 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
117 | 119 | </tr>'; |
120 | + } |
|
118 | 121 | |
119 | 122 | // We have some errors, must be some mods installed :P |
120 | 123 | foreach ($context['errors'] as $error) |
@@ -128,16 +131,18 @@ discard block |
||
128 | 131 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
129 | 132 | ', $error['time'], '<br>'; |
130 | 133 | |
131 | - if (!empty($error['member']['ip'])) |
|
132 | - echo ' |
|
134 | + if (!empty($error['member']['ip'])) { |
|
135 | + echo ' |
|
133 | 136 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
134 | 137 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>'; |
138 | + } |
|
135 | 139 | |
136 | - if ($error['member']['session'] != '') |
|
137 | - echo ' |
|
140 | + if ($error['member']['session'] != '') { |
|
141 | + echo ' |
|
138 | 142 | <br> |
139 | 143 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
140 | 144 | ', $error['member']['session'], '<br>'; |
145 | + } |
|
141 | 146 | |
142 | 147 | echo ' |
143 | 148 | </div> |
@@ -152,12 +157,13 @@ discard block |
||
152 | 157 | <a href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
153 | 158 | '; |
154 | 159 | |
155 | - if (!empty($error['file'])) |
|
156 | - echo ' |
|
160 | + if (!empty($error['file'])) { |
|
161 | + echo ' |
|
157 | 162 | <div> |
158 | 163 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '">' |
159 | 164 | . ' <span class="generic_icons filter"></span></a> ', $error['file']['link'], ' (', $txt['line'], ' ', $error['file']['line'], ') |
160 | 165 | </div>'; |
166 | + } |
|
161 | 167 | |
162 | 168 | echo ' |
163 | 169 | </div> |
@@ -186,9 +192,10 @@ discard block |
||
186 | 192 | </div> |
187 | 193 | </div>'; |
188 | 194 | |
189 | - if ($context['sort_direction'] == 'down') |
|
190 | - echo ' |
|
195 | + if ($context['sort_direction'] == 'down') { |
|
196 | + echo ' |
|
191 | 197 | <input type="hidden" name="desc" value="1">'; |
198 | + } |
|
192 | 199 | |
193 | 200 | echo ' |
194 | 201 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -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 |