@@ -86,7 +86,7 @@ |
||
86 | 86 | foreach ($board['children'] as $child) |
87 | 87 | { |
88 | 88 | if (!$child['is_redirect']) |
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | 90 | else |
91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
92 | 92 |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
19 | 19 | |
20 | 20 | // Let them know why their message became unapproved. |
21 | - if ($context['becomesUnapproved']) |
|
22 | - echo ' |
|
21 | + if ($context['becomesUnapproved']) { |
|
22 | + echo ' |
|
23 | 23 | <div class="noticebox"> |
24 | 24 | ', $txt['post_becomesUnapproved'], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
46 | 47 | </a>'; |
47 | 48 | |
48 | 49 | // Has it outstanding posts for approval? |
49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
50 | - echo ' |
|
50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
51 | + echo ' |
|
51 | 52 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
53 | + } |
|
52 | 54 | |
53 | 55 | echo ' |
54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
55 | 57 | |
56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
58 | - echo ' |
|
59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
60 | + echo ' |
|
59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | // Show some basic information about the number of posts, etc. |
62 | 65 | echo ' |
@@ -68,9 +71,10 @@ discard block |
||
68 | 71 | </div> |
69 | 72 | <div class="lastpost lpr_border">'; |
70 | 73 | |
71 | - if (!empty($board['last_post']['id'])) |
|
72 | - echo ' |
|
74 | + if (!empty($board['last_post']['id'])) { |
|
75 | + echo ' |
|
73 | 76 | <p>', $board['last_post']['last_post_message'], '</p>'; |
77 | + } |
|
74 | 78 | |
75 | 79 | echo ' |
76 | 80 | </div>'; |
@@ -84,14 +88,16 @@ discard block |
||
84 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
85 | 89 | foreach ($board['children'] as $child) |
86 | 90 | { |
87 | - if (!$child['is_redirect']) |
|
88 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | - else |
|
90 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Has it posts awaiting approval? |
93 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
94 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
100 | + } |
|
95 | 101 | |
96 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
97 | 103 | } |
@@ -111,8 +117,9 @@ discard block |
||
111 | 117 | } |
112 | 118 | |
113 | 119 | // They can only mark read if they are logged in and it's enabled! |
114 | - if (!$context['user']['is_logged']) |
|
115 | - unset($context['normal_buttons']['markread']); |
|
120 | + if (!$context['user']['is_logged']) { |
|
121 | + unset($context['normal_buttons']['markread']); |
|
122 | + } |
|
116 | 123 | |
117 | 124 | if (!$context['no_topic_listing']) |
118 | 125 | { |
@@ -139,13 +146,15 @@ discard block |
||
139 | 146 | <h3>', $context['name'], '</h3> |
140 | 147 | <p>'; |
141 | 148 | |
142 | - if ($context['description'] != '') |
|
143 | - echo ' |
|
149 | + if ($context['description'] != '') { |
|
150 | + echo ' |
|
144 | 151 | ', $context['description']; |
152 | + } |
|
145 | 153 | |
146 | - if (!empty($context['moderators'])) |
|
147 | - echo ' |
|
154 | + if (!empty($context['moderators'])) { |
|
155 | + echo ' |
|
148 | 156 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
157 | + } |
|
149 | 158 | |
150 | 159 | echo ' |
151 | 160 | </p> |
@@ -153,9 +162,10 @@ discard block |
||
153 | 162 | } |
154 | 163 | |
155 | 164 | // If Quick Moderation is enabled start the form. |
156 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
157 | - echo ' |
|
165 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
166 | + echo ' |
|
158 | 167 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
168 | + } |
|
159 | 169 | |
160 | 170 | echo ' |
161 | 171 | <div id="messageindex">'; |
@@ -165,11 +175,11 @@ discard block |
||
165 | 175 | echo ' |
166 | 176 | <div class="information">'; |
167 | 177 | |
168 | - if ($settings['display_who_viewing'] == 1) |
|
169 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
170 | - |
|
171 | - else |
|
172 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
178 | + if ($settings['display_who_viewing'] == 1) { |
|
179 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
180 | + } else { |
|
181 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
182 | + } |
|
173 | 183 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
174 | 184 | |
175 | 185 | echo ' |
@@ -189,32 +199,36 @@ discard block |
||
189 | 199 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
190 | 200 | |
191 | 201 | // Show a "select all" box for quick moderation? |
192 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
193 | - echo ' |
|
202 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
203 | + echo ' |
|
194 | 204 | <div class="moderation"> |
195 | 205 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
196 | 206 | </div>'; |
207 | + } |
|
197 | 208 | |
198 | 209 | // If it's on in "image" mode, don't show anything but the column. |
199 | - elseif (!empty($context['can_quick_mod'])) |
|
200 | - echo ' |
|
210 | + elseif (!empty($context['can_quick_mod'])) { |
|
211 | + echo ' |
|
201 | 212 | <div class="moderation"></div>'; |
213 | + } |
|
202 | 214 | } |
203 | 215 | |
204 | 216 | // No topics... just say, "sorry bub". |
205 | - else |
|
206 | - echo ' |
|
217 | + else { |
|
218 | + echo ' |
|
207 | 219 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
220 | + } |
|
208 | 221 | |
209 | 222 | echo ' |
210 | 223 | </div><!-- #topic_header -->'; |
211 | 224 | |
212 | 225 | // If this person can approve items and we have some awaiting approval tell them. |
213 | - if (!empty($context['unapproved_posts_message'])) |
|
214 | - echo ' |
|
226 | + if (!empty($context['unapproved_posts_message'])) { |
|
227 | + echo ' |
|
215 | 228 | <div class="information"> |
216 | 229 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
217 | 230 | </div>'; |
231 | + } |
|
218 | 232 | |
219 | 233 | // Contain the topic list |
220 | 234 | echo ' |
@@ -235,25 +249,30 @@ discard block |
||
235 | 249 | echo ' |
236 | 250 | <div class="icons floatright">'; |
237 | 251 | |
238 | - if ($topic['is_watched']) |
|
239 | - echo ' |
|
252 | + if ($topic['is_watched']) { |
|
253 | + echo ' |
|
240 | 254 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
255 | + } |
|
241 | 256 | |
242 | - if ($topic['is_locked']) |
|
243 | - echo ' |
|
257 | + if ($topic['is_locked']) { |
|
258 | + echo ' |
|
244 | 259 | <span class="generic_icons lock"></span>'; |
260 | + } |
|
245 | 261 | |
246 | - if ($topic['is_sticky']) |
|
247 | - echo ' |
|
262 | + if ($topic['is_sticky']) { |
|
263 | + echo ' |
|
248 | 264 | <span class="generic_icons sticky"></span>'; |
265 | + } |
|
249 | 266 | |
250 | - if ($topic['is_redirect']) |
|
251 | - echo ' |
|
267 | + if ($topic['is_redirect']) { |
|
268 | + echo ' |
|
252 | 269 | <span class="generic_icons move"></span>'; |
270 | + } |
|
253 | 271 | |
254 | - if ($topic['is_poll']) |
|
255 | - echo ' |
|
272 | + if ($topic['is_poll']) { |
|
273 | + echo ' |
|
256 | 274 | <span class="generic_icons poll"></span>'; |
275 | + } |
|
257 | 276 | |
258 | 277 | echo ' |
259 | 278 | </div>'; |
@@ -285,26 +304,31 @@ discard block |
||
285 | 304 | echo ' |
286 | 305 | <div class="moderation">'; |
287 | 306 | |
288 | - if ($options['display_quick_mod'] == 1) |
|
289 | - echo ' |
|
307 | + if ($options['display_quick_mod'] == 1) { |
|
308 | + echo ' |
|
290 | 309 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
291 | - else |
|
310 | + } else |
|
292 | 311 | { |
293 | 312 | // Check permissions on each and show only the ones they are allowed to use. |
294 | - if ($topic['quick_mod']['remove']) |
|
295 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
313 | + if ($topic['quick_mod']['remove']) { |
|
314 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
315 | + } |
|
296 | 316 | |
297 | - if ($topic['quick_mod']['lock']) |
|
298 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
317 | + if ($topic['quick_mod']['lock']) { |
|
318 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
319 | + } |
|
299 | 320 | |
300 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
301 | - echo '<br>'; |
|
321 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
322 | + echo '<br>'; |
|
323 | + } |
|
302 | 324 | |
303 | - if ($topic['quick_mod']['sticky']) |
|
304 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
325 | + if ($topic['quick_mod']['sticky']) { |
|
326 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
327 | + } |
|
305 | 328 | |
306 | - if ($topic['quick_mod']['move']) |
|
307 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
329 | + if ($topic['quick_mod']['move']) { |
|
330 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
331 | + } |
|
308 | 332 | } |
309 | 333 | echo ' |
310 | 334 | </div><!-- .moderation -->'; |
@@ -322,18 +346,20 @@ discard block |
||
322 | 346 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
323 | 347 | <option value="">--------</option>'; |
324 | 348 | |
325 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
326 | - if ($context['can_' . $qmod_action]) |
|
349 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
350 | + if ($context['can_' . $qmod_action]) |
|
327 | 351 | echo ' |
328 | 352 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
353 | + } |
|
329 | 354 | |
330 | 355 | echo ' |
331 | 356 | </select>'; |
332 | 357 | |
333 | 358 | // Show a list of boards they can move the topic to. |
334 | - if ($context['can_move']) |
|
335 | - echo ' |
|
359 | + if ($context['can_move']) { |
|
360 | + echo ' |
|
336 | 361 | <span id="quick_mod_jump_to"></span>'; |
362 | + } |
|
337 | 363 | |
338 | 364 | echo ' |
339 | 365 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -344,10 +370,11 @@ discard block |
||
344 | 370 | </div><!-- #messageindex -->'; |
345 | 371 | |
346 | 372 | // Finish off the form - again. |
347 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
348 | - echo ' |
|
373 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
374 | + echo ' |
|
349 | 375 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
350 | 376 | </form>'; |
377 | + } |
|
351 | 378 | |
352 | 379 | // Mobile action buttons (bottom) |
353 | 380 | echo ' |
@@ -369,8 +396,8 @@ discard block |
||
369 | 396 | // Show breadcrumbs at the bottom too. |
370 | 397 | theme_linktree(); |
371 | 398 | |
372 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
373 | - echo ' |
|
399 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
400 | + echo ' |
|
374 | 401 | <script> |
375 | 402 | if (typeof(window.XMLHttpRequest) != "undefined") |
376 | 403 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -389,6 +416,7 @@ discard block |
||
389 | 416 | sCustomName: "move_to" |
390 | 417 | }); |
391 | 418 | </script>'; |
419 | + } |
|
392 | 420 | |
393 | 421 | // Javascript for inline editing. |
394 | 422 | echo ' |
@@ -425,8 +453,8 @@ discard block |
||
425 | 453 | <div class="information"> |
426 | 454 | <p class="floatright" id="message_index_jump_to"></p>'; |
427 | 455 | |
428 | - if (empty($context['no_topic_listing'])) |
|
429 | - echo ' |
|
456 | + if (empty($context['no_topic_listing'])) { |
|
457 | + echo ' |
|
430 | 458 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
431 | 459 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
432 | 460 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -436,9 +464,10 @@ discard block |
||
436 | 464 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
437 | 465 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
438 | 466 | </p>'; |
467 | + } |
|
439 | 468 | |
440 | - if (!empty($context['jump_to'])) |
|
441 | - echo ' |
|
469 | + if (!empty($context['jump_to'])) { |
|
470 | + echo ' |
|
442 | 471 | <script> |
443 | 472 | if (typeof(window.XMLHttpRequest) != "undefined") |
444 | 473 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -454,6 +483,7 @@ discard block |
||
454 | 483 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
455 | 484 | }); |
456 | 485 | </script>'; |
486 | + } |
|
457 | 487 | |
458 | 488 | echo ' |
459 | 489 | <br class="clear"> |
@@ -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 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | if (!empty($recycle_boards)) |
@@ -844,9 +876,9 @@ discard block |
||
844 | 876 | require_once($sourcedir . '/Subs-Boards.php'); |
845 | 877 | sortBoards($recycle_boards); |
846 | 878 | $recycle_boards = array('') + $recycle_boards; |
879 | + } else { |
|
880 | + $recycle_boards = array(''); |
|
847 | 881 | } |
848 | - else |
|
849 | - $recycle_boards = array(''); |
|
850 | 882 | |
851 | 883 | // Here and the board settings... |
852 | 884 | $config_vars = array( |
@@ -864,8 +896,9 @@ discard block |
||
864 | 896 | |
865 | 897 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
866 | 898 | |
867 | - if ($return_config) |
|
868 | - return $config_vars; |
|
899 | + if ($return_config) { |
|
900 | + return $config_vars; |
|
901 | + } |
|
869 | 902 | |
870 | 903 | // Needed for the settings template. |
871 | 904 | require_once($sourcedir . '/ManageServer.php'); |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -1719,7 +1719,7 @@ |
||
1719 | 1719 | $id_theme = $modSettings['theme_guests']; |
1720 | 1720 | |
1721 | 1721 | // We already load the basic stuff? |
1722 | - if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
|
1722 | + if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme) |
|
1723 | 1723 | { |
1724 | 1724 | // Verify the id_theme... no foul play. |
1725 | 1725 | // Always allow the board specific theme, if they are overriding. |
@@ -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 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,28 +48,36 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -405,27 +422,28 @@ discard block |
||
405 | 422 | break; |
406 | 423 | } |
407 | 424 | } |
425 | + } else { |
|
426 | + $id_member = 0; |
|
408 | 427 | } |
409 | - else |
|
410 | - $id_member = 0; |
|
411 | 428 | |
412 | 429 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
413 | 430 | { |
414 | 431 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
415 | 432 | |
416 | - if (empty($cookie_data)) |
|
417 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + if (empty($cookie_data)) { |
|
434 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | list ($id_member, $password) = $cookie_data; |
420 | 438 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
421 | - } |
|
422 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
439 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
423 | 440 | { |
424 | 441 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
425 | 442 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
426 | 443 | |
427 | - if (empty($cookie_data)) |
|
428 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + if (empty($cookie_data)) { |
|
445 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
446 | + } |
|
429 | 447 | |
430 | 448 | list ($id_member, $password, $login_span) = $cookie_data; |
431 | 449 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -450,30 +468,34 @@ discard block |
||
450 | 468 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
451 | 469 | $smcFunc['db_free_result']($request); |
452 | 470 | |
453 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
454 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
472 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
473 | + } |
|
455 | 474 | |
456 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
457 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
476 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
477 | + } |
|
458 | 478 | } |
459 | 479 | |
460 | 480 | // Did we find 'im? If not, junk it. |
461 | 481 | if (!empty($user_settings)) |
462 | 482 | { |
463 | 483 | // As much as the password should be right, we can assume the integration set things up. |
464 | - if (!empty($already_verified) && $already_verified === true) |
|
465 | - $check = true; |
|
484 | + if (!empty($already_verified) && $already_verified === true) { |
|
485 | + $check = true; |
|
486 | + } |
|
466 | 487 | // SHA-512 hash should be 128 characters long. |
467 | - elseif (strlen($password) == 128) |
|
468 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
469 | - else |
|
470 | - $check = false; |
|
488 | + elseif (strlen($password) == 128) { |
|
489 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
490 | + } else { |
|
491 | + $check = false; |
|
492 | + } |
|
471 | 493 | |
472 | 494 | // Wrong password or not activated - either way, you're going nowhere. |
473 | 495 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
496 | + } else { |
|
497 | + $id_member = 0; |
|
474 | 498 | } |
475 | - else |
|
476 | - $id_member = 0; |
|
477 | 499 | |
478 | 500 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
479 | 501 | if (!$id_member) |
@@ -502,8 +524,9 @@ discard block |
||
502 | 524 | |
503 | 525 | list ($tfamember, $tfasecret) = $tfa_data; |
504 | 526 | |
505 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
506 | - $tfasecret = null; |
|
527 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
528 | + $tfasecret = null; |
|
529 | + } |
|
507 | 530 | } |
508 | 531 | |
509 | 532 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -523,10 +546,12 @@ discard block |
||
523 | 546 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
524 | 547 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
525 | 548 | { |
526 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
549 | + if ($modSettings['tfa_mode'] == 2) { |
|
550 | + //only do this if we are just forcing SOME membergroups |
|
527 | 551 | { |
528 | 552 | //Build an array of ALL user membergroups. |
529 | 553 | $full_groups = array($user_settings['id_group']); |
554 | + } |
|
530 | 555 | if (!empty($user_settings['additional_groups'])) |
531 | 556 | { |
532 | 557 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -546,15 +571,17 @@ discard block |
||
546 | 571 | ); |
547 | 572 | $row = $smcFunc['db_fetch_assoc']($request); |
548 | 573 | $smcFunc['db_free_result']($request); |
574 | + } else { |
|
575 | + $row['total'] = 1; |
|
549 | 576 | } |
550 | - else |
|
551 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
577 | + //simplifies logics in the next "if" |
|
552 | 578 | |
553 | 579 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
554 | 580 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
555 | 581 | |
556 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
557 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
583 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
584 | + } |
|
558 | 585 | } |
559 | 586 | } |
560 | 587 | |
@@ -591,33 +618,37 @@ discard block |
||
591 | 618 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
592 | 619 | $user_settings['last_login'] = time(); |
593 | 620 | |
594 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
595 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
622 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
623 | + } |
|
596 | 624 | |
597 | - if (!empty($modSettings['cache_enable'])) |
|
598 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + if (!empty($modSettings['cache_enable'])) { |
|
626 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
627 | + } |
|
599 | 628 | } |
629 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
630 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
600 | 631 | } |
601 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
602 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
603 | 632 | |
604 | 633 | $username = $user_settings['member_name']; |
605 | 634 | |
606 | - if (empty($user_settings['additional_groups'])) |
|
607 | - $user_info = array( |
|
635 | + if (empty($user_settings['additional_groups'])) { |
|
636 | + $user_info = array( |
|
608 | 637 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
609 | 638 | ); |
610 | - else |
|
611 | - $user_info = array( |
|
639 | + } else { |
|
640 | + $user_info = array( |
|
612 | 641 | 'groups' => array_merge( |
613 | 642 | array($user_settings['id_group'], $user_settings['id_post_group']), |
614 | 643 | explode(',', $user_settings['additional_groups']) |
615 | 644 | ) |
616 | 645 | ); |
646 | + } |
|
617 | 647 | |
618 | 648 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
619 | - foreach ($user_info['groups'] as $k => $v) |
|
620 | - $user_info['groups'][$k] = (int) $v; |
|
649 | + foreach ($user_info['groups'] as $k => $v) { |
|
650 | + $user_info['groups'][$k] = (int) $v; |
|
651 | + } |
|
621 | 652 | |
622 | 653 | // This is a logged in user, so definitely not a spider. |
623 | 654 | $user_info['possibly_robot'] = false; |
@@ -631,8 +662,7 @@ discard block |
||
631 | 662 | $time_system = new DateTime('now', $tz_system); |
632 | 663 | $time_user = new DateTime('now', $tz_user); |
633 | 664 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
634 | - } |
|
635 | - else |
|
665 | + } else |
|
636 | 666 | { |
637 | 667 | // !!! Compatibility. |
638 | 668 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -646,8 +676,9 @@ discard block |
||
646 | 676 | $user_info = array('groups' => array(-1)); |
647 | 677 | $user_settings = array(); |
648 | 678 | |
649 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
650 | - $_COOKIE[$cookiename] = ''; |
|
679 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
680 | + $_COOKIE[$cookiename] = ''; |
|
681 | + } |
|
651 | 682 | |
652 | 683 | // Expire the 2FA cookie |
653 | 684 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -664,19 +695,20 @@ discard block |
||
664 | 695 | } |
665 | 696 | |
666 | 697 | // Create a login token if it doesn't exist yet. |
667 | - if (!isset($_SESSION['token']['post-login'])) |
|
668 | - createToken('login'); |
|
669 | - else |
|
670 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
698 | + if (!isset($_SESSION['token']['post-login'])) { |
|
699 | + createToken('login'); |
|
700 | + } else { |
|
701 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
702 | + } |
|
671 | 703 | |
672 | 704 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
673 | 705 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
674 | 706 | { |
675 | 707 | require_once($sourcedir . '/ManageSearchEngines.php'); |
676 | 708 | $user_info['possibly_robot'] = SpiderCheck(); |
709 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
710 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
677 | 711 | } |
678 | - elseif (!empty($modSettings['spider_mode'])) |
|
679 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
680 | 712 | // If we haven't turned on proper spider hunts then have a guess! |
681 | 713 | else |
682 | 714 | { |
@@ -724,8 +756,9 @@ discard block |
||
724 | 756 | $user_info['groups'] = array_unique($user_info['groups']); |
725 | 757 | |
726 | 758 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
727 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
728 | - unset($user_info['ignoreboards'][$tmp]); |
|
759 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
760 | + unset($user_info['ignoreboards'][$tmp]); |
|
761 | + } |
|
729 | 762 | |
730 | 763 | // Allow the user to change their language. |
731 | 764 | if (!empty($modSettings['userLanguage'])) |
@@ -738,13 +771,14 @@ discard block |
||
738 | 771 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
739 | 772 | |
740 | 773 | // Make it permanent for members. |
741 | - if (!empty($user_info['id'])) |
|
742 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
743 | - else |
|
744 | - $_SESSION['language'] = $user_info['language']; |
|
774 | + if (!empty($user_info['id'])) { |
|
775 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
776 | + } else { |
|
777 | + $_SESSION['language'] = $user_info['language']; |
|
778 | + } |
|
779 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
780 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
745 | 781 | } |
746 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
747 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
748 | 782 | } |
749 | 783 | |
750 | 784 | $temp = build_query_board($user_info['id']); |
@@ -807,9 +841,9 @@ discard block |
||
807 | 841 | } |
808 | 842 | |
809 | 843 | // Remember redirection is the key to avoiding fallout from your bosses. |
810 | - if (!empty($topic)) |
|
811 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
812 | - else |
|
844 | + if (!empty($topic)) { |
|
845 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
846 | + } else |
|
813 | 847 | { |
814 | 848 | loadPermissions(); |
815 | 849 | loadTheme(); |
@@ -827,10 +861,11 @@ discard block |
||
827 | 861 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
828 | 862 | { |
829 | 863 | // @todo SLOW? |
830 | - if (!empty($topic)) |
|
831 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
832 | - else |
|
833 | - $temp = cache_get_data('board-' . $board, 120); |
|
864 | + if (!empty($topic)) { |
|
865 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
866 | + } else { |
|
867 | + $temp = cache_get_data('board-' . $board, 120); |
|
868 | + } |
|
834 | 869 | |
835 | 870 | if (!empty($temp)) |
836 | 871 | { |
@@ -868,8 +903,9 @@ discard block |
||
868 | 903 | $row = $smcFunc['db_fetch_assoc']($request); |
869 | 904 | |
870 | 905 | // Set the current board. |
871 | - if (!empty($row['id_board'])) |
|
872 | - $board = $row['id_board']; |
|
906 | + if (!empty($row['id_board'])) { |
|
907 | + $board = $row['id_board']; |
|
908 | + } |
|
873 | 909 | |
874 | 910 | // Basic operating information. (globals... :/) |
875 | 911 | $board_info = array( |
@@ -905,21 +941,23 @@ discard block |
||
905 | 941 | |
906 | 942 | do |
907 | 943 | { |
908 | - if (!empty($row['id_moderator'])) |
|
909 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
944 | + if (!empty($row['id_moderator'])) { |
|
945 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
910 | 946 | 'id' => $row['id_moderator'], |
911 | 947 | 'name' => $row['real_name'], |
912 | 948 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
913 | 949 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
914 | 950 | ); |
951 | + } |
|
915 | 952 | |
916 | - if (!empty($row['id_moderator_group'])) |
|
917 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
953 | + if (!empty($row['id_moderator_group'])) { |
|
954 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
918 | 955 | 'id' => $row['id_moderator_group'], |
919 | 956 | 'name' => $row['group_name'], |
920 | 957 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
921 | 958 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
922 | 959 | ); |
960 | + } |
|
923 | 961 | } |
924 | 962 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
925 | 963 | |
@@ -951,12 +989,12 @@ discard block |
||
951 | 989 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
952 | 990 | { |
953 | 991 | // @todo SLOW? |
954 | - if (!empty($topic)) |
|
955 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
992 | + if (!empty($topic)) { |
|
993 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
994 | + } |
|
956 | 995 | cache_put_data('board-' . $board, $board_info, 120); |
957 | 996 | } |
958 | - } |
|
959 | - else |
|
997 | + } else |
|
960 | 998 | { |
961 | 999 | // Otherwise the topic is invalid, there are no moderators, etc. |
962 | 1000 | $board_info = array( |
@@ -970,8 +1008,9 @@ discard block |
||
970 | 1008 | $smcFunc['db_free_result']($request); |
971 | 1009 | } |
972 | 1010 | |
973 | - if (!empty($topic)) |
|
974 | - $_GET['board'] = (int) $board; |
|
1011 | + if (!empty($topic)) { |
|
1012 | + $_GET['board'] = (int) $board; |
|
1013 | + } |
|
975 | 1014 | |
976 | 1015 | if (!empty($board)) |
977 | 1016 | { |
@@ -981,10 +1020,12 @@ discard block |
||
981 | 1020 | // Now check if the user is a moderator. |
982 | 1021 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
983 | 1022 | |
984 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
985 | - $board_info['error'] = 'access'; |
|
986 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
987 | - $board_info['error'] = 'access'; |
|
1023 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1024 | + $board_info['error'] = 'access'; |
|
1025 | + } |
|
1026 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1027 | + $board_info['error'] = 'access'; |
|
1028 | + } |
|
988 | 1029 | |
989 | 1030 | // Build up the linktree. |
990 | 1031 | $context['linktree'] = array_merge( |
@@ -1007,8 +1048,9 @@ discard block |
||
1007 | 1048 | $context['current_board'] = $board; |
1008 | 1049 | |
1009 | 1050 | // No posting in redirection boards! |
1010 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1011 | - $board_info['error'] == 'post_in_redirect'; |
|
1051 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1052 | + $board_info['error'] == 'post_in_redirect'; |
|
1053 | + } |
|
1012 | 1054 | |
1013 | 1055 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1014 | 1056 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1034,24 +1076,23 @@ discard block |
||
1034 | 1076 | ob_end_clean(); |
1035 | 1077 | header('HTTP/1.1 403 Forbidden'); |
1036 | 1078 | die; |
1037 | - } |
|
1038 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1079 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1039 | 1080 | { |
1040 | 1081 | // Slightly different error message here... |
1041 | 1082 | fatal_lang_error('cannot_post_redirect', false); |
1042 | - } |
|
1043 | - elseif ($user_info['is_guest']) |
|
1083 | + } elseif ($user_info['is_guest']) |
|
1044 | 1084 | { |
1045 | 1085 | loadLanguage('Errors'); |
1046 | 1086 | is_not_guest($txt['topic_gone']); |
1087 | + } else { |
|
1088 | + fatal_lang_error('topic_gone', false); |
|
1047 | 1089 | } |
1048 | - else |
|
1049 | - fatal_lang_error('topic_gone', false); |
|
1050 | 1090 | } |
1051 | 1091 | |
1052 | - if ($user_info['is_mod']) |
|
1053 | - $user_info['groups'][] = 3; |
|
1054 | -} |
|
1092 | + if ($user_info['is_mod']) { |
|
1093 | + $user_info['groups'][] = 3; |
|
1094 | + } |
|
1095 | + } |
|
1055 | 1096 | |
1056 | 1097 | /** |
1057 | 1098 | * Load this user's permissions. |
@@ -1072,8 +1113,9 @@ discard block |
||
1072 | 1113 | asort($cache_groups); |
1073 | 1114 | $cache_groups = implode(',', $cache_groups); |
1074 | 1115 | // If it's a spider then cache it different. |
1075 | - if ($user_info['possibly_robot']) |
|
1076 | - $cache_groups .= '-spider'; |
|
1116 | + if ($user_info['possibly_robot']) { |
|
1117 | + $cache_groups .= '-spider'; |
|
1118 | + } |
|
1077 | 1119 | |
1078 | 1120 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1079 | 1121 | { |
@@ -1081,9 +1123,9 @@ discard block |
||
1081 | 1123 | banPermissions(); |
1082 | 1124 | |
1083 | 1125 | return; |
1126 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1127 | + list ($user_info['permissions'], $removals) = $temp; |
|
1084 | 1128 | } |
1085 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1086 | - list ($user_info['permissions'], $removals) = $temp; |
|
1087 | 1129 | } |
1088 | 1130 | |
1089 | 1131 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1105,23 +1147,26 @@ discard block |
||
1105 | 1147 | $removals = array(); |
1106 | 1148 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1107 | 1149 | { |
1108 | - if (empty($row['add_deny'])) |
|
1109 | - $removals[] = $row['permission']; |
|
1110 | - else |
|
1111 | - $user_info['permissions'][] = $row['permission']; |
|
1150 | + if (empty($row['add_deny'])) { |
|
1151 | + $removals[] = $row['permission']; |
|
1152 | + } else { |
|
1153 | + $user_info['permissions'][] = $row['permission']; |
|
1154 | + } |
|
1112 | 1155 | } |
1113 | 1156 | $smcFunc['db_free_result']($request); |
1114 | 1157 | |
1115 | - if (isset($cache_groups)) |
|
1116 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1158 | + if (isset($cache_groups)) { |
|
1159 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1160 | + } |
|
1117 | 1161 | } |
1118 | 1162 | |
1119 | 1163 | // Get the board permissions. |
1120 | 1164 | if (!empty($board)) |
1121 | 1165 | { |
1122 | 1166 | // Make sure the board (if any) has been loaded by loadBoard(). |
1123 | - if (!isset($board_info['profile'])) |
|
1124 | - fatal_lang_error('no_board'); |
|
1167 | + if (!isset($board_info['profile'])) { |
|
1168 | + fatal_lang_error('no_board'); |
|
1169 | + } |
|
1125 | 1170 | |
1126 | 1171 | $request = $smcFunc['db_query']('', ' |
1127 | 1172 | SELECT permission, add_deny |
@@ -1137,20 +1182,23 @@ discard block |
||
1137 | 1182 | ); |
1138 | 1183 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1139 | 1184 | { |
1140 | - if (empty($row['add_deny'])) |
|
1141 | - $removals[] = $row['permission']; |
|
1142 | - else |
|
1143 | - $user_info['permissions'][] = $row['permission']; |
|
1185 | + if (empty($row['add_deny'])) { |
|
1186 | + $removals[] = $row['permission']; |
|
1187 | + } else { |
|
1188 | + $user_info['permissions'][] = $row['permission']; |
|
1189 | + } |
|
1144 | 1190 | } |
1145 | 1191 | $smcFunc['db_free_result']($request); |
1146 | 1192 | } |
1147 | 1193 | |
1148 | 1194 | // Remove all the permissions they shouldn't have ;). |
1149 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1150 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1195 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1196 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1197 | + } |
|
1151 | 1198 | |
1152 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1153 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1199 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1200 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1201 | + } |
|
1154 | 1202 | |
1155 | 1203 | // Banned? Watch, don't touch.. |
1156 | 1204 | banPermissions(); |
@@ -1162,17 +1210,18 @@ discard block |
||
1162 | 1210 | { |
1163 | 1211 | require_once($sourcedir . '/Subs-Auth.php'); |
1164 | 1212 | rebuildModCache(); |
1213 | + } else { |
|
1214 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1165 | 1215 | } |
1166 | - else |
|
1167 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1168 | 1216 | |
1169 | 1217 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1170 | 1218 | // For example this drastically simplifies certain changes to the profile area. |
1171 | 1219 | $user_info['permissions'][] = 'is_not_guest'; |
1172 | 1220 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1173 | 1221 | $user_info['permissions'][] = 'profile_view_own'; |
1174 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1175 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1222 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1223 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1224 | + } |
|
1176 | 1225 | } |
1177 | 1226 | } |
1178 | 1227 | |
@@ -1190,8 +1239,9 @@ discard block |
||
1190 | 1239 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1191 | 1240 | |
1192 | 1241 | // Can't just look for no users :P. |
1193 | - if (empty($users)) |
|
1194 | - return array(); |
|
1242 | + if (empty($users)) { |
|
1243 | + return array(); |
|
1244 | + } |
|
1195 | 1245 | |
1196 | 1246 | // Pass the set value |
1197 | 1247 | $context['loadMemberContext_set'] = $set; |
@@ -1206,8 +1256,9 @@ discard block |
||
1206 | 1256 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1207 | 1257 | { |
1208 | 1258 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1209 | - if ($data == null) |
|
1210 | - continue; |
|
1259 | + if ($data == null) { |
|
1260 | + continue; |
|
1261 | + } |
|
1211 | 1262 | |
1212 | 1263 | $loaded_ids[] = $data['id_member']; |
1213 | 1264 | $user_profile[$data['id_member']] = $data; |
@@ -1274,16 +1325,19 @@ discard block |
||
1274 | 1325 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1275 | 1326 | |
1276 | 1327 | // Take care of proxying avatar if required, do this here for maximum reach |
1277 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1278 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1328 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1329 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1330 | + } |
|
1279 | 1331 | |
1280 | 1332 | // Keep track of the member's normal member group |
1281 | 1333 | $row['primary_group'] = $row['member_group']; |
1282 | 1334 | |
1283 | - if (isset($row['member_ip'])) |
|
1284 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1285 | - if (isset($row['member_ip2'])) |
|
1286 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1335 | + if (isset($row['member_ip'])) { |
|
1336 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1337 | + } |
|
1338 | + if (isset($row['member_ip2'])) { |
|
1339 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1340 | + } |
|
1287 | 1341 | $new_loaded_ids[] = $row['id_member']; |
1288 | 1342 | $loaded_ids[] = $row['id_member']; |
1289 | 1343 | $row['options'] = array(); |
@@ -1302,8 +1356,9 @@ discard block |
||
1302 | 1356 | 'loaded_ids' => $new_loaded_ids, |
1303 | 1357 | ) |
1304 | 1358 | ); |
1305 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1306 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1360 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1361 | + } |
|
1307 | 1362 | $smcFunc['db_free_result']($request); |
1308 | 1363 | } |
1309 | 1364 | |
@@ -1314,10 +1369,11 @@ discard block |
||
1314 | 1369 | { |
1315 | 1370 | foreach ($loaded_ids as $a_member) |
1316 | 1371 | { |
1317 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1318 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1319 | - else |
|
1320 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1372 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1373 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1374 | + } else { |
|
1375 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1376 | + } |
|
1321 | 1377 | |
1322 | 1378 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1323 | 1379 | |
@@ -1330,8 +1386,9 @@ discard block |
||
1330 | 1386 | |
1331 | 1387 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1332 | 1388 | { |
1333 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1334 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1389 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1390 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1391 | + } |
|
1335 | 1392 | } |
1336 | 1393 | |
1337 | 1394 | // Are we loading any moderators? If so, fix their group data... |
@@ -1357,14 +1414,17 @@ discard block |
||
1357 | 1414 | foreach ($temp_mods as $id) |
1358 | 1415 | { |
1359 | 1416 | // By popular demand, don't show admins or global moderators as moderators. |
1360 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1361 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1417 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1418 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1419 | + } |
|
1362 | 1420 | |
1363 | 1421 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1364 | - if (!empty($row['icons'])) |
|
1365 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1366 | - if (!empty($row['member_group_color'])) |
|
1367 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1422 | + if (!empty($row['icons'])) { |
|
1423 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1424 | + } |
|
1425 | + if (!empty($row['member_group_color'])) { |
|
1426 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1427 | + } |
|
1368 | 1428 | } |
1369 | 1429 | } |
1370 | 1430 | |
@@ -1386,12 +1446,14 @@ discard block |
||
1386 | 1446 | static $loadedLanguages = array(); |
1387 | 1447 | |
1388 | 1448 | // If this person's data is already loaded, skip it. |
1389 | - if (isset($dataLoaded[$user])) |
|
1390 | - return true; |
|
1449 | + if (isset($dataLoaded[$user])) { |
|
1450 | + return true; |
|
1451 | + } |
|
1391 | 1452 | |
1392 | 1453 | // We can't load guests or members not loaded by loadMemberData()! |
1393 | - if ($user == 0) |
|
1394 | - return false; |
|
1454 | + if ($user == 0) { |
|
1455 | + return false; |
|
1456 | + } |
|
1395 | 1457 | if (!isset($user_profile[$user])) |
1396 | 1458 | { |
1397 | 1459 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1417,12 +1479,16 @@ discard block |
||
1417 | 1479 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1418 | 1480 | |
1419 | 1481 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1420 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1482 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1483 | + //icon is set and exists |
|
1421 | 1484 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1422 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1485 | + } elseif (isset($profile['icons'][1])) { |
|
1486 | + //icon is set and doesn't exist, fallback to default |
|
1423 | 1487 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1424 | - else //not set, bye bye |
|
1488 | + } else { |
|
1489 | + //not set, bye bye |
|
1425 | 1490 | $group_icon_url = ''; |
1491 | + } |
|
1426 | 1492 | |
1427 | 1493 | // These minimal values are always loaded |
1428 | 1494 | $memberContext[$user] = array( |
@@ -1441,8 +1507,9 @@ discard block |
||
1441 | 1507 | if ($context['loadMemberContext_set'] != 'minimal') |
1442 | 1508 | { |
1443 | 1509 | // Go the extra mile and load the user's native language name. |
1444 | - if (empty($loadedLanguages)) |
|
1445 | - $loadedLanguages = getLanguages(); |
|
1510 | + if (empty($loadedLanguages)) { |
|
1511 | + $loadedLanguages = getLanguages(); |
|
1512 | + } |
|
1446 | 1513 | |
1447 | 1514 | $memberContext[$user] += array( |
1448 | 1515 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1497,31 +1564,33 @@ discard block |
||
1497 | 1564 | { |
1498 | 1565 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1499 | 1566 | { |
1500 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1501 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1502 | - else |
|
1503 | - $image = get_gravatar_url($profile['email_address']); |
|
1504 | - } |
|
1505 | - else |
|
1567 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1568 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1569 | + } else { |
|
1570 | + $image = get_gravatar_url($profile['email_address']); |
|
1571 | + } |
|
1572 | + } else |
|
1506 | 1573 | { |
1507 | 1574 | // So it's stored in the member table? |
1508 | 1575 | if (!empty($profile['avatar'])) |
1509 | 1576 | { |
1510 | 1577 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1578 | + } elseif (!empty($profile['filename'])) { |
|
1579 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1511 | 1580 | } |
1512 | - elseif (!empty($profile['filename'])) |
|
1513 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1514 | 1581 | // Right... no avatar...use the default one |
1515 | - else |
|
1516 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1582 | + else { |
|
1583 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1584 | + } |
|
1517 | 1585 | } |
1518 | - if (!empty($image)) |
|
1519 | - $memberContext[$user]['avatar'] = array( |
|
1586 | + if (!empty($image)) { |
|
1587 | + $memberContext[$user]['avatar'] = array( |
|
1520 | 1588 | 'name' => $profile['avatar'], |
1521 | 1589 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1522 | 1590 | 'href' => $image, |
1523 | 1591 | 'url' => $image, |
1524 | 1592 | ); |
1593 | + } |
|
1525 | 1594 | } |
1526 | 1595 | |
1527 | 1596 | // Are we also loading the members custom fields into context? |
@@ -1529,13 +1598,15 @@ discard block |
||
1529 | 1598 | { |
1530 | 1599 | $memberContext[$user]['custom_fields'] = array(); |
1531 | 1600 | |
1532 | - if (!isset($context['display_fields'])) |
|
1533 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1601 | + if (!isset($context['display_fields'])) { |
|
1602 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1603 | + } |
|
1534 | 1604 | |
1535 | 1605 | foreach ($context['display_fields'] as $custom) |
1536 | 1606 | { |
1537 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1538 | - continue; |
|
1607 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1608 | + continue; |
|
1609 | + } |
|
1539 | 1610 | |
1540 | 1611 | $value = $profile['options'][$custom['col_name']]; |
1541 | 1612 | |
@@ -1543,31 +1614,36 @@ discard block |
||
1543 | 1614 | $currentKey = 0; |
1544 | 1615 | |
1545 | 1616 | // Create a key => value array for multiple options fields |
1546 | - if (!empty($custom['options'])) |
|
1547 | - foreach ($custom['options'] as $k => $v) |
|
1617 | + if (!empty($custom['options'])) { |
|
1618 | + foreach ($custom['options'] as $k => $v) |
|
1548 | 1619 | { |
1549 | 1620 | $fieldOptions[] = $v; |
1550 | - if (empty($currentKey)) |
|
1551 | - $currentKey = $v == $value ? $k : 0; |
|
1621 | + } |
|
1622 | + if (empty($currentKey)) { |
|
1623 | + $currentKey = $v == $value ? $k : 0; |
|
1624 | + } |
|
1552 | 1625 | } |
1553 | 1626 | |
1554 | 1627 | // BBC? |
1555 | - if ($custom['bbc']) |
|
1556 | - $value = parse_bbc($value); |
|
1628 | + if ($custom['bbc']) { |
|
1629 | + $value = parse_bbc($value); |
|
1630 | + } |
|
1557 | 1631 | |
1558 | 1632 | // ... or checkbox? |
1559 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1560 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1633 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1634 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1635 | + } |
|
1561 | 1636 | |
1562 | 1637 | // Enclosing the user input within some other text? |
1563 | - if (!empty($custom['enclose'])) |
|
1564 | - $value = strtr($custom['enclose'], array( |
|
1638 | + if (!empty($custom['enclose'])) { |
|
1639 | + $value = strtr($custom['enclose'], array( |
|
1565 | 1640 | '{SCRIPTURL}' => $scripturl, |
1566 | 1641 | '{IMAGES_URL}' => $settings['images_url'], |
1567 | 1642 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1568 | 1643 | '{INPUT}' => $value, |
1569 | 1644 | '{KEY}' => $currentKey, |
1570 | 1645 | )); |
1646 | + } |
|
1571 | 1647 | |
1572 | 1648 | $memberContext[$user]['custom_fields'][] = array( |
1573 | 1649 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1594,8 +1670,9 @@ discard block |
||
1594 | 1670 | global $smcFunc, $txt, $scripturl, $settings; |
1595 | 1671 | |
1596 | 1672 | // Do not waste my time... |
1597 | - if (empty($users) || empty($params)) |
|
1598 | - return false; |
|
1673 | + if (empty($users) || empty($params)) { |
|
1674 | + return false; |
|
1675 | + } |
|
1599 | 1676 | |
1600 | 1677 | // Make sure it's an array. |
1601 | 1678 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1626,38 +1703,44 @@ discard block |
||
1626 | 1703 | foreach (explode(',', $row['field_options']) as $k => $v) |
1627 | 1704 | { |
1628 | 1705 | $fieldOptions[] = $v; |
1629 | - if (empty($currentKey)) |
|
1630 | - $currentKey = $v == $row['value'] ? $k : 0; |
|
1706 | + if (empty($currentKey)) { |
|
1707 | + $currentKey = $v == $row['value'] ? $k : 0; |
|
1708 | + } |
|
1631 | 1709 | } |
1632 | 1710 | } |
1633 | 1711 | |
1634 | 1712 | // BBC? |
1635 | - if (!empty($row['bbc'])) |
|
1636 | - $row['value'] = parse_bbc($row['value']); |
|
1713 | + if (!empty($row['bbc'])) { |
|
1714 | + $row['value'] = parse_bbc($row['value']); |
|
1715 | + } |
|
1637 | 1716 | |
1638 | 1717 | // ... or checkbox? |
1639 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1640 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1718 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1719 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1720 | + } |
|
1641 | 1721 | |
1642 | 1722 | // Enclosing the user input within some other text? |
1643 | - if (!empty($row['enclose'])) |
|
1644 | - $row['value'] = strtr($row['enclose'], array( |
|
1723 | + if (!empty($row['enclose'])) { |
|
1724 | + $row['value'] = strtr($row['enclose'], array( |
|
1645 | 1725 | '{SCRIPTURL}' => $scripturl, |
1646 | 1726 | '{IMAGES_URL}' => $settings['images_url'], |
1647 | 1727 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1648 | 1728 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1649 | 1729 | '{KEY}' => $currentKey, |
1650 | 1730 | )); |
1731 | + } |
|
1651 | 1732 | |
1652 | 1733 | // Send a simple array if there is just 1 param |
1653 | - if (count($params) == 1) |
|
1654 | - $return[$row['id_member']] = $row; |
|
1734 | + if (count($params) == 1) { |
|
1735 | + $return[$row['id_member']] = $row; |
|
1736 | + } |
|
1655 | 1737 | |
1656 | 1738 | // More than 1? knock yourself out... |
1657 | 1739 | else |
1658 | 1740 | { |
1659 | - if (!isset($return[$row['id_member']])) |
|
1660 | - $return[$row['id_member']] = array(); |
|
1741 | + if (!isset($return[$row['id_member']])) { |
|
1742 | + $return[$row['id_member']] = array(); |
|
1743 | + } |
|
1661 | 1744 | |
1662 | 1745 | $return[$row['id_member']][$row['variable']] = $row; |
1663 | 1746 | } |
@@ -1691,8 +1774,9 @@ discard block |
||
1691 | 1774 | global $context; |
1692 | 1775 | |
1693 | 1776 | // Don't know any browser! |
1694 | - if (empty($context['browser'])) |
|
1695 | - detectBrowser(); |
|
1777 | + if (empty($context['browser'])) { |
|
1778 | + detectBrowser(); |
|
1779 | + } |
|
1696 | 1780 | |
1697 | 1781 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1698 | 1782 | } |
@@ -1710,8 +1794,9 @@ discard block |
||
1710 | 1794 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1711 | 1795 | |
1712 | 1796 | // The theme was specified by parameter. |
1713 | - if (!empty($id_theme)) |
|
1714 | - $id_theme = (int) $id_theme; |
|
1797 | + if (!empty($id_theme)) { |
|
1798 | + $id_theme = (int) $id_theme; |
|
1799 | + } |
|
1715 | 1800 | // The theme was specified by REQUEST. |
1716 | 1801 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1717 | 1802 | { |
@@ -1719,54 +1804,61 @@ discard block |
||
1719 | 1804 | $_SESSION['id_theme'] = $id_theme; |
1720 | 1805 | } |
1721 | 1806 | // The theme was specified by REQUEST... previously. |
1722 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1723 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1807 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1808 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1809 | + } |
|
1724 | 1810 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1725 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1726 | - $id_theme = $user_info['theme']; |
|
1811 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1812 | + $id_theme = $user_info['theme']; |
|
1813 | + } |
|
1727 | 1814 | // The theme was specified by the board. |
1728 | - elseif (!empty($board_info['theme'])) |
|
1729 | - $id_theme = $board_info['theme']; |
|
1815 | + elseif (!empty($board_info['theme'])) { |
|
1816 | + $id_theme = $board_info['theme']; |
|
1817 | + } |
|
1730 | 1818 | // The theme is the forum's default. |
1731 | - else |
|
1732 | - $id_theme = $modSettings['theme_guests']; |
|
1819 | + else { |
|
1820 | + $id_theme = $modSettings['theme_guests']; |
|
1821 | + } |
|
1733 | 1822 | |
1734 | 1823 | // We already load the basic stuff? |
1735 | 1824 | if (empty($settings['theme_id']) || $settings['theme_id'] != $id_theme ) |
1736 | 1825 | { |
1737 | 1826 | // Verify the id_theme... no foul play. |
1738 | 1827 | // Always allow the board specific theme, if they are overriding. |
1739 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1740 | - $id_theme = $board_info['theme']; |
|
1828 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1829 | + $id_theme = $board_info['theme']; |
|
1830 | + } |
|
1741 | 1831 | // If they have specified a particular theme to use with SSI allow it to be used. |
1742 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1743 | - $id_theme = (int) $id_theme; |
|
1744 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1832 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1833 | + $id_theme = (int) $id_theme; |
|
1834 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1745 | 1835 | { |
1746 | 1836 | $themes = explode(',', $modSettings['enableThemes']); |
1747 | - if (!in_array($id_theme, $themes)) |
|
1748 | - $id_theme = $modSettings['theme_guests']; |
|
1749 | - else |
|
1750 | - $id_theme = (int) $id_theme; |
|
1837 | + if (!in_array($id_theme, $themes)) { |
|
1838 | + $id_theme = $modSettings['theme_guests']; |
|
1839 | + } else { |
|
1840 | + $id_theme = (int) $id_theme; |
|
1841 | + } |
|
1842 | + } else { |
|
1843 | + $id_theme = (int) $id_theme; |
|
1751 | 1844 | } |
1752 | - else |
|
1753 | - $id_theme = (int) $id_theme; |
|
1754 | 1845 | |
1755 | 1846 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1756 | 1847 | |
1757 | 1848 | // Disable image proxy if we don't have SSL enabled |
1758 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1759 | - $image_proxy_enabled = false; |
|
1849 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1850 | + $image_proxy_enabled = false; |
|
1851 | + } |
|
1760 | 1852 | |
1761 | 1853 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1762 | 1854 | { |
1763 | 1855 | $themeData = $temp; |
1764 | 1856 | $flag = true; |
1857 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1858 | + $themeData = $temp + array($member => array()); |
|
1859 | + } else { |
|
1860 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1765 | 1861 | } |
1766 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1767 | - $themeData = $temp + array($member => array()); |
|
1768 | - else |
|
1769 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1770 | 1862 | |
1771 | 1863 | if (empty($flag)) |
1772 | 1864 | { |
@@ -1785,31 +1877,37 @@ discard block |
||
1785 | 1877 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1786 | 1878 | { |
1787 | 1879 | // There are just things we shouldn't be able to change as members. |
1788 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1789 | - continue; |
|
1880 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1881 | + continue; |
|
1882 | + } |
|
1790 | 1883 | |
1791 | 1884 | // If this is the theme_dir of the default theme, store it. |
1792 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1793 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1885 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1886 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1796 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1797 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1890 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1891 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1892 | + } |
|
1798 | 1893 | } |
1799 | 1894 | $smcFunc['db_free_result']($result); |
1800 | 1895 | |
1801 | - if (!empty($themeData[-1])) |
|
1802 | - foreach ($themeData[-1] as $k => $v) |
|
1896 | + if (!empty($themeData[-1])) { |
|
1897 | + foreach ($themeData[-1] as $k => $v) |
|
1803 | 1898 | { |
1804 | 1899 | if (!isset($themeData[$member][$k])) |
1805 | 1900 | $themeData[$member][$k] = $v; |
1901 | + } |
|
1806 | 1902 | } |
1807 | 1903 | |
1808 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1809 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1904 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1905 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1906 | + } |
|
1810 | 1907 | // Only if we didn't already load that part of the cache... |
1811 | - elseif (!isset($temp)) |
|
1812 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1908 | + elseif (!isset($temp)) { |
|
1909 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1910 | + } |
|
1813 | 1911 | } |
1814 | 1912 | |
1815 | 1913 | $settings = $themeData[0]; |
@@ -1826,17 +1924,20 @@ discard block |
||
1826 | 1924 | $settings['template_dirs'][] = $settings['theme_dir']; |
1827 | 1925 | |
1828 | 1926 | // Based on theme (if there is one). |
1829 | - if (!empty($settings['base_theme_dir'])) |
|
1830 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1927 | + if (!empty($settings['base_theme_dir'])) { |
|
1928 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1929 | + } |
|
1831 | 1930 | |
1832 | 1931 | // Lastly the default theme. |
1833 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1834 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1932 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1933 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1934 | + } |
|
1835 | 1935 | } |
1836 | 1936 | |
1837 | 1937 | |
1838 | - if (!$initialize) |
|
1839 | - return; |
|
1938 | + if (!$initialize) { |
|
1939 | + return; |
|
1940 | + } |
|
1840 | 1941 | |
1841 | 1942 | // Check to see if we're forcing SSL |
1842 | 1943 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
@@ -1857,8 +1958,9 @@ discard block |
||
1857 | 1958 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1858 | 1959 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1859 | 1960 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1860 | - if ($temp != '/') |
|
1861 | - $detected_url .= $temp; |
|
1961 | + if ($temp != '/') { |
|
1962 | + $detected_url .= $temp; |
|
1963 | + } |
|
1862 | 1964 | } |
1863 | 1965 | if (isset($detected_url) && $detected_url != $boardurl) |
1864 | 1966 | { |
@@ -1870,8 +1972,9 @@ discard block |
||
1870 | 1972 | foreach ($aliases as $alias) |
1871 | 1973 | { |
1872 | 1974 | // Rip off all the boring parts, spaces, etc. |
1873 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1874 | - $do_fix = true; |
|
1975 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1976 | + $do_fix = true; |
|
1977 | + } |
|
1875 | 1978 | } |
1876 | 1979 | } |
1877 | 1980 | |
@@ -1879,21 +1982,23 @@ discard block |
||
1879 | 1982 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1880 | 1983 | { |
1881 | 1984 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1882 | - if (empty($_GET)) |
|
1883 | - redirectexit('wwwRedirect'); |
|
1884 | - else |
|
1985 | + if (empty($_GET)) { |
|
1986 | + redirectexit('wwwRedirect'); |
|
1987 | + } else |
|
1885 | 1988 | { |
1886 | 1989 | $k = key($_GET); |
1887 | 1990 | $v = current($_GET); |
1888 | 1991 | |
1889 | - if ($k != 'wwwRedirect') |
|
1890 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1992 | + if ($k != 'wwwRedirect') { |
|
1993 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1994 | + } |
|
1891 | 1995 | } |
1892 | 1996 | } |
1893 | 1997 | |
1894 | 1998 | // #3 is just a check for SSL... |
1895 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1896 | - $do_fix = true; |
|
1999 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
2000 | + $do_fix = true; |
|
2001 | + } |
|
1897 | 2002 | |
1898 | 2003 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1899 | 2004 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1928,8 +2033,9 @@ discard block |
||
1928 | 2033 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1929 | 2034 | } |
1930 | 2035 | } |
1931 | - foreach ($context['linktree'] as $k => $dummy) |
|
1932 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2036 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2037 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2038 | + } |
|
1933 | 2039 | } |
1934 | 2040 | } |
1935 | 2041 | // Set up the contextual user array. |
@@ -1948,16 +2054,16 @@ discard block |
||
1948 | 2054 | 'email' => $user_info['email'], |
1949 | 2055 | 'ignoreusers' => $user_info['ignoreusers'], |
1950 | 2056 | ); |
1951 | - if (!$context['user']['is_guest']) |
|
1952 | - $context['user']['name'] = $user_info['name']; |
|
1953 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1954 | - $context['user']['name'] = $txt['guest_title']; |
|
2057 | + if (!$context['user']['is_guest']) { |
|
2058 | + $context['user']['name'] = $user_info['name']; |
|
2059 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2060 | + $context['user']['name'] = $txt['guest_title']; |
|
2061 | + } |
|
1955 | 2062 | |
1956 | 2063 | // Determine the current smiley set. |
1957 | 2064 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1958 | 2065 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1959 | - } |
|
1960 | - else |
|
2066 | + } else |
|
1961 | 2067 | { |
1962 | 2068 | // What to do when there is no $user_info (e.g., an error very early in the login process) |
1963 | 2069 | $context['user'] = array( |
@@ -1991,18 +2097,24 @@ discard block |
||
1991 | 2097 | } |
1992 | 2098 | |
1993 | 2099 | // Some basic information... |
1994 | - if (!isset($context['html_headers'])) |
|
1995 | - $context['html_headers'] = ''; |
|
1996 | - if (!isset($context['javascript_files'])) |
|
1997 | - $context['javascript_files'] = array(); |
|
1998 | - if (!isset($context['css_files'])) |
|
1999 | - $context['css_files'] = array(); |
|
2000 | - if (!isset($context['css_header'])) |
|
2001 | - $context['css_header'] = array(); |
|
2002 | - if (!isset($context['javascript_inline'])) |
|
2003 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2004 | - if (!isset($context['javascript_vars'])) |
|
2005 | - $context['javascript_vars'] = array(); |
|
2100 | + if (!isset($context['html_headers'])) { |
|
2101 | + $context['html_headers'] = ''; |
|
2102 | + } |
|
2103 | + if (!isset($context['javascript_files'])) { |
|
2104 | + $context['javascript_files'] = array(); |
|
2105 | + } |
|
2106 | + if (!isset($context['css_files'])) { |
|
2107 | + $context['css_files'] = array(); |
|
2108 | + } |
|
2109 | + if (!isset($context['css_header'])) { |
|
2110 | + $context['css_header'] = array(); |
|
2111 | + } |
|
2112 | + if (!isset($context['javascript_inline'])) { |
|
2113 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2114 | + } |
|
2115 | + if (!isset($context['javascript_vars'])) { |
|
2116 | + $context['javascript_vars'] = array(); |
|
2117 | + } |
|
2006 | 2118 | |
2007 | 2119 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
2008 | 2120 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -2014,16 +2126,18 @@ discard block |
||
2014 | 2126 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
2015 | 2127 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
2016 | 2128 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
2017 | - if (isset($modSettings['load_average'])) |
|
2018 | - $context['load_average'] = $modSettings['load_average']; |
|
2129 | + if (isset($modSettings['load_average'])) { |
|
2130 | + $context['load_average'] = $modSettings['load_average']; |
|
2131 | + } |
|
2019 | 2132 | |
2020 | 2133 | // Detect the browser. This is separated out because it's also used in attachment downloads |
2021 | 2134 | detectBrowser(); |
2022 | 2135 | |
2023 | 2136 | // Set the top level linktree up. |
2024 | 2137 | // Note that if we're dealing with certain very early errors (e.g., login) the linktree might not be set yet... |
2025 | - if (empty($context['linktree'])) |
|
2026 | - $context['linktree'] = array(); |
|
2138 | + if (empty($context['linktree'])) { |
|
2139 | + $context['linktree'] = array(); |
|
2140 | + } |
|
2027 | 2141 | array_unshift($context['linktree'], array( |
2028 | 2142 | 'url' => $scripturl, |
2029 | 2143 | 'name' => $context['forum_name_html_safe'] |
@@ -2032,8 +2146,9 @@ discard block |
||
2032 | 2146 | // This allows sticking some HTML on the page output - useful for controls. |
2033 | 2147 | $context['insert_after_template'] = ''; |
2034 | 2148 | |
2035 | - if (!isset($txt)) |
|
2036 | - $txt = array(); |
|
2149 | + if (!isset($txt)) { |
|
2150 | + $txt = array(); |
|
2151 | + } |
|
2037 | 2152 | |
2038 | 2153 | $simpleActions = array( |
2039 | 2154 | 'findmember', |
@@ -2079,9 +2194,10 @@ discard block |
||
2079 | 2194 | |
2080 | 2195 | // See if theres any extra param to check. |
2081 | 2196 | $requiresXML = false; |
2082 | - foreach ($extraParams as $key => $extra) |
|
2083 | - if (isset($_REQUEST[$extra])) |
|
2197 | + foreach ($extraParams as $key => $extra) { |
|
2198 | + if (isset($_REQUEST[$extra])) |
|
2084 | 2199 | $requiresXML = true; |
2200 | + } |
|
2085 | 2201 | |
2086 | 2202 | // Output is fully XML, so no need for the index template. |
2087 | 2203 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2096,37 +2212,39 @@ discard block |
||
2096 | 2212 | { |
2097 | 2213 | loadLanguage('index+Modifications'); |
2098 | 2214 | $context['template_layers'] = array(); |
2099 | - } |
|
2100 | - |
|
2101 | - else |
|
2215 | + } else |
|
2102 | 2216 | { |
2103 | 2217 | // Custom templates to load, or just default? |
2104 | - if (isset($settings['theme_templates'])) |
|
2105 | - $templates = explode(',', $settings['theme_templates']); |
|
2106 | - else |
|
2107 | - $templates = array('index'); |
|
2218 | + if (isset($settings['theme_templates'])) { |
|
2219 | + $templates = explode(',', $settings['theme_templates']); |
|
2220 | + } else { |
|
2221 | + $templates = array('index'); |
|
2222 | + } |
|
2108 | 2223 | |
2109 | 2224 | // Load each template... |
2110 | - foreach ($templates as $template) |
|
2111 | - loadTemplate($template); |
|
2225 | + foreach ($templates as $template) { |
|
2226 | + loadTemplate($template); |
|
2227 | + } |
|
2112 | 2228 | |
2113 | 2229 | // ...and attempt to load their associated language files. |
2114 | 2230 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2115 | 2231 | loadLanguage($required_files, '', false); |
2116 | 2232 | |
2117 | 2233 | // Custom template layers? |
2118 | - if (isset($settings['theme_layers'])) |
|
2119 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2120 | - else |
|
2121 | - $context['template_layers'] = array('html', 'body'); |
|
2234 | + if (isset($settings['theme_layers'])) { |
|
2235 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2236 | + } else { |
|
2237 | + $context['template_layers'] = array('html', 'body'); |
|
2238 | + } |
|
2122 | 2239 | } |
2123 | 2240 | |
2124 | 2241 | // Initialize the theme. |
2125 | 2242 | loadSubTemplate('init', 'ignore'); |
2126 | 2243 | |
2127 | 2244 | // Allow overriding the board wide time/number formats. |
2128 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2129 | - $user_info['time_format'] = $txt['time_format']; |
|
2245 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2246 | + $user_info['time_format'] = $txt['time_format']; |
|
2247 | + } |
|
2130 | 2248 | |
2131 | 2249 | // Set the character set from the template. |
2132 | 2250 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2134,12 +2252,14 @@ discard block |
||
2134 | 2252 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2135 | 2253 | |
2136 | 2254 | // Guests may still need a name. |
2137 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2138 | - $context['user']['name'] = $txt['guest_title']; |
|
2255 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2256 | + $context['user']['name'] = $txt['guest_title']; |
|
2257 | + } |
|
2139 | 2258 | |
2140 | 2259 | // Any theme-related strings that need to be loaded? |
2141 | - if (!empty($settings['require_theme_strings'])) |
|
2142 | - loadLanguage('ThemeStrings', '', false); |
|
2260 | + if (!empty($settings['require_theme_strings'])) { |
|
2261 | + loadLanguage('ThemeStrings', '', false); |
|
2262 | + } |
|
2143 | 2263 | |
2144 | 2264 | // Make a special URL for the language. |
2145 | 2265 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2150,8 +2270,9 @@ discard block |
||
2150 | 2270 | // Here is my luvly Responsive CSS |
2151 | 2271 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2152 | 2272 | |
2153 | - if ($context['right_to_left']) |
|
2154 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2273 | + if ($context['right_to_left']) { |
|
2274 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2275 | + } |
|
2155 | 2276 | |
2156 | 2277 | // We allow theme variants, because we're cool. |
2157 | 2278 | $context['theme_variant'] = ''; |
@@ -2159,14 +2280,17 @@ discard block |
||
2159 | 2280 | if (!empty($settings['theme_variants'])) |
2160 | 2281 | { |
2161 | 2282 | // Overriding - for previews and that ilk. |
2162 | - if (!empty($_REQUEST['variant'])) |
|
2163 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2283 | + if (!empty($_REQUEST['variant'])) { |
|
2284 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2285 | + } |
|
2164 | 2286 | // User selection? |
2165 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2166 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2287 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2288 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2289 | + } |
|
2167 | 2290 | // If not a user variant, select the default. |
2168 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2169 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2291 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2292 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2293 | + } |
|
2170 | 2294 | |
2171 | 2295 | // Do this to keep things easier in the templates. |
2172 | 2296 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2175,20 +2299,23 @@ discard block |
||
2175 | 2299 | if (!empty($context['theme_variant'])) |
2176 | 2300 | { |
2177 | 2301 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2178 | - if ($context['right_to_left']) |
|
2179 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2302 | + if ($context['right_to_left']) { |
|
2303 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2304 | + } |
|
2180 | 2305 | } |
2181 | 2306 | } |
2182 | 2307 | |
2183 | 2308 | // Let's be compatible with old themes! |
2184 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2185 | - $context['template_layers'] = array('main'); |
|
2309 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2310 | + $context['template_layers'] = array('main'); |
|
2311 | + } |
|
2186 | 2312 | |
2187 | 2313 | $context['tabindex'] = 1; |
2188 | 2314 | |
2189 | 2315 | // Compatibility. |
2190 | - if (!isset($settings['theme_version'])) |
|
2191 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2316 | + if (!isset($settings['theme_version'])) { |
|
2317 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2318 | + } |
|
2192 | 2319 | |
2193 | 2320 | // Default JS variables for use in every theme |
2194 | 2321 | $context['javascript_vars'] = array( |
@@ -2207,18 +2334,18 @@ discard block |
||
2207 | 2334 | ); |
2208 | 2335 | |
2209 | 2336 | // Add the JQuery library to the list of files to load. |
2210 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2211 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2212 | - |
|
2213 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2214 | - loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2215 | - |
|
2216 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2217 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2337 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2338 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2339 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2340 | + loadJavaScriptFile('jquery-3.2.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2341 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2342 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2343 | + } |
|
2218 | 2344 | |
2219 | 2345 | // Auto loading? template_javascript() will take care of the local half of this. |
2220 | - else |
|
2221 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2346 | + else { |
|
2347 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2348 | + } |
|
2222 | 2349 | |
2223 | 2350 | // Queue our JQuery plugins! |
2224 | 2351 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2241,12 +2368,12 @@ discard block |
||
2241 | 2368 | require_once($sourcedir . '/ScheduledTasks.php'); |
2242 | 2369 | |
2243 | 2370 | // What to do, what to do?! |
2244 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2245 | - AutoTask(); |
|
2246 | - else |
|
2247 | - ReduceMailQueue(); |
|
2248 | - } |
|
2249 | - else |
|
2371 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2372 | + AutoTask(); |
|
2373 | + } else { |
|
2374 | + ReduceMailQueue(); |
|
2375 | + } |
|
2376 | + } else |
|
2250 | 2377 | { |
2251 | 2378 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2252 | 2379 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2297,8 +2424,9 @@ discard block |
||
2297 | 2424 | foreach ($theme_includes as $include) |
2298 | 2425 | { |
2299 | 2426 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2300 | - if (file_exists($include)) |
|
2301 | - require_once($include); |
|
2427 | + if (file_exists($include)) { |
|
2428 | + require_once($include); |
|
2429 | + } |
|
2302 | 2430 | } |
2303 | 2431 | } |
2304 | 2432 | |
@@ -2328,16 +2456,19 @@ discard block |
||
2328 | 2456 | // Do any style sheets first, cause we're easy with those. |
2329 | 2457 | if (!empty($style_sheets)) |
2330 | 2458 | { |
2331 | - if (!is_array($style_sheets)) |
|
2332 | - $style_sheets = array($style_sheets); |
|
2459 | + if (!is_array($style_sheets)) { |
|
2460 | + $style_sheets = array($style_sheets); |
|
2461 | + } |
|
2333 | 2462 | |
2334 | - foreach ($style_sheets as $sheet) |
|
2335 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2463 | + foreach ($style_sheets as $sheet) { |
|
2464 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2465 | + } |
|
2336 | 2466 | } |
2337 | 2467 | |
2338 | 2468 | // No template to load? |
2339 | - if ($template_name === false) |
|
2340 | - return true; |
|
2469 | + if ($template_name === false) { |
|
2470 | + return true; |
|
2471 | + } |
|
2341 | 2472 | |
2342 | 2473 | $loaded = false; |
2343 | 2474 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2352,12 +2483,14 @@ discard block |
||
2352 | 2483 | |
2353 | 2484 | if ($loaded) |
2354 | 2485 | { |
2355 | - if ($db_show_debug === true) |
|
2356 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2486 | + if ($db_show_debug === true) { |
|
2487 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2488 | + } |
|
2357 | 2489 | |
2358 | 2490 | // If they have specified an initialization function for this template, go ahead and call it now. |
2359 | - if (function_exists('template_' . $template_name . '_init')) |
|
2360 | - call_user_func('template_' . $template_name . '_init'); |
|
2491 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2492 | + call_user_func('template_' . $template_name . '_init'); |
|
2493 | + } |
|
2361 | 2494 | } |
2362 | 2495 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2363 | 2496 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2377,13 +2510,14 @@ discard block |
||
2377 | 2510 | loadTemplate($template_name); |
2378 | 2511 | } |
2379 | 2512 | // Cause an error otherwise. |
2380 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2381 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2382 | - elseif ($fatal) |
|
2383 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2384 | - else |
|
2385 | - return false; |
|
2386 | -} |
|
2513 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2514 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2515 | + } elseif ($fatal) { |
|
2516 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2517 | + } else { |
|
2518 | + return false; |
|
2519 | + } |
|
2520 | + } |
|
2387 | 2521 | |
2388 | 2522 | /** |
2389 | 2523 | * Load a sub-template. |
@@ -2401,17 +2535,19 @@ discard block |
||
2401 | 2535 | { |
2402 | 2536 | global $context, $txt, $db_show_debug; |
2403 | 2537 | |
2404 | - if ($db_show_debug === true) |
|
2405 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2538 | + if ($db_show_debug === true) { |
|
2539 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2540 | + } |
|
2406 | 2541 | |
2407 | 2542 | // Figure out what the template function is named. |
2408 | 2543 | $theme_function = 'template_' . $sub_template_name; |
2409 | - if (function_exists($theme_function)) |
|
2410 | - $theme_function(); |
|
2411 | - elseif ($fatal === false) |
|
2412 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2413 | - elseif ($fatal !== 'ignore') |
|
2414 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2544 | + if (function_exists($theme_function)) { |
|
2545 | + $theme_function(); |
|
2546 | + } elseif ($fatal === false) { |
|
2547 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2548 | + } elseif ($fatal !== 'ignore') { |
|
2549 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2550 | + } |
|
2415 | 2551 | |
2416 | 2552 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2417 | 2553 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2448,8 +2584,9 @@ discard block |
||
2448 | 2584 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2449 | 2585 | |
2450 | 2586 | // If this is an external file, automatically set this to false. |
2451 | - if (!empty($params['external'])) |
|
2452 | - $params['minimize'] = false; |
|
2587 | + if (!empty($params['external'])) { |
|
2588 | + $params['minimize'] = false; |
|
2589 | + } |
|
2453 | 2590 | |
2454 | 2591 | // Account for shorthand like admin.css?alp21 filenames |
2455 | 2592 | $has_seed = strpos($fileName, '.css?'); |
@@ -2466,13 +2603,10 @@ discard block |
||
2466 | 2603 | { |
2467 | 2604 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2468 | 2605 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2606 | + } else { |
|
2607 | + $fileUrl = false; |
|
2469 | 2608 | } |
2470 | - |
|
2471 | - else |
|
2472 | - $fileUrl = false; |
|
2473 | - } |
|
2474 | - |
|
2475 | - else |
|
2609 | + } else |
|
2476 | 2610 | { |
2477 | 2611 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2478 | 2612 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2487,12 +2621,14 @@ discard block |
||
2487 | 2621 | } |
2488 | 2622 | |
2489 | 2623 | // Add it to the array for use in the template |
2490 | - if (!empty($fileName)) |
|
2491 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2624 | + if (!empty($fileName)) { |
|
2625 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2626 | + } |
|
2492 | 2627 | |
2493 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2494 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2495 | -} |
|
2628 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2629 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2630 | + } |
|
2631 | + } |
|
2496 | 2632 | |
2497 | 2633 | /** |
2498 | 2634 | * Add a block of inline css code to be executed later |
@@ -2509,8 +2645,9 @@ discard block |
||
2509 | 2645 | global $context; |
2510 | 2646 | |
2511 | 2647 | // Gotta add something... |
2512 | - if (empty($css)) |
|
2513 | - return false; |
|
2648 | + if (empty($css)) { |
|
2649 | + return false; |
|
2650 | + } |
|
2514 | 2651 | |
2515 | 2652 | $context['css_header'][] = $css; |
2516 | 2653 | } |
@@ -2545,8 +2682,9 @@ discard block |
||
2545 | 2682 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2546 | 2683 | |
2547 | 2684 | // If this is an external file, automatically set this to false. |
2548 | - if (!empty($params['external'])) |
|
2549 | - $params['minimize'] = false; |
|
2685 | + if (!empty($params['external'])) { |
|
2686 | + $params['minimize'] = false; |
|
2687 | + } |
|
2550 | 2688 | |
2551 | 2689 | // Account for shorthand like admin.js?alp21 filenames |
2552 | 2690 | $has_seed = strpos($fileName, '.js?'); |
@@ -2563,16 +2701,12 @@ discard block |
||
2563 | 2701 | { |
2564 | 2702 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2565 | 2703 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2566 | - } |
|
2567 | - |
|
2568 | - else |
|
2704 | + } else |
|
2569 | 2705 | { |
2570 | 2706 | $fileUrl = false; |
2571 | 2707 | $filePath = false; |
2572 | 2708 | } |
2573 | - } |
|
2574 | - |
|
2575 | - else |
|
2709 | + } else |
|
2576 | 2710 | { |
2577 | 2711 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2578 | 2712 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2587,9 +2721,10 @@ discard block |
||
2587 | 2721 | } |
2588 | 2722 | |
2589 | 2723 | // Add it to the array for use in the template |
2590 | - if (!empty($fileName)) |
|
2591 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2592 | -} |
|
2724 | + if (!empty($fileName)) { |
|
2725 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2726 | + } |
|
2727 | + } |
|
2593 | 2728 | |
2594 | 2729 | /** |
2595 | 2730 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2603,9 +2738,10 @@ discard block |
||
2603 | 2738 | { |
2604 | 2739 | global $context; |
2605 | 2740 | |
2606 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2607 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2608 | -} |
|
2741 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2742 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2743 | + } |
|
2744 | + } |
|
2609 | 2745 | |
2610 | 2746 | /** |
2611 | 2747 | * Add a block of inline Javascript code to be executed later |
@@ -2622,8 +2758,9 @@ discard block |
||
2622 | 2758 | { |
2623 | 2759 | global $context; |
2624 | 2760 | |
2625 | - if (empty($javascript)) |
|
2626 | - return false; |
|
2761 | + if (empty($javascript)) { |
|
2762 | + return false; |
|
2763 | + } |
|
2627 | 2764 | |
2628 | 2765 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2629 | 2766 | } |
@@ -2644,15 +2781,18 @@ discard block |
||
2644 | 2781 | static $already_loaded = array(); |
2645 | 2782 | |
2646 | 2783 | // Default to the user's language. |
2647 | - if ($lang == '') |
|
2648 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2784 | + if ($lang == '') { |
|
2785 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2786 | + } |
|
2649 | 2787 | |
2650 | 2788 | // Do we want the English version of language file as fallback? |
2651 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2652 | - loadLanguage($template_name, 'english', false); |
|
2789 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2790 | + loadLanguage($template_name, 'english', false); |
|
2791 | + } |
|
2653 | 2792 | |
2654 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2655 | - return $lang; |
|
2793 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2794 | + return $lang; |
|
2795 | + } |
|
2656 | 2796 | |
2657 | 2797 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2658 | 2798 | if (empty($settings['default_theme_dir'])) |
@@ -2663,8 +2803,9 @@ discard block |
||
2663 | 2803 | |
2664 | 2804 | // What theme are we in? |
2665 | 2805 | $theme_name = basename($settings['theme_url']); |
2666 | - if (empty($theme_name)) |
|
2667 | - $theme_name = 'unknown'; |
|
2806 | + if (empty($theme_name)) { |
|
2807 | + $theme_name = 'unknown'; |
|
2808 | + } |
|
2668 | 2809 | |
2669 | 2810 | // For each file open it up and write it out! |
2670 | 2811 | foreach (explode('+', $template_name) as $template) |
@@ -2706,8 +2847,9 @@ discard block |
||
2706 | 2847 | $found = true; |
2707 | 2848 | |
2708 | 2849 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2709 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2710 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2850 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2851 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2852 | + } |
|
2711 | 2853 | |
2712 | 2854 | break; |
2713 | 2855 | } |
@@ -2747,8 +2889,9 @@ discard block |
||
2747 | 2889 | } |
2748 | 2890 | |
2749 | 2891 | // Keep track of what we're up to soldier. |
2750 | - if ($db_show_debug === true) |
|
2751 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2892 | + if ($db_show_debug === true) { |
|
2893 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2894 | + } |
|
2752 | 2895 | |
2753 | 2896 | // Remember what we have loaded, and in which language. |
2754 | 2897 | $already_loaded[$template_name] = $lang; |
@@ -2794,8 +2937,9 @@ discard block |
||
2794 | 2937 | ) |
2795 | 2938 | ); |
2796 | 2939 | // In the EXTREMELY unlikely event this happens, give an error message. |
2797 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2798 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2940 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2941 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2942 | + } |
|
2799 | 2943 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2800 | 2944 | { |
2801 | 2945 | if (!isset($boards[$row['id_board']])) |
@@ -2812,8 +2956,8 @@ discard block |
||
2812 | 2956 | ); |
2813 | 2957 | } |
2814 | 2958 | // If a moderator exists for this board, add that moderator for all children too. |
2815 | - if (!empty($row['id_moderator'])) |
|
2816 | - foreach ($boards as $id => $dummy) |
|
2959 | + if (!empty($row['id_moderator'])) { |
|
2960 | + foreach ($boards as $id => $dummy) |
|
2817 | 2961 | { |
2818 | 2962 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2819 | 2963 | 'id' => $row['id_moderator'], |
@@ -2821,11 +2965,12 @@ discard block |
||
2821 | 2965 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2822 | 2966 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2823 | 2967 | ); |
2968 | + } |
|
2824 | 2969 | } |
2825 | 2970 | |
2826 | 2971 | // If a moderator group exists for this board, add that moderator group for all children too |
2827 | - if (!empty($row['id_moderator_group'])) |
|
2828 | - foreach ($boards as $id => $dummy) |
|
2972 | + if (!empty($row['id_moderator_group'])) { |
|
2973 | + foreach ($boards as $id => $dummy) |
|
2829 | 2974 | { |
2830 | 2975 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2831 | 2976 | 'id' => $row['id_moderator_group'], |
@@ -2833,6 +2978,7 @@ discard block |
||
2833 | 2978 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2834 | 2979 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2835 | 2980 | ); |
2981 | + } |
|
2836 | 2982 | } |
2837 | 2983 | } |
2838 | 2984 | $smcFunc['db_free_result']($result); |
@@ -2859,23 +3005,27 @@ discard block |
||
2859 | 3005 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2860 | 3006 | { |
2861 | 3007 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2862 | - if (empty($smcFunc['ucwords'])) |
|
2863 | - reloadSettings(); |
|
3008 | + if (empty($smcFunc['ucwords'])) { |
|
3009 | + reloadSettings(); |
|
3010 | + } |
|
2864 | 3011 | |
2865 | 3012 | // If we don't have our theme information yet, let's get it. |
2866 | - if (empty($settings['default_theme_dir'])) |
|
2867 | - loadTheme(0, false); |
|
3013 | + if (empty($settings['default_theme_dir'])) { |
|
3014 | + loadTheme(0, false); |
|
3015 | + } |
|
2868 | 3016 | |
2869 | 3017 | // Default language directories to try. |
2870 | 3018 | $language_directories = array( |
2871 | 3019 | $settings['default_theme_dir'] . '/languages', |
2872 | 3020 | ); |
2873 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2874 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3021 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
3022 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
3023 | + } |
|
2875 | 3024 | |
2876 | 3025 | // We possibly have a base theme directory. |
2877 | - if (!empty($settings['base_theme_dir'])) |
|
2878 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3026 | + if (!empty($settings['base_theme_dir'])) { |
|
3027 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
3028 | + } |
|
2879 | 3029 | |
2880 | 3030 | // Remove any duplicates. |
2881 | 3031 | $language_directories = array_unique($language_directories); |
@@ -2889,20 +3039,21 @@ discard block |
||
2889 | 3039 | foreach ($language_directories as $language_dir) |
2890 | 3040 | { |
2891 | 3041 | // Can't look in here... doesn't exist! |
2892 | - if (!file_exists($language_dir)) |
|
2893 | - continue; |
|
3042 | + if (!file_exists($language_dir)) { |
|
3043 | + continue; |
|
3044 | + } |
|
2894 | 3045 | |
2895 | 3046 | $dir = dir($language_dir); |
2896 | 3047 | while ($entry = $dir->read()) |
2897 | 3048 | { |
2898 | 3049 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2899 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2900 | - continue; |
|
2901 | - |
|
2902 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2903 | - $langName = $langList[$matches[1]]; |
|
3050 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3051 | + continue; |
|
3052 | + } |
|
2904 | 3053 | |
2905 | - else |
|
3054 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3055 | + $langName = $langList[$matches[1]]; |
|
3056 | + } else |
|
2906 | 3057 | { |
2907 | 3058 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2908 | 3059 | |
@@ -2943,12 +3094,14 @@ discard block |
||
2943 | 3094 | } |
2944 | 3095 | |
2945 | 3096 | // Do we need to store the lang list? |
2946 | - if (empty($langList)) |
|
2947 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3097 | + if (empty($langList)) { |
|
3098 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3099 | + } |
|
2948 | 3100 | |
2949 | 3101 | // Let's cash in on this deal. |
2950 | - if (!empty($modSettings['cache_enable'])) |
|
2951 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3102 | + if (!empty($modSettings['cache_enable'])) { |
|
3103 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3104 | + } |
|
2952 | 3105 | } |
2953 | 3106 | |
2954 | 3107 | return $context['languages']; |
@@ -2971,8 +3124,9 @@ discard block |
||
2971 | 3124 | global $modSettings, $options, $txt; |
2972 | 3125 | static $censor_vulgar = null, $censor_proper; |
2973 | 3126 | |
2974 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2975 | - return $text; |
|
3127 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3128 | + return $text; |
|
3129 | + } |
|
2976 | 3130 | |
2977 | 3131 | // If they haven't yet been loaded, load them. |
2978 | 3132 | if ($censor_vulgar == null) |
@@ -3000,9 +3154,9 @@ discard block |
||
3000 | 3154 | { |
3001 | 3155 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
3002 | 3156 | $text = $func($censor_vulgar, $censor_proper, $text); |
3157 | + } else { |
|
3158 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3003 | 3159 | } |
3004 | - else |
|
3005 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
3006 | 3160 | |
3007 | 3161 | return $text; |
3008 | 3162 | } |
@@ -3028,38 +3182,42 @@ discard block |
||
3028 | 3182 | @ini_set('track_errors', '1'); |
3029 | 3183 | |
3030 | 3184 | // Don't include the file more than once, if $once is true. |
3031 | - if ($once && in_array($filename, $templates)) |
|
3032 | - return; |
|
3185 | + if ($once && in_array($filename, $templates)) { |
|
3186 | + return; |
|
3187 | + } |
|
3033 | 3188 | // Add this file to the include list, whether $once is true or not. |
3034 | - else |
|
3035 | - $templates[] = $filename; |
|
3189 | + else { |
|
3190 | + $templates[] = $filename; |
|
3191 | + } |
|
3036 | 3192 | |
3037 | 3193 | // Are we going to use eval? |
3038 | 3194 | if (empty($modSettings['disableTemplateEval'])) |
3039 | 3195 | { |
3040 | 3196 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
3041 | 3197 | $settings['current_include_filename'] = $filename; |
3042 | - } |
|
3043 | - else |
|
3198 | + } else |
|
3044 | 3199 | { |
3045 | 3200 | $file_found = file_exists($filename); |
3046 | 3201 | |
3047 | - if ($once && $file_found) |
|
3048 | - require_once($filename); |
|
3049 | - elseif ($file_found) |
|
3050 | - require($filename); |
|
3202 | + if ($once && $file_found) { |
|
3203 | + require_once($filename); |
|
3204 | + } elseif ($file_found) { |
|
3205 | + require($filename); |
|
3206 | + } |
|
3051 | 3207 | } |
3052 | 3208 | |
3053 | 3209 | if ($file_found !== true) |
3054 | 3210 | { |
3055 | 3211 | ob_end_clean(); |
3056 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3057 | - @ob_start('ob_gzhandler'); |
|
3058 | - else |
|
3059 | - ob_start(); |
|
3212 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3213 | + @ob_start('ob_gzhandler'); |
|
3214 | + } else { |
|
3215 | + ob_start(); |
|
3216 | + } |
|
3060 | 3217 | |
3061 | - if (isset($_GET['debug'])) |
|
3062 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3218 | + if (isset($_GET['debug'])) { |
|
3219 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3220 | + } |
|
3063 | 3221 | |
3064 | 3222 | // Don't cache error pages!! |
3065 | 3223 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3078,12 +3236,13 @@ discard block |
||
3078 | 3236 | echo '<!DOCTYPE html> |
3079 | 3237 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3080 | 3238 | <head>'; |
3081 | - if (isset($context['character_set'])) |
|
3082 | - echo ' |
|
3239 | + if (isset($context['character_set'])) { |
|
3240 | + echo ' |
|
3083 | 3241 | <meta charset="', $context['character_set'], '">'; |
3242 | + } |
|
3084 | 3243 | |
3085 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3086 | - echo ' |
|
3244 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3245 | + echo ' |
|
3087 | 3246 | <title>', $mtitle, '</title> |
3088 | 3247 | </head> |
3089 | 3248 | <body> |
@@ -3091,8 +3250,8 @@ discard block |
||
3091 | 3250 | ', $mmessage, ' |
3092 | 3251 | </body> |
3093 | 3252 | </html>'; |
3094 | - elseif (!allowedTo('admin_forum')) |
|
3095 | - echo ' |
|
3253 | + } elseif (!allowedTo('admin_forum')) { |
|
3254 | + echo ' |
|
3096 | 3255 | <title>', $txt['template_parse_error'], '</title> |
3097 | 3256 | </head> |
3098 | 3257 | <body> |
@@ -3100,16 +3259,18 @@ discard block |
||
3100 | 3259 | ', $txt['template_parse_error_message'], ' |
3101 | 3260 | </body> |
3102 | 3261 | </html>'; |
3103 | - else |
|
3262 | + } else |
|
3104 | 3263 | { |
3105 | 3264 | require_once($sourcedir . '/Subs-Package.php'); |
3106 | 3265 | |
3107 | 3266 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3108 | 3267 | $error_array = error_get_last(); |
3109 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3110 | - $error = $error_array['message']; |
|
3111 | - if (empty($error)) |
|
3112 | - $error = $txt['template_parse_errmsg']; |
|
3268 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3269 | + $error = $error_array['message']; |
|
3270 | + } |
|
3271 | + if (empty($error)) { |
|
3272 | + $error = $txt['template_parse_errmsg']; |
|
3273 | + } |
|
3113 | 3274 | |
3114 | 3275 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3115 | 3276 | |
@@ -3120,11 +3281,12 @@ discard block |
||
3120 | 3281 | <h3>', $txt['template_parse_error'], '</h3> |
3121 | 3282 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3122 | 3283 | |
3123 | - if (!empty($error)) |
|
3124 | - echo ' |
|
3284 | + if (!empty($error)) { |
|
3285 | + echo ' |
|
3125 | 3286 | <hr> |
3126 | 3287 | |
3127 | 3288 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3289 | + } |
|
3128 | 3290 | |
3129 | 3291 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3130 | 3292 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3134,10 +3296,11 @@ discard block |
||
3134 | 3296 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3135 | 3297 | |
3136 | 3298 | // Fix the PHP code stuff... |
3137 | - if (!isBrowser('gecko')) |
|
3138 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3139 | - else |
|
3140 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3299 | + if (!isBrowser('gecko')) { |
|
3300 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3301 | + } else { |
|
3302 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3303 | + } |
|
3141 | 3304 | |
3142 | 3305 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3143 | 3306 | $j = -1; |
@@ -3145,8 +3308,9 @@ discard block |
||
3145 | 3308 | { |
3146 | 3309 | $j++; |
3147 | 3310 | |
3148 | - if (substr_count($line, '<br>') == 0) |
|
3149 | - continue; |
|
3311 | + if (substr_count($line, '<br>') == 0) { |
|
3312 | + continue; |
|
3313 | + } |
|
3150 | 3314 | |
3151 | 3315 | $n = substr_count($line, '<br>'); |
3152 | 3316 | for ($i = 0; $i < $n; $i++) |
@@ -3165,38 +3329,42 @@ discard block |
||
3165 | 3329 | // Figure out what the color coding was before... |
3166 | 3330 | $line = max($match[1] - 9, 1); |
3167 | 3331 | $last_line = ''; |
3168 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3169 | - if (strpos($data2[$line2], '<') !== false) |
|
3332 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3333 | + if (strpos($data2[$line2], '<') !== false) |
|
3170 | 3334 | { |
3171 | 3335 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3172 | 3336 | $last_line = $color_match[1]; |
3337 | + } |
|
3173 | 3338 | break; |
3174 | 3339 | } |
3175 | 3340 | |
3176 | 3341 | // Show the relevant lines... |
3177 | 3342 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3178 | 3343 | { |
3179 | - if ($line == $match[1]) |
|
3180 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3344 | + if ($line == $match[1]) { |
|
3345 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3346 | + } |
|
3181 | 3347 | |
3182 | 3348 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3183 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3184 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3349 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3350 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3351 | + } |
|
3185 | 3352 | |
3186 | 3353 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3187 | 3354 | { |
3188 | 3355 | $last_line = $color_match[1]; |
3189 | 3356 | echo '</', substr($last_line, 1, 4), '>'; |
3357 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3358 | + $last_line = ''; |
|
3359 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3360 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3190 | 3361 | } |
3191 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3192 | - $last_line = ''; |
|
3193 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3194 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3195 | 3362 | |
3196 | - if ($line == $match[1]) |
|
3197 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3198 | - else |
|
3199 | - echo "\n"; |
|
3363 | + if ($line == $match[1]) { |
|
3364 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3365 | + } else { |
|
3366 | + echo "\n"; |
|
3367 | + } |
|
3200 | 3368 | } |
3201 | 3369 | |
3202 | 3370 | echo '</pre></div>'; |
@@ -3220,8 +3388,9 @@ discard block |
||
3220 | 3388 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3221 | 3389 | |
3222 | 3390 | // Figure out what type of database we are using. |
3223 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3224 | - $db_type = 'mysql'; |
|
3391 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3392 | + $db_type = 'mysql'; |
|
3393 | + } |
|
3225 | 3394 | |
3226 | 3395 | // Load the file for the database. |
3227 | 3396 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3229,8 +3398,9 @@ discard block |
||
3229 | 3398 | $db_options = array(); |
3230 | 3399 | |
3231 | 3400 | // Add in the port if needed |
3232 | - if (!empty($db_port)) |
|
3233 | - $db_options['port'] = $db_port; |
|
3401 | + if (!empty($db_port)) { |
|
3402 | + $db_options['port'] = $db_port; |
|
3403 | + } |
|
3234 | 3404 | |
3235 | 3405 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3236 | 3406 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3249,13 +3419,15 @@ discard block |
||
3249 | 3419 | } |
3250 | 3420 | |
3251 | 3421 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3252 | - if (!$db_connection) |
|
3253 | - display_db_error(); |
|
3422 | + if (!$db_connection) { |
|
3423 | + display_db_error(); |
|
3424 | + } |
|
3254 | 3425 | |
3255 | 3426 | // If in SSI mode fix up the prefix. |
3256 | - if (SMF == 'SSI') |
|
3257 | - db_fix_prefix($db_prefix, $db_name); |
|
3258 | -} |
|
3427 | + if (SMF == 'SSI') { |
|
3428 | + db_fix_prefix($db_prefix, $db_name); |
|
3429 | + } |
|
3430 | + } |
|
3259 | 3431 | |
3260 | 3432 | /** |
3261 | 3433 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3269,10 +3441,11 @@ discard block |
||
3269 | 3441 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3270 | 3442 | |
3271 | 3443 | // Not overriding this and we have a cacheAPI, send it back. |
3272 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3273 | - return $cacheAPI; |
|
3274 | - elseif (is_null($cacheAPI)) |
|
3275 | - $cacheAPI = false; |
|
3444 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3445 | + return $cacheAPI; |
|
3446 | + } elseif (is_null($cacheAPI)) { |
|
3447 | + $cacheAPI = false; |
|
3448 | + } |
|
3276 | 3449 | |
3277 | 3450 | // Make sure our class is in session. |
3278 | 3451 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3293,8 +3466,9 @@ discard block |
||
3293 | 3466 | if (!$testAPI->isSupported()) |
3294 | 3467 | { |
3295 | 3468 | // Can we save ourselves? |
3296 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3297 | - return loadCacheAccelerator(null, false); |
|
3469 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3470 | + return loadCacheAccelerator(null, false); |
|
3471 | + } |
|
3298 | 3472 | return false; |
3299 | 3473 | } |
3300 | 3474 | |
@@ -3306,9 +3480,9 @@ discard block |
||
3306 | 3480 | { |
3307 | 3481 | $cacheAPI = $testAPI; |
3308 | 3482 | return $cacheAPI; |
3483 | + } else { |
|
3484 | + return $testAPI; |
|
3309 | 3485 | } |
3310 | - else |
|
3311 | - return $testAPI; |
|
3312 | 3486 | } |
3313 | 3487 | } |
3314 | 3488 | |
@@ -3328,8 +3502,9 @@ discard block |
||
3328 | 3502 | |
3329 | 3503 | // @todo Why are we doing this if caching is disabled? |
3330 | 3504 | |
3331 | - if (function_exists('call_integration_hook')) |
|
3332 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3505 | + if (function_exists('call_integration_hook')) { |
|
3506 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3507 | + } |
|
3333 | 3508 | |
3334 | 3509 | /* Refresh the cache if either: |
3335 | 3510 | 1. Caching is disabled. |
@@ -3343,16 +3518,19 @@ discard block |
||
3343 | 3518 | require_once($sourcedir . '/' . $file); |
3344 | 3519 | $cache_block = call_user_func_array($function, $params); |
3345 | 3520 | |
3346 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3347 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3521 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3522 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3523 | + } |
|
3348 | 3524 | } |
3349 | 3525 | |
3350 | 3526 | // Some cached data may need a freshening up after retrieval. |
3351 | - if (!empty($cache_block['post_retri_eval'])) |
|
3352 | - eval($cache_block['post_retri_eval']); |
|
3527 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3528 | + eval($cache_block['post_retri_eval']); |
|
3529 | + } |
|
3353 | 3530 | |
3354 | - if (function_exists('call_integration_hook')) |
|
3355 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3531 | + if (function_exists('call_integration_hook')) { |
|
3532 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3533 | + } |
|
3356 | 3534 | |
3357 | 3535 | return $cache_block['data']; |
3358 | 3536 | } |
@@ -3379,8 +3557,9 @@ discard block |
||
3379 | 3557 | global $smcFunc, $cache_enable, $cacheAPI; |
3380 | 3558 | global $cache_hits, $cache_count, $db_show_debug; |
3381 | 3559 | |
3382 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3383 | - return; |
|
3560 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3561 | + return; |
|
3562 | + } |
|
3384 | 3563 | |
3385 | 3564 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3386 | 3565 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3393,12 +3572,14 @@ discard block |
||
3393 | 3572 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3394 | 3573 | $cacheAPI->putData($key, $value, $ttl); |
3395 | 3574 | |
3396 | - if (function_exists('call_integration_hook')) |
|
3397 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3575 | + if (function_exists('call_integration_hook')) { |
|
3576 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3577 | + } |
|
3398 | 3578 | |
3399 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3400 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3401 | -} |
|
3579 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3580 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3581 | + } |
|
3582 | + } |
|
3402 | 3583 | |
3403 | 3584 | /** |
3404 | 3585 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3414,8 +3595,9 @@ discard block |
||
3414 | 3595 | global $smcFunc, $cache_enable, $cacheAPI; |
3415 | 3596 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3416 | 3597 | |
3417 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3418 | - return; |
|
3598 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3599 | + return; |
|
3600 | + } |
|
3419 | 3601 | |
3420 | 3602 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3421 | 3603 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3435,16 +3617,18 @@ discard block |
||
3435 | 3617 | |
3436 | 3618 | if (empty($value)) |
3437 | 3619 | { |
3438 | - if (!is_array($cache_misses)) |
|
3439 | - $cache_misses = array(); |
|
3620 | + if (!is_array($cache_misses)) { |
|
3621 | + $cache_misses = array(); |
|
3622 | + } |
|
3440 | 3623 | |
3441 | 3624 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3442 | 3625 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3443 | 3626 | } |
3444 | 3627 | } |
3445 | 3628 | |
3446 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3447 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3629 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3630 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3631 | + } |
|
3448 | 3632 | |
3449 | 3633 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3450 | 3634 | } |
@@ -3466,8 +3650,9 @@ discard block |
||
3466 | 3650 | global $cacheAPI; |
3467 | 3651 | |
3468 | 3652 | // If we can't get to the API, can't do this. |
3469 | - if (empty($cacheAPI)) |
|
3470 | - return; |
|
3653 | + if (empty($cacheAPI)) { |
|
3654 | + return; |
|
3655 | + } |
|
3471 | 3656 | |
3472 | 3657 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3473 | 3658 | $cacheAPI->cleanCache($type); |
@@ -3492,8 +3677,9 @@ discard block |
||
3492 | 3677 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3493 | 3678 | |
3494 | 3679 | // Come on! |
3495 | - if (empty($data)) |
|
3496 | - return array(); |
|
3680 | + if (empty($data)) { |
|
3681 | + return array(); |
|
3682 | + } |
|
3497 | 3683 | |
3498 | 3684 | // Set a nice default var. |
3499 | 3685 | $image = ''; |
@@ -3501,11 +3687,11 @@ discard block |
||
3501 | 3687 | // Gravatar has been set as mandatory! |
3502 | 3688 | if (!empty($modSettings['gravatarOverride'])) |
3503 | 3689 | { |
3504 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3505 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3506 | - |
|
3507 | - else if (!empty($data['email'])) |
|
3508 | - $image = get_gravatar_url($data['email']); |
|
3690 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3691 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3692 | + } else if (!empty($data['email'])) { |
|
3693 | + $image = get_gravatar_url($data['email']); |
|
3694 | + } |
|
3509 | 3695 | } |
3510 | 3696 | |
3511 | 3697 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3517,54 +3703,60 @@ discard block |
||
3517 | 3703 | // Gravatar. |
3518 | 3704 | if (stristr($data['avatar'], 'gravatar://')) |
3519 | 3705 | { |
3520 | - if ($data['avatar'] == 'gravatar://') |
|
3521 | - $image = get_gravatar_url($data['email']); |
|
3522 | - |
|
3523 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3524 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3706 | + if ($data['avatar'] == 'gravatar://') { |
|
3707 | + $image = get_gravatar_url($data['email']); |
|
3708 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3709 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3710 | + } |
|
3525 | 3711 | } |
3526 | 3712 | |
3527 | 3713 | // External url. |
3528 | 3714 | else |
3529 | 3715 | { |
3530 | 3716 | // Using ssl? |
3531 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3532 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3717 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3718 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3719 | + } |
|
3533 | 3720 | |
3534 | 3721 | // Just a plain external url. |
3535 | - else |
|
3536 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3722 | + else { |
|
3723 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3724 | + } |
|
3537 | 3725 | } |
3538 | 3726 | } |
3539 | 3727 | |
3540 | 3728 | // Perhaps this user has an attachment as avatar... |
3541 | - else if (!empty($data['filename'])) |
|
3542 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3729 | + else if (!empty($data['filename'])) { |
|
3730 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3731 | + } |
|
3543 | 3732 | |
3544 | 3733 | // Right... no avatar... use our default image. |
3545 | - else |
|
3546 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3734 | + else { |
|
3735 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3736 | + } |
|
3547 | 3737 | } |
3548 | 3738 | |
3549 | 3739 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3550 | 3740 | |
3551 | 3741 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3552 | - if (!empty($image)) |
|
3553 | - return array( |
|
3742 | + if (!empty($image)) { |
|
3743 | + return array( |
|
3554 | 3744 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3555 | 3745 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3556 | 3746 | 'href' => $image, |
3557 | 3747 | 'url' => $image, |
3558 | 3748 | ); |
3749 | + } |
|
3559 | 3750 | |
3560 | 3751 | // Fallback to make life easier for everyone... |
3561 | - else |
|
3562 | - return array( |
|
3752 | + else { |
|
3753 | + return array( |
|
3563 | 3754 | 'name' => '', |
3564 | 3755 | 'image' => '', |
3565 | 3756 | 'href' => '', |
3566 | 3757 | 'url' => '', |
3567 | 3758 | ); |
3568 | -} |
|
3759 | + } |
|
3760 | + } |
|
3569 | 3761 | |
3570 | 3762 | ?> |
3571 | 3763 | \ No newline at end of file |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | 'class' => 'centercol', |
1335 | 1335 | ), |
1336 | 1336 | 'data' => array( |
1337 | - 'function' => function ($rowData) |
|
1337 | + 'function' => function($rowData) |
|
1338 | 1338 | { |
1339 | 1339 | $isChecked = $rowData['disabled'] ? '' : ' checked'; |
1340 | 1340 | $onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : ''; |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | 'class' => 'centercol', |
1351 | 1351 | ), |
1352 | 1352 | 'data' => array( |
1353 | - 'function' => function ($rowData) |
|
1353 | + 'function' => function($rowData) |
|
1354 | 1354 | { |
1355 | 1355 | $isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : ''; |
1356 | 1356 | $isDisabled = $rowData['can_show_register'] ? '' : ' disabled'; |
@@ -1397,15 +1397,15 @@ discard block |
||
1397 | 1397 | 'value' => $txt['custom_profile_fieldorder'], |
1398 | 1398 | ), |
1399 | 1399 | 'data' => array( |
1400 | - 'function' => function ($rowData) use ($context, $txt, $scripturl) |
|
1400 | + 'function' => function($rowData) use ($context, $txt, $scripturl) |
|
1401 | 1401 | { |
1402 | - $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
|
1402 | + $return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br>'; |
|
1403 | 1403 | |
1404 | 1404 | if ($rowData['field_order'] > 1) |
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1405 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>'; |
|
1406 | 1406 | |
1407 | 1407 | if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1408 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>'; |
|
1409 | 1409 | |
1410 | 1410 | $return .= '</p>'; |
1411 | 1411 | |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | 'value' => $txt['custom_profile_fieldname'], |
1424 | 1424 | ), |
1425 | 1425 | 'data' => array( |
1426 | - 'function' => function ($rowData) use ($scripturl) |
|
1426 | + 'function' => function($rowData) use ($scripturl) |
|
1427 | 1427 | { |
1428 | 1428 | return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']); |
1429 | 1429 | }, |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | 'value' => $txt['custom_profile_fieldtype'], |
1440 | 1440 | ), |
1441 | 1441 | 'data' => array( |
1442 | - 'function' => function ($rowData) use ($txt) |
|
1442 | + 'function' => function($rowData) use ($txt) |
|
1443 | 1443 | { |
1444 | 1444 | $textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']); |
1445 | 1445 | return isset($txt[$textKey]) ? $txt[$textKey] : $textKey; |
@@ -1457,7 +1457,7 @@ discard block |
||
1457 | 1457 | 'value' => $txt['custom_profile_active'], |
1458 | 1458 | ), |
1459 | 1459 | 'data' => array( |
1460 | - 'function' => function ($rowData) use ($txt) |
|
1460 | + 'function' => function($rowData) use ($txt) |
|
1461 | 1461 | { |
1462 | 1462 | return $rowData['active'] ? $txt['yes'] : $txt['no']; |
1463 | 1463 | }, |
@@ -1474,7 +1474,7 @@ discard block |
||
1474 | 1474 | 'value' => $txt['custom_profile_placement'], |
1475 | 1475 | ), |
1476 | 1476 | 'data' => array( |
1477 | - 'function' => function ($rowData) |
|
1477 | + 'function' => function($rowData) |
|
1478 | 1478 | { |
1479 | 1479 | global $txt, $context; |
1480 | 1480 | |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
1710 | 1710 | |
1711 | 1711 | // All good, proceed. |
1712 | - $smcFunc['db_query']('',' |
|
1712 | + $smcFunc['db_query']('', ' |
|
1713 | 1713 | UPDATE {db_prefix}custom_fields |
1714 | 1714 | SET field_order = {int:old_order} |
1715 | 1715 | WHERE field_order = {int:new_order}', |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | 'old_order' => $context['field']['order'], |
1719 | 1719 | ) |
1720 | 1720 | ); |
1721 | - $smcFunc['db_query']('',' |
|
1721 | + $smcFunc['db_query']('', ' |
|
1722 | 1722 | UPDATE {db_prefix}custom_fields |
1723 | 1723 | SET field_order = {int:new_order} |
1724 | 1724 | WHERE id_field = {int:id_field}', |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $smcFunc['db_free_result']($request); |
1821 | 1821 | |
1822 | 1822 | $unique = false; |
1823 | - for ($i = 0; !$unique && $i < 9; $i ++) |
|
1823 | + for ($i = 0; !$unique && $i < 9; $i++) |
|
1824 | 1824 | { |
1825 | 1825 | if (!in_array($col_name, $current_fields)) |
1826 | 1826 | $unique = true; |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | ); |
1994 | 1994 | |
1995 | 1995 | // Re-arrange the order. |
1996 | - $smcFunc['db_query']('',' |
|
1996 | + $smcFunc['db_query']('', ' |
|
1997 | 1997 | UPDATE {db_prefix}custom_fields |
1998 | 1998 | SET field_order = field_order - 1 |
1999 | 1999 | WHERE field_order > {int:current_order}', |
@@ -2257,7 +2257,7 @@ discard block |
||
2257 | 2257 | $context['token_check'] = 'noti-admin'; |
2258 | 2258 | |
2259 | 2259 | // Specify our action since we'll want to post back here instead of the profile |
2260 | - $context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id']; |
|
2260 | + $context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id']; |
|
2261 | 2261 | |
2262 | 2262 | loadTemplate('Profile'); |
2263 | 2263 | loadLanguage('Profile'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or. |
@@ -206,16 +207,18 @@ discard block |
||
206 | 207 | { |
207 | 208 | $all_zones = timezone_identifiers_list(); |
208 | 209 | // Make sure we set the value to the same as the printed value. |
209 | - foreach ($all_zones as $zone) |
|
210 | - $config_vars['default_timezone'][2][$zone] = $zone; |
|
210 | + foreach ($all_zones as $zone) { |
|
211 | + $config_vars['default_timezone'][2][$zone] = $zone; |
|
212 | + } |
|
213 | + } else { |
|
214 | + unset($config_vars['default_timezone']); |
|
211 | 215 | } |
212 | - else |
|
213 | - unset($config_vars['default_timezone']); |
|
214 | 216 | |
215 | 217 | call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); |
216 | 218 | |
217 | - if ($return_config) |
|
218 | - return $config_vars; |
|
219 | + if ($return_config) { |
|
220 | + return $config_vars; |
|
221 | + } |
|
219 | 222 | |
220 | 223 | // Saving? |
221 | 224 | if (isset($_GET['save'])) |
@@ -223,8 +226,9 @@ discard block |
||
223 | 226 | checkSession(); |
224 | 227 | |
225 | 228 | // Prevent absurd boundaries here - make it a day tops. |
226 | - if (isset($_POST['lastActive'])) |
|
227 | - $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
229 | + if (isset($_POST['lastActive'])) { |
|
230 | + $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); |
|
231 | + } |
|
228 | 232 | |
229 | 233 | call_integration_hook('integrate_save_basic_settings'); |
230 | 234 | |
@@ -269,8 +273,9 @@ discard block |
||
269 | 273 | |
270 | 274 | call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); |
271 | 275 | |
272 | - if ($return_config) |
|
273 | - return $config_vars; |
|
276 | + if ($return_config) { |
|
277 | + return $config_vars; |
|
278 | + } |
|
274 | 279 | |
275 | 280 | // Setup the template. |
276 | 281 | require_once($sourcedir . '/ManageServer.php'); |
@@ -287,13 +292,15 @@ discard block |
||
287 | 292 | |
288 | 293 | // Clean up the tags. |
289 | 294 | $bbcTags = array(); |
290 | - foreach (parse_bbc(false) as $tag) |
|
291 | - $bbcTags[] = $tag['tag']; |
|
295 | + foreach (parse_bbc(false) as $tag) { |
|
296 | + $bbcTags[] = $tag['tag']; |
|
297 | + } |
|
292 | 298 | |
293 | - if (!isset($_POST['disabledBBC_enabledTags'])) |
|
294 | - $_POST['disabledBBC_enabledTags'] = array(); |
|
295 | - elseif (!is_array($_POST['disabledBBC_enabledTags'])) |
|
296 | - $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
299 | + if (!isset($_POST['disabledBBC_enabledTags'])) { |
|
300 | + $_POST['disabledBBC_enabledTags'] = array(); |
|
301 | + } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { |
|
302 | + $_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']); |
|
303 | + } |
|
297 | 304 | // Work out what is actually disabled! |
298 | 305 | $_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags'])); |
299 | 306 | |
@@ -337,8 +344,9 @@ discard block |
||
337 | 344 | |
338 | 345 | call_integration_hook('integrate_layout_settings', array(&$config_vars)); |
339 | 346 | |
340 | - if ($return_config) |
|
341 | - return $config_vars; |
|
347 | + if ($return_config) { |
|
348 | + return $config_vars; |
|
349 | + } |
|
342 | 350 | |
343 | 351 | // Saving? |
344 | 352 | if (isset($_GET['save'])) |
@@ -379,8 +387,9 @@ discard block |
||
379 | 387 | |
380 | 388 | call_integration_hook('integrate_likes_settings', array(&$config_vars)); |
381 | 389 | |
382 | - if ($return_config) |
|
383 | - return $config_vars; |
|
390 | + if ($return_config) { |
|
391 | + return $config_vars; |
|
392 | + } |
|
384 | 393 | |
385 | 394 | // Saving? |
386 | 395 | if (isset($_GET['save'])) |
@@ -418,8 +427,9 @@ discard block |
||
418 | 427 | |
419 | 428 | call_integration_hook('integrate_mentions_settings', array(&$config_vars)); |
420 | 429 | |
421 | - if ($return_config) |
|
422 | - return $config_vars; |
|
430 | + if ($return_config) { |
|
431 | + return $config_vars; |
|
432 | + } |
|
423 | 433 | |
424 | 434 | // Saving? |
425 | 435 | if (isset($_GET['save'])) |
@@ -463,8 +473,8 @@ discard block |
||
463 | 473 | 'enable' => array('check', 'warning_enable'), |
464 | 474 | ); |
465 | 475 | |
466 | - if (!empty($modSettings['warning_settings']) && $currently_enabled) |
|
467 | - $config_vars += array( |
|
476 | + if (!empty($modSettings['warning_settings']) && $currently_enabled) { |
|
477 | + $config_vars += array( |
|
468 | 478 | '', |
469 | 479 | array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']), |
470 | 480 | 'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']), |
@@ -473,15 +483,18 @@ discard block |
||
473 | 483 | 'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']), |
474 | 484 | array('permissions', 'view_warning'), |
475 | 485 | ); |
486 | + } |
|
476 | 487 | |
477 | 488 | call_integration_hook('integrate_warning_settings', array(&$config_vars)); |
478 | 489 | |
479 | - if ($return_config) |
|
480 | - return $config_vars; |
|
490 | + if ($return_config) { |
|
491 | + return $config_vars; |
|
492 | + } |
|
481 | 493 | |
482 | 494 | // Cannot use moderation if post moderation is not enabled. |
483 | - if (!$modSettings['postmod_active']) |
|
484 | - unset($config_vars['moderate']); |
|
495 | + if (!$modSettings['postmod_active']) { |
|
496 | + unset($config_vars['moderate']); |
|
497 | + } |
|
485 | 498 | |
486 | 499 | // Will need the utility functions from here. |
487 | 500 | require_once($sourcedir . '/ManageServer.php'); |
@@ -506,16 +519,16 @@ discard block |
||
506 | 519 | 'warning_watch' => 10, |
507 | 520 | 'warning_mute' => 60, |
508 | 521 | ); |
509 | - if ($modSettings['postmod_active']) |
|
510 | - $vars['warning_moderate'] = 35; |
|
522 | + if ($modSettings['postmod_active']) { |
|
523 | + $vars['warning_moderate'] = 35; |
|
524 | + } |
|
511 | 525 | |
512 | 526 | foreach ($vars as $var => $value) |
513 | 527 | { |
514 | 528 | $config_vars[] = array('int', $var); |
515 | 529 | $_POST[$var] = $value; |
516 | 530 | } |
517 | - } |
|
518 | - else |
|
531 | + } else |
|
519 | 532 | { |
520 | 533 | $_POST['warning_watch'] = min($_POST['warning_watch'], 100); |
521 | 534 | $_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0; |
@@ -603,8 +616,9 @@ discard block |
||
603 | 616 | |
604 | 617 | call_integration_hook('integrate_spam_settings', array(&$config_vars)); |
605 | 618 | |
606 | - if ($return_config) |
|
607 | - return $config_vars; |
|
619 | + if ($return_config) { |
|
620 | + return $config_vars; |
|
621 | + } |
|
608 | 622 | |
609 | 623 | // You need to be an admin to edit settings! |
610 | 624 | isAllowedTo('admin_forum'); |
@@ -638,8 +652,9 @@ discard block |
||
638 | 652 | |
639 | 653 | if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers'])) |
640 | 654 | { |
641 | - if (empty($context['settings_insert_above'])) |
|
642 | - $context['settings_insert_above'] = ''; |
|
655 | + if (empty($context['settings_insert_above'])) { |
|
656 | + $context['settings_insert_above'] = ''; |
|
657 | + } |
|
643 | 658 | |
644 | 659 | $context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>'; |
645 | 660 | } |
@@ -682,8 +697,9 @@ discard block |
||
682 | 697 | $_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour']; |
683 | 698 | |
684 | 699 | // Hack in guest requiring verification! |
685 | - if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) |
|
686 | - $_POST['posts_require_captcha'] = -1; |
|
700 | + if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) { |
|
701 | + $_POST['posts_require_captcha'] = -1; |
|
702 | + } |
|
687 | 703 | |
688 | 704 | $save_vars = $config_vars; |
689 | 705 | unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']); |
@@ -700,14 +716,16 @@ discard block |
||
700 | 716 | foreach ($context['qa_languages'] as $lang_id => $dummy) |
701 | 717 | { |
702 | 718 | // If we had some questions for this language before, but don't now, delete everything from that language. |
703 | - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) |
|
704 | - $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
719 | + if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) { |
|
720 | + $changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]); |
|
721 | + } |
|
705 | 722 | |
706 | 723 | // Now step through and see if any existing questions no longer exist. |
707 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
708 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
724 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
725 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
709 | 726 | if (empty($_POST['question'][$lang_id][$q_id])) |
710 | 727 | $changes['delete'][] = $q_id; |
728 | + } |
|
711 | 729 | |
712 | 730 | // Now let's see if there are new questions or ones that need updating. |
713 | 731 | if (isset($_POST['question'][$lang_id])) |
@@ -716,14 +734,16 @@ discard block |
||
716 | 734 | { |
717 | 735 | // Ignore junky ids. |
718 | 736 | $q_id = (int) $q_id; |
719 | - if ($q_id <= 0) |
|
720 | - continue; |
|
737 | + if ($q_id <= 0) { |
|
738 | + continue; |
|
739 | + } |
|
721 | 740 | |
722 | 741 | // Check the question isn't empty (because they want to delete it?) |
723 | 742 | if (empty($question) || trim($question) == '') |
724 | 743 | { |
725 | - if (isset($context['question_answers'][$q_id])) |
|
726 | - $changes['delete'][] = $q_id; |
|
744 | + if (isset($context['question_answers'][$q_id])) { |
|
745 | + $changes['delete'][] = $q_id; |
|
746 | + } |
|
727 | 747 | continue; |
728 | 748 | } |
729 | 749 | $question = $smcFunc['htmlspecialchars'](trim($question)); |
@@ -731,19 +751,22 @@ discard block |
||
731 | 751 | // Get the answers. Firstly check there actually might be some. |
732 | 752 | if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) |
733 | 753 | { |
734 | - if (isset($context['question_answers'][$q_id])) |
|
735 | - $changes['delete'][] = $q_id; |
|
754 | + if (isset($context['question_answers'][$q_id])) { |
|
755 | + $changes['delete'][] = $q_id; |
|
756 | + } |
|
736 | 757 | continue; |
737 | 758 | } |
738 | 759 | // Now get them and check that they might be viable. |
739 | 760 | $answers = array(); |
740 | - foreach ($_POST['answer'][$lang_id][$q_id] as $answer) |
|
741 | - if (!empty($answer) && trim($answer) !== '') |
|
761 | + foreach ($_POST['answer'][$lang_id][$q_id] as $answer) { |
|
762 | + if (!empty($answer) && trim($answer) !== '') |
|
742 | 763 | $answers[] = $smcFunc['htmlspecialchars'](trim($answer)); |
764 | + } |
|
743 | 765 | if (empty($answers)) |
744 | 766 | { |
745 | - if (isset($context['question_answers'][$q_id])) |
|
746 | - $changes['delete'][] = $q_id; |
|
767 | + if (isset($context['question_answers'][$q_id])) { |
|
768 | + $changes['delete'][] = $q_id; |
|
769 | + } |
|
747 | 770 | continue; |
748 | 771 | } |
749 | 772 | $answers = $smcFunc['json_encode']($answers); |
@@ -753,16 +776,17 @@ discard block |
||
753 | 776 | { |
754 | 777 | // New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids. |
755 | 778 | $changes['insert'][] = array($lang_id, $question, $answers); |
756 | - } |
|
757 | - else |
|
779 | + } else |
|
758 | 780 | { |
759 | 781 | // It's an existing question. Let's see what's changed, if anything. |
760 | - if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) |
|
761 | - $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
782 | + if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) { |
|
783 | + $changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers); |
|
784 | + } |
|
762 | 785 | } |
763 | 786 | |
764 | - if (!isset($qs_per_lang[$lang_id])) |
|
765 | - $qs_per_lang[$lang_id] = 0; |
|
787 | + if (!isset($qs_per_lang[$lang_id])) { |
|
788 | + $qs_per_lang[$lang_id] = 0; |
|
789 | + } |
|
766 | 790 | $qs_per_lang[$lang_id]++; |
767 | 791 | } |
768 | 792 | } |
@@ -812,8 +836,9 @@ discard block |
||
812 | 836 | |
813 | 837 | // Lastly, the count of messages needs to be no more than the lowest number of questions for any one language. |
814 | 838 | $count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang); |
815 | - if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) |
|
816 | - $_POST['qa_verification_number'] = $count_questions; |
|
839 | + if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) { |
|
840 | + $_POST['qa_verification_number'] = $count_questions; |
|
841 | + } |
|
817 | 842 | |
818 | 843 | call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); |
819 | 844 | |
@@ -828,24 +853,27 @@ discard block |
||
828 | 853 | |
829 | 854 | $character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y')); |
830 | 855 | $_SESSION['visual_verification_code'] = ''; |
831 | - for ($i = 0; $i < 6; $i++) |
|
832 | - $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
856 | + for ($i = 0; $i < 6; $i++) { |
|
857 | + $_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)]; |
|
858 | + } |
|
833 | 859 | |
834 | 860 | // Some javascript for CAPTCHA. |
835 | 861 | $context['settings_post_javascript'] = ''; |
836 | - if ($context['use_graphic_library']) |
|
837 | - $context['settings_post_javascript'] .= ' |
|
862 | + if ($context['use_graphic_library']) { |
|
863 | + $context['settings_post_javascript'] .= ' |
|
838 | 864 | function refreshImages() |
839 | 865 | { |
840 | 866 | var imageType = document.getElementById(\'visual_verification_type\').value; |
841 | 867 | document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType; |
842 | 868 | }'; |
869 | + } |
|
843 | 870 | |
844 | 871 | // Show the image itself, or text saying we can't. |
845 | - if ($context['use_graphic_library']) |
|
846 | - $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
847 | - else |
|
848 | - $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
872 | + if ($context['use_graphic_library']) { |
|
873 | + $config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>'; |
|
874 | + } else { |
|
875 | + $config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>'; |
|
876 | + } |
|
849 | 877 | |
850 | 878 | // Hack for PM spam settings. |
851 | 879 | list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']); |
@@ -855,9 +883,10 @@ discard block |
||
855 | 883 | $modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha']; |
856 | 884 | |
857 | 885 | // Some minor javascript for the guest post setting. |
858 | - if ($modSettings['posts_require_captcha']) |
|
859 | - $context['settings_post_javascript'] .= ' |
|
886 | + if ($modSettings['posts_require_captcha']) { |
|
887 | + $context['settings_post_javascript'] .= ' |
|
860 | 888 | document.getElementById(\'guests_require_captcha\').disabled = true;'; |
889 | + } |
|
861 | 890 | |
862 | 891 | // And everything else. |
863 | 892 | $context['post_url'] = $scripturl . '?action=admin;area=antispam;save'; |
@@ -904,8 +933,9 @@ discard block |
||
904 | 933 | |
905 | 934 | call_integration_hook('integrate_signature_settings', array(&$config_vars)); |
906 | 935 | |
907 | - if ($return_config) |
|
908 | - return $config_vars; |
|
936 | + if ($return_config) { |
|
937 | + return $config_vars; |
|
938 | + } |
|
909 | 939 | |
910 | 940 | // Setup the template. |
911 | 941 | $context['page_title'] = $txt['signature_settings']; |
@@ -960,8 +990,9 @@ discard block |
||
960 | 990 | $sig = strtr($row['signature'], array('<br>' => "\n")); |
961 | 991 | |
962 | 992 | // Max characters... |
963 | - if (!empty($sig_limits[1])) |
|
964 | - $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
993 | + if (!empty($sig_limits[1])) { |
|
994 | + $sig = $smcFunc['substr']($sig, 0, $sig_limits[1]); |
|
995 | + } |
|
965 | 996 | // Max lines... |
966 | 997 | if (!empty($sig_limits[2])) |
967 | 998 | { |
@@ -971,8 +1002,9 @@ discard block |
||
971 | 1002 | if ($sig[$i] == "\n") |
972 | 1003 | { |
973 | 1004 | $count++; |
974 | - if ($count >= $sig_limits[2]) |
|
975 | - $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1005 | + if ($count >= $sig_limits[2]) { |
|
1006 | + $sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' ')); |
|
1007 | + } |
|
976 | 1008 | } |
977 | 1009 | } |
978 | 1010 | } |
@@ -983,17 +1015,19 @@ discard block |
||
983 | 1015 | { |
984 | 1016 | $limit_broke = 0; |
985 | 1017 | // Attempt to allow all sizes of abuse, so to speak. |
986 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
987 | - $limit_broke = $sig_limits[7] . 'px'; |
|
988 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
989 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
990 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
991 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
992 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
993 | - $limit_broke = 'large'; |
|
994 | - |
|
995 | - if ($limit_broke) |
|
996 | - $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1018 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
1019 | + $limit_broke = $sig_limits[7] . 'px'; |
|
1020 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
1021 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
1022 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
1023 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
1024 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
1025 | + $limit_broke = 'large'; |
|
1026 | + } |
|
1027 | + |
|
1028 | + if ($limit_broke) { |
|
1029 | + $sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig); |
|
1030 | + } |
|
997 | 1031 | } |
998 | 1032 | } |
999 | 1033 | |
@@ -1049,32 +1083,34 @@ discard block |
||
1049 | 1083 | $img_offset = false; |
1050 | 1084 | } |
1051 | 1085 | } |
1086 | + } else { |
|
1087 | + $replaces[$image] = ''; |
|
1052 | 1088 | } |
1053 | - else |
|
1054 | - $replaces[$image] = ''; |
|
1055 | 1089 | |
1056 | 1090 | continue; |
1057 | 1091 | } |
1058 | 1092 | |
1059 | 1093 | // Does it have predefined restraints? Width first. |
1060 | - if ($matches[6][$key]) |
|
1061 | - $matches[2][$key] = $matches[6][$key]; |
|
1094 | + if ($matches[6][$key]) { |
|
1095 | + $matches[2][$key] = $matches[6][$key]; |
|
1096 | + } |
|
1062 | 1097 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
1063 | 1098 | { |
1064 | 1099 | $width = $sig_limits[5]; |
1065 | 1100 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
1101 | + } elseif ($matches[2][$key]) { |
|
1102 | + $width = $matches[2][$key]; |
|
1066 | 1103 | } |
1067 | - elseif ($matches[2][$key]) |
|
1068 | - $width = $matches[2][$key]; |
|
1069 | 1104 | // ... and height. |
1070 | 1105 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
1071 | 1106 | { |
1072 | 1107 | $height = $sig_limits[6]; |
1073 | - if ($width != -1) |
|
1074 | - $width = $width * ($height / $matches[4][$key]); |
|
1108 | + if ($width != -1) { |
|
1109 | + $width = $width * ($height / $matches[4][$key]); |
|
1110 | + } |
|
1111 | + } elseif ($matches[4][$key]) { |
|
1112 | + $height = $matches[4][$key]; |
|
1075 | 1113 | } |
1076 | - elseif ($matches[4][$key]) |
|
1077 | - $height = $matches[4][$key]; |
|
1078 | 1114 | |
1079 | 1115 | // If the dimensions are still not fixed - we need to check the actual image. |
1080 | 1116 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -1092,12 +1128,13 @@ discard block |
||
1092 | 1128 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
1093 | 1129 | { |
1094 | 1130 | $height = $sig_limits[6]; |
1095 | - if ($width == -1) |
|
1096 | - $width = $sizes[0]; |
|
1131 | + if ($width == -1) { |
|
1132 | + $width = $sizes[0]; |
|
1133 | + } |
|
1097 | 1134 | $width = $width * ($height / $sizes[1]); |
1135 | + } elseif ($width != -1) { |
|
1136 | + $height = $sizes[1]; |
|
1098 | 1137 | } |
1099 | - elseif ($width != -1) |
|
1100 | - $height = $sizes[1]; |
|
1101 | 1138 | } |
1102 | 1139 | } |
1103 | 1140 | |
@@ -1110,8 +1147,9 @@ discard block |
||
1110 | 1147 | // Record that we got one. |
1111 | 1148 | $image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1; |
1112 | 1149 | } |
1113 | - if (!empty($replaces)) |
|
1114 | - $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1150 | + if (!empty($replaces)) { |
|
1151 | + $sig = str_replace(array_keys($replaces), array_values($replaces), $sig); |
|
1152 | + } |
|
1115 | 1153 | } |
1116 | 1154 | } |
1117 | 1155 | // Try to fix disabled tags. |
@@ -1123,18 +1161,20 @@ discard block |
||
1123 | 1161 | |
1124 | 1162 | $sig = strtr($sig, array("\n" => '<br>')); |
1125 | 1163 | call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); |
1126 | - if ($sig != $row['signature']) |
|
1127 | - $changes[$row['id_member']] = $sig; |
|
1164 | + if ($sig != $row['signature']) { |
|
1165 | + $changes[$row['id_member']] = $sig; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1169 | + $done = true; |
|
1128 | 1170 | } |
1129 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1130 | - $done = true; |
|
1131 | 1171 | $smcFunc['db_free_result']($request); |
1132 | 1172 | |
1133 | 1173 | // Do we need to delete what we have? |
1134 | 1174 | if (!empty($changes)) |
1135 | 1175 | { |
1136 | - foreach ($changes as $id => $sig) |
|
1137 | - $smcFunc['db_query']('', ' |
|
1176 | + foreach ($changes as $id => $sig) { |
|
1177 | + $smcFunc['db_query']('', ' |
|
1138 | 1178 | UPDATE {db_prefix}members |
1139 | 1179 | SET signature = {string:signature} |
1140 | 1180 | WHERE id_member = {int:id_member}', |
@@ -1143,11 +1183,13 @@ discard block |
||
1143 | 1183 | 'signature' => $sig, |
1144 | 1184 | ) |
1145 | 1185 | ); |
1186 | + } |
|
1146 | 1187 | } |
1147 | 1188 | |
1148 | 1189 | $_GET['step'] += 50; |
1149 | - if (!$done) |
|
1150 | - pauseSignatureApplySettings(); |
|
1190 | + if (!$done) { |
|
1191 | + pauseSignatureApplySettings(); |
|
1192 | + } |
|
1151 | 1193 | } |
1152 | 1194 | $settings_applied = true; |
1153 | 1195 | } |
@@ -1165,8 +1207,9 @@ discard block |
||
1165 | 1207 | ); |
1166 | 1208 | |
1167 | 1209 | // Temporarily make each setting a modSetting! |
1168 | - foreach ($context['signature_settings'] as $key => $value) |
|
1169 | - $modSettings['signature_' . $key] = $value; |
|
1210 | + foreach ($context['signature_settings'] as $key => $value) { |
|
1211 | + $modSettings['signature_' . $key] = $value; |
|
1212 | + } |
|
1170 | 1213 | |
1171 | 1214 | // Make sure we check the right tags! |
1172 | 1215 | $modSettings['bbc_disabled_signature_bbc'] = $disabledTags; |
@@ -1178,23 +1221,26 @@ discard block |
||
1178 | 1221 | |
1179 | 1222 | // Clean up the tag stuff! |
1180 | 1223 | $bbcTags = array(); |
1181 | - foreach (parse_bbc(false) as $tag) |
|
1182 | - $bbcTags[] = $tag['tag']; |
|
1224 | + foreach (parse_bbc(false) as $tag) { |
|
1225 | + $bbcTags[] = $tag['tag']; |
|
1226 | + } |
|
1183 | 1227 | |
1184 | - if (!isset($_POST['signature_bbc_enabledTags'])) |
|
1185 | - $_POST['signature_bbc_enabledTags'] = array(); |
|
1186 | - elseif (!is_array($_POST['signature_bbc_enabledTags'])) |
|
1187 | - $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1228 | + if (!isset($_POST['signature_bbc_enabledTags'])) { |
|
1229 | + $_POST['signature_bbc_enabledTags'] = array(); |
|
1230 | + } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { |
|
1231 | + $_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']); |
|
1232 | + } |
|
1188 | 1233 | |
1189 | 1234 | $sig_limits = array(); |
1190 | 1235 | foreach ($context['signature_settings'] as $key => $value) |
1191 | 1236 | { |
1192 | - if ($key == 'allow_smileys') |
|
1193 | - continue; |
|
1194 | - elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) |
|
1195 | - $sig_limits[] = -1; |
|
1196 | - else |
|
1197 | - $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1237 | + if ($key == 'allow_smileys') { |
|
1238 | + continue; |
|
1239 | + } elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) { |
|
1240 | + $sig_limits[] = -1; |
|
1241 | + } else { |
|
1242 | + $sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0; |
|
1243 | + } |
|
1198 | 1244 | } |
1199 | 1245 | |
1200 | 1246 | call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); |
@@ -1227,12 +1273,14 @@ discard block |
||
1227 | 1273 | |
1228 | 1274 | // Try get more time... |
1229 | 1275 | @set_time_limit(600); |
1230 | - if (function_exists('apache_reset_timeout')) |
|
1231 | - @apache_reset_timeout(); |
|
1276 | + if (function_exists('apache_reset_timeout')) { |
|
1277 | + @apache_reset_timeout(); |
|
1278 | + } |
|
1232 | 1279 | |
1233 | 1280 | // Have we exhausted all the time we allowed? |
1234 | - if (time() - array_sum(explode(' ', $sig_start)) < 3) |
|
1235 | - return; |
|
1281 | + if (time() - array_sum(explode(' ', $sig_start)) < 3) { |
|
1282 | + return; |
|
1283 | + } |
|
1236 | 1284 | |
1237 | 1285 | $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
1238 | 1286 | $context['page_title'] = $txt['not_done_title']; |
@@ -1278,9 +1326,10 @@ discard block |
||
1278 | 1326 | $disable_fields = array_flip($standard_fields); |
1279 | 1327 | if (!empty($_POST['active'])) |
1280 | 1328 | { |
1281 | - foreach ($_POST['active'] as $value) |
|
1282 | - if (isset($disable_fields[$value])) |
|
1329 | + foreach ($_POST['active'] as $value) { |
|
1330 | + if (isset($disable_fields[$value])) |
|
1283 | 1331 | unset($disable_fields[$value]); |
1332 | + } |
|
1284 | 1333 | } |
1285 | 1334 | // What we have left! |
1286 | 1335 | $changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields)); |
@@ -1289,16 +1338,18 @@ discard block |
||
1289 | 1338 | $reg_fields = array(); |
1290 | 1339 | if (!empty($_POST['reg'])) |
1291 | 1340 | { |
1292 | - foreach ($_POST['reg'] as $value) |
|
1293 | - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1341 | + foreach ($_POST['reg'] as $value) { |
|
1342 | + if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) |
|
1294 | 1343 | $reg_fields[] = $value; |
1344 | + } |
|
1295 | 1345 | } |
1296 | 1346 | // What we have left! |
1297 | 1347 | $changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields); |
1298 | 1348 | |
1299 | 1349 | $_SESSION['adm-save'] = true; |
1300 | - if (!empty($changes)) |
|
1301 | - updateSettings($changes); |
|
1350 | + if (!empty($changes)) { |
|
1351 | + updateSettings($changes); |
|
1352 | + } |
|
1302 | 1353 | } |
1303 | 1354 | |
1304 | 1355 | createToken('admin-scp'); |
@@ -1401,11 +1452,13 @@ discard block |
||
1401 | 1452 | { |
1402 | 1453 | $return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br>'; |
1403 | 1454 | |
1404 | - if ($rowData['field_order'] > 1) |
|
1405 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1455 | + if ($rowData['field_order'] > 1) { |
|
1456 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>'; |
|
1457 | + } |
|
1406 | 1458 | |
1407 | - if ($rowData['field_order'] < $context['custFieldsMaxOrder']) |
|
1408 | - $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1459 | + if ($rowData['field_order'] < $context['custFieldsMaxOrder']) { |
|
1460 | + $return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>'; |
|
1461 | + } |
|
1409 | 1462 | |
1410 | 1463 | $return .= '</p>'; |
1411 | 1464 | |
@@ -1543,16 +1596,16 @@ discard block |
||
1543 | 1596 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array(); |
1544 | 1597 | $registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array(); |
1545 | 1598 | |
1546 | - foreach ($standard_fields as $field) |
|
1547 | - $list[] = array( |
|
1599 | + foreach ($standard_fields as $field) { |
|
1600 | + $list[] = array( |
|
1548 | 1601 | 'id' => $field, |
1549 | 1602 | 'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field), |
1550 | 1603 | 'disabled' => in_array($field, $disabled_fields), |
1551 | 1604 | 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), |
1552 | 1605 | 'can_show_register' => !in_array($field, $fields_no_registration), |
1553 | 1606 | ); |
1554 | - } |
|
1555 | - else |
|
1607 | + } |
|
1608 | + } else |
|
1556 | 1609 | { |
1557 | 1610 | // Load all the fields. |
1558 | 1611 | $request = $smcFunc['db_query']('', ' |
@@ -1566,8 +1619,9 @@ discard block |
||
1566 | 1619 | 'items_per_page' => $items_per_page, |
1567 | 1620 | ) |
1568 | 1621 | ); |
1569 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1570 | - $list[] = $row; |
|
1622 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1623 | + $list[] = $row; |
|
1624 | + } |
|
1571 | 1625 | $smcFunc['db_free_result']($request); |
1572 | 1626 | } |
1573 | 1627 | |
@@ -1633,9 +1687,9 @@ discard block |
||
1633 | 1687 | $context['field'] = array(); |
1634 | 1688 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1635 | 1689 | { |
1636 | - if ($row['field_type'] == 'textarea') |
|
1637 | - @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1638 | - else |
|
1690 | + if ($row['field_type'] == 'textarea') { |
|
1691 | + @list ($rows, $cols) = @explode(',', $row['default_value']); |
|
1692 | + } else |
|
1639 | 1693 | { |
1640 | 1694 | $rows = 3; |
1641 | 1695 | $cols = 30; |
@@ -1671,8 +1725,8 @@ discard block |
||
1671 | 1725 | } |
1672 | 1726 | |
1673 | 1727 | // Setup the default values as needed. |
1674 | - if (empty($context['field'])) |
|
1675 | - $context['field'] = array( |
|
1728 | + if (empty($context['field'])) { |
|
1729 | + $context['field'] = array( |
|
1676 | 1730 | 'name' => '', |
1677 | 1731 | 'col_name' => '???', |
1678 | 1732 | 'desc' => '', |
@@ -1697,6 +1751,7 @@ discard block |
||
1697 | 1751 | 'enclose' => '', |
1698 | 1752 | 'placement' => 0, |
1699 | 1753 | ); |
1754 | + } |
|
1700 | 1755 | |
1701 | 1756 | // Are we moving it? |
1702 | 1757 | if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to)) |
@@ -1705,8 +1760,10 @@ discard block |
||
1705 | 1760 | $new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1)); |
1706 | 1761 | |
1707 | 1762 | // Is this a valid position? |
1708 | - if ($new_order <= 0 || $new_order > $order_count) |
|
1709 | - redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler |
|
1763 | + if ($new_order <= 0 || $new_order > $order_count) { |
|
1764 | + redirectexit('action=admin;area=featuresettings;sa=profile'); |
|
1765 | + } |
|
1766 | + // @todo implement an error handler |
|
1710 | 1767 | |
1711 | 1768 | // All good, proceed. |
1712 | 1769 | $smcFunc['db_query']('',' |
@@ -1737,12 +1794,14 @@ discard block |
||
1737 | 1794 | validateToken('admin-ecp'); |
1738 | 1795 | |
1739 | 1796 | // Everyone needs a name - even the (bracket) unknown... |
1740 | - if (trim($_POST['field_name']) == '') |
|
1741 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1797 | + if (trim($_POST['field_name']) == '') { |
|
1798 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name'); |
|
1799 | + } |
|
1742 | 1800 | |
1743 | 1801 | // Regex you say? Do a very basic test to see if the pattern is valid |
1744 | - if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) |
|
1745 | - redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1802 | + if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) { |
|
1803 | + redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error'); |
|
1804 | + } |
|
1746 | 1805 | |
1747 | 1806 | $_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']); |
1748 | 1807 | $_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']); |
@@ -1759,8 +1818,9 @@ discard block |
||
1759 | 1818 | |
1760 | 1819 | // Some masking stuff... |
1761 | 1820 | $mask = isset($_POST['mask']) ? $_POST['mask'] : ''; |
1762 | - if ($mask == 'regex' && isset($_POST['regex'])) |
|
1763 | - $mask .= $_POST['regex']; |
|
1821 | + if ($mask == 'regex' && isset($_POST['regex'])) { |
|
1822 | + $mask .= $_POST['regex']; |
|
1823 | + } |
|
1764 | 1824 | |
1765 | 1825 | $field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255; |
1766 | 1826 | $enclose = isset($_POST['enclose']) ? $_POST['enclose'] : ''; |
@@ -1779,8 +1839,9 @@ discard block |
||
1779 | 1839 | $v = strtr($v, array(',' => '')); |
1780 | 1840 | |
1781 | 1841 | // Nada, zip, etc... |
1782 | - if (trim($v) == '') |
|
1783 | - continue; |
|
1842 | + if (trim($v) == '') { |
|
1843 | + continue; |
|
1844 | + } |
|
1784 | 1845 | |
1785 | 1846 | // Otherwise, save it boy. |
1786 | 1847 | $field_options .= $v . ','; |
@@ -1788,15 +1849,17 @@ discard block |
||
1788 | 1849 | $newOptions[$k] = $v; |
1789 | 1850 | |
1790 | 1851 | // Is it default? |
1791 | - if (isset($_POST['default_select']) && $_POST['default_select'] == $k) |
|
1792 | - $default = $v; |
|
1852 | + if (isset($_POST['default_select']) && $_POST['default_select'] == $k) { |
|
1853 | + $default = $v; |
|
1854 | + } |
|
1793 | 1855 | } |
1794 | 1856 | $field_options = substr($field_options, 0, -1); |
1795 | 1857 | } |
1796 | 1858 | |
1797 | 1859 | // Text area has default has dimensions |
1798 | - if ($_POST['field_type'] == 'textarea') |
|
1799 | - $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1860 | + if ($_POST['field_type'] == 'textarea') { |
|
1861 | + $default = (int) $_POST['rows'] . ',' . (int) $_POST['cols']; |
|
1862 | + } |
|
1800 | 1863 | |
1801 | 1864 | // Come up with the unique name? |
1802 | 1865 | if (empty($context['fid'])) |
@@ -1805,32 +1868,36 @@ discard block |
||
1805 | 1868 | preg_match('~([\w\d_-]+)~', $col_name, $matches); |
1806 | 1869 | |
1807 | 1870 | // If there is nothing to the name, then let's start out own - for foreign languages etc. |
1808 | - if (isset($matches[1])) |
|
1809 | - $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1810 | - else |
|
1811 | - $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1871 | + if (isset($matches[1])) { |
|
1872 | + $col_name = $initial_col_name = 'cust_' . strtolower($matches[1]); |
|
1873 | + } else { |
|
1874 | + $col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999); |
|
1875 | + } |
|
1812 | 1876 | |
1813 | 1877 | // Make sure this is unique. |
1814 | 1878 | $current_fields = array(); |
1815 | 1879 | $request = $smcFunc['db_query']('', ' |
1816 | 1880 | SELECT id_field, col_name |
1817 | 1881 | FROM {db_prefix}custom_fields'); |
1818 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1819 | - $current_fields[$row['id_field']] = $row['col_name']; |
|
1882 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1883 | + $current_fields[$row['id_field']] = $row['col_name']; |
|
1884 | + } |
|
1820 | 1885 | $smcFunc['db_free_result']($request); |
1821 | 1886 | |
1822 | 1887 | $unique = false; |
1823 | 1888 | for ($i = 0; !$unique && $i < 9; $i ++) |
1824 | 1889 | { |
1825 | - if (!in_array($col_name, $current_fields)) |
|
1826 | - $unique = true; |
|
1827 | - else |
|
1828 | - $col_name = $initial_col_name . $i; |
|
1890 | + if (!in_array($col_name, $current_fields)) { |
|
1891 | + $unique = true; |
|
1892 | + } else { |
|
1893 | + $col_name = $initial_col_name . $i; |
|
1894 | + } |
|
1829 | 1895 | } |
1830 | 1896 | |
1831 | 1897 | // Still not a unique column name? Leave it up to the user, then. |
1832 | - if (!$unique) |
|
1833 | - fatal_lang_error('custom_option_not_unique'); |
|
1898 | + if (!$unique) { |
|
1899 | + fatal_lang_error('custom_option_not_unique'); |
|
1900 | + } |
|
1834 | 1901 | } |
1835 | 1902 | // Work out what to do with the user data otherwise... |
1836 | 1903 | else |
@@ -1858,8 +1925,9 @@ discard block |
||
1858 | 1925 | // Work out what's changed! |
1859 | 1926 | foreach ($context['field']['options'] as $k => $option) |
1860 | 1927 | { |
1861 | - if (trim($option) == '') |
|
1862 | - continue; |
|
1928 | + if (trim($option) == '') { |
|
1929 | + continue; |
|
1930 | + } |
|
1863 | 1931 | |
1864 | 1932 | // Still exists? |
1865 | 1933 | if (in_array($option, $newOptions)) |
@@ -1873,8 +1941,8 @@ discard block |
||
1873 | 1941 | foreach ($optionChanges as $k => $option) |
1874 | 1942 | { |
1875 | 1943 | // Just been renamed? |
1876 | - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) |
|
1877 | - $smcFunc['db_query']('', ' |
|
1944 | + if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { |
|
1945 | + $smcFunc['db_query']('', ' |
|
1878 | 1946 | UPDATE {db_prefix}themes |
1879 | 1947 | SET value = {string:new_value} |
1880 | 1948 | WHERE variable = {string:current_column} |
@@ -1887,6 +1955,7 @@ discard block |
||
1887 | 1955 | 'old_value' => $option, |
1888 | 1956 | ) |
1889 | 1957 | ); |
1958 | + } |
|
1890 | 1959 | } |
1891 | 1960 | } |
1892 | 1961 | // @todo Maybe we should adjust based on new text length limits? |
@@ -1929,8 +1998,8 @@ discard block |
||
1929 | 1998 | ); |
1930 | 1999 | |
1931 | 2000 | // Just clean up any old selects - these are a pain! |
1932 | - if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) |
|
1933 | - $smcFunc['db_query']('', ' |
|
2001 | + if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) { |
|
2002 | + $smcFunc['db_query']('', ' |
|
1934 | 2003 | DELETE FROM {db_prefix}themes |
1935 | 2004 | WHERE variable = {string:current_column} |
1936 | 2005 | AND value NOT IN ({array_string:new_option_values}) |
@@ -1941,8 +2010,8 @@ discard block |
||
1941 | 2010 | 'current_column' => $context['field']['col_name'], |
1942 | 2011 | ) |
1943 | 2012 | ); |
1944 | - } |
|
1945 | - else |
|
2013 | + } |
|
2014 | + } else |
|
1946 | 2015 | { |
1947 | 2016 | // Gotta figure it out the order. |
1948 | 2017 | $new_order = $order_count > 1 ? ($order_count + 1) : 1; |
@@ -2116,11 +2185,13 @@ discard block |
||
2116 | 2185 | call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false)); |
2117 | 2186 | |
2118 | 2187 | $prune_toggle_dt = array(); |
2119 | - foreach ($prune_toggle as $item) |
|
2120 | - $prune_toggle_dt[] = 'setting_' . $item; |
|
2188 | + foreach ($prune_toggle as $item) { |
|
2189 | + $prune_toggle_dt[] = 'setting_' . $item; |
|
2190 | + } |
|
2121 | 2191 | |
2122 | - if ($return_config) |
|
2123 | - return $config_vars; |
|
2192 | + if ($return_config) { |
|
2193 | + return $config_vars; |
|
2194 | + } |
|
2124 | 2195 | |
2125 | 2196 | addInlineJavaScript(' |
2126 | 2197 | function togglePruned() |
@@ -2158,15 +2229,16 @@ discard block |
||
2158 | 2229 | $vals = array(); |
2159 | 2230 | foreach ($config_vars as $index => $dummy) |
2160 | 2231 | { |
2161 | - if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) |
|
2162 | - continue; |
|
2232 | + if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) { |
|
2233 | + continue; |
|
2234 | + } |
|
2163 | 2235 | |
2164 | 2236 | $vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]]; |
2165 | 2237 | } |
2166 | 2238 | $_POST['pruningOptions'] = implode(',', $vals); |
2239 | + } else { |
|
2240 | + $_POST['pruningOptions'] = ''; |
|
2167 | 2241 | } |
2168 | - else |
|
2169 | - $_POST['pruningOptions'] = ''; |
|
2170 | 2242 | |
2171 | 2243 | saveDBSettings($savevar); |
2172 | 2244 | $_SESSION['adm-save'] = true; |
@@ -2178,10 +2250,11 @@ discard block |
||
2178 | 2250 | $context['sub_template'] = 'show_settings'; |
2179 | 2251 | |
2180 | 2252 | // Get the actual values |
2181 | - if (!empty($modSettings['pruningOptions'])) |
|
2182 | - @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2183 | - else |
|
2184 | - $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2253 | + if (!empty($modSettings['pruningOptions'])) { |
|
2254 | + @list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']); |
|
2255 | + } else { |
|
2256 | + $modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0; |
|
2257 | + } |
|
2185 | 2258 | |
2186 | 2259 | prepareDBSettingContext($config_vars); |
2187 | 2260 | } |
@@ -2203,8 +2276,9 @@ discard block |
||
2203 | 2276 | // Make it even easier to add new settings. |
2204 | 2277 | call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); |
2205 | 2278 | |
2206 | - if ($return_config) |
|
2207 | - return $config_vars; |
|
2279 | + if ($return_config) { |
|
2280 | + return $config_vars; |
|
2281 | + } |
|
2208 | 2282 | |
2209 | 2283 | $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general'; |
2210 | 2284 | $context['settings_title'] = $txt['mods_cat_modifications_misc']; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $query_where = array(); |
167 | 167 | $query_params = $search_data['params']; |
168 | 168 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
169 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
170 | 170 | $modSettings['search_simple_fulltext'] = true; |
171 | 171 | |
172 | 172 | if ($query_params['id_search']) |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | if (!empty($modSettings['search_simple_fulltext'])) |
211 | 211 | { |
212 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
212 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
213 | 213 | { |
214 | 214 | $language_ftx = $smcFunc['db_search_language'](); |
215 | 215 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // remove any indexed words that are used in the complex body search terms |
228 | 228 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
229 | 229 | |
230 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
230 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
231 | 231 | $row = 0; |
232 | 232 | foreach ($words['indexed_words'] as $fulltextWord) { |
233 | 233 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | // if we have bool terms to search, add them in |
245 | 245 | if ($query_params['boolean_match']) { |
246 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
246 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
247 | 247 | { |
248 | 248 | $language_ftx = $smcFunc['db_search_language'](); |
249 | 249 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
259 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
260 | 260 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
261 | 261 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
262 | 262 | SELECT ' . implode(', ', $query_select) . ' |
@@ -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 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,44 +168,54 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
170 | - $modSettings['search_simple_fulltext'] = true; |
|
171 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
172 | + $modSettings['search_simple_fulltext'] = true; |
|
173 | + } |
|
171 | 174 | |
172 | - if ($query_params['id_search']) |
|
173 | - $query_select['id_search'] = '{int:id_search}'; |
|
175 | + if ($query_params['id_search']) { |
|
176 | + $query_select['id_search'] = '{int:id_search}'; |
|
177 | + } |
|
174 | 178 | |
175 | 179 | $count = 0; |
176 | - if (empty($modSettings['search_simple_fulltext'])) |
|
177 | - foreach ($words['words'] as $regularWord) |
|
180 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
181 | + foreach ($words['words'] as $regularWord) |
|
178 | 182 | { |
179 | 183 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
184 | + } |
|
180 | 185 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
181 | 186 | } |
182 | 187 | |
183 | - if ($query_params['user_query']) |
|
184 | - $query_where[] = '{raw:user_query}'; |
|
185 | - if ($query_params['board_query']) |
|
186 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
188 | + if ($query_params['user_query']) { |
|
189 | + $query_where[] = '{raw:user_query}'; |
|
190 | + } |
|
191 | + if ($query_params['board_query']) { |
|
192 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
193 | + } |
|
187 | 194 | |
188 | - if ($query_params['topic']) |
|
189 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
190 | - if ($query_params['min_msg_id']) |
|
191 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
192 | - if ($query_params['max_msg_id']) |
|
193 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
195 | + if ($query_params['topic']) { |
|
196 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
197 | + } |
|
198 | + if ($query_params['min_msg_id']) { |
|
199 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
200 | + } |
|
201 | + if ($query_params['max_msg_id']) { |
|
202 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
203 | + } |
|
194 | 204 | |
195 | 205 | $count = 0; |
196 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
197 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
206 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
207 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
198 | 208 | { |
199 | 209 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
210 | + } |
|
200 | 211 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
201 | 212 | } |
202 | 213 | $count = 0; |
203 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
204 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
214 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
215 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
205 | 216 | { |
206 | 217 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
218 | + } |
|
207 | 219 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
208 | 220 | } |
209 | 221 | |
@@ -215,12 +227,11 @@ discard block |
||
215 | 227 | |
216 | 228 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
217 | 229 | $query_params['language_ftx'] = $language_ftx; |
230 | + } else { |
|
231 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 232 | } |
219 | - else |
|
220 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
221 | 233 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
222 | - } |
|
223 | - else |
|
234 | + } else |
|
224 | 235 | { |
225 | 236 | $query_params['boolean_match'] = ''; |
226 | 237 | |
@@ -234,10 +245,10 @@ discard block |
||
234 | 245 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
235 | 246 | $row++; |
236 | 247 | } |
237 | - } |
|
238 | - else |
|
239 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
248 | + } else { |
|
249 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
240 | 250 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
251 | + } |
|
241 | 252 | |
242 | 253 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
243 | 254 | |
@@ -249,9 +260,9 @@ discard block |
||
249 | 260 | |
250 | 261 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
251 | 262 | $query_params['language_ftx'] = $language_ftx; |
263 | + } else { |
|
264 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 265 | } |
253 | - else |
|
254 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
255 | 266 | } |
256 | 267 | |
257 | 268 | } |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
257 | 257 | |
258 | 258 | $js_time_string = str_replace( |
259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
261 | 261 | $time_string |
262 | 262 | ); |
263 | 263 | |
@@ -1305,14 +1305,14 @@ discard block |
||
1305 | 1305 | if (isset($context['name']) && isset($context['email'])) |
1306 | 1306 | { |
1307 | 1307 | $context['posting_fields']['guestname'] = array( |
1308 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1308 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1309 | 1309 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" required>', |
1310 | 1310 | ); |
1311 | 1311 | |
1312 | 1312 | if (empty($modSettings['guest_post_no_email'])) |
1313 | 1313 | { |
1314 | 1314 | $context['posting_fields']['email'] = array( |
1315 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1315 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1316 | 1316 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" required>', |
1317 | 1317 | ); |
1318 | 1318 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
55 | 58 | |
56 | 59 | // You must be posting to *some* board. |
57 | - if (empty($board) && !$context['make_event']) |
|
58 | - fatal_lang_error('no_board', false); |
|
60 | + if (empty($board) && !$context['make_event']) { |
|
61 | + fatal_lang_error('no_board', false); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
78 | 82 | array( |
79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
80 | 84 | )); |
81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
83 | - else |
|
84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
87 | + } else { |
|
88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
89 | + } |
|
85 | 90 | $smcFunc['db_free_result']($request); |
86 | 91 | } |
87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | 115 | // If this topic already has a poll, they sure can't add another. |
111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
112 | - unset($_REQUEST['poll']); |
|
116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
117 | + unset($_REQUEST['poll']); |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (empty($_REQUEST['msg'])) |
115 | 121 | { |
116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
117 | - is_not_guest(); |
|
122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
123 | + is_not_guest(); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | // By default the reply will be approved... |
120 | 127 | $context['becomes_approved'] = true; |
121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
122 | 129 | { |
123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
124 | - $context['becomes_approved'] = false; |
|
125 | - else |
|
126 | - isAllowedTo('post_reply_any'); |
|
127 | - } |
|
128 | - elseif (!allowedTo('post_reply_any')) |
|
130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
131 | + $context['becomes_approved'] = false; |
|
132 | + } else { |
|
133 | + isAllowedTo('post_reply_any'); |
|
134 | + } |
|
135 | + } elseif (!allowedTo('post_reply_any')) |
|
129 | 136 | { |
130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
131 | - $context['becomes_approved'] = false; |
|
132 | - else |
|
133 | - isAllowedTo('post_reply_own'); |
|
137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
138 | + $context['becomes_approved'] = false; |
|
139 | + } else { |
|
140 | + isAllowedTo('post_reply_own'); |
|
141 | + } |
|
134 | 142 | } |
143 | + } else { |
|
144 | + $context['becomes_approved'] = true; |
|
135 | 145 | } |
136 | - else |
|
137 | - $context['becomes_approved'] = true; |
|
138 | 146 | |
139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
147 | 155 | |
148 | 156 | // Check whether this is a really old post being bumped... |
149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
151 | - } |
|
152 | - else |
|
157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
159 | + } |
|
160 | + } else |
|
153 | 161 | { |
154 | 162 | $context['becomes_approved'] = true; |
155 | 163 | if ((!$context['make_event'] || !empty($board))) |
156 | 164 | { |
157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
158 | - $context['becomes_approved'] = false; |
|
159 | - else |
|
160 | - isAllowedTo('post_new'); |
|
165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
166 | + $context['becomes_approved'] = false; |
|
167 | + } else { |
|
168 | + isAllowedTo('post_new'); |
|
169 | + } |
|
161 | 170 | } |
162 | 171 | |
163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
193 | 202 | } |
194 | 203 | |
195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
196 | - if ($locked && !allowedTo('moderate_board')) |
|
197 | - fatal_lang_error('topic_locked', false); |
|
205 | + if ($locked && !allowedTo('moderate_board')) { |
|
206 | + fatal_lang_error('topic_locked', false); |
|
207 | + } |
|
198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
200 | 210 | { |
201 | 211 | // New topic, new poll. |
202 | - if (empty($topic)) |
|
203 | - isAllowedTo('poll_post'); |
|
212 | + if (empty($topic)) { |
|
213 | + isAllowedTo('poll_post'); |
|
214 | + } |
|
204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
206 | - isAllowedTo('poll_add_own'); |
|
216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
217 | + isAllowedTo('poll_add_own'); |
|
218 | + } |
|
207 | 219 | // If you're not the owner, can you add to any poll? |
208 | - else |
|
209 | - isAllowedTo('poll_add_any'); |
|
220 | + else { |
|
221 | + isAllowedTo('poll_add_any'); |
|
222 | + } |
|
210 | 223 | |
211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
235 | 248 | if ($context['make_event']) |
236 | 249 | { |
237 | 250 | // They might want to pick a board. |
238 | - if (!isset($context['current_board'])) |
|
239 | - $context['current_board'] = 0; |
|
251 | + if (!isset($context['current_board'])) { |
|
252 | + $context['current_board'] = 0; |
|
253 | + } |
|
240 | 254 | |
241 | 255 | // Start loading up the event info. |
242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
250 | 264 | isAllowedTo('calendar_post'); |
251 | 265 | |
252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
254 | - $time_string = '%k:%M'; |
|
255 | - else |
|
256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
268 | + $time_string = '%k:%M'; |
|
269 | + } else { |
|
270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | $js_time_string = str_replace( |
259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
278 | - } |
|
279 | - else |
|
293 | + } else |
|
280 | 294 | { |
281 | 295 | // Get the current event information. |
282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
285 | 299 | |
286 | 300 | // Make sure the year and month are in the valid range. |
287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
288 | - fatal_lang_error('invalid_month', false); |
|
289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
290 | - fatal_lang_error('invalid_year', false); |
|
301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
302 | + fatal_lang_error('invalid_month', false); |
|
303 | + } |
|
304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
305 | + fatal_lang_error('invalid_year', false); |
|
306 | + } |
|
291 | 307 | |
292 | 308 | // Get a list of boards they can post in. |
293 | 309 | $boards = boardsAllowedTo('post_new'); |
294 | - if (empty($boards)) |
|
295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
310 | + if (empty($boards)) { |
|
311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
312 | + } |
|
296 | 313 | |
297 | 314 | // Load a list of boards for this event in the context. |
298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
411 | 428 | |
412 | 429 | if (!empty($context['new_replies'])) |
413 | 430 | { |
414 | - if ($context['new_replies'] == 1) |
|
415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
416 | - else |
|
417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
431 | + if ($context['new_replies'] == 1) { |
|
432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
433 | + } else { |
|
434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | $post_errors[] = 'new_replies'; |
420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
428 | 446 | { |
429 | - if ($language === $user_info['language']) |
|
430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
431 | - else |
|
447 | + if ($language === $user_info['language']) { |
|
448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
449 | + } else |
|
432 | 450 | { |
433 | 451 | loadLanguage('index', $language, false); |
434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
441 | 459 | // Do we have a body, but an error happened. |
442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
443 | 461 | { |
444 | - if (isset($_REQUEST['quickReply'])) |
|
445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
462 | + if (isset($_REQUEST['quickReply'])) { |
|
463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
464 | + } |
|
446 | 465 | |
447 | 466 | // Validate inputs. |
448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
450 | 469 | // This means they didn't click Post and get an error. |
451 | 470 | $really_previewing = true; |
452 | 471 | |
453 | - } |
|
454 | - else |
|
472 | + } else |
|
455 | 473 | { |
456 | - if (!isset($_REQUEST['subject'])) |
|
457 | - $_REQUEST['subject'] = ''; |
|
458 | - if (!isset($_REQUEST['message'])) |
|
459 | - $_REQUEST['message'] = ''; |
|
460 | - if (!isset($_REQUEST['icon'])) |
|
461 | - $_REQUEST['icon'] = 'xx'; |
|
474 | + if (!isset($_REQUEST['subject'])) { |
|
475 | + $_REQUEST['subject'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['message'])) { |
|
478 | + $_REQUEST['message'] = ''; |
|
479 | + } |
|
480 | + if (!isset($_REQUEST['icon'])) { |
|
481 | + $_REQUEST['icon'] = 'xx'; |
|
482 | + } |
|
462 | 483 | |
463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
475 | 496 | |
476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if (isset($_REQUEST['poll'])) |
481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
488 | 510 | foreach ($_POST['options'] as $option) |
489 | 511 | { |
490 | - if (trim($option) == '') |
|
491 | - continue; |
|
512 | + if (trim($option) == '') { |
|
513 | + continue; |
|
514 | + } |
|
492 | 515 | |
493 | 516 | $context['choices'][] = array( |
494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
550 | 573 | $context['preview_subject'] = $form_subject; |
551 | 574 | |
552 | 575 | censorText($context['preview_subject']); |
576 | + } else { |
|
577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 578 | } |
554 | - else |
|
555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
556 | 579 | |
557 | 580 | // Protect any CDATA blocks. |
558 | - if (isset($_REQUEST['xml'])) |
|
559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
581 | + if (isset($_REQUEST['xml'])) { |
|
582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
599 | - fatal_lang_error('no_board', false); |
|
622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
623 | + fatal_lang_error('no_board', false); |
|
624 | + } |
|
600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
601 | 626 | |
602 | 627 | $attachment_stuff = array($row); |
603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
604 | - $attachment_stuff[] = $row2; |
|
628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
629 | + $attachment_stuff[] = $row2; |
|
630 | + } |
|
605 | 631 | $smcFunc['db_free_result']($request); |
606 | 632 | |
607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
608 | 634 | { |
609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
611 | - fatal_lang_error('modify_post_time_passed', false); |
|
612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
613 | - isAllowedTo('modify_replies'); |
|
614 | - else |
|
615 | - isAllowedTo('modify_own'); |
|
636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
637 | + fatal_lang_error('modify_post_time_passed', false); |
|
638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
639 | + isAllowedTo('modify_replies'); |
|
640 | + } else { |
|
641 | + isAllowedTo('modify_own'); |
|
642 | + } |
|
643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
644 | + isAllowedTo('modify_replies'); |
|
645 | + } else { |
|
646 | + isAllowedTo('modify_any'); |
|
616 | 647 | } |
617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
618 | - isAllowedTo('modify_replies'); |
|
619 | - else |
|
620 | - isAllowedTo('modify_any'); |
|
621 | 648 | |
622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
641 | 668 | |
642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
643 | 670 | { |
644 | - if ($row['filesize'] <= 0) |
|
645 | - continue; |
|
671 | + if ($row['filesize'] <= 0) { |
|
672 | + continue; |
|
673 | + } |
|
646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
712 | 740 | ) |
713 | 741 | ); |
714 | 742 | // The message they were trying to edit was most likely deleted. |
715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
716 | - fatal_lang_error('no_message', false); |
|
743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
744 | + fatal_lang_error('no_message', false); |
|
745 | + } |
|
717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
718 | 747 | |
719 | 748 | $attachment_stuff = array($row); |
720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
721 | - $attachment_stuff[] = $row2; |
|
749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
750 | + $attachment_stuff[] = $row2; |
|
751 | + } |
|
722 | 752 | $smcFunc['db_free_result']($request); |
723 | 753 | |
724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
725 | 755 | { |
726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
728 | - fatal_lang_error('modify_post_time_passed', false); |
|
729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
730 | - isAllowedTo('modify_replies'); |
|
731 | - else |
|
732 | - isAllowedTo('modify_own'); |
|
757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
758 | + fatal_lang_error('modify_post_time_passed', false); |
|
759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
760 | + isAllowedTo('modify_replies'); |
|
761 | + } else { |
|
762 | + isAllowedTo('modify_own'); |
|
763 | + } |
|
764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
765 | + isAllowedTo('modify_replies'); |
|
766 | + } else { |
|
767 | + isAllowedTo('modify_any'); |
|
733 | 768 | } |
734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
735 | - isAllowedTo('modify_replies'); |
|
736 | - else |
|
737 | - isAllowedTo('modify_any'); |
|
738 | 769 | |
739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
761 | 792 | $context['icon'] = $row['icon']; |
762 | 793 | |
763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
764 | - if (!$row['approved'] && !$context['show_approval']) |
|
765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
797 | + } |
|
766 | 798 | |
767 | 799 | // Sort the attachments so they are in the order saved |
768 | 800 | $temp = array(); |
769 | 801 | foreach ($attachment_stuff as $attachment) |
770 | 802 | { |
771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
772 | - $temp[$attachment['id_attach']] = $attachment; |
|
803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
804 | + $temp[$attachment['id_attach']] = $attachment; |
|
805 | + } |
|
773 | 806 | |
774 | 807 | } |
775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
831 | 864 | 'is_approved' => 1, |
832 | 865 | ) |
833 | 866 | ); |
834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
835 | - fatal_lang_error('quoted_post_deleted', false); |
|
867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
868 | + fatal_lang_error('quoted_post_deleted', false); |
|
869 | + } |
|
836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
837 | 871 | $smcFunc['db_free_result']($request); |
838 | 872 | |
839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
876 | + } |
|
842 | 877 | |
843 | 878 | // Censor the message and subject. |
844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
852 | 887 | { |
853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
854 | - if ($i % 4 == 0) |
|
855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
889 | + if ($i % 4 == 0) { |
|
890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
856 | 891 | { |
857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
893 | + } |
|
858 | 894 | }, $parts[$i]); |
859 | 895 | } |
860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
864 | 900 | |
865 | 901 | // Remove any nested quotes, if necessary. |
866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
904 | + } |
|
868 | 905 | |
869 | 906 | // Add a quote string on the front and end. |
870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
876 | 913 | $form_subject = $first_subject; |
877 | 914 | |
878 | 915 | // Add 'Re: ' to the front of the subject. |
879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
918 | + } |
|
881 | 919 | |
882 | 920 | // Censor the subject. |
883 | 921 | censorText($form_subject); |
884 | 922 | |
885 | 923 | $form_message = ''; |
886 | - } |
|
887 | - else |
|
924 | + } else |
|
888 | 925 | { |
889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
902 | 939 | if (isset($_REQUEST['msg'])) |
903 | 940 | { |
904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
905 | - foreach ($context['current_attachments'] as $attachment) |
|
906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
942 | + foreach ($context['current_attachments'] as $attachment) { |
|
943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
944 | + } |
|
907 | 945 | } |
908 | 946 | |
909 | 947 | // A bit of house keeping first. |
910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
911 | - unset($_SESSION['temp_attachments']); |
|
948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
949 | + unset($_SESSION['temp_attachments']); |
|
950 | + } |
|
912 | 951 | |
913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
917 | 956 | { |
918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
919 | 958 | { |
920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
921 | - if (file_exists($attachment['tmp_name'])) |
|
959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
960 | + if (file_exists($attachment['tmp_name'])) |
|
922 | 961 | unlink($attachment['tmp_name']); |
962 | + } |
|
923 | 963 | } |
924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
935 | 975 | { |
936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
937 | - continue; |
|
976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
977 | + continue; |
|
978 | + } |
|
938 | 979 | |
939 | 980 | if (file_exists($attachment['tmp_name'])) |
940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
944 | 985 | break; |
945 | 986 | } |
946 | 987 | } |
947 | - } |
|
948 | - else |
|
988 | + } else |
|
949 | 989 | { |
950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
951 | - if (!empty($topic)) |
|
952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
953 | - else |
|
954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
991 | + if (!empty($topic)) { |
|
992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
993 | + } else { |
|
994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
995 | + } |
|
955 | 996 | |
956 | 997 | // Compile a list of the files to show the user. |
957 | 998 | $file_list = array(); |
958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
960 | 1001 | $file_list[] = $attachment['name']; |
1002 | + } |
|
961 | 1003 | |
962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
969 | 1011 | |
970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
971 | 1013 | $context['ignore_temp_attachments'] = true; |
972 | - } |
|
973 | - else |
|
1014 | + } else |
|
974 | 1015 | { |
975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
978 | 1019 | } |
979 | 1020 | } |
980 | 1021 | |
981 | - if (!empty($context['we_are_history'])) |
|
982 | - $post_errors[] = $context['we_are_history']; |
|
1022 | + if (!empty($context['we_are_history'])) { |
|
1023 | + $post_errors[] = $context['we_are_history']; |
|
1024 | + } |
|
983 | 1025 | |
984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
985 | 1027 | { |
986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
987 | - break; |
|
1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1029 | + break; |
|
1030 | + } |
|
988 | 1031 | |
989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
990 | - continue; |
|
1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1033 | + continue; |
|
1034 | + } |
|
991 | 1035 | |
992 | 1036 | if ($attachID == 'initial_error') |
993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
1002 | 1046 | { |
1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1005 | - foreach ($attachment['errors'] as $error) |
|
1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1049 | + foreach ($attachment['errors'] as $error) { |
|
1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1051 | + } |
|
1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
1008 | 1053 | $post_errors[] = 'attach_errors'; |
1009 | 1054 | |
1010 | 1055 | // Take out the trash. |
1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
1012 | - if (file_exists($attachment['tmp_name'])) |
|
1013 | - unlink($attachment['tmp_name']); |
|
1057 | + if (file_exists($attachment['tmp_name'])) { |
|
1058 | + unlink($attachment['tmp_name']); |
|
1059 | + } |
|
1014 | 1060 | continue; |
1015 | 1061 | } |
1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
1023 | 1069 | |
1024 | 1070 | $context['attachments']['quantity']++; |
1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
1026 | - if (!isset($context['files_in_session_warning'])) |
|
1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1072 | + if (!isset($context['files_in_session_warning'])) { |
|
1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1074 | + } |
|
1028 | 1075 | |
1029 | 1076 | $context['current_attachments'][$attachID] = array( |
1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
1052 | 1099 | } |
1053 | 1100 | |
1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1056 | - $post_errors[] = 'need_qr_verification'; |
|
1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1103 | + $post_errors[] = 'need_qr_verification'; |
|
1104 | + } |
|
1057 | 1105 | |
1058 | 1106 | /* |
1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
1070 | 1118 | { |
1071 | 1119 | loadLanguage('Errors'); |
1072 | 1120 | $context['error_type'] = 'minor'; |
1073 | - foreach ($post_errors as $post_error) |
|
1074 | - if (is_array($post_error)) |
|
1121 | + foreach ($post_errors as $post_error) { |
|
1122 | + if (is_array($post_error)) |
|
1075 | 1123 | { |
1076 | 1124 | $post_error_id = $post_error[0]; |
1125 | + } |
|
1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1078 | 1127 | |
1079 | 1128 | // If it's not a minor error flag it as such. |
1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
1081 | - $context['error_type'] = 'serious'; |
|
1082 | - } |
|
1083 | - else |
|
1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1130 | + $context['error_type'] = 'serious'; |
|
1131 | + } |
|
1132 | + } else |
|
1084 | 1133 | { |
1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1086 | 1135 | |
1087 | 1136 | // If it's not a minor error flag it as such. |
1088 | - if (!in_array($post_error, $minor_errors)) |
|
1089 | - $context['error_type'] = 'serious'; |
|
1137 | + if (!in_array($post_error, $minor_errors)) { |
|
1138 | + $context['error_type'] = 'serious'; |
|
1139 | + } |
|
1090 | 1140 | } |
1091 | 1141 | } |
1092 | 1142 | |
1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1094 | - if (isset($_REQUEST['poll'])) |
|
1095 | - $context['page_title'] = $txt['new_poll']; |
|
1096 | - elseif ($context['make_event']) |
|
1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1098 | - elseif (isset($_REQUEST['msg'])) |
|
1099 | - $context['page_title'] = $txt['modify_msg']; |
|
1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1102 | - elseif (empty($topic)) |
|
1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
1104 | - else |
|
1105 | - $context['page_title'] = $txt['post_reply']; |
|
1144 | + if (isset($_REQUEST['poll'])) { |
|
1145 | + $context['page_title'] = $txt['new_poll']; |
|
1146 | + } elseif ($context['make_event']) { |
|
1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
1149 | + $context['page_title'] = $txt['modify_msg']; |
|
1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1152 | + } elseif (empty($topic)) { |
|
1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
1154 | + } else { |
|
1155 | + $context['page_title'] = $txt['post_reply']; |
|
1156 | + } |
|
1106 | 1157 | |
1107 | 1158 | // Build the link tree. |
1108 | - if (empty($topic)) |
|
1109 | - $context['linktree'][] = array( |
|
1159 | + if (empty($topic)) { |
|
1160 | + $context['linktree'][] = array( |
|
1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1111 | 1162 | ); |
1112 | - else |
|
1113 | - $context['linktree'][] = array( |
|
1163 | + } else { |
|
1164 | + $context['linktree'][] = array( |
|
1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1115 | 1166 | 'name' => $form_subject, |
1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1118 | 1169 | ); |
1170 | + } |
|
1119 | 1171 | |
1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
1159 | 1211 | // Message icons - customized icons are off? |
1160 | 1212 | $context['icons'] = getMessageIcons($board); |
1161 | 1213 | |
1162 | - if (!empty($context['icons'])) |
|
1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1214 | + if (!empty($context['icons'])) { |
|
1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1216 | + } |
|
1164 | 1217 | |
1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1181 | 1234 | { |
1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1183 | - if ($context['icons'][$i]['selected']) |
|
1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1236 | + if ($context['icons'][$i]['selected']) { |
|
1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1238 | + } |
|
1185 | 1239 | } |
1186 | 1240 | if (empty($context['icon_url'])) |
1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
1195 | 1249 | )); |
1196 | 1250 | } |
1197 | 1251 | |
1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1199 | - getTopic(); |
|
1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1253 | + getTopic(); |
|
1254 | + } |
|
1200 | 1255 | |
1201 | 1256 | // If the user can post attachments prepare the warning labels. |
1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
1207 | 1262 | $context['attachment_restrictions'] = array(); |
1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
1211 | - if (!empty($modSettings[$type])) |
|
1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1266 | + if (!empty($modSettings[$type])) |
|
1212 | 1267 | { |
1213 | 1268 | // Show the max number of attachments if not 0. |
1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1271 | + } |
|
1216 | 1272 | } |
1217 | 1273 | } |
1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
1246 | 1302 | |
1247 | 1303 | if (!empty($context['current_attachments'])) |
1248 | 1304 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1306 | + addInlineJavaScript(' |
|
1251 | 1307 | current_attachments.push({ |
1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1314 | });', true); |
1315 | + } |
|
1259 | 1316 | } |
1260 | 1317 | |
1261 | 1318 | // File Upload. |
@@ -1340,8 +1397,9 @@ discard block |
||
1340 | 1397 | |
1341 | 1398 | |
1342 | 1399 | // Finally, load the template. |
1343 | - if (!isset($_REQUEST['xml'])) |
|
1344 | - loadTemplate('Post'); |
|
1400 | + if (!isset($_REQUEST['xml'])) { |
|
1401 | + loadTemplate('Post'); |
|
1402 | + } |
|
1345 | 1403 | |
1346 | 1404 | call_integration_hook('integrate_post_end'); |
1347 | 1405 | } |
@@ -1362,13 +1420,14 @@ discard block |
||
1362 | 1420 | // Sneaking off, are we? |
1363 | 1421 | if (empty($_POST) && empty($topic)) |
1364 | 1422 | { |
1365 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1366 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1367 | - else |
|
1368 | - fatal_lang_error('post_upload_error', false); |
|
1423 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1424 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1425 | + } else { |
|
1426 | + fatal_lang_error('post_upload_error', false); |
|
1427 | + } |
|
1428 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1429 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1369 | 1430 | } |
1370 | - elseif (empty($_POST) && !empty($topic)) |
|
1371 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1372 | 1431 | |
1373 | 1432 | // No need! |
1374 | 1433 | $context['robot_no_index'] = true; |
@@ -1380,8 +1439,9 @@ discard block |
||
1380 | 1439 | $post_errors = array(); |
1381 | 1440 | |
1382 | 1441 | // If the session has timed out, let the user re-submit their form. |
1383 | - if (checkSession('post', '', false) != '') |
|
1384 | - $post_errors[] = 'session_timeout'; |
|
1442 | + if (checkSession('post', '', false) != '') { |
|
1443 | + $post_errors[] = 'session_timeout'; |
|
1444 | + } |
|
1385 | 1445 | |
1386 | 1446 | // Wrong verification code? |
1387 | 1447 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1391,33 +1451,38 @@ discard block |
||
1391 | 1451 | 'id' => 'post', |
1392 | 1452 | ); |
1393 | 1453 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1394 | - if (is_array($context['require_verification'])) |
|
1395 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1454 | + if (is_array($context['require_verification'])) { |
|
1455 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1456 | + } |
|
1396 | 1457 | } |
1397 | 1458 | |
1398 | 1459 | require_once($sourcedir . '/Subs-Post.php'); |
1399 | 1460 | loadLanguage('Post'); |
1400 | 1461 | |
1401 | 1462 | // Drafts enabled and needed? |
1402 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1403 | - require_once($sourcedir . '/Drafts.php'); |
|
1463 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1464 | + require_once($sourcedir . '/Drafts.php'); |
|
1465 | + } |
|
1404 | 1466 | |
1405 | 1467 | // First check to see if they are trying to delete any current attachments. |
1406 | 1468 | if (isset($_POST['attach_del'])) |
1407 | 1469 | { |
1408 | 1470 | $keep_temp = array(); |
1409 | 1471 | $keep_ids = array(); |
1410 | - foreach ($_POST['attach_del'] as $dummy) |
|
1411 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1472 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1473 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1412 | 1474 | $keep_temp[] = $dummy; |
1413 | - else |
|
1414 | - $keep_ids[] = (int) $dummy; |
|
1475 | + } |
|
1476 | + else { |
|
1477 | + $keep_ids[] = (int) $dummy; |
|
1478 | + } |
|
1415 | 1479 | |
1416 | - if (isset($_SESSION['temp_attachments'])) |
|
1417 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1480 | + if (isset($_SESSION['temp_attachments'])) { |
|
1481 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1418 | 1482 | { |
1419 | 1483 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1420 | 1484 | continue; |
1485 | + } |
|
1421 | 1486 | |
1422 | 1487 | unset($_SESSION['temp_attachments'][$attachID]); |
1423 | 1488 | unlink($attachment['tmp_name']); |
@@ -1459,12 +1524,14 @@ discard block |
||
1459 | 1524 | $smcFunc['db_free_result']($request); |
1460 | 1525 | |
1461 | 1526 | // Though the topic should be there, it might have vanished. |
1462 | - if (!is_array($topic_info)) |
|
1463 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1527 | + if (!is_array($topic_info)) { |
|
1528 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1529 | + } |
|
1464 | 1530 | |
1465 | 1531 | // Did this topic suddenly move? Just checking... |
1466 | - if ($topic_info['id_board'] != $board) |
|
1467 | - fatal_lang_error('not_a_topic'); |
|
1532 | + if ($topic_info['id_board'] != $board) { |
|
1533 | + fatal_lang_error('not_a_topic'); |
|
1534 | + } |
|
1468 | 1535 | |
1469 | 1536 | // Do the permissions and approval stuff... |
1470 | 1537 | $becomesApproved = true; |
@@ -1487,49 +1554,50 @@ discard block |
||
1487 | 1554 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1488 | 1555 | { |
1489 | 1556 | // Don't allow a post if it's locked. |
1490 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1491 | - fatal_lang_error('topic_locked', false); |
|
1557 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1558 | + fatal_lang_error('topic_locked', false); |
|
1559 | + } |
|
1492 | 1560 | |
1493 | 1561 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1494 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1495 | - unset($_REQUEST['poll']); |
|
1496 | - |
|
1497 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1498 | - { |
|
1499 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1500 | - $becomesApproved = false; |
|
1501 | - |
|
1502 | - else |
|
1503 | - isAllowedTo('post_reply_any'); |
|
1504 | - } |
|
1505 | - elseif (!allowedTo('post_reply_any')) |
|
1562 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1563 | + unset($_REQUEST['poll']); |
|
1564 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1565 | + { |
|
1566 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1567 | + $becomesApproved = false; |
|
1568 | + } else { |
|
1569 | + isAllowedTo('post_reply_any'); |
|
1570 | + } |
|
1571 | + } elseif (!allowedTo('post_reply_any')) |
|
1506 | 1572 | { |
1507 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1508 | - $becomesApproved = false; |
|
1509 | - |
|
1510 | - else |
|
1511 | - isAllowedTo('post_reply_own'); |
|
1573 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1574 | + $becomesApproved = false; |
|
1575 | + } else { |
|
1576 | + isAllowedTo('post_reply_own'); |
|
1577 | + } |
|
1512 | 1578 | } |
1513 | 1579 | |
1514 | 1580 | if (isset($_POST['lock'])) |
1515 | 1581 | { |
1516 | 1582 | // Nothing is changed to the lock. |
1517 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1518 | - unset($_POST['lock']); |
|
1583 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1584 | + unset($_POST['lock']); |
|
1585 | + } |
|
1519 | 1586 | |
1520 | 1587 | // You're have no permission to lock this topic. |
1521 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1522 | - unset($_POST['lock']); |
|
1588 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1589 | + unset($_POST['lock']); |
|
1590 | + } |
|
1523 | 1591 | |
1524 | 1592 | // You are allowed to (un)lock your own topic only. |
1525 | 1593 | elseif (!allowedTo('lock_any')) |
1526 | 1594 | { |
1527 | 1595 | // You cannot override a moderator lock. |
1528 | - if ($topic_info['locked'] == 1) |
|
1529 | - unset($_POST['lock']); |
|
1530 | - |
|
1531 | - else |
|
1532 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1596 | + if ($topic_info['locked'] == 1) { |
|
1597 | + unset($_POST['lock']); |
|
1598 | + } else { |
|
1599 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1600 | + } |
|
1533 | 1601 | } |
1534 | 1602 | // Hail mighty moderator, (un)lock this topic immediately. |
1535 | 1603 | else |
@@ -1537,19 +1605,21 @@ discard block |
||
1537 | 1605 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1538 | 1606 | |
1539 | 1607 | // Did someone (un)lock this while you were posting? |
1540 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1541 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1608 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1609 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1610 | + } |
|
1542 | 1611 | } |
1543 | 1612 | } |
1544 | 1613 | |
1545 | 1614 | // So you wanna (un)sticky this...let's see. |
1546 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1547 | - unset($_POST['sticky']); |
|
1548 | - elseif (isset($_POST['sticky'])) |
|
1615 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1616 | + unset($_POST['sticky']); |
|
1617 | + } elseif (isset($_POST['sticky'])) |
|
1549 | 1618 | { |
1550 | 1619 | // Did someone (un)sticky this while you were posting? |
1551 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1552 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1620 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1621 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1622 | + } |
|
1553 | 1623 | } |
1554 | 1624 | |
1555 | 1625 | // If drafts are enabled, then pass this off |
@@ -1576,26 +1646,31 @@ discard block |
||
1576 | 1646 | |
1577 | 1647 | // Do like, the permissions, for safety and stuff... |
1578 | 1648 | $becomesApproved = true; |
1579 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1580 | - $becomesApproved = false; |
|
1581 | - else |
|
1582 | - isAllowedTo('post_new'); |
|
1649 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1650 | + $becomesApproved = false; |
|
1651 | + } else { |
|
1652 | + isAllowedTo('post_new'); |
|
1653 | + } |
|
1583 | 1654 | |
1584 | 1655 | if (isset($_POST['lock'])) |
1585 | 1656 | { |
1586 | 1657 | // New topics are by default not locked. |
1587 | - if (empty($_POST['lock'])) |
|
1588 | - unset($_POST['lock']); |
|
1658 | + if (empty($_POST['lock'])) { |
|
1659 | + unset($_POST['lock']); |
|
1660 | + } |
|
1589 | 1661 | // Besides, you need permission. |
1590 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1591 | - unset($_POST['lock']); |
|
1662 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1663 | + unset($_POST['lock']); |
|
1664 | + } |
|
1592 | 1665 | // A moderator-lock (1) can override a user-lock (2). |
1593 | - else |
|
1594 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1666 | + else { |
|
1667 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1668 | + } |
|
1595 | 1669 | } |
1596 | 1670 | |
1597 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1598 | - unset($_POST['sticky']); |
|
1671 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1672 | + unset($_POST['sticky']); |
|
1673 | + } |
|
1599 | 1674 | |
1600 | 1675 | // Saving your new topic as a draft first? |
1601 | 1676 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1620,31 +1695,37 @@ discard block |
||
1620 | 1695 | 'id_msg' => $_REQUEST['msg'], |
1621 | 1696 | ) |
1622 | 1697 | ); |
1623 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1624 | - fatal_lang_error('cant_find_messages', false); |
|
1698 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1699 | + fatal_lang_error('cant_find_messages', false); |
|
1700 | + } |
|
1625 | 1701 | $row = $smcFunc['db_fetch_assoc']($request); |
1626 | 1702 | $smcFunc['db_free_result']($request); |
1627 | 1703 | |
1628 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1629 | - fatal_lang_error('topic_locked', false); |
|
1704 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1705 | + fatal_lang_error('topic_locked', false); |
|
1706 | + } |
|
1630 | 1707 | |
1631 | 1708 | if (isset($_POST['lock'])) |
1632 | 1709 | { |
1633 | 1710 | // Nothing changes to the lock status. |
1634 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1635 | - unset($_POST['lock']); |
|
1711 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1712 | + unset($_POST['lock']); |
|
1713 | + } |
|
1636 | 1714 | // You're simply not allowed to (un)lock this. |
1637 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1638 | - unset($_POST['lock']); |
|
1715 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1716 | + unset($_POST['lock']); |
|
1717 | + } |
|
1639 | 1718 | // You're only allowed to lock your own topics. |
1640 | 1719 | elseif (!allowedTo('lock_any')) |
1641 | 1720 | { |
1642 | 1721 | // You're not allowed to break a moderator's lock. |
1643 | - if ($topic_info['locked'] == 1) |
|
1644 | - unset($_POST['lock']); |
|
1722 | + if ($topic_info['locked'] == 1) { |
|
1723 | + unset($_POST['lock']); |
|
1724 | + } |
|
1645 | 1725 | // Lock it with a soft lock or unlock it. |
1646 | - else |
|
1647 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1726 | + else { |
|
1727 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1728 | + } |
|
1648 | 1729 | } |
1649 | 1730 | // You must be the moderator. |
1650 | 1731 | else |
@@ -1652,44 +1733,46 @@ discard block |
||
1652 | 1733 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1653 | 1734 | |
1654 | 1735 | // Did someone (un)lock this while you were posting? |
1655 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1656 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1736 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1737 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1738 | + } |
|
1657 | 1739 | } |
1658 | 1740 | } |
1659 | 1741 | |
1660 | 1742 | // Change the sticky status of this topic? |
1661 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1662 | - unset($_POST['sticky']); |
|
1663 | - elseif (isset($_POST['sticky'])) |
|
1743 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1744 | + unset($_POST['sticky']); |
|
1745 | + } elseif (isset($_POST['sticky'])) |
|
1664 | 1746 | { |
1665 | 1747 | // Did someone (un)sticky this while you were posting? |
1666 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1667 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1748 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1749 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1750 | + } |
|
1668 | 1751 | } |
1669 | 1752 | |
1670 | 1753 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1671 | 1754 | { |
1672 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1673 | - fatal_lang_error('modify_post_time_passed', false); |
|
1674 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1675 | - isAllowedTo('modify_replies'); |
|
1676 | - else |
|
1677 | - isAllowedTo('modify_own'); |
|
1678 | - } |
|
1679 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1755 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1756 | + fatal_lang_error('modify_post_time_passed', false); |
|
1757 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1758 | + isAllowedTo('modify_replies'); |
|
1759 | + } else { |
|
1760 | + isAllowedTo('modify_own'); |
|
1761 | + } |
|
1762 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1680 | 1763 | { |
1681 | 1764 | isAllowedTo('modify_replies'); |
1682 | 1765 | |
1683 | 1766 | // If you're modifying a reply, I say it better be logged... |
1684 | 1767 | $moderationAction = true; |
1685 | - } |
|
1686 | - else |
|
1768 | + } else |
|
1687 | 1769 | { |
1688 | 1770 | isAllowedTo('modify_any'); |
1689 | 1771 | |
1690 | 1772 | // Log it, assuming you're not modifying your own post. |
1691 | - if ($row['id_member'] != $user_info['id']) |
|
1692 | - $moderationAction = true; |
|
1773 | + if ($row['id_member'] != $user_info['id']) { |
|
1774 | + $moderationAction = true; |
|
1775 | + } |
|
1693 | 1776 | } |
1694 | 1777 | |
1695 | 1778 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1729 | 1812 | |
1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1731 | - $post_errors[] = 'no_name'; |
|
1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1733 | - $post_errors[] = 'long_name'; |
|
1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1814 | + $post_errors[] = 'no_name'; |
|
1815 | + } |
|
1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1817 | + $post_errors[] = 'long_name'; |
|
1818 | + } |
|
1734 | 1819 | |
1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
1736 | 1821 | { |
1737 | 1822 | // Only check if they changed it! |
1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1739 | 1824 | { |
1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1741 | - $post_errors[] = 'no_email'; |
|
1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1743 | - $post_errors[] = 'bad_email'; |
|
1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1826 | + $post_errors[] = 'no_email'; |
|
1827 | + } |
|
1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1829 | + $post_errors[] = 'bad_email'; |
|
1830 | + } |
|
1744 | 1831 | } |
1745 | 1832 | |
1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
1756 | 1843 | } |
1757 | 1844 | |
1758 | 1845 | // Coming from the quickReply? |
1759 | - if (isset($_POST['quickReply'])) |
|
1760 | - $_POST['message'] = $_POST['quickReply']; |
|
1846 | + if (isset($_POST['quickReply'])) { |
|
1847 | + $_POST['message'] = $_POST['quickReply']; |
|
1848 | + } |
|
1761 | 1849 | |
1762 | 1850 | // Check the subject and message. |
1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1764 | - $post_errors[] = 'no_subject'; |
|
1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1766 | - $post_errors[] = 'no_message'; |
|
1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1769 | - else |
|
1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1852 | + $post_errors[] = 'no_subject'; |
|
1853 | + } |
|
1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1855 | + $post_errors[] = 'no_message'; |
|
1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1858 | + } else |
|
1770 | 1859 | { |
1771 | 1860 | // Prepare the message a bit for some additional testing. |
1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1773 | 1862 | |
1774 | 1863 | // Preparse code. (Zef) |
1775 | - if ($user_info['is_guest']) |
|
1776 | - $user_info['name'] = $_POST['guestname']; |
|
1864 | + if ($user_info['is_guest']) { |
|
1865 | + $user_info['name'] = $_POST['guestname']; |
|
1866 | + } |
|
1777 | 1867 | preparsecode($_POST['message']); |
1778 | 1868 | |
1779 | 1869 | // Let's see if there's still some content left without the tags. |
1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1781 | - $post_errors[] = 'no_message'; |
|
1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1871 | + $post_errors[] = 'no_message'; |
|
1872 | + } |
|
1873 | + } |
|
1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1875 | + $post_errors[] = 'no_event'; |
|
1782 | 1876 | } |
1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1784 | - $post_errors[] = 'no_event'; |
|
1785 | 1877 | // You are not! |
1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1880 | + } |
|
1788 | 1881 | |
1789 | 1882 | // Validate the poll... |
1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1791 | 1884 | { |
1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1793 | - fatal_lang_error('no_access', false); |
|
1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1886 | + fatal_lang_error('no_access', false); |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // This is a new topic... so it's a new poll. |
1796 | - if (empty($topic)) |
|
1797 | - isAllowedTo('poll_post'); |
|
1890 | + if (empty($topic)) { |
|
1891 | + isAllowedTo('poll_post'); |
|
1892 | + } |
|
1798 | 1893 | // Can you add to your own topics? |
1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1800 | - isAllowedTo('poll_add_own'); |
|
1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1895 | + isAllowedTo('poll_add_own'); |
|
1896 | + } |
|
1801 | 1897 | // Can you add polls to any topic, then? |
1802 | - else |
|
1803 | - isAllowedTo('poll_add_any'); |
|
1898 | + else { |
|
1899 | + isAllowedTo('poll_add_any'); |
|
1900 | + } |
|
1804 | 1901 | |
1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1806 | - $post_errors[] = 'no_question'; |
|
1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1903 | + $post_errors[] = 'no_question'; |
|
1904 | + } |
|
1807 | 1905 | |
1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1809 | 1907 | |
1810 | 1908 | // Get rid of empty ones. |
1811 | - foreach ($_POST['options'] as $k => $option) |
|
1812 | - if ($option == '') |
|
1909 | + foreach ($_POST['options'] as $k => $option) { |
|
1910 | + if ($option == '') |
|
1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1912 | + } |
|
1814 | 1913 | |
1815 | 1914 | // What are you going to vote between with one choice?!? |
1816 | - if (count($_POST['options']) < 2) |
|
1817 | - $post_errors[] = 'poll_few'; |
|
1818 | - elseif (count($_POST['options']) > 256) |
|
1819 | - $post_errors[] = 'poll_many'; |
|
1915 | + if (count($_POST['options']) < 2) { |
|
1916 | + $post_errors[] = 'poll_few'; |
|
1917 | + } elseif (count($_POST['options']) > 256) { |
|
1918 | + $post_errors[] = 'poll_many'; |
|
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | 1922 | if ($posterIsGuest) |
1823 | 1923 | { |
1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1827 | - $post_errors[] = 'bad_name'; |
|
1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1927 | + $post_errors[] = 'bad_name'; |
|
1928 | + } |
|
1828 | 1929 | } |
1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
1855 | 1956 | } |
1856 | 1957 | |
1857 | 1958 | // Make sure the user isn't spamming the board. |
1858 | - if (!isset($_REQUEST['msg'])) |
|
1859 | - spamProtection('post'); |
|
1959 | + if (!isset($_REQUEST['msg'])) { |
|
1960 | + spamProtection('post'); |
|
1961 | + } |
|
1860 | 1962 | |
1861 | 1963 | // At about this point, we're posting and that's that. |
1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1870 | 1972 | |
1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1976 | + } |
|
1874 | 1977 | |
1875 | 1978 | // Same with the "why did you edit this" text. |
1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1981 | + } |
|
1878 | 1982 | |
1879 | 1983 | // Make the poll... |
1880 | 1984 | if (isset($_REQUEST['poll'])) |
1881 | 1985 | { |
1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1884 | - $_POST['poll_max_votes'] = 1; |
|
1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1887 | - else |
|
1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1988 | + $_POST['poll_max_votes'] = 1; |
|
1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1991 | + } else { |
|
1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1993 | + } |
|
1889 | 1994 | |
1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1892 | 1997 | |
1893 | 1998 | // Just set it to zero if it's not there.. |
1894 | - if (!isset($_POST['poll_hide'])) |
|
1895 | - $_POST['poll_hide'] = 0; |
|
1896 | - else |
|
1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1999 | + if (!isset($_POST['poll_hide'])) { |
|
2000 | + $_POST['poll_hide'] = 0; |
|
2001 | + } else { |
|
2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2003 | + } |
|
1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1899 | 2005 | |
1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
1903 | 2009 | { |
1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1907 | - $_POST['poll_guest_vote'] = 0; |
|
2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2013 | + $_POST['poll_guest_vote'] = 0; |
|
2014 | + } |
|
1908 | 2015 | } |
1909 | 2016 | |
1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1912 | - fatal_lang_error('poll_range_error', false); |
|
2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2019 | + fatal_lang_error('poll_range_error', false); |
|
2020 | + } |
|
1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1915 | - $_POST['poll_hide'] = 1; |
|
2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2023 | + $_POST['poll_hide'] = 1; |
|
2024 | + } |
|
1916 | 2025 | |
1917 | 2026 | // Clean up the question and answers. |
1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
1926 | 2035 | { |
1927 | 2036 | $attachIDs = array(); |
1928 | 2037 | $attach_errors = array(); |
1929 | - if (!empty($context['we_are_history'])) |
|
1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2038 | + if (!empty($context['we_are_history'])) { |
|
2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2040 | + } |
|
1931 | 2041 | |
1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1933 | 2043 | { |
1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1935 | - continue; |
|
2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2045 | + continue; |
|
2046 | + } |
|
1936 | 2047 | |
1937 | 2048 | // If there was an initial error just show that message. |
1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
1961 | 2072 | if (createAttachment($attachmentOptions)) |
1962 | 2073 | { |
1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
1964 | - if (!empty($attachmentOptions['thumb'])) |
|
1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2077 | + } |
|
1966 | 2078 | } |
2079 | + } else { |
|
2080 | + $attach_errors[] = '<dt> </dt>'; |
|
1967 | 2081 | } |
1968 | - else |
|
1969 | - $attach_errors[] = '<dt> </dt>'; |
|
1970 | 2082 | |
1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
1978 | 2090 | if (!is_array($error)) |
1979 | 2091 | { |
1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1981 | - if (in_array($error, $log_these)) |
|
1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2093 | + if (in_array($error, $log_these)) { |
|
2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2095 | + } |
|
2096 | + } else { |
|
2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1983 | 2098 | } |
1984 | - else |
|
1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1986 | 2099 | } |
1987 | - if (file_exists($attachment['tmp_name'])) |
|
1988 | - unlink($attachment['tmp_name']); |
|
2100 | + if (file_exists($attachment['tmp_name'])) { |
|
2101 | + unlink($attachment['tmp_name']); |
|
2102 | + } |
|
1989 | 2103 | } |
1990 | 2104 | } |
1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
2026 | 2140 | ); |
2027 | 2141 | |
2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2143 | + } else { |
|
2144 | + $id_poll = 0; |
|
2029 | 2145 | } |
2030 | - else |
|
2031 | - $id_poll = 0; |
|
2032 | 2146 | |
2033 | 2147 | // Creating a new topic? |
2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2035 | 2149 | |
2036 | 2150 | // Check the icon. |
2037 | - if (!isset($_POST['icon'])) |
|
2038 | - $_POST['icon'] = 'xx'; |
|
2039 | - |
|
2040 | - else |
|
2151 | + if (!isset($_POST['icon'])) { |
|
2152 | + $_POST['icon'] = 'xx'; |
|
2153 | + } else |
|
2041 | 2154 | { |
2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2043 | 2156 | |
2044 | 2157 | // Need to figure it out if this is a valid icon name. |
2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2046 | - $_POST['icon'] = 'xx'; |
|
2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2159 | + $_POST['icon'] = 'xx'; |
|
2160 | + } |
|
2047 | 2161 | } |
2048 | 2162 | |
2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
2084 | 2198 | } |
2085 | 2199 | |
2086 | 2200 | // This will save some time... |
2087 | - if (empty($approve_has_changed)) |
|
2088 | - unset($msgOptions['approved']); |
|
2201 | + if (empty($approve_has_changed)) { |
|
2202 | + unset($msgOptions['approved']); |
|
2203 | + } |
|
2089 | 2204 | |
2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
2094 | 2209 | { |
2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
2096 | 2211 | |
2097 | - if (isset($topicOptions['id'])) |
|
2098 | - $topic = $topicOptions['id']; |
|
2212 | + if (isset($topicOptions['id'])) { |
|
2213 | + $topic = $topicOptions['id']; |
|
2214 | + } |
|
2099 | 2215 | } |
2100 | 2216 | |
2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
2107 | 2223 | } |
2108 | 2224 | |
2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2111 | - DeleteDraft($_POST['id_draft']); |
|
2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2227 | + DeleteDraft($_POST['id_draft']); |
|
2228 | + } |
|
2112 | 2229 | |
2113 | 2230 | // Editing or posting an event? |
2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
2127 | 2244 | 'member' => $user_info['id'], |
2128 | 2245 | ); |
2129 | 2246 | insertEvent($eventOptions); |
2130 | - } |
|
2131 | - elseif (isset($_POST['calendar'])) |
|
2247 | + } elseif (isset($_POST['calendar'])) |
|
2132 | 2248 | { |
2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
2156 | 2272 | } |
2157 | 2273 | |
2158 | 2274 | // Delete it? |
2159 | - if (isset($_REQUEST['deleteevent'])) |
|
2160 | - $smcFunc['db_query']('', ' |
|
2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
2276 | + $smcFunc['db_query']('', ' |
|
2161 | 2277 | DELETE FROM {db_prefix}calendar |
2162 | 2278 | WHERE id_event = {int:id_event}', |
2163 | 2279 | array( |
2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
2165 | 2281 | ) |
2166 | 2282 | ); |
2283 | + } |
|
2167 | 2284 | // ... or just update it? |
2168 | 2285 | else |
2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
2205 | 2322 | array($user_info['id'], $topic, 0), |
2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
2207 | 2324 | ); |
2208 | - } |
|
2209 | - elseif (!$newTopic) |
|
2210 | - $smcFunc['db_query']('', ' |
|
2325 | + } elseif (!$newTopic) { |
|
2326 | + $smcFunc['db_query']('', ' |
|
2211 | 2327 | DELETE FROM {db_prefix}log_notify |
2212 | 2328 | WHERE id_member = {int:current_member} |
2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
2216 | 2332 | 'current_topic' => $topic, |
2217 | 2333 | ) |
2218 | 2334 | ); |
2335 | + } |
|
2219 | 2336 | |
2220 | 2337 | // Log an act of moderation - modifying. |
2221 | - if (!empty($moderationAction)) |
|
2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2338 | + if (!empty($moderationAction)) { |
|
2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2340 | + } |
|
2223 | 2341 | |
2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2344 | + } |
|
2226 | 2345 | |
2227 | - if (isset($_POST['sticky'])) |
|
2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2346 | + if (isset($_POST['sticky'])) { |
|
2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2348 | + } |
|
2229 | 2349 | |
2230 | 2350 | // Returning to the topic? |
2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
2244 | 2364 | ); |
2245 | 2365 | } |
2246 | 2366 | |
2247 | - if ($board_info['num_topics'] == 0) |
|
2248 | - cache_put_data('board-' . $board, null, 120); |
|
2367 | + if ($board_info['num_topics'] == 0) { |
|
2368 | + cache_put_data('board-' . $board, null, 120); |
|
2369 | + } |
|
2249 | 2370 | |
2250 | 2371 | call_integration_hook('integrate_post2_end'); |
2251 | 2372 | |
2252 | - if (!empty($_POST['announce_topic'])) |
|
2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2373 | + if (!empty($_POST['announce_topic'])) { |
|
2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2375 | + } |
|
2254 | 2376 | |
2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2379 | + } |
|
2257 | 2380 | |
2258 | 2381 | // Return to post if the mod is on. |
2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2261 | - elseif (!empty($_REQUEST['goback'])) |
|
2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2386 | + } |
|
2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2264 | - else |
|
2265 | - redirectexit('board=' . $board . '.0'); |
|
2266 | -} |
|
2388 | + else { |
|
2389 | + redirectexit('board=' . $board . '.0'); |
|
2390 | + } |
|
2391 | + } |
|
2267 | 2392 | |
2268 | 2393 | /** |
2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
2281 | 2406 | |
2282 | 2407 | validateSession(); |
2283 | 2408 | |
2284 | - if (empty($topic)) |
|
2285 | - fatal_lang_error('topic_gone', false); |
|
2409 | + if (empty($topic)) { |
|
2410 | + fatal_lang_error('topic_gone', false); |
|
2411 | + } |
|
2286 | 2412 | |
2287 | 2413 | loadLanguage('Post'); |
2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
2309 | 2435 | global $txt, $context, $topic, $board_info, $smcFunc; |
2310 | 2436 | |
2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
2312 | - foreach ($groups as $id => $group) |
|
2313 | - $groups[$id] = (int) $group; |
|
2438 | + foreach ($groups as $id => $group) { |
|
2439 | + $groups[$id] = (int) $group; |
|
2440 | + } |
|
2314 | 2441 | |
2315 | 2442 | $context['groups'] = array(); |
2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
2353 | 2480 | 'group_list' => $groups, |
2354 | 2481 | ) |
2355 | 2482 | ); |
2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2485 | + } |
|
2358 | 2486 | $smcFunc['db_free_result']($request); |
2359 | 2487 | |
2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
2398 | 2526 | |
2399 | - if (isset($_POST['membergroups'])) |
|
2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2527 | + if (isset($_POST['membergroups'])) { |
|
2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2529 | + } |
|
2401 | 2530 | |
2402 | 2531 | // Check whether at least one membergroup was selected. |
2403 | - if (empty($_POST['who'])) |
|
2404 | - fatal_lang_error('no_membergroup_selected'); |
|
2532 | + if (empty($_POST['who'])) { |
|
2533 | + fatal_lang_error('no_membergroup_selected'); |
|
2534 | + } |
|
2405 | 2535 | |
2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
2407 | - foreach ($_POST['who'] as $id => $mg) |
|
2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2539 | + } |
|
2409 | 2540 | |
2410 | 2541 | // Get the topic subject and censor it. |
2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
2452 | 2583 | { |
2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2456 | - elseif (!empty($_REQUEST['goback'])) |
|
2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2458 | - else |
|
2459 | - redirectexit('board=' . $board . '.0'); |
|
2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2589 | + } else { |
|
2590 | + redirectexit('board=' . $board . '.0'); |
|
2591 | + } |
|
2460 | 2592 | } |
2461 | 2593 | |
2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
2475 | 2607 | foreach ($rows as $row) |
2476 | 2608 | { |
2477 | 2609 | // Force them to have it? |
2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2479 | - continue; |
|
2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2611 | + continue; |
|
2612 | + } |
|
2480 | 2613 | |
2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
2504 | 2637 | } |
2505 | 2638 | |
2506 | 2639 | // For each language send a different mail - low priority... |
2507 | - foreach ($announcements as $lang => $mail) |
|
2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2640 | + foreach ($announcements as $lang => $mail) { |
|
2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2642 | + } |
|
2509 | 2643 | |
2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
2516 | 2650 | |
2517 | 2651 | // Go back to the correct language for the user ;). |
2518 | - if (!empty($modSettings['userLanguage'])) |
|
2519 | - loadLanguage('Post'); |
|
2520 | -} |
|
2652 | + if (!empty($modSettings['userLanguage'])) { |
|
2653 | + loadLanguage('Post'); |
|
2654 | + } |
|
2655 | + } |
|
2521 | 2656 | |
2522 | 2657 | /** |
2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
2530 | 2665 | { |
2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2532 | 2667 | |
2533 | - if (isset($_REQUEST['xml'])) |
|
2534 | - $limit = ' |
|
2668 | + if (isset($_REQUEST['xml'])) { |
|
2669 | + $limit = ' |
|
2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2536 | - else |
|
2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2671 | + } else { |
|
2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2674 | + } |
|
2539 | 2675 | |
2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2574 | 2710 | ); |
2575 | 2711 | |
2576 | - if (!empty($context['new_replies'])) |
|
2577 | - $context['new_replies']--; |
|
2712 | + if (!empty($context['new_replies'])) { |
|
2713 | + $context['new_replies']--; |
|
2714 | + } |
|
2578 | 2715 | } |
2579 | 2716 | $smcFunc['db_free_result']($request); |
2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
2591 | 2728 | global $sourcedir, $smcFunc; |
2592 | 2729 | |
2593 | 2730 | loadLanguage('Post'); |
2594 | - if (!isset($_REQUEST['xml'])) |
|
2595 | - loadTemplate('Post'); |
|
2731 | + if (!isset($_REQUEST['xml'])) { |
|
2732 | + loadTemplate('Post'); |
|
2733 | + } |
|
2596 | 2734 | |
2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
2623 | 2761 | $smcFunc['db_free_result']($request); |
2624 | 2762 | |
2625 | 2763 | $context['sub_template'] = 'quotefast'; |
2626 | - if (!empty($row)) |
|
2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2764 | + if (!empty($row)) { |
|
2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2766 | + } |
|
2628 | 2767 | |
2629 | 2768 | if (!empty($can_view_post)) |
2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
2657 | 2796 | } |
2658 | 2797 | |
2659 | 2798 | // Remove any nested quotes. |
2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2801 | + } |
|
2662 | 2802 | |
2663 | 2803 | $lb = "\n"; |
2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
2684 | 2824 | 'time' => '', |
2685 | 2825 | ), |
2686 | 2826 | ); |
2687 | - } |
|
2688 | - else |
|
2689 | - $context['quote'] = array( |
|
2827 | + } else { |
|
2828 | + $context['quote'] = array( |
|
2690 | 2829 | 'xml' => '', |
2691 | 2830 | 'mozilla' => '', |
2692 | 2831 | 'text' => '', |
2693 | 2832 | ); |
2694 | -} |
|
2833 | + } |
|
2834 | + } |
|
2695 | 2835 | |
2696 | 2836 | /** |
2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
2704 | 2844 | |
2705 | 2845 | // We have to have a topic! |
2706 | - if (empty($topic)) |
|
2707 | - obExit(false); |
|
2846 | + if (empty($topic)) { |
|
2847 | + obExit(false); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | checkSession('get'); |
2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
2730 | 2871 | 'guest_id' => 0, |
2731 | 2872 | ) |
2732 | 2873 | ); |
2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2734 | - fatal_lang_error('no_board', false); |
|
2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2875 | + fatal_lang_error('no_board', false); |
|
2876 | + } |
|
2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
2736 | 2878 | $smcFunc['db_free_result']($request); |
2737 | 2879 | |
2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2740 | 2882 | { |
2741 | - if (!empty($row['locked'])) |
|
2742 | - isAllowedTo('moderate_board'); |
|
2883 | + if (!empty($row['locked'])) { |
|
2884 | + isAllowedTo('moderate_board'); |
|
2885 | + } |
|
2743 | 2886 | |
2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2745 | 2888 | { |
2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2749 | - isAllowedTo('modify_replies'); |
|
2750 | - else |
|
2751 | - isAllowedTo('modify_own'); |
|
2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2892 | + isAllowedTo('modify_replies'); |
|
2893 | + } else { |
|
2894 | + isAllowedTo('modify_own'); |
|
2895 | + } |
|
2752 | 2896 | } |
2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2755 | - isAllowedTo('modify_replies'); |
|
2756 | - else |
|
2757 | - isAllowedTo('modify_any'); |
|
2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2899 | + isAllowedTo('modify_replies'); |
|
2900 | + } else { |
|
2901 | + isAllowedTo('modify_any'); |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | // Only log this action if it wasn't your message. |
2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2767 | 2912 | |
2768 | 2913 | // Maximum number of characters. |
2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2771 | - } |
|
2772 | - elseif (isset($_POST['subject'])) |
|
2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2916 | + } |
|
2917 | + } elseif (isset($_POST['subject'])) |
|
2773 | 2918 | { |
2774 | 2919 | $post_errors[] = 'no_subject'; |
2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
2781 | 2926 | { |
2782 | 2927 | $post_errors[] = 'no_message'; |
2783 | 2928 | unset($_POST['message']); |
2784 | - } |
|
2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2786 | 2930 | { |
2787 | 2931 | $post_errors[] = 'long_message'; |
2788 | 2932 | unset($_POST['message']); |
2789 | - } |
|
2790 | - else |
|
2933 | + } else |
|
2791 | 2934 | { |
2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
2803 | 2946 | |
2804 | 2947 | if (isset($_POST['lock'])) |
2805 | 2948 | { |
2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2807 | - unset($_POST['lock']); |
|
2808 | - elseif (!allowedTo('lock_any')) |
|
2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2950 | + unset($_POST['lock']); |
|
2951 | + } elseif (!allowedTo('lock_any')) |
|
2809 | 2952 | { |
2810 | - if ($row['locked'] == 1) |
|
2811 | - unset($_POST['lock']); |
|
2812 | - else |
|
2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2953 | + if ($row['locked'] == 1) { |
|
2954 | + unset($_POST['lock']); |
|
2955 | + } else { |
|
2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2957 | + } |
|
2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2959 | + unset($_POST['lock']); |
|
2960 | + } else { |
|
2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2814 | 2962 | } |
2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2816 | - unset($_POST['lock']); |
|
2817 | - else |
|
2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2819 | 2963 | } |
2820 | 2964 | |
2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2822 | - unset($_POST['sticky']); |
|
2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2966 | + unset($_POST['sticky']); |
|
2967 | + } |
|
2823 | 2968 | |
2824 | 2969 | if (isset($_POST['modify_reason'])) |
2825 | 2970 | { |
2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2827 | 2972 | |
2828 | 2973 | // Maximum number of characters. |
2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2976 | + } |
|
2831 | 2977 | } |
2832 | 2978 | |
2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
2864 | 3010 | } |
2865 | 3011 | } |
2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
2867 | - else |
|
2868 | - $moderationAction = false; |
|
3013 | + else { |
|
3014 | + $moderationAction = false; |
|
3015 | + } |
|
2869 | 3016 | |
2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
2883 | 3030 | // Get the proper (default language) response prefix first. |
2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2885 | 3032 | { |
2886 | - if ($language === $user_info['language']) |
|
2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2888 | - else |
|
3033 | + if ($language === $user_info['language']) { |
|
3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3035 | + } else |
|
2889 | 3036 | { |
2890 | 3037 | loadLanguage('index', $language, false); |
2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
2907 | 3054 | ); |
2908 | 3055 | } |
2909 | 3056 | |
2910 | - if (!empty($moderationAction)) |
|
2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3057 | + if (!empty($moderationAction)) { |
|
3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3059 | + } |
|
2912 | 3060 | } |
2913 | 3061 | |
2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
2949 | 3097 | ); |
2950 | 3098 | |
2951 | 3099 | censorText($context['message']['subject']); |
2952 | - } |
|
2953 | - else |
|
3100 | + } else |
|
2954 | 3101 | { |
2955 | 3102 | $context['message'] = array( |
2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
2962 | 3109 | loadLanguage('Errors'); |
2963 | 3110 | foreach ($post_errors as $post_error) |
2964 | 3111 | { |
2965 | - if ($post_error == 'long_message') |
|
2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2967 | - else |
|
2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3112 | + if ($post_error == 'long_message') { |
|
3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3114 | + } else { |
|
3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3116 | + } |
|
2969 | 3117 | } |
2970 | 3118 | } |
3119 | + } else { |
|
3120 | + obExit(false); |
|
3121 | + } |
|
2971 | 3122 | } |
2972 | - else |
|
2973 | - obExit(false); |
|
2974 | -} |
|
2975 | 3123 | |
2976 | 3124 | ?> |
2977 | 3125 | \ No newline at end of file |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'class' => 'centercol', |
257 | 257 | ), |
258 | 258 | 'data' => array( |
259 | - 'function' => function ($entry) |
|
259 | + 'function' => function($entry) |
|
260 | 260 | { |
261 | 261 | return '<input type="checkbox" name="delete[]" value="' . $entry['id'] . '"' . ($entry['editable'] ? '' : ' disabled') . '>'; |
262 | 262 | }, |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | if (empty($entries[$k]['action_text'])) |
639 | 639 | $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
640 | 640 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
641 | - function ($matches) use ($entries, $k) |
|
641 | + function($matches) use ($entries, $k) |
|
642 | 642 | { |
643 | 643 | return isset($entries[$k]['extra'][$matches[1]]) ? $entries[$k]['extra'][$matches[1]] : ''; |
644 | 644 | }, $entries[$k]['action_text']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Prepares the information from the moderation log for viewing. |
@@ -32,14 +33,16 @@ discard block |
||
32 | 33 | |
33 | 34 | // Are we looking at the moderation log or the administration log. |
34 | 35 | $context['log_type'] = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 3 : 1; |
35 | - if ($context['log_type'] == 3) |
|
36 | - isAllowedTo('admin_forum'); |
|
36 | + if ($context['log_type'] == 3) { |
|
37 | + isAllowedTo('admin_forum'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | // These change dependant on whether we are viewing the moderation or admin log. |
39 | - if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') |
|
40 | - $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
41 | - else |
|
42 | - $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
41 | + if ($context['log_type'] == 3 || $_REQUEST['action'] == 'admin') { |
|
42 | + $context['url_start'] = '?action=admin;area=logs;sa=' . ($context['log_type'] == 3 ? 'adminlog' : 'modlog') . ';type=' . $context['log_type']; |
|
43 | + } else { |
|
44 | + $context['url_start'] = '?action=moderate;area=modlog;type=' . $context['log_type']; |
|
45 | + } |
|
43 | 46 | |
44 | 47 | $context['can_delete'] = allowedTo('admin_forum'); |
45 | 48 | |
@@ -67,8 +70,7 @@ discard block |
||
67 | 70 | $log_type = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'adminlog' ? 'admin' : 'moderate'; |
68 | 71 | logAction('clearlog_' . $log_type, array(), $log_type); |
69 | 72 | |
70 | - } |
|
71 | - elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
73 | + } elseif (!empty($_POST['remove']) && isset($_POST['delete']) && $context['can_delete']) |
|
72 | 74 | { |
73 | 75 | checkSession(); |
74 | 76 | validateToken('mod-ml'); |
@@ -114,15 +116,17 @@ discard block |
||
114 | 116 | 'ip' => array('sql' => 'lm.ip', 'label' => $txt['modlog_ip']) |
115 | 117 | ); |
116 | 118 | |
117 | - if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) |
|
118 | - $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
119 | - else |
|
120 | - $search_params_string = $search_params['string']; |
|
119 | + if (!isset($search_params['string']) || (!empty($_REQUEST['search']) && $search_params['string'] != $_REQUEST['search'])) { |
|
120 | + $search_params_string = empty($_REQUEST['search']) ? '' : $_REQUEST['search']; |
|
121 | + } else { |
|
122 | + $search_params_string = $search_params['string']; |
|
123 | + } |
|
121 | 124 | |
122 | - if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) |
|
123 | - $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
124 | - else |
|
125 | - $search_params_type = $search_params['type']; |
|
125 | + if (isset($_REQUEST['search_type']) || empty($search_params['type']) || !isset($searchTypes[$search_params['type']])) { |
|
126 | + $search_params_type = isset($_REQUEST['search_type']) && isset($searchTypes[$_REQUEST['search_type']]) ? $_REQUEST['search_type'] : (isset($searchTypes[$context['order']]) ? $context['order'] : 'member'); |
|
127 | + } else { |
|
128 | + $search_params_type = $search_params['type']; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | $search_params_column = $searchTypes[$search_params_type]['sql']; |
128 | 132 | $search_params = array( |
@@ -301,15 +305,16 @@ discard block |
||
301 | 305 | $context['default_list'] = 'moderation_log_list'; |
302 | 306 | |
303 | 307 | // If a hook has changed this, respect it. |
304 | - if (!empty($moderation_menu_name)) |
|
305 | - $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
306 | - elseif (isset($context['moderation_menu_name'])) |
|
307 | - $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | + if (!empty($moderation_menu_name)) { |
|
309 | + $context[$context['moderation_menu_name']]['tab_data'] = $moderation_menu_name; |
|
310 | + } elseif (isset($context['moderation_menu_name'])) { |
|
311 | + $context[$context['moderation_menu_name']]['tab_data'] = array( |
|
308 | 312 | 'title' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log'], |
309 | 313 | 'help' => $context['log_type'] == 3 ? 'adminlog' : 'modlog', |
310 | 314 | 'description' => $txt['modlog_' . ($context['log_type'] == 3 ? 'admin' : 'moderation') . '_log_desc'] |
311 | 315 | ); |
312 | -} |
|
316 | + } |
|
317 | + } |
|
313 | 318 | |
314 | 319 | /** |
315 | 320 | * Get the number of mod log entries. |
@@ -413,30 +418,35 @@ discard block |
||
413 | 418 | // Add on some of the column stuff info |
414 | 419 | if (!empty($row['id_board'])) |
415 | 420 | { |
416 | - if ($row['action'] == 'move') |
|
417 | - $row['extra']['board_to'] = $row['id_board']; |
|
418 | - else |
|
419 | - $row['extra']['board'] = $row['id_board']; |
|
421 | + if ($row['action'] == 'move') { |
|
422 | + $row['extra']['board_to'] = $row['id_board']; |
|
423 | + } else { |
|
424 | + $row['extra']['board'] = $row['id_board']; |
|
425 | + } |
|
420 | 426 | } |
421 | 427 | |
422 | - if (!empty($row['id_topic'])) |
|
423 | - $row['extra']['topic'] = $row['id_topic']; |
|
424 | - if (!empty($row['id_msg'])) |
|
425 | - $row['extra']['message'] = $row['id_msg']; |
|
428 | + if (!empty($row['id_topic'])) { |
|
429 | + $row['extra']['topic'] = $row['id_topic']; |
|
430 | + } |
|
431 | + if (!empty($row['id_msg'])) { |
|
432 | + $row['extra']['message'] = $row['id_msg']; |
|
433 | + } |
|
426 | 434 | |
427 | 435 | // Is this associated with a topic? |
428 | - if (isset($row['extra']['topic'])) |
|
429 | - $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
430 | - if (isset($row['extra']['new_topic'])) |
|
431 | - $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
436 | + if (isset($row['extra']['topic'])) { |
|
437 | + $topics[(int) $row['extra']['topic']][] = $row['id_action']; |
|
438 | + } |
|
439 | + if (isset($row['extra']['new_topic'])) { |
|
440 | + $topics[(int) $row['extra']['new_topic']][] = $row['id_action']; |
|
441 | + } |
|
432 | 442 | |
433 | 443 | // How about a member? |
434 | 444 | if (isset($row['extra']['member'])) |
435 | 445 | { |
436 | 446 | // Guests don't have names! |
437 | - if (empty($row['extra']['member'])) |
|
438 | - $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
439 | - else |
|
447 | + if (empty($row['extra']['member'])) { |
|
448 | + $row['extra']['member'] = $txt['modlog_parameter_guest']; |
|
449 | + } else |
|
440 | 450 | { |
441 | 451 | // Try to find it... |
442 | 452 | $members[(int) $row['extra']['member']][] = $row['id_action']; |
@@ -444,35 +454,42 @@ discard block |
||
444 | 454 | } |
445 | 455 | |
446 | 456 | // Associated with a board? |
447 | - if (isset($row['extra']['board_to'])) |
|
448 | - $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
449 | - if (isset($row['extra']['board_from'])) |
|
450 | - $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
451 | - if (isset($row['extra']['board'])) |
|
452 | - $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
457 | + if (isset($row['extra']['board_to'])) { |
|
458 | + $boards[(int) $row['extra']['board_to']][] = $row['id_action']; |
|
459 | + } |
|
460 | + if (isset($row['extra']['board_from'])) { |
|
461 | + $boards[(int) $row['extra']['board_from']][] = $row['id_action']; |
|
462 | + } |
|
463 | + if (isset($row['extra']['board'])) { |
|
464 | + $boards[(int) $row['extra']['board']][] = $row['id_action']; |
|
465 | + } |
|
453 | 466 | |
454 | 467 | // A message? |
455 | - if (isset($row['extra']['message'])) |
|
456 | - $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
468 | + if (isset($row['extra']['message'])) { |
|
469 | + $messages[(int) $row['extra']['message']][] = $row['id_action']; |
|
470 | + } |
|
457 | 471 | |
458 | 472 | // IP Info? |
459 | - if (isset($row['extra']['ip_range'])) |
|
460 | - if ($seeIP) |
|
473 | + if (isset($row['extra']['ip_range'])) { |
|
474 | + if ($seeIP) |
|
461 | 475 | $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>'; |
462 | - else |
|
463 | - $row['extra']['ip_range'] = $txt['logged']; |
|
476 | + } else { |
|
477 | + $row['extra']['ip_range'] = $txt['logged']; |
|
478 | + } |
|
464 | 479 | |
465 | 480 | // Email? |
466 | - if (isset($row['extra']['email'])) |
|
467 | - $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
481 | + if (isset($row['extra']['email'])) { |
|
482 | + $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>'; |
|
483 | + } |
|
468 | 484 | |
469 | 485 | // Bans are complex. |
470 | 486 | if ($row['action'] == 'ban' || $row['action'] == 'banremove') |
471 | 487 | { |
472 | 488 | $row['action_text'] = $txt['modlog_ac_ban' . ($row['action'] == 'banremove' ? '_remove' : '')]; |
473 | - foreach (array('member', 'email', 'ip_range', 'hostname') as $type) |
|
474 | - if (isset($row['extra'][$type])) |
|
489 | + foreach (array('member', 'email', 'ip_range', 'hostname') as $type) { |
|
490 | + if (isset($row['extra'][$type])) |
|
475 | 491 | $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type]; |
492 | + } |
|
476 | 493 | } |
477 | 494 | |
478 | 495 | // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details. |
@@ -508,12 +525,13 @@ discard block |
||
508 | 525 | foreach ($boards[$row['id_board']] as $action) |
509 | 526 | { |
510 | 527 | // Make the board number into a link - dealing with moving too. |
511 | - if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) |
|
512 | - $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
513 | - elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) |
|
514 | - $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
515 | - elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) |
|
516 | - $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
528 | + if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) { |
|
529 | + $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
530 | + } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) { |
|
531 | + $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
532 | + } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) { |
|
533 | + $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
534 | + } |
|
517 | 535 | } |
518 | 536 | } |
519 | 537 | $smcFunc['db_free_result']($request); |
@@ -547,10 +565,11 @@ discard block |
||
547 | 565 | ); |
548 | 566 | |
549 | 567 | // Make the topic number into a link - dealing with splitting too. |
550 | - if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) |
|
551 | - $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
552 | - elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) |
|
553 | - $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
568 | + if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) { |
|
569 | + $this_action['extra']['topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
570 | + } elseif (isset($this_action['extra']['new_topic']) && $this_action['extra']['new_topic'] == $row['id_topic']) { |
|
571 | + $this_action['extra']['new_topic'] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.' . (isset($this_action['extra']['message']) ? 'msg' . $this_action['extra']['message'] . '#msg' . $this_action['extra']['message'] : '0') . '">' . $row['subject'] . '</a>'; |
|
572 | + } |
|
554 | 573 | } |
555 | 574 | } |
556 | 575 | $smcFunc['db_free_result']($request); |
@@ -583,8 +602,9 @@ discard block |
||
583 | 602 | ); |
584 | 603 | |
585 | 604 | // Make the message number into a link. |
586 | - if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) |
|
587 | - $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
605 | + if (isset($this_action['extra']['message']) && $this_action['extra']['message'] == $row['id_msg']) { |
|
606 | + $this_action['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
607 | + } |
|
588 | 608 | } |
589 | 609 | } |
590 | 610 | $smcFunc['db_free_result']($request); |
@@ -624,25 +644,29 @@ discard block |
||
624 | 644 | foreach ($entries as $k => $entry) |
625 | 645 | { |
626 | 646 | // Make any message info links so its easier to go find that message. |
627 | - if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) |
|
628 | - $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
647 | + if (isset($entry['extra']['message']) && (empty($entry['message']) || empty($entry['message']['id']))) { |
|
648 | + $entries[$k]['extra']['message'] = '<a href="' . $scripturl . '?msg=' . $entry['extra']['message'] . '">' . $entry['extra']['message'] . '</a>'; |
|
649 | + } |
|
629 | 650 | |
630 | 651 | // Mark up any deleted members, topics and boards. |
631 | - foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) |
|
632 | - if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
652 | + foreach (array('board', 'board_from', 'board_to', 'member', 'topic', 'new_topic') as $type) { |
|
653 | + if (!empty($entry['extra'][$type]) && is_numeric($entry['extra'][$type])) |
|
633 | 654 | $entries[$k]['extra'][$type] = sprintf($txt['modlog_id'], $entry['extra'][$type]); |
655 | + } |
|
634 | 656 | |
635 | 657 | if (isset($entry['extra']['report'])) |
636 | 658 | { |
637 | 659 | // Member profile reports go in a different area |
638 | - if (stristr($entry['action'], 'user_report')) |
|
639 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
640 | - else |
|
641 | - $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
660 | + if (stristr($entry['action'], 'user_report')) { |
|
661 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
662 | + } else { |
|
663 | + $entries[$k]['extra']['report'] = '<a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=details;rid=' . $entry['extra']['report'] . '">' . $txt['modlog_report'] . '</a>'; |
|
664 | + } |
|
642 | 665 | } |
643 | 666 | |
644 | - if (empty($entries[$k]['action_text'])) |
|
645 | - $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
667 | + if (empty($entries[$k]['action_text'])) { |
|
668 | + $entries[$k]['action_text'] = isset($txt['modlog_ac_' . $entry['action']]) ? $txt['modlog_ac_' . $entry['action']] : $entry['action']; |
|
669 | + } |
|
646 | 670 | $entries[$k]['action_text'] = preg_replace_callback('~\{([A-Za-z\d_]+)\}~i', |
647 | 671 | function ($matches) use ($entries, $k) |
648 | 672 | { |
@@ -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) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +132,11 @@ discard block |
||
127 | 132 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
128 | 133 | |
129 | 134 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
135 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
136 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
137 | + } else { |
|
138 | + setTFACookie(-3600, 0, ''); |
|
139 | + } |
|
134 | 140 | } |
135 | 141 | |
136 | 142 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +147,20 @@ discard block |
||
141 | 147 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 148 | { |
143 | 149 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
150 | + if ($_GET['member'] != $user_info['id']) { |
|
151 | + fatal_lang_error('login_cookie_error', false); |
|
152 | + } |
|
146 | 153 | |
147 | 154 | $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'])))); |
148 | 155 | |
149 | 156 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | + if (empty($_SESSION['login_url'])) { |
|
158 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
159 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 160 | { |
154 | 161 | unset ($_SESSION['login_url']); |
155 | 162 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
163 | + } else |
|
158 | 164 | { |
159 | 165 | // Best not to clutter the session data too much... |
160 | 166 | $temp = $_SESSION['login_url']; |
@@ -165,8 +171,9 @@ discard block |
||
165 | 171 | } |
166 | 172 | |
167 | 173 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
174 | + if (!$user_info['is_guest']) { |
|
175 | + redirectexit(); |
|
176 | + } |
|
170 | 177 | |
171 | 178 | // Are you guessing with a script? |
172 | 179 | checkSession(); |
@@ -174,18 +181,21 @@ discard block |
||
174 | 181 | spamProtection('login'); |
175 | 182 | |
176 | 183 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - 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)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
184 | + 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)) { |
|
185 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + } |
|
179 | 187 | |
180 | 188 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
189 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
190 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
194 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
195 | + $modSettings['cookieTime'] = 3153600; |
|
196 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
197 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
198 | + } |
|
189 | 199 | |
190 | 200 | loadLanguage('Login'); |
191 | 201 | // Load the template stuff. |
@@ -305,8 +315,9 @@ discard block |
||
305 | 315 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 316 | |
307 | 317 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
318 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
319 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + } |
|
310 | 321 | |
311 | 322 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 323 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +337,29 @@ discard block |
||
326 | 337 | // Some common md5 ones. |
327 | 338 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 339 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
340 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 341 | { |
332 | 342 | // Maybe they are using a hash from before the password fix. |
333 | 343 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 344 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 345 | |
336 | 346 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
347 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
348 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + } |
|
339 | 350 | |
340 | 351 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 352 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 353 | { |
343 | 354 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
355 | + if (function_exists('iconv')) { |
|
356 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + } |
|
346 | 358 | |
347 | 359 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $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']))); |
|
360 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
361 | + $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']))); |
|
362 | + } |
|
350 | 363 | } |
351 | 364 | } |
352 | 365 | |
@@ -376,8 +389,9 @@ discard block |
||
376 | 389 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 390 | |
378 | 391 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
392 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
393 | + redirectexit('action=reminder'); |
|
394 | + } |
|
381 | 395 | // We'll give you another chance... |
382 | 396 | else |
383 | 397 | { |
@@ -388,8 +402,7 @@ discard block |
||
388 | 402 | return; |
389 | 403 | } |
390 | 404 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
405 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 406 | { |
394 | 407 | // Let's be sure they weren't a little hacker. |
395 | 408 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +419,9 @@ discard block |
||
406 | 419 | } |
407 | 420 | |
408 | 421 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
422 | + if (!checkActivation()) { |
|
423 | + return; |
|
424 | + } |
|
411 | 425 | |
412 | 426 | DoLogin(); |
413 | 427 | } |
@@ -419,8 +433,9 @@ discard block |
||
419 | 433 | { |
420 | 434 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 435 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
436 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
437 | + fatal_lang_error('no_access', false); |
|
438 | + } |
|
424 | 439 | |
425 | 440 | loadLanguage('Profile'); |
426 | 441 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +443,9 @@ discard block |
||
428 | 443 | $member = $context['tfa_member']; |
429 | 444 | |
430 | 445 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
446 | + if (time() - $member['last_login'] < 120) { |
|
447 | + fatal_lang_error('tfa_wait', false); |
|
448 | + } |
|
433 | 449 | |
434 | 450 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 451 | $totp->setRange(1); |
@@ -443,8 +459,9 @@ discard block |
||
443 | 459 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 460 | { |
445 | 461 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
462 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
463 | + fatal_lang_error('login_ssl_required'); |
|
464 | + } |
|
448 | 465 | |
449 | 466 | $code = $_POST['tfa_code']; |
450 | 467 | |
@@ -454,20 +471,19 @@ discard block |
||
454 | 471 | |
455 | 472 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 473 | redirectexit(); |
457 | - } |
|
458 | - else |
|
474 | + } else |
|
459 | 475 | { |
460 | 476 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 477 | |
462 | 478 | $context['tfa_error'] = true; |
463 | 479 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 480 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
481 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 482 | { |
468 | 483 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
484 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
485 | + fatal_lang_error('login_ssl_required'); |
|
486 | + } |
|
471 | 487 | |
472 | 488 | $backup = $_POST['tfa_backup']; |
473 | 489 | |
@@ -481,8 +497,7 @@ discard block |
||
481 | 497 | )); |
482 | 498 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 499 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
500 | + } else |
|
486 | 501 | { |
487 | 502 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 503 | |
@@ -505,8 +520,9 @@ discard block |
||
505 | 520 | { |
506 | 521 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 522 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
523 | + if (!isset($context['login_errors'])) { |
|
524 | + $context['login_errors'] = array(); |
|
525 | + } |
|
510 | 526 | |
511 | 527 | // What is the true activation status of this account? |
512 | 528 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +534,9 @@ discard block |
||
518 | 534 | return false; |
519 | 535 | } |
520 | 536 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
537 | + elseif ($activation_status == 3) { |
|
538 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + } |
|
523 | 540 | // Awaiting deletion, changed their mind? |
524 | 541 | elseif ($activation_status == 4) |
525 | 542 | { |
@@ -527,8 +544,7 @@ discard block |
||
527 | 544 | { |
528 | 545 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 546 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
547 | + } else |
|
532 | 548 | { |
533 | 549 | $context['disable_login_hashing'] = true; |
534 | 550 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 585 | |
570 | 586 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
587 | + if (isset($_SESSION['failed_login'])) { |
|
588 | + unset($_SESSION['failed_login']); |
|
589 | + } |
|
573 | 590 | |
574 | 591 | $user_info['is_guest'] = false; |
575 | 592 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +608,18 @@ discard block |
||
591 | 608 | 'id_member' => $user_info['id'], |
592 | 609 | ) |
593 | 610 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
611 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
612 | + $_SESSION['first_login'] = true; |
|
613 | + } else { |
|
614 | + unset($_SESSION['first_login']); |
|
615 | + } |
|
598 | 616 | $smcFunc['db_free_result']($request); |
599 | 617 | |
600 | 618 | // You've logged in, haven't you? |
601 | 619 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
620 | + if (empty($user_settings['tfa_secret'])) { |
|
621 | + $update['last_login'] = time(); |
|
622 | + } |
|
604 | 623 | updateMemberData($user_info['id'], $update); |
605 | 624 | |
606 | 625 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +633,8 @@ discard block |
||
614 | 633 | $_SESSION['log_time'] = 0; |
615 | 634 | |
616 | 635 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
636 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
637 | + $smcFunc['db_insert']('insert', |
|
619 | 638 | '{db_prefix}member_logins', |
620 | 639 | array( |
621 | 640 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +646,15 @@ discard block |
||
627 | 646 | 'id_member', 'time' |
628 | 647 | ) |
629 | 648 | ); |
649 | + } |
|
630 | 650 | |
631 | 651 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
652 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
653 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
654 | + } else { |
|
655 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
656 | + } |
|
657 | + } |
|
637 | 658 | |
638 | 659 | /** |
639 | 660 | * Logs the current user out of their account. |
@@ -649,13 +670,15 @@ discard block |
||
649 | 670 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 671 | |
651 | 672 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
673 | + if (!$internal) { |
|
674 | + checkSession('get'); |
|
675 | + } |
|
654 | 676 | |
655 | 677 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 678 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
679 | + if (isset($_SESSION['pack_ftp'])) { |
|
680 | + $_SESSION['pack_ftp'] = null; |
|
681 | + } |
|
659 | 682 | |
660 | 683 | // It won't be first login anymore. |
661 | 684 | unset($_SESSION['first_login']); |
@@ -683,8 +706,9 @@ discard block |
||
683 | 706 | |
684 | 707 | // And some other housekeeping while we're at it. |
685 | 708 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
709 | + if (!empty($user_info['id'])) { |
|
710 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + } |
|
688 | 712 | |
689 | 713 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 714 | { |
@@ -693,10 +717,11 @@ discard block |
||
693 | 717 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
694 | 718 | |
695 | 719 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
720 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
721 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
722 | + } else { |
|
723 | + setTFACookie(-3600, 0, ''); |
|
724 | + } |
|
700 | 725 | } |
701 | 726 | |
702 | 727 | session_destroy(); |
@@ -704,14 +729,13 @@ discard block |
||
704 | 729 | // Off to the merry board index we go! |
705 | 730 | if ($redirect) |
706 | 731 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
732 | + if (empty($_SESSION['logout_url'])) { |
|
733 | + redirectexit('', $context['server']['needs_login_fix']); |
|
734 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 735 | { |
711 | 736 | unset ($_SESSION['logout_url']); |
712 | 737 | redirectexit(); |
713 | - } |
|
714 | - else |
|
738 | + } else |
|
715 | 739 | { |
716 | 740 | $temp = $_SESSION['logout_url']; |
717 | 741 | unset($_SESSION['logout_url']); |
@@ -744,8 +768,9 @@ discard block |
||
744 | 768 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 769 | { |
746 | 770 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
771 | + if (strlen($passwd_hash) != 34) { |
|
772 | + return; |
|
773 | + } |
|
749 | 774 | |
750 | 775 | // Range of characters allowed. |
751 | 776 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +781,9 @@ discard block |
||
756 | 781 | $salt = substr($passwd_hash, 4, 8); |
757 | 782 | |
758 | 783 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
784 | + for (; $count != 0; --$count) { |
|
785 | + $hash = md5($hash . $passwd, true); |
|
786 | + } |
|
761 | 787 | |
762 | 788 | $output = substr($passwd_hash, 0, 12); |
763 | 789 | $i = 0; |
@@ -766,21 +792,25 @@ discard block |
||
766 | 792 | $value = ord($hash[$i++]); |
767 | 793 | $output .= $range[$value & 0x3f]; |
768 | 794 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
795 | + if ($i < 16) { |
|
796 | + $value |= ord($hash[$i]) << 8; |
|
797 | + } |
|
771 | 798 | |
772 | 799 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 800 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
801 | + if ($i++ >= 16) { |
|
802 | + break; |
|
803 | + } |
|
776 | 804 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
805 | + if ($i < 16) { |
|
806 | + $value |= ord($hash[$i]) << 16; |
|
807 | + } |
|
779 | 808 | |
780 | 809 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 810 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
811 | + if ($i++ >= 16) { |
|
812 | + break; |
|
813 | + } |
|
784 | 814 | |
785 | 815 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 816 | } |
@@ -812,8 +842,9 @@ discard block |
||
812 | 842 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 843 | setLoginCookie(-3600, 0); |
814 | 844 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
845 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
846 | + unset($_SESSION['login_' . $cookiename]); |
|
847 | + } |
|
817 | 848 | } |
818 | 849 | |
819 | 850 | // We need a member! |
@@ -827,8 +858,9 @@ discard block |
||
827 | 858 | } |
828 | 859 | |
829 | 860 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
861 | + if ($password_flood_value !== false) { |
|
862 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + } |
|
832 | 864 | |
833 | 865 | // Timestamp or number of tries invalid? |
834 | 866 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +876,17 @@ discard block |
||
844 | 876 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 877 | |
846 | 878 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
879 | + if ($time_stamp < time() - 10) { |
|
880 | + $time_stamp = time(); |
|
881 | + } |
|
849 | 882 | } |
850 | 883 | |
851 | 884 | $number_tries++; |
852 | 885 | |
853 | 886 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
887 | + if ($number_tries > 5) { |
|
888 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + } |
|
856 | 890 | |
857 | 891 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 892 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -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 | * Activate an account. |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | logAction('approve_member', array('member' => $memID), 'admin'); |
49 | 50 | |
50 | 51 | // If we are doing approval, update the stats for the member just in case. |
51 | - if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) |
|
52 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
52 | + if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) { |
|
53 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
|
54 | + } |
|
53 | 55 | |
54 | 56 | // Make sure we update the stats too. |
55 | 57 | updateStats('member', false); |
@@ -76,8 +78,9 @@ discard block |
||
76 | 78 | $issueErrors = array(); |
77 | 79 | |
78 | 80 | // Doesn't hurt to be overly cautious. |
79 | - if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) |
|
80 | - fatal_lang_error('no_access', false); |
|
81 | + if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) { |
|
82 | + fatal_lang_error('no_access', false); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | // Get the base (errors related) stuff done. |
83 | 86 | loadLanguage('Errors'); |
@@ -135,16 +138,18 @@ discard block |
||
135 | 138 | |
136 | 139 | // This cannot be empty! |
137 | 140 | $_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : ''; |
138 | - if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) |
|
139 | - $issueErrors[] = 'warning_no_reason'; |
|
141 | + if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) { |
|
142 | + $issueErrors[] = 'warning_no_reason'; |
|
143 | + } |
|
140 | 144 | $_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']); |
141 | 145 | |
142 | 146 | $_POST['warning_level'] = (int) $_POST['warning_level']; |
143 | 147 | $_POST['warning_level'] = max(0, min(100, $_POST['warning_level'])); |
144 | - if ($_POST['warning_level'] < $context['min_allowed']) |
|
145 | - $_POST['warning_level'] = $context['min_allowed']; |
|
146 | - elseif ($_POST['warning_level'] > $context['max_allowed']) |
|
147 | - $_POST['warning_level'] = $context['max_allowed']; |
|
148 | + if ($_POST['warning_level'] < $context['min_allowed']) { |
|
149 | + $_POST['warning_level'] = $context['min_allowed']; |
|
150 | + } elseif ($_POST['warning_level'] > $context['max_allowed']) { |
|
151 | + $_POST['warning_level'] = $context['max_allowed']; |
|
152 | + } |
|
148 | 153 | |
149 | 154 | // Do we actually have to issue them with a PM? |
150 | 155 | $id_notice = 0; |
@@ -152,8 +157,9 @@ discard block |
||
152 | 157 | { |
153 | 158 | $_POST['warn_sub'] = trim($_POST['warn_sub']); |
154 | 159 | $_POST['warn_body'] = trim($_POST['warn_body']); |
155 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
156 | - $issueErrors[] = 'warning_notify_blank'; |
|
160 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
161 | + $issueErrors[] = 'warning_notify_blank'; |
|
162 | + } |
|
157 | 163 | // Send the PM? |
158 | 164 | else |
159 | 165 | { |
@@ -190,8 +196,8 @@ discard block |
||
190 | 196 | if (empty($issueErrors)) |
191 | 197 | { |
192 | 198 | // Log what we've done! |
193 | - if (!$context['user']['is_owner']) |
|
194 | - $smcFunc['db_insert']('', |
|
199 | + if (!$context['user']['is_owner']) { |
|
200 | + $smcFunc['db_insert']('', |
|
195 | 201 | '{db_prefix}log_comments', |
196 | 202 | array( |
197 | 203 | 'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255', |
@@ -203,14 +209,14 @@ discard block |
||
203 | 209 | ), |
204 | 210 | array('id_comment') |
205 | 211 | ); |
212 | + } |
|
206 | 213 | |
207 | 214 | // Make the change. |
208 | 215 | updateMemberData($memID, array('warning' => $_POST['warning_level'])); |
209 | 216 | |
210 | 217 | // Leave a lovely message. |
211 | 218 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success']; |
212 | - } |
|
213 | - else |
|
219 | + } else |
|
214 | 220 | { |
215 | 221 | // Try to remember some bits. |
216 | 222 | $context['warning_data'] = array( |
@@ -229,8 +235,9 @@ discard block |
||
229 | 235 | { |
230 | 236 | $warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : ''; |
231 | 237 | $context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : ''; |
232 | - if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) |
|
233 | - $issueErrors[] = 'warning_notify_blank'; |
|
238 | + if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) { |
|
239 | + $issueErrors[] = 'warning_notify_blank'; |
|
240 | + } |
|
234 | 241 | |
235 | 242 | if (!empty($_POST['warn_body'])) |
236 | 243 | { |
@@ -254,8 +261,9 @@ discard block |
||
254 | 261 | { |
255 | 262 | // Fill in the suite of errors. |
256 | 263 | $context['post_errors'] = array(); |
257 | - foreach ($issueErrors as $error) |
|
258 | - $context['post_errors'][] = $txt[$error]; |
|
264 | + foreach ($issueErrors as $error) { |
|
265 | + $context['post_errors'][] = $txt[$error]; |
|
266 | + } |
|
259 | 267 | } |
260 | 268 | |
261 | 269 | |
@@ -272,9 +280,10 @@ discard block |
||
272 | 280 | $modSettings['warning_mute'] => $txt['profile_warning_effect_mute'], |
273 | 281 | ); |
274 | 282 | $context['current_level'] = 0; |
275 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
276 | - if ($context['member']['warning'] >= $limit) |
|
283 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
284 | + if ($context['member']['warning'] >= $limit) |
|
277 | 285 | $context['current_level'] = $limit; |
286 | + } |
|
278 | 287 | |
279 | 288 | $listOptions = array( |
280 | 289 | 'id' => 'view_warnings', |
@@ -337,11 +346,12 @@ discard block |
||
337 | 346 | ' . $warning['reason'] . ' |
338 | 347 | </div>'; |
339 | 348 | |
340 | - if (!empty($warning['id_notice'])) |
|
341 | - $ret .= ' |
|
349 | + if (!empty($warning['id_notice'])) { |
|
350 | + $ret .= ' |
|
342 | 351 | <div class="floatright"> |
343 | 352 | <a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a> |
344 | 353 | </div>'; |
354 | + } |
|
345 | 355 | |
346 | 356 | return $ret; |
347 | 357 | }, |
@@ -413,8 +423,9 @@ discard block |
||
413 | 423 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
414 | 424 | { |
415 | 425 | // If we're not warning for a message skip any that are. |
416 | - if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) |
|
417 | - continue; |
|
426 | + if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) { |
|
427 | + continue; |
|
428 | + } |
|
418 | 429 | |
419 | 430 | $context['notification_templates'][] = array( |
420 | 431 | 'title' => $row['template_title'], |
@@ -424,16 +435,18 @@ discard block |
||
424 | 435 | $smcFunc['db_free_result']($request); |
425 | 436 | |
426 | 437 | // Setup the "default" templates. |
427 | - foreach (array('spamming', 'offence', 'insulting') as $type) |
|
428 | - $context['notification_templates'][] = array( |
|
438 | + foreach (array('spamming', 'offence', 'insulting') as $type) { |
|
439 | + $context['notification_templates'][] = array( |
|
429 | 440 | 'title' => $txt['profile_warning_notify_title_' . $type], |
430 | 441 | 'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]), |
431 | 442 | ); |
443 | + } |
|
432 | 444 | |
433 | 445 | // Replace all the common variables in the templates. |
434 | - foreach ($context['notification_templates'] as $k => $name) |
|
435 | - $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
436 | -} |
|
446 | + foreach ($context['notification_templates'] as $k => $name) { |
|
447 | + $context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team'])); |
|
448 | + } |
|
449 | + } |
|
437 | 450 | |
438 | 451 | /** |
439 | 452 | * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning() |
@@ -517,10 +530,11 @@ discard block |
||
517 | 530 | { |
518 | 531 | global $txt, $context, $modSettings, $cur_profile; |
519 | 532 | |
520 | - if (!$context['user']['is_owner']) |
|
521 | - isAllowedTo('profile_remove_any'); |
|
522 | - elseif (!allowedTo('profile_remove_any')) |
|
523 | - isAllowedTo('profile_remove_own'); |
|
533 | + if (!$context['user']['is_owner']) { |
|
534 | + isAllowedTo('profile_remove_any'); |
|
535 | + } elseif (!allowedTo('profile_remove_any')) { |
|
536 | + isAllowedTo('profile_remove_own'); |
|
537 | + } |
|
524 | 538 | |
525 | 539 | // Permissions for removing stuff... |
526 | 540 | $context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum'); |
@@ -547,10 +561,11 @@ discard block |
||
547 | 561 | |
548 | 562 | // @todo Add a way to delete pms as well? |
549 | 563 | |
550 | - if (!$context['user']['is_owner']) |
|
551 | - isAllowedTo('profile_remove_any'); |
|
552 | - elseif (!allowedTo('profile_remove_any')) |
|
553 | - isAllowedTo('profile_remove_own'); |
|
564 | + if (!$context['user']['is_owner']) { |
|
565 | + isAllowedTo('profile_remove_any'); |
|
566 | + } elseif (!allowedTo('profile_remove_any')) { |
|
567 | + isAllowedTo('profile_remove_own'); |
|
568 | + } |
|
554 | 569 | |
555 | 570 | checkSession(); |
556 | 571 | |
@@ -576,8 +591,9 @@ discard block |
||
576 | 591 | list ($another) = $smcFunc['db_fetch_row']($request); |
577 | 592 | $smcFunc['db_free_result']($request); |
578 | 593 | |
579 | - if (empty($another)) |
|
580 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
594 | + if (empty($another)) { |
|
595 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
596 | + } |
|
581 | 597 | } |
582 | 598 | |
583 | 599 | // This file is needed for the deleteMembers function. |
@@ -656,8 +672,9 @@ discard block |
||
656 | 672 | ) |
657 | 673 | ); |
658 | 674 | $topicIDs = array(); |
659 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
660 | - $topicIDs[] = $row['id_topic']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $topicIDs[] = $row['id_topic']; |
|
677 | + } |
|
661 | 678 | $smcFunc['db_free_result']($request); |
662 | 679 | |
663 | 680 | // Actually remove the topics. Ignore recycling if we want to perma-delete things... |
@@ -680,8 +697,9 @@ discard block |
||
680 | 697 | // This could take a while... but ya know it's gonna be worth it in the end. |
681 | 698 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
682 | 699 | { |
683 | - if (function_exists('apache_reset_timeout')) |
|
684 | - @apache_reset_timeout(); |
|
700 | + if (function_exists('apache_reset_timeout')) { |
|
701 | + @apache_reset_timeout(); |
|
702 | + } |
|
685 | 703 | |
686 | 704 | removeMessage($row['id_msg']); |
687 | 705 | } |
@@ -689,8 +707,9 @@ discard block |
||
689 | 707 | } |
690 | 708 | |
691 | 709 | // Only delete this poor members account if they are actually being booted out of camp. |
692 | - if (isset($_POST['deleteAccount'])) |
|
693 | - deleteMembers($memID); |
|
710 | + if (isset($_POST['deleteAccount'])) { |
|
711 | + deleteMembers($memID); |
|
712 | + } |
|
694 | 713 | } |
695 | 714 | // Do they need approval to delete? |
696 | 715 | elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum')) |
@@ -741,18 +760,18 @@ discard block |
||
741 | 760 | { |
742 | 761 | foreach ($costs as $duration => $cost) |
743 | 762 | { |
744 | - if ($cost != 0) |
|
745 | - $cost_array[$duration] = $cost; |
|
763 | + if ($cost != 0) { |
|
764 | + $cost_array[$duration] = $cost; |
|
765 | + } |
|
746 | 766 | } |
747 | - } |
|
748 | - else |
|
767 | + } else |
|
749 | 768 | { |
750 | 769 | $cost_array['fixed'] = $costs['fixed']; |
751 | 770 | } |
752 | 771 | |
753 | - if (empty($cost_array)) |
|
754 | - unset($context['subscriptions'][$id]); |
|
755 | - else |
|
772 | + if (empty($cost_array)) { |
|
773 | + unset($context['subscriptions'][$id]); |
|
774 | + } else |
|
756 | 775 | { |
757 | 776 | $context['subscriptions'][$id]['member'] = 0; |
758 | 777 | $context['subscriptions'][$id]['subscribed'] = false; |
@@ -765,13 +784,15 @@ discard block |
||
765 | 784 | foreach ($gateways as $id => $gateway) |
766 | 785 | { |
767 | 786 | $gateways[$id] = new $gateway['display_class'](); |
768 | - if (!$gateways[$id]->gatewayEnabled()) |
|
769 | - unset($gateways[$id]); |
|
787 | + if (!$gateways[$id]->gatewayEnabled()) { |
|
788 | + unset($gateways[$id]); |
|
789 | + } |
|
770 | 790 | } |
771 | 791 | |
772 | 792 | // No gateways yet? |
773 | - if (empty($gateways)) |
|
774 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
793 | + if (empty($gateways)) { |
|
794 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
795 | + } |
|
775 | 796 | |
776 | 797 | // Get the current subscriptions. |
777 | 798 | $request = $smcFunc['db_query']('', ' |
@@ -786,8 +807,9 @@ discard block |
||
786 | 807 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
787 | 808 | { |
788 | 809 | // The subscription must exist! |
789 | - if (!isset($context['subscriptions'][$row['id_subscribe']])) |
|
790 | - continue; |
|
810 | + if (!isset($context['subscriptions'][$row['id_subscribe']])) { |
|
811 | + continue; |
|
812 | + } |
|
791 | 813 | |
792 | 814 | $context['current'][$row['id_subscribe']] = array( |
793 | 815 | 'id' => $row['id_sublog'], |
@@ -801,8 +823,9 @@ discard block |
||
801 | 823 | 'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'], |
802 | 824 | ); |
803 | 825 | |
804 | - if ($row['status'] == 1) |
|
805 | - $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
826 | + if ($row['status'] == 1) { |
|
827 | + $context['subscriptions'][$row['id_subscribe']]['subscribed'] = true; |
|
828 | + } |
|
806 | 829 | } |
807 | 830 | $smcFunc['db_free_result']($request); |
808 | 831 | |
@@ -853,21 +876,25 @@ discard block |
||
853 | 876 | if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id'])) |
854 | 877 | { |
855 | 878 | // Hopefully just one. |
856 | - foreach ($_POST['sub_id'] as $k => $v) |
|
857 | - $ID_SUB = (int) $k; |
|
879 | + foreach ($_POST['sub_id'] as $k => $v) { |
|
880 | + $ID_SUB = (int) $k; |
|
881 | + } |
|
858 | 882 | |
859 | - if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) |
|
860 | - fatal_lang_error('paid_sub_not_active'); |
|
883 | + if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) { |
|
884 | + fatal_lang_error('paid_sub_not_active'); |
|
885 | + } |
|
861 | 886 | |
862 | 887 | // Simplify... |
863 | 888 | $context['sub'] = $context['subscriptions'][$ID_SUB]; |
864 | 889 | $period = 'xx'; |
865 | - if ($context['sub']['flexible']) |
|
866 | - $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
890 | + if ($context['sub']['flexible']) { |
|
891 | + $period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx'; |
|
892 | + } |
|
867 | 893 | |
868 | 894 | // Check we have a valid cost. |
869 | - if ($context['sub']['flexible'] && $period == 'xx') |
|
870 | - fatal_lang_error('paid_sub_not_active'); |
|
895 | + if ($context['sub']['flexible'] && $period == 'xx') { |
|
896 | + fatal_lang_error('paid_sub_not_active'); |
|
897 | + } |
|
871 | 898 | |
872 | 899 | // Sort out the cost/currency. |
873 | 900 | $context['currency'] = $modSettings['paid_currency_code']; |
@@ -880,8 +907,7 @@ discard block |
||
880 | 907 | $context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]]; |
881 | 908 | // The period value for paypal. |
882 | 909 | $context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1)); |
883 | - } |
|
884 | - else |
|
910 | + } else |
|
885 | 911 | { |
886 | 912 | // Real cost... |
887 | 913 | $context['value'] = $context['sub']['costs']['fixed']; |
@@ -898,13 +924,15 @@ discard block |
||
898 | 924 | foreach ($gateways as $id => $gateway) |
899 | 925 | { |
900 | 926 | $fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done'); |
901 | - if (!empty($fields['form'])) |
|
902 | - $context['gateways'][] = $fields; |
|
927 | + if (!empty($fields['form'])) { |
|
928 | + $context['gateways'][] = $fields; |
|
929 | + } |
|
903 | 930 | } |
904 | 931 | |
905 | 932 | // Bugger?! |
906 | - if (empty($context['gateways'])) |
|
907 | - fatal_error($txt['paid_admin_not_setup_gateway']); |
|
933 | + if (empty($context['gateways'])) { |
|
934 | + fatal_error($txt['paid_admin_not_setup_gateway']); |
|
935 | + } |
|
908 | 936 | |
909 | 937 | // Now we are going to assume they want to take this out ;) |
910 | 938 | $new_data = array($context['sub']['id'], $context['value'], $period, 'prepay'); |
@@ -912,16 +940,19 @@ discard block |
||
912 | 940 | { |
913 | 941 | // What are the details like? |
914 | 942 | $current_pending = array(); |
915 | - if ($context['current'][$context['sub']['id']]['pending_details'] != '') |
|
916 | - $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
943 | + if ($context['current'][$context['sub']['id']]['pending_details'] != '') { |
|
944 | + $current_pending = $smcFunc['json_decode']($context['current'][$context['sub']['id']]['pending_details'], true); |
|
945 | + } |
|
917 | 946 | // Don't get silly. |
918 | - if (count($current_pending) > 9) |
|
919 | - $current_pending = array(); |
|
947 | + if (count($current_pending) > 9) { |
|
948 | + $current_pending = array(); |
|
949 | + } |
|
920 | 950 | $pending_count = 0; |
921 | 951 | // Only record real pending payments as will otherwise confuse the admin! |
922 | - foreach ($current_pending as $pending) |
|
923 | - if ($pending[3] == 'payback') |
|
952 | + foreach ($current_pending as $pending) { |
|
953 | + if ($pending[3] == 'payback') |
|
924 | 954 | $pending_count++; |
955 | + } |
|
925 | 956 | |
926 | 957 | if (!in_array($new_data, $current_pending)) |
927 | 958 | { |
@@ -966,9 +997,9 @@ discard block |
||
966 | 997 | |
967 | 998 | // Quit. |
968 | 999 | return; |
1000 | + } else { |
|
1001 | + $context['sub_template'] = 'user_subscription'; |
|
1002 | + } |
|
969 | 1003 | } |
970 | - else |
|
971 | - $context['sub_template'] = 'user_subscription'; |
|
972 | -} |
|
973 | 1004 | |
974 | 1005 | ?> |
975 | 1006 | \ No newline at end of file |