@@ -37,9 +37,10 @@ discard block |
||
37 | 37 | echo ' |
38 | 38 | <optgroup label="', $category['name'], '">'; |
39 | 39 | |
40 | - foreach ($category['boards'] as $board) |
|
41 | - echo ' |
|
40 | + foreach ($category['boards'] as $board) { |
|
41 | + echo ' |
|
42 | 42 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
43 | + } |
|
43 | 44 | echo ' |
44 | 45 | </optgroup>'; |
45 | 46 | } |
@@ -70,9 +71,10 @@ discard block |
||
70 | 71 | </div><!-- .move_topic --> |
71 | 72 | </div><!-- .windowbg -->'; |
72 | 73 | |
73 | - if ($context['back_to_topic']) |
|
74 | - echo ' |
|
74 | + if ($context['back_to_topic']) { |
|
75 | + echo ' |
|
75 | 76 | <input type="hidden" name="goback" value="1">'; |
77 | + } |
|
76 | 78 | |
77 | 79 | echo ' |
78 | 80 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -125,10 +127,10 @@ discard block |
||
125 | 127 | <option value="86400">', $txt['two_months'], '</option> |
126 | 128 | </select> |
127 | 129 | </dd>'; |
128 | - } |
|
129 | - else |
|
130 | - echo ' |
|
130 | + } else { |
|
131 | + echo ' |
|
131 | 132 | <input type="hidden" name="redirect_expires" value="0">'; |
133 | + } |
|
132 | 134 | |
133 | 135 | echo ' |
134 | 136 | </dl> |
@@ -207,9 +209,10 @@ discard block |
||
207 | 209 | echo ' |
208 | 210 | <optgroup label="', $cat['name'], '">'; |
209 | 211 | |
210 | - foreach ($cat['boards'] as $board) |
|
211 | - echo ' |
|
212 | + foreach ($cat['boards'] as $board) { |
|
213 | + echo ' |
|
212 | 214 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
215 | + } |
|
213 | 216 | |
214 | 217 | echo ' |
215 | 218 | </optgroup>'; |
@@ -219,9 +222,9 @@ discard block |
||
219 | 222 | <input type="hidden" name="from" value="' . $context['origin_topic'] . '"> |
220 | 223 | <input type="submit" value="', $txt['go'], '" class="button"> |
221 | 224 | </form>'; |
225 | + } else { |
|
226 | + echo $txt['target_below']; |
|
222 | 227 | } |
223 | - else |
|
224 | - echo $txt['target_below']; |
|
225 | 228 | |
226 | 229 | echo ' </h4> |
227 | 230 | </div><!-- .title_bar --> |
@@ -239,12 +242,13 @@ discard block |
||
239 | 242 | |
240 | 243 | $merge_button = create_button('merge', 'merge', ''); |
241 | 244 | |
242 | - foreach ($context['topics'] as $topic) |
|
243 | - echo ' |
|
245 | + foreach ($context['topics'] as $topic) { |
|
246 | + echo ' |
|
244 | 247 | <li> |
245 | 248 | <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a> |
246 | 249 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], ' |
247 | 250 | </li>'; |
251 | + } |
|
248 | 252 | |
249 | 253 | echo ' |
250 | 254 | </ul> |
@@ -255,9 +259,10 @@ discard block |
||
255 | 259 | </div>'; |
256 | 260 | } |
257 | 261 | // Just a nice "There aren't any topics" message |
258 | - else |
|
259 | - echo ' |
|
262 | + else { |
|
263 | + echo ' |
|
260 | 264 | <div class="windowbg2">', $txt['topic_alert_none'], '</div>'; |
265 | + } |
|
261 | 266 | |
262 | 267 | echo ' |
263 | 268 | <br> |
@@ -307,8 +312,8 @@ discard block |
||
307 | 312 | </thead> |
308 | 313 | <tbody>'; |
309 | 314 | |
310 | - foreach ($context['topics'] as $topic) |
|
311 | - echo ' |
|
315 | + foreach ($context['topics'] as $topic) { |
|
316 | + echo ' |
|
312 | 317 | <tr class="windowbg"> |
313 | 318 | <td> |
314 | 319 | <input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked> |
@@ -328,6 +333,7 @@ discard block |
||
328 | 333 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked> |
329 | 334 | </td> |
330 | 335 | </tr>'; |
336 | + } |
|
331 | 337 | echo ' |
332 | 338 | </tbody> |
333 | 339 | </table> |
@@ -337,9 +343,10 @@ discard block |
||
337 | 343 | <legend>', $txt['merge_select_subject'], '</legend> |
338 | 344 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">'; |
339 | 345 | |
340 | - foreach ($context['topics'] as $topic) |
|
341 | - echo ' |
|
346 | + foreach ($context['topics'] as $topic) { |
|
347 | + echo ' |
|
342 | 348 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>'; |
349 | + } |
|
343 | 350 | echo ' |
344 | 351 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
345 | 352 | </select> |
@@ -358,11 +365,12 @@ discard block |
||
358 | 365 | <legend>', $txt['merge_select_target_board'], '</legend> |
359 | 366 | <ul>'; |
360 | 367 | |
361 | - foreach ($context['boards'] as $board) |
|
362 | - echo ' |
|
368 | + foreach ($context['boards'] as $board) { |
|
369 | + echo ' |
|
363 | 370 | <li> |
364 | 371 | <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . ' |
365 | 372 | </li>'; |
373 | + } |
|
366 | 374 | echo ' |
367 | 375 | </ul> |
368 | 376 | </fieldset>'; |
@@ -374,11 +382,12 @@ discard block |
||
374 | 382 | <legend>' . $txt['merge_select_poll'] . '</legend> |
375 | 383 | <ul>'; |
376 | 384 | |
377 | - foreach ($context['polls'] as $poll) |
|
378 | - echo ' |
|
385 | + foreach ($context['polls'] as $poll) { |
|
386 | + echo ' |
|
379 | 387 | <li> |
380 | 388 | <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>) |
381 | 389 | </li>'; |
390 | + } |
|
382 | 391 | echo ' |
383 | 392 | <li> |
384 | 393 | <input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ') |
@@ -18,23 +18,25 @@ discard block |
||
18 | 18 | global $context; |
19 | 19 | |
20 | 20 | // Prevent Chrome from auto completing fields when viewing/editing other members profiles |
21 | - if (isBrowser('is_chrome') && !$context['user']['is_owner']) |
|
22 | - echo ' |
|
21 | + if (isBrowser('is_chrome') && !$context['user']['is_owner']) { |
|
22 | + echo ' |
|
23 | 23 | <script> |
24 | 24 | disableAutoComplete(); |
25 | 25 | </script>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | // If an error occurred while trying to save previously, give the user a clue! |
28 | 29 | echo ' |
29 | 30 | ', template_error_message(); |
30 | 31 | |
31 | 32 | // If the profile was update successfully, let the user know this. |
32 | - if (!empty($context['profile_updated'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile_updated'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="infobox"> |
35 | 36 | ', $context['profile_updated'], ' |
36 | 37 | </div>'; |
37 | -} |
|
38 | + } |
|
39 | + } |
|
38 | 40 | |
39 | 41 | /** |
40 | 42 | * Template for any HTML needed below the profile (closing off divs/tables, etc.) |
@@ -99,19 +101,19 @@ discard block |
||
99 | 101 | </div> |
100 | 102 | <div class="alerts_unread">'; |
101 | 103 | |
102 | - if (empty($context['unread_alerts'])) |
|
103 | - template_alerts_all_read(); |
|
104 | - |
|
105 | - else |
|
104 | + if (empty($context['unread_alerts'])) { |
|
105 | + template_alerts_all_read(); |
|
106 | + } else |
|
106 | 107 | { |
107 | - foreach ($context['unread_alerts'] as $id_alert => $details) |
|
108 | - echo ' |
|
108 | + foreach ($context['unread_alerts'] as $id_alert => $details) { |
|
109 | + echo ' |
|
109 | 110 | <div class="unread"> |
110 | 111 | ', !empty($details['sender']) ? $details['sender']['avatar']['image'] : '', ' |
111 | 112 | <div class="details"> |
112 | 113 | ', !empty($details['icon']) ? $details['icon'] : '', '<span>', $details['text'], '</span> - ', $details['time'], ' |
113 | 114 | </div> |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | } |
116 | 118 | |
117 | 119 | echo ' |
@@ -158,37 +160,41 @@ discard block |
||
158 | 160 | if (!empty($context['print_custom_fields']['above_member'])) |
159 | 161 | { |
160 | 162 | $fields = ''; |
161 | - foreach ($context['print_custom_fields']['above_member'] as $field) |
|
162 | - if (!empty($field['output_html'])) |
|
163 | + foreach ($context['print_custom_fields']['above_member'] as $field) { |
|
164 | + if (!empty($field['output_html'])) |
|
163 | 165 | $fields .= ' |
164 | 166 | <li>' . $field['output_html'] . '</li>'; |
167 | + } |
|
165 | 168 | |
166 | - if (!empty($fields)) |
|
167 | - echo ' |
|
169 | + if (!empty($fields)) { |
|
170 | + echo ' |
|
168 | 171 | <div class="custom_fields_above_name"> |
169 | 172 | <ul>', $fields, ' |
170 | 173 | </ul> |
171 | 174 | </div>'; |
175 | + } |
|
172 | 176 | } |
173 | 177 | |
174 | 178 | echo ' |
175 | 179 | <div class="username clear"> |
176 | 180 | <h4>'; |
177 | 181 | |
178 | - if (!empty($context['print_custom_fields']['before_member'])) |
|
179 | - foreach ($context['print_custom_fields']['before_member'] as $field) |
|
182 | + if (!empty($context['print_custom_fields']['before_member'])) { |
|
183 | + foreach ($context['print_custom_fields']['before_member'] as $field) |
|
180 | 184 | if (!empty($field['output_html'])) |
181 | 185 | echo ' |
182 | 186 | <span>', $field['output_html'], '</span>'; |
187 | + } |
|
183 | 188 | |
184 | 189 | echo ' |
185 | 190 | ', $context['member']['name']; |
186 | 191 | |
187 | - if (!empty($context['print_custom_fields']['after_member'])) |
|
188 | - foreach ($context['print_custom_fields']['after_member'] as $field) |
|
192 | + if (!empty($context['print_custom_fields']['after_member'])) { |
|
193 | + foreach ($context['print_custom_fields']['after_member'] as $field) |
|
189 | 194 | if (!empty($field['output_html'])) |
190 | 195 | echo ' |
191 | 196 | <span>', $field['output_html'], '</span>'; |
197 | + } |
|
192 | 198 | |
193 | 199 | |
194 | 200 | echo ' |
@@ -201,39 +207,44 @@ discard block |
||
201 | 207 | if (!empty($context['print_custom_fields']['below_avatar'])) |
202 | 208 | { |
203 | 209 | $fields = ''; |
204 | - foreach ($context['print_custom_fields']['below_avatar'] as $field) |
|
205 | - if (!empty($field['output_html'])) |
|
210 | + foreach ($context['print_custom_fields']['below_avatar'] as $field) { |
|
211 | + if (!empty($field['output_html'])) |
|
206 | 212 | $fields .= ' |
207 | 213 | <li>' . $field['output_html'] . '</li>'; |
214 | + } |
|
208 | 215 | |
209 | - if (!empty($fields)) |
|
210 | - echo ' |
|
216 | + if (!empty($fields)) { |
|
217 | + echo ' |
|
211 | 218 | <div class="custom_fields_below_avatar"> |
212 | 219 | <ul>', $fields, ' |
213 | 220 | </ul> |
214 | 221 | </div>'; |
222 | + } |
|
215 | 223 | } |
216 | 224 | |
217 | 225 | echo ' |
218 | 226 | <ul class="icon_fields clear">'; |
219 | 227 | |
220 | 228 | // Email is only visible if it's your profile or you have the moderate_forum permission |
221 | - if ($context['member']['show_email']) |
|
222 | - echo ' |
|
229 | + if ($context['member']['show_email']) { |
|
230 | + echo ' |
|
223 | 231 | <li><a href="mailto:', $context['member']['email'], '" title="', $context['member']['email'], '" rel="nofollow"><span class="generic_icons mail" title="' . $txt['email'] . '"></span></a></li>'; |
232 | + } |
|
224 | 233 | |
225 | 234 | // Don't show an icon if they haven't specified a website. |
226 | - if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) |
|
227 | - echo ' |
|
235 | + if ($context['member']['website']['url'] !== '' && !isset($context['disabled_fields']['website'])) { |
|
236 | + echo ' |
|
228 | 237 | <li><a href="', $context['member']['website']['url'], '" title="' . $context['member']['website']['title'] . '" target="_blank" rel="noopener">', ($settings['use_image_buttons'] ? '<span class="generic_icons www" title="' . $context['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
238 | + } |
|
229 | 239 | |
230 | 240 | // Are there any custom profile fields as icons? |
231 | 241 | if (!empty($context['print_custom_fields']['icons'])) |
232 | 242 | { |
233 | - foreach ($context['print_custom_fields']['icons'] as $field) |
|
234 | - if (!empty($field['output_html'])) |
|
243 | + foreach ($context['print_custom_fields']['icons'] as $field) { |
|
244 | + if (!empty($field['output_html'])) |
|
235 | 245 | echo ' |
236 | 246 | <li class="custom_field">', $field['output_html'], '</li>'; |
247 | + } |
|
237 | 248 | } |
238 | 249 | |
239 | 250 | echo ' |
@@ -242,24 +253,27 @@ discard block |
||
242 | 253 | ', $context['can_send_pm'] ? '<a href="' . $context['member']['online']['href'] . '" title="' . $context['member']['online']['text'] . '" rel="nofollow">' : '', $settings['use_image_buttons'] ? '<span class="' . ($context['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $context['member']['online']['text'] . '"></span>' : $context['member']['online']['label'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['label'] . '</span>' : ''; |
243 | 254 | |
244 | 255 | // Can they add this member as a buddy? |
245 | - if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) |
|
246 | - echo ' |
|
256 | + if (!empty($context['can_have_buddy']) && !$context['user']['is_owner']) { |
|
257 | + echo ' |
|
247 | 258 | <br> |
248 | 259 | <a href="', $scripturl, '?action=buddy;u=', $context['id_member'], ';', $context['session_var'], '=', $context['session_id'], '">[', $txt['buddy_' . ($context['member']['is_buddy'] ? 'remove' : 'add')], ']</a>'; |
260 | + } |
|
249 | 261 | |
250 | 262 | echo ' |
251 | 263 | </span>'; |
252 | 264 | |
253 | - if (!$context['user']['is_owner'] && $context['can_send_pm']) |
|
254 | - echo ' |
|
265 | + if (!$context['user']['is_owner'] && $context['can_send_pm']) { |
|
266 | + echo ' |
|
255 | 267 | <a href="', $scripturl, '?action=pm;sa=send;u=', $context['id_member'], '" class="infolinks">', $txt['profile_sendpm_short'], '</a>'; |
268 | + } |
|
256 | 269 | |
257 | 270 | echo ' |
258 | 271 | <a href="', $scripturl, '?action=profile;area=showposts;u=', $context['id_member'], '" class="infolinks">', $txt['showPosts'], '</a>'; |
259 | 272 | |
260 | - if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) |
|
261 | - echo ' |
|
273 | + if ($context['user']['is_owner'] && !empty($modSettings['drafts_post_enabled'])) { |
|
274 | + echo ' |
|
262 | 275 | <a href="', $scripturl, '?action=profile;area=showdrafts;u=', $context['id_member'], '" class="infolinks">', $txt['drafts_show'], '</a>'; |
276 | + } |
|
263 | 277 | |
264 | 278 | echo ' |
265 | 279 | <a href="', $scripturl, '?action=profile;area=statistics;u=', $context['id_member'], '" class="infolinks">', $txt['statPanel'], '</a>'; |
@@ -268,17 +282,19 @@ discard block |
||
268 | 282 | if (!empty($context['print_custom_fields']['bottom_poster'])) |
269 | 283 | { |
270 | 284 | $fields = ''; |
271 | - foreach ($context['print_custom_fields']['bottom_poster'] as $field) |
|
272 | - if (!empty($field['output_html'])) |
|
285 | + foreach ($context['print_custom_fields']['bottom_poster'] as $field) { |
|
286 | + if (!empty($field['output_html'])) |
|
273 | 287 | $fields .= ' |
274 | 288 | <li>' . $field['output_html'] . '</li>'; |
289 | + } |
|
275 | 290 | |
276 | - if (!empty($fields)) |
|
277 | - echo ' |
|
291 | + if (!empty($fields)) { |
|
292 | + echo ' |
|
278 | 293 | <div class="custom_fields_bottom"> |
279 | 294 | <ul class="nolist">', $fields, ' |
280 | 295 | </ul> |
281 | 296 | </div>'; |
297 | + } |
|
282 | 298 | } |
283 | 299 | |
284 | 300 | echo ' |
@@ -287,30 +303,35 @@ discard block |
||
287 | 303 | <div id="detailedinfo"> |
288 | 304 | <dl class="settings">'; |
289 | 305 | |
290 | - if ($context['user']['is_owner'] || $context['user']['is_admin']) |
|
291 | - echo ' |
|
306 | + if ($context['user']['is_owner'] || $context['user']['is_admin']) { |
|
307 | + echo ' |
|
292 | 308 | <dt>', $txt['username'], ': </dt> |
293 | 309 | <dd>', $context['member']['username'], '</dd>'; |
310 | + } |
|
294 | 311 | |
295 | - if (!isset($context['disabled_fields']['posts'])) |
|
296 | - echo ' |
|
312 | + if (!isset($context['disabled_fields']['posts'])) { |
|
313 | + echo ' |
|
297 | 314 | <dt>', $txt['profile_posts'], ': </dt> |
298 | 315 | <dd>', $context['member']['posts'], ' (', $context['member']['posts_per_day'], ' ', $txt['posts_per_day'], ')</dd>'; |
316 | + } |
|
299 | 317 | |
300 | - if ($context['member']['show_email']) |
|
301 | - echo ' |
|
318 | + if ($context['member']['show_email']) { |
|
319 | + echo ' |
|
302 | 320 | <dt>', $txt['email'], ': </dt> |
303 | 321 | <dd><a href="mailto:', $context['member']['email'], '">', $context['member']['email'], '</a></dd>'; |
322 | + } |
|
304 | 323 | |
305 | - if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) |
|
306 | - echo ' |
|
324 | + if (!empty($modSettings['titlesEnable']) && !empty($context['member']['title'])) { |
|
325 | + echo ' |
|
307 | 326 | <dt>', $txt['custom_title'], ': </dt> |
308 | 327 | <dd>', $context['member']['title'], '</dd>'; |
328 | + } |
|
309 | 329 | |
310 | - if (!empty($context['member']['blurb'])) |
|
311 | - echo ' |
|
330 | + if (!empty($context['member']['blurb'])) { |
|
331 | + echo ' |
|
312 | 332 | <dt>', $txt['personal_text'], ': </dt> |
313 | 333 | <dd>', $context['member']['blurb'], '</dd>'; |
334 | + } |
|
314 | 335 | |
315 | 336 | echo ' |
316 | 337 | <dt>', $txt['age'], ':</dt> |
@@ -324,19 +345,21 @@ discard block |
||
324 | 345 | { |
325 | 346 | $fields = array(); |
326 | 347 | |
327 | - foreach ($context['print_custom_fields']['standard'] as $field) |
|
328 | - if (!empty($field['output_html'])) |
|
348 | + foreach ($context['print_custom_fields']['standard'] as $field) { |
|
349 | + if (!empty($field['output_html'])) |
|
329 | 350 | $fields[] = $field; |
351 | + } |
|
330 | 352 | |
331 | 353 | if (count($fields) > 0) |
332 | 354 | { |
333 | 355 | echo ' |
334 | 356 | <dl class="settings">'; |
335 | 357 | |
336 | - foreach ($fields as $field) |
|
337 | - echo ' |
|
358 | + foreach ($fields as $field) { |
|
359 | + echo ' |
|
338 | 360 | <dt>', $field['name'], ':</dt> |
339 | 361 | <dd>', $field['output_html'], '</dd>'; |
362 | + } |
|
340 | 363 | |
341 | 364 | echo ' |
342 | 365 | </dl>'; |
@@ -355,9 +378,10 @@ discard block |
||
355 | 378 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=', ($context['can_issue_warning'] && !$context['user']['is_owner'] ? 'issuewarning' : 'viewwarning'), '">', $context['member']['warning'], '%</a>'; |
356 | 379 | |
357 | 380 | // Can we provide information on what this means? |
358 | - if (!empty($context['warning_status'])) |
|
359 | - echo ' |
|
381 | + if (!empty($context['warning_status'])) { |
|
382 | + echo ' |
|
360 | 383 | <span class="smalltext">(', $context['warning_status'], ')</span>'; |
384 | + } |
|
361 | 385 | |
362 | 386 | echo ' |
363 | 387 | </dd>'; |
@@ -367,11 +391,12 @@ discard block |
||
367 | 391 | if (!empty($context['activate_message']) || !empty($context['member']['bans'])) |
368 | 392 | { |
369 | 393 | // If the person looking at the summary has permission, and the account isn't activated, give the viewer the ability to do it themselves. |
370 | - if (!empty($context['activate_message'])) |
|
371 | - echo ' |
|
394 | + if (!empty($context['activate_message'])) { |
|
395 | + echo ' |
|
372 | 396 | <dt class="clear"> |
373 | 397 | <span class="alert">', $context['activate_message'], '</span> (<a href="', $context['activate_link'], '"', ($context['activate_type'] == 4 ? ' class="you_sure" data-confirm="' . $txt['profileConfirm'] . '"' : ''), '>', $context['activate_link_text'], '</a>) |
374 | 398 | </dt>'; |
399 | + } |
|
375 | 400 | |
376 | 401 | // If the current member is banned, show a message and possibly a link to the ban. |
377 | 402 | if (!empty($context['member']['bans'])) |
@@ -383,10 +408,11 @@ discard block |
||
383 | 408 | <dt class="clear" id="ban_info" style="display: none;"> |
384 | 409 | <strong>', $txt['user_banned_by_following'], ':</strong>'; |
385 | 410 | |
386 | - foreach ($context['member']['bans'] as $ban) |
|
387 | - echo ' |
|
411 | + foreach ($context['member']['bans'] as $ban) { |
|
412 | + echo ' |
|
388 | 413 | <br> |
389 | 414 | <span class="smalltext">', $ban['explanation'], '</span>'; |
415 | + } |
|
390 | 416 | |
391 | 417 | echo ' |
392 | 418 | </dt>'; |
@@ -400,30 +426,34 @@ discard block |
||
400 | 426 | // If the person looking is allowed, they can check the members IP address and hostname. |
401 | 427 | if ($context['can_see_ip']) |
402 | 428 | { |
403 | - if (!empty($context['member']['ip'])) |
|
404 | - echo ' |
|
429 | + if (!empty($context['member']['ip'])) { |
|
430 | + echo ' |
|
405 | 431 | <dt>', $txt['ip'], ': </dt> |
406 | 432 | <dd><a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['member']['ip'], ';u=', $context['member']['id'], '">', $context['member']['ip'], '</a></dd>'; |
433 | + } |
|
407 | 434 | |
408 | - if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) |
|
409 | - echo ' |
|
435 | + if (empty($modSettings['disableHostnameLookup']) && !empty($context['member']['ip'])) { |
|
436 | + echo ' |
|
410 | 437 | <dt>', $txt['hostname'], ': </dt> |
411 | 438 | <dd>', $context['member']['hostname'], '</dd>'; |
439 | + } |
|
412 | 440 | } |
413 | 441 | |
414 | 442 | echo ' |
415 | 443 | <dt>', $txt['local_time'], ':</dt> |
416 | 444 | <dd>', $context['member']['local_time'], '</dd>'; |
417 | 445 | |
418 | - if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) |
|
419 | - echo ' |
|
446 | + if (!empty($modSettings['userLanguage']) && !empty($context['member']['language'])) { |
|
447 | + echo ' |
|
420 | 448 | <dt>', $txt['language'], ':</dt> |
421 | 449 | <dd>', $context['member']['language'], '</dd>'; |
450 | + } |
|
422 | 451 | |
423 | - if ($context['member']['show_last_login']) |
|
424 | - echo ' |
|
452 | + if ($context['member']['show_last_login']) { |
|
453 | + echo ' |
|
425 | 454 | <dt>', $txt['lastLoggedIn'], ': </dt> |
426 | 455 | <dd>', $context['member']['last_login'], (!empty($context['member']['is_hidden']) ? ' (' . $txt['hidden'] . ')' : ''), '</dd>'; |
456 | + } |
|
427 | 457 | |
428 | 458 | echo ' |
429 | 459 | </dl>'; |
@@ -432,42 +462,47 @@ discard block |
||
432 | 462 | if (!empty($context['print_custom_fields']['above_signature'])) |
433 | 463 | { |
434 | 464 | $fields = ''; |
435 | - foreach ($context['print_custom_fields']['above_signature'] as $field) |
|
436 | - if (!empty($field['output_html'])) |
|
465 | + foreach ($context['print_custom_fields']['above_signature'] as $field) { |
|
466 | + if (!empty($field['output_html'])) |
|
437 | 467 | $fields .= ' |
438 | 468 | <li>' . $field['output_html'] . '</li>'; |
469 | + } |
|
439 | 470 | |
440 | - if (!empty($fields)) |
|
441 | - echo ' |
|
471 | + if (!empty($fields)) { |
|
472 | + echo ' |
|
442 | 473 | <div class="custom_fields_above_signature"> |
443 | 474 | <ul class="nolist">', $fields, ' |
444 | 475 | </ul> |
445 | 476 | </div>'; |
477 | + } |
|
446 | 478 | } |
447 | 479 | |
448 | 480 | // Show the users signature. |
449 | - if ($context['signature_enabled'] && !empty($context['member']['signature'])) |
|
450 | - echo ' |
|
481 | + if ($context['signature_enabled'] && !empty($context['member']['signature'])) { |
|
482 | + echo ' |
|
451 | 483 | <div class="signature"> |
452 | 484 | <h5>', $txt['signature'], ':</h5> |
453 | 485 | ', $context['member']['signature'], ' |
454 | 486 | </div>'; |
487 | + } |
|
455 | 488 | |
456 | 489 | // Are there any custom profile fields for below the signature? |
457 | 490 | if (!empty($context['print_custom_fields']['below_signature'])) |
458 | 491 | { |
459 | 492 | $fields = ''; |
460 | - foreach ($context['print_custom_fields']['below_signature'] as $field) |
|
461 | - if (!empty($field['output_html'])) |
|
493 | + foreach ($context['print_custom_fields']['below_signature'] as $field) { |
|
494 | + if (!empty($field['output_html'])) |
|
462 | 495 | $fields .= ' |
463 | 496 | <li>' . $field['output_html'] . '</li>'; |
497 | + } |
|
464 | 498 | |
465 | - if (!empty($fields)) |
|
466 | - echo ' |
|
499 | + if (!empty($fields)) { |
|
500 | + echo ' |
|
467 | 501 | <div class="custom_fields_below_signature"> |
468 | 502 | <ul class="nolist">', $fields, ' |
469 | 503 | </ul> |
470 | 504 | </div>'; |
505 | + } |
|
471 | 506 | } |
472 | 507 | |
473 | 508 | echo ' |
@@ -509,62 +544,70 @@ discard block |
||
509 | 544 | </div> |
510 | 545 | <div class="list_posts">'; |
511 | 546 | |
512 | - if (!$post['approved']) |
|
513 | - echo ' |
|
547 | + if (!$post['approved']) { |
|
548 | + echo ' |
|
514 | 549 | <div class="approve_post"> |
515 | 550 | <em>', $txt['post_awaiting_approval'], '</em> |
516 | 551 | </div>'; |
552 | + } |
|
517 | 553 | |
518 | 554 | echo ' |
519 | 555 | ', $post['body'], ' |
520 | 556 | </div>'; |
521 | 557 | |
522 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
523 | - echo ' |
|
558 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
559 | + echo ' |
|
524 | 560 | <div class="floatright"> |
525 | 561 | <ul class="quickbuttons">'; |
562 | + } |
|
526 | 563 | |
527 | 564 | // If they *can* reply? |
528 | - if ($post['can_reply']) |
|
529 | - echo ' |
|
565 | + if ($post['can_reply']) { |
|
566 | + echo ' |
|
530 | 567 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
568 | + } |
|
531 | 569 | |
532 | 570 | // If they *can* quote? |
533 | - if ($post['can_quote']) |
|
534 | - echo ' |
|
571 | + if ($post['can_quote']) { |
|
572 | + echo ' |
|
535 | 573 | <li><a href="', $scripturl . '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
574 | + } |
|
536 | 575 | |
537 | 576 | // How about... even... remove it entirely?! |
538 | - if ($post['can_delete']) |
|
539 | - echo ' |
|
577 | + if ($post['can_delete']) { |
|
578 | + echo ' |
|
540 | 579 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';profile;u=', $context['member']['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
580 | + } |
|
541 | 581 | |
542 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
543 | - echo ' |
|
582 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
583 | + echo ' |
|
544 | 584 | </ul> |
545 | 585 | </div><!-- .floatright -->'; |
586 | + } |
|
546 | 587 | |
547 | 588 | echo ' |
548 | 589 | </div><!-- $post[css_class] -->'; |
549 | 590 | } |
591 | + } else { |
|
592 | + template_show_list('attachments'); |
|
550 | 593 | } |
551 | - else |
|
552 | - template_show_list('attachments'); |
|
553 | 594 | |
554 | 595 | // No posts? Just end with a informative message. |
555 | - if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) |
|
556 | - echo ' |
|
596 | + if ((isset($context['attachments']) && empty($context['attachments'])) || (!isset($context['attachments']) && empty($context['posts']))) { |
|
597 | + echo ' |
|
557 | 598 | <div class="windowbg2"> |
558 | 599 | ', isset($context['attachments']) ? $txt['show_attachments_none'] : ($context['is_topics'] ? $txt['show_topics_none'] : $txt['show_posts_none']), ' |
559 | 600 | </div>'; |
601 | + } |
|
560 | 602 | |
561 | 603 | // Show more page numbers. |
562 | - if (!empty($context['page_index'])) |
|
563 | - echo ' |
|
604 | + if (!empty($context['page_index'])) { |
|
605 | + echo ' |
|
564 | 606 | <div class="pagesection"> |
565 | 607 | <div class="pagelinks">', $context['page_index'], '</div> |
566 | 608 | </div>'; |
567 | -} |
|
609 | + } |
|
610 | + } |
|
568 | 611 | |
569 | 612 | /** |
570 | 613 | * Template for showing alerts within the alerts popup |
@@ -574,11 +617,12 @@ discard block |
||
574 | 617 | global $context, $txt, $scripturl; |
575 | 618 | |
576 | 619 | // Do we have an update message? |
577 | - if (!empty($context['update_message'])) |
|
578 | - echo ' |
|
620 | + if (!empty($context['update_message'])) { |
|
621 | + echo ' |
|
579 | 622 | <div class="infobox"> |
580 | 623 | ', $context['update_message'], ' |
581 | 624 | </div>'; |
625 | + } |
|
582 | 626 | |
583 | 627 | echo ' |
584 | 628 | <div class="cat_bar"> |
@@ -587,19 +631,19 @@ discard block |
||
587 | 631 | </h3> |
588 | 632 | </div>'; |
589 | 633 | |
590 | - if (empty($context['alerts'])) |
|
591 | - echo ' |
|
634 | + if (empty($context['alerts'])) { |
|
635 | + echo ' |
|
592 | 636 | <div class="information"> |
593 | 637 | ', $txt['alerts_none'], ' |
594 | 638 | </div>'; |
595 | - |
|
596 | - else |
|
639 | + } else |
|
597 | 640 | { |
598 | 641 | |
599 | 642 | // Start the form if checkboxes are in use |
600 | - if ($context['showCheckboxes']) |
|
601 | - echo ' |
|
643 | + if ($context['showCheckboxes']) { |
|
644 | + echo ' |
|
602 | 645 | <form action="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;save" method="post" accept-charset="', $context['character_set'], '" id="mark_all">'; |
646 | + } |
|
603 | 647 | |
604 | 648 | echo ' |
605 | 649 | <table id="alerts" class="table_grid">'; |
@@ -615,9 +659,10 @@ discard block |
||
615 | 659 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=remove;aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li> |
616 | 660 | <li><a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=showalerts;do=', ($alert['is_read'] != 0 ? 'unread' : 'read'), ';aid=', $id, ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons ', $alert['is_read'] != 0 ? 'unread_button' : 'read_button', '"></span>', ($alert['is_read'] != 0 ? $txt['mark_unread'] : $txt['mark_read_short']), '</a></li>'; |
617 | 661 | |
618 | - if ($context['showCheckboxes']) |
|
619 | - echo ' |
|
662 | + if ($context['showCheckboxes']) { |
|
663 | + echo ' |
|
620 | 664 | <li><input type="checkbox" name="mark[', $id, ']" value="', $id, '"></li>'; |
665 | + } |
|
621 | 666 | |
622 | 667 | echo ' |
623 | 668 | </ul> |
@@ -632,8 +677,8 @@ discard block |
||
632 | 677 | ', $context['pagination'], ' |
633 | 678 | </div>'; |
634 | 679 | |
635 | - if ($context['showCheckboxes']) |
|
636 | - echo ' |
|
680 | + if ($context['showCheckboxes']) { |
|
681 | + echo ' |
|
637 | 682 | <div class="floatright"> |
638 | 683 | ', $txt['check_all'], ': <input type="checkbox" name="select_all" id="select_all"> |
639 | 684 | <select name="mark_as"> |
@@ -644,14 +689,16 @@ discard block |
||
644 | 689 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
645 | 690 | <input type="submit" name="req" value="', $txt['quick_mod_go'], '" class="button you_sure"> |
646 | 691 | </div>'; |
692 | + } |
|
647 | 693 | |
648 | 694 | echo ' |
649 | 695 | </div>'; |
650 | 696 | |
651 | - if ($context['showCheckboxes']) |
|
652 | - echo ' |
|
697 | + if ($context['showCheckboxes']) { |
|
698 | + echo ' |
|
653 | 699 | </form>'; |
654 | 700 | } |
701 | + } |
|
655 | 702 | } |
656 | 703 | |
657 | 704 | /** |
@@ -672,12 +719,12 @@ discard block |
||
672 | 719 | </div>' : ''; |
673 | 720 | |
674 | 721 | // No drafts? Just show an informative message. |
675 | - if (empty($context['drafts'])) |
|
676 | - echo ' |
|
722 | + if (empty($context['drafts'])) { |
|
723 | + echo ' |
|
677 | 724 | <div class="windowbg2 centertext"> |
678 | 725 | ', $txt['draft_none'], ' |
679 | 726 | </div>'; |
680 | - else |
|
727 | + } else |
|
681 | 728 | { |
682 | 729 | // For every draft to be displayed, give it its own div, and show the important details of the draft. |
683 | 730 | foreach ($context['drafts'] as $draft) |
@@ -689,13 +736,15 @@ discard block |
||
689 | 736 | <h5> |
690 | 737 | <strong><a href="', $scripturl, '?board=', $draft['board']['id'], '.0">', $draft['board']['name'], '</a> / ', $draft['topic']['link'], '</strong> '; |
691 | 738 | |
692 | - if (!empty($draft['sticky'])) |
|
693 | - echo ' |
|
739 | + if (!empty($draft['sticky'])) { |
|
740 | + echo ' |
|
694 | 741 | <span class="generic_icons sticky" title="', $txt['sticky_topic'], '"></span>'; |
742 | + } |
|
695 | 743 | |
696 | - if (!empty($draft['locked'])) |
|
697 | - echo ' |
|
744 | + if (!empty($draft['locked'])) { |
|
745 | + echo ' |
|
698 | 746 | <span class="generic_icons lock" title="', $txt['locked_topic'], '"></span>'; |
747 | + } |
|
699 | 748 | |
700 | 749 | echo ' |
701 | 750 | </h5> |
@@ -728,13 +777,13 @@ discard block |
||
728 | 777 | { |
729 | 778 | global $context, $scripturl, $txt; |
730 | 779 | |
731 | - if (!empty($context['saved_successful'])) |
|
732 | - echo ' |
|
780 | + if (!empty($context['saved_successful'])) { |
|
781 | + echo ' |
|
733 | 782 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
734 | - |
|
735 | - elseif (!empty($context['saved_failed'])) |
|
736 | - echo ' |
|
783 | + } elseif (!empty($context['saved_failed'])) { |
|
784 | + echo ' |
|
737 | 785 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
786 | + } |
|
738 | 787 | |
739 | 788 | echo ' |
740 | 789 | <div id="edit_buddies"> |
@@ -749,14 +798,16 @@ discard block |
||
749 | 798 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
750 | 799 | <th scope="col">', $txt['status'], '</th>'; |
751 | 800 | |
752 | - if (allowedTo('moderate_forum')) |
|
753 | - echo ' |
|
801 | + if (allowedTo('moderate_forum')) { |
|
802 | + echo ' |
|
754 | 803 | <th scope="col">', $txt['email'], '</th>'; |
804 | + } |
|
755 | 805 | |
756 | - if (!empty($context['custom_pf'])) |
|
757 | - foreach ($context['custom_pf'] as $column) |
|
806 | + if (!empty($context['custom_pf'])) { |
|
807 | + foreach ($context['custom_pf'] as $column) |
|
758 | 808 | echo ' |
759 | 809 | <th scope="col">', $column['label'], '</th>'; |
810 | + } |
|
760 | 811 | |
761 | 812 | echo ' |
762 | 813 | <th scope="col">', $txt['remove'], '</th> |
@@ -765,13 +816,14 @@ discard block |
||
765 | 816 | <tbody>'; |
766 | 817 | |
767 | 818 | // If they don't have any buddies don't list them! |
768 | - if (empty($context['buddies'])) |
|
769 | - echo ' |
|
819 | + if (empty($context['buddies'])) { |
|
820 | + echo ' |
|
770 | 821 | <tr class="windowbg"> |
771 | 822 | <td colspan="', allowedTo('moderate_forum') ? '10' : '9', '"> |
772 | 823 | <strong>', $txt['no_buddies'], '</strong> |
773 | 824 | </td> |
774 | 825 | </tr>'; |
826 | + } |
|
775 | 827 | |
776 | 828 | // Now loop through each buddy showing info on each. |
777 | 829 | else |
@@ -785,17 +837,19 @@ discard block |
||
785 | 837 | <a href="', $buddy['online']['href'], '"><span class="' . ($buddy['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $buddy['online']['text'] . '"></span></a> |
786 | 838 | </td>'; |
787 | 839 | |
788 | - if ($buddy['show_email']) |
|
789 | - echo ' |
|
840 | + if ($buddy['show_email']) { |
|
841 | + echo ' |
|
790 | 842 | <td> |
791 | 843 | <a href="mailto:' . $buddy['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $buddy['name'] . '"></span></a> |
792 | 844 | </td>'; |
845 | + } |
|
793 | 846 | |
794 | 847 | // Show the custom profile fields for this user. |
795 | - if (!empty($context['custom_pf'])) |
|
796 | - foreach ($context['custom_pf'] as $key => $column) |
|
848 | + if (!empty($context['custom_pf'])) { |
|
849 | + foreach ($context['custom_pf'] as $key => $column) |
|
797 | 850 | echo ' |
798 | 851 | <td class="lefttext">', $buddy['options'][$key], '</td>'; |
852 | + } |
|
799 | 853 | |
800 | 854 | echo ' |
801 | 855 | <td> |
@@ -828,9 +882,10 @@ discard block |
||
828 | 882 | </dl> |
829 | 883 | </div>'; |
830 | 884 | |
831 | - if (!empty($context['token_check'])) |
|
832 | - echo ' |
|
885 | + if (!empty($context['token_check'])) { |
|
886 | + echo ' |
|
833 | 887 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
888 | + } |
|
834 | 889 | |
835 | 890 | echo ' |
836 | 891 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -856,13 +911,13 @@ discard block |
||
856 | 911 | { |
857 | 912 | global $context, $scripturl, $txt; |
858 | 913 | |
859 | - if (!empty($context['saved_successful'])) |
|
860 | - echo ' |
|
914 | + if (!empty($context['saved_successful'])) { |
|
915 | + echo ' |
|
861 | 916 | <div class="infobox">', $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $context['member']['name']), '</div>'; |
862 | - |
|
863 | - elseif (!empty($context['saved_failed'])) |
|
864 | - echo ' |
|
917 | + } elseif (!empty($context['saved_failed'])) { |
|
918 | + echo ' |
|
865 | 919 | <div class="errorbox">', $context['saved_failed'], '</div>'; |
920 | + } |
|
866 | 921 | |
867 | 922 | echo ' |
868 | 923 | <div id="edit_buddies"> |
@@ -877,9 +932,10 @@ discard block |
||
877 | 932 | <th scope="col" class="quarter_table">', $txt['name'], '</th> |
878 | 933 | <th scope="col">', $txt['status'], '</th>'; |
879 | 934 | |
880 | - if (allowedTo('moderate_forum')) |
|
881 | - echo ' |
|
935 | + if (allowedTo('moderate_forum')) { |
|
936 | + echo ' |
|
882 | 937 | <th scope="col">', $txt['email'], '</th>'; |
938 | + } |
|
883 | 939 | |
884 | 940 | echo ' |
885 | 941 | <th scope="col">', $txt['ignore_remove'], '</th> |
@@ -888,13 +944,14 @@ discard block |
||
888 | 944 | <tbody>'; |
889 | 945 | |
890 | 946 | // If they don't have anyone on their ignore list, don't list it! |
891 | - if (empty($context['ignore_list'])) |
|
892 | - echo ' |
|
947 | + if (empty($context['ignore_list'])) { |
|
948 | + echo ' |
|
893 | 949 | <tr class="windowbg"> |
894 | 950 | <td colspan="', allowedTo('moderate_forum') ? '4' : '3', '"> |
895 | 951 | <strong>', $txt['no_ignore'], '</strong> |
896 | 952 | </td> |
897 | 953 | </tr>'; |
954 | + } |
|
898 | 955 | |
899 | 956 | // Now loop through each buddy showing info on each. |
900 | 957 | foreach ($context['ignore_list'] as $member) |
@@ -906,11 +963,12 @@ discard block |
||
906 | 963 | <a href="', $member['online']['href'], '"><span class="' . ($member['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $member['online']['text'] . '"></span></a> |
907 | 964 | </td>'; |
908 | 965 | |
909 | - if ($member['show_email']) |
|
910 | - echo ' |
|
966 | + if ($member['show_email']) { |
|
967 | + echo ' |
|
911 | 968 | <td> |
912 | 969 | <a href="mailto:' . $member['email'] . '" rel="nofollow"><span class="generic_icons mail icon" title="' . $txt['email'] . ' ' . $member['name'] . '"></span></a> |
913 | 970 | </td>'; |
971 | + } |
|
914 | 972 | echo ' |
915 | 973 | <td> |
916 | 974 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=lists;sa=ignore;remove=', $member['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons delete" title="', $txt['ignore_remove'], '"></span></a> |
@@ -940,9 +998,10 @@ discard block |
||
940 | 998 | </dl> |
941 | 999 | </div>'; |
942 | 1000 | |
943 | - if (!empty($context['token_check'])) |
|
944 | - echo ' |
|
1001 | + if (!empty($context['token_check'])) { |
|
1002 | + echo ' |
|
945 | 1003 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1004 | + } |
|
946 | 1005 | |
947 | 1006 | echo ' |
948 | 1007 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -988,9 +1047,10 @@ discard block |
||
988 | 1047 | <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip'], ';u=', $context['member']['id'], '">', $context['last_ip'], '</a>'; |
989 | 1048 | |
990 | 1049 | // Second address detected? |
991 | - if (!empty($context['last_ip2'])) |
|
992 | - echo ' |
|
1050 | + if (!empty($context['last_ip2'])) { |
|
1051 | + echo ' |
|
993 | 1052 | , <a href="', $scripturl, '?action=profile;area=tracking;sa=ip;searchip=', $context['last_ip2'], ';u=', $context['member']['id'], '">', $context['last_ip2'], '</a>'; |
1053 | + } |
|
994 | 1054 | |
995 | 1055 | echo ' |
996 | 1056 | </dd>'; |
@@ -1056,9 +1116,10 @@ discard block |
||
1056 | 1116 | </div> |
1057 | 1117 | <div class="windowbg2 noup">'; |
1058 | 1118 | |
1059 | - foreach ($context['whois_servers'] as $server) |
|
1060 | - echo ' |
|
1119 | + foreach ($context['whois_servers'] as $server) { |
|
1120 | + echo ' |
|
1061 | 1121 | <a href="', $server['url'], '" target="_blank" rel="noopener"', '>', $server['name'], '</a><br>'; |
1122 | + } |
|
1062 | 1123 | echo ' |
1063 | 1124 | </div> |
1064 | 1125 | <br>'; |
@@ -1070,13 +1131,12 @@ discard block |
||
1070 | 1131 | <h3 class="catbg">', $txt['members_from_ip'], ' ', $context['ip'], '</h3> |
1071 | 1132 | </div>'; |
1072 | 1133 | |
1073 | - if (empty($context['ips'])) |
|
1074 | - echo ' |
|
1134 | + if (empty($context['ips'])) { |
|
1135 | + echo ' |
|
1075 | 1136 | <p class="windowbg2 description"> |
1076 | 1137 | <em>', $txt['no_members_from_ip'], '</em> |
1077 | 1138 | </p>'; |
1078 | - |
|
1079 | - else |
|
1139 | + } else |
|
1080 | 1140 | { |
1081 | 1141 | echo ' |
1082 | 1142 | <table class="table_grid"> |
@@ -1089,12 +1149,13 @@ discard block |
||
1089 | 1149 | <tbody>'; |
1090 | 1150 | |
1091 | 1151 | // Loop through each of the members and display them. |
1092 | - foreach ($context['ips'] as $ip => $memberlist) |
|
1093 | - echo ' |
|
1152 | + foreach ($context['ips'] as $ip => $memberlist) { |
|
1153 | + echo ' |
|
1094 | 1154 | <tr class="windowbg"> |
1095 | 1155 | <td><a href="', $context['base_url'], ';searchip=', $ip, '">', $ip, '</a></td> |
1096 | 1156 | <td>', implode(', ', $memberlist), '</td> |
1097 | 1157 | </tr>'; |
1158 | + } |
|
1098 | 1159 | |
1099 | 1160 | echo ' |
1100 | 1161 | </tbody> |
@@ -1136,11 +1197,10 @@ discard block |
||
1136 | 1197 | </h3> |
1137 | 1198 | </div>'; |
1138 | 1199 | |
1139 | - if ($context['member']['has_all_permissions']) |
|
1140 | - echo ' |
|
1200 | + if ($context['member']['has_all_permissions']) { |
|
1201 | + echo ' |
|
1141 | 1202 | <div class="information">', $txt['showPermissions_all'], '</div>'; |
1142 | - |
|
1143 | - else |
|
1203 | + } else |
|
1144 | 1204 | { |
1145 | 1205 | echo ' |
1146 | 1206 | <div class="information">',$txt['showPermissions_help'], '</div> |
@@ -1155,9 +1215,10 @@ discard block |
||
1155 | 1215 | <div class="windowbg smalltext"> |
1156 | 1216 | ', $txt['showPermissions_restricted_boards_desc'], ':<br>'; |
1157 | 1217 | |
1158 | - foreach ($context['no_access_boards'] as $no_access_board) |
|
1159 | - echo ' |
|
1218 | + foreach ($context['no_access_boards'] as $no_access_board) { |
|
1219 | + echo ' |
|
1160 | 1220 | <a href="', $scripturl, '?board=', $no_access_board['id'], '.0">', $no_access_board['name'], '</a>', $no_access_board['is_last'] ? '' : ', '; |
1221 | + } |
|
1161 | 1222 | echo ' |
1162 | 1223 | </div>'; |
1163 | 1224 | } |
@@ -1189,12 +1250,13 @@ discard block |
||
1189 | 1250 | </td> |
1190 | 1251 | <td class="smalltext">'; |
1191 | 1252 | |
1192 | - if ($permission['is_denied']) |
|
1193 | - echo ' |
|
1253 | + if ($permission['is_denied']) { |
|
1254 | + echo ' |
|
1194 | 1255 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1195 | - else |
|
1196 | - echo ' |
|
1256 | + } else { |
|
1257 | + echo ' |
|
1197 | 1258 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1259 | + } |
|
1198 | 1260 | |
1199 | 1261 | echo ' |
1200 | 1262 | </td> |
@@ -1205,10 +1267,10 @@ discard block |
||
1205 | 1267 | </table> |
1206 | 1268 | </div><!-- .tborder --> |
1207 | 1269 | <br>'; |
1208 | - } |
|
1209 | - else |
|
1210 | - echo ' |
|
1270 | + } else { |
|
1271 | + echo ' |
|
1211 | 1272 | <p class="windowbg2">', $txt['showPermissions_none_general'], '</p>'; |
1273 | + } |
|
1212 | 1274 | |
1213 | 1275 | // Board permission section. |
1214 | 1276 | echo ' |
@@ -1219,14 +1281,16 @@ discard block |
||
1219 | 1281 | <select name="board" onchange="if (this.options[this.selectedIndex].value) this.form.submit();"> |
1220 | 1282 | <option value="0"', $context['board'] == 0 ? ' selected' : '', '>', $txt['showPermissions_global'], '</option>'; |
1221 | 1283 | |
1222 | - if (!empty($context['boards'])) |
|
1223 | - echo ' |
|
1284 | + if (!empty($context['boards'])) { |
|
1285 | + echo ' |
|
1224 | 1286 | <option value="" disabled>---------------------------</option>'; |
1287 | + } |
|
1225 | 1288 | |
1226 | 1289 | // Fill the box with any local permission boards. |
1227 | - foreach ($context['boards'] as $board) |
|
1228 | - echo ' |
|
1290 | + foreach ($context['boards'] as $board) { |
|
1291 | + echo ' |
|
1229 | 1292 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['name'], ' (', $board['profile_name'], ')</option>'; |
1293 | + } |
|
1230 | 1294 | |
1231 | 1295 | echo ' |
1232 | 1296 | </select> |
@@ -1255,13 +1319,13 @@ discard block |
||
1255 | 1319 | </td> |
1256 | 1320 | <td class="smalltext">'; |
1257 | 1321 | |
1258 | - if ($permission['is_denied']) |
|
1259 | - echo ' |
|
1322 | + if ($permission['is_denied']) { |
|
1323 | + echo ' |
|
1260 | 1324 | <span class="alert">', $txt['showPermissions_denied'], ': ', implode(', ', $permission['groups']['denied']), '</span>'; |
1261 | - |
|
1262 | - else |
|
1263 | - echo ' |
|
1325 | + } else { |
|
1326 | + echo ' |
|
1264 | 1327 | ', $txt['showPermissions_given'], ': ', implode(', ', $permission['groups']['allowed']); |
1328 | + } |
|
1265 | 1329 | |
1266 | 1330 | echo ' |
1267 | 1331 | </td> |
@@ -1270,10 +1334,10 @@ discard block |
||
1270 | 1334 | echo ' |
1271 | 1335 | </tbody> |
1272 | 1336 | </table>'; |
1273 | - } |
|
1274 | - else |
|
1275 | - echo ' |
|
1337 | + } else { |
|
1338 | + echo ' |
|
1276 | 1339 | <p class="windowbg2">', $txt['showPermissions_none_board'], '</p>'; |
1340 | + } |
|
1277 | 1341 | echo ' |
1278 | 1342 | </div><!-- #permissions -->'; |
1279 | 1343 | } |
@@ -1314,9 +1378,10 @@ discard block |
||
1314 | 1378 | </div>'; |
1315 | 1379 | |
1316 | 1380 | // If they haven't post at all, don't draw the graph. |
1317 | - if (empty($context['posts_by_time'])) |
|
1318 | - echo ' |
|
1381 | + if (empty($context['posts_by_time'])) { |
|
1382 | + echo ' |
|
1319 | 1383 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1384 | + } |
|
1320 | 1385 | |
1321 | 1386 | // Otherwise do! |
1322 | 1387 | else |
@@ -1325,8 +1390,8 @@ discard block |
||
1325 | 1390 | <ul class="activity_stats flow_hidden">'; |
1326 | 1391 | |
1327 | 1392 | // The labels. |
1328 | - foreach ($context['posts_by_time'] as $time_of_day) |
|
1329 | - echo ' |
|
1393 | + foreach ($context['posts_by_time'] as $time_of_day) { |
|
1394 | + echo ' |
|
1330 | 1395 | <li', $time_of_day['is_last'] ? ' class="last"' : '', '> |
1331 | 1396 | <div class="bar" style="padding-top: ', ((int) (100 - $time_of_day['relative_percent'])), 'px;" title="', sprintf($txt['statPanel_activityTime_posts'], $time_of_day['posts'], $time_of_day['posts_percent']), '"> |
1332 | 1397 | <div style="height: ', (int) $time_of_day['relative_percent'], 'px;"> |
@@ -1335,6 +1400,7 @@ discard block |
||
1335 | 1400 | </div> |
1336 | 1401 | <span class="stats_hour">', $time_of_day['hour_format'], '</span> |
1337 | 1402 | </li>'; |
1403 | + } |
|
1338 | 1404 | |
1339 | 1405 | echo ' |
1340 | 1406 | </ul>'; |
@@ -1353,11 +1419,10 @@ discard block |
||
1353 | 1419 | </h3> |
1354 | 1420 | </div>'; |
1355 | 1421 | |
1356 | - if (empty($context['popular_boards'])) |
|
1357 | - echo ' |
|
1422 | + if (empty($context['popular_boards'])) { |
|
1423 | + echo ' |
|
1358 | 1424 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1359 | - |
|
1360 | - else |
|
1425 | + } else |
|
1361 | 1426 | { |
1362 | 1427 | echo ' |
1363 | 1428 | <dl class="stats">'; |
@@ -1387,10 +1452,10 @@ discard block |
||
1387 | 1452 | </h3> |
1388 | 1453 | </div>'; |
1389 | 1454 | |
1390 | - if (empty($context['board_activity'])) |
|
1391 | - echo ' |
|
1455 | + if (empty($context['board_activity'])) { |
|
1456 | + echo ' |
|
1392 | 1457 | <p class="centertext padding">', $txt['statPanel_noPosts'], '</p>'; |
1393 | - else |
|
1458 | + } else |
|
1394 | 1459 | { |
1395 | 1460 | echo ' |
1396 | 1461 | <dl class="stats">'; |
@@ -1441,90 +1506,97 @@ discard block |
||
1441 | 1506 | <h3 class="catbg profile_hd">'; |
1442 | 1507 | |
1443 | 1508 | // Don't say "Profile" if this isn't the profile... |
1444 | - if (!empty($context['profile_header_text'])) |
|
1445 | - echo ' |
|
1509 | + if (!empty($context['profile_header_text'])) { |
|
1510 | + echo ' |
|
1446 | 1511 | ', $context['profile_header_text']; |
1447 | - else |
|
1448 | - echo ' |
|
1512 | + } else { |
|
1513 | + echo ' |
|
1449 | 1514 | ', $txt['profile']; |
1515 | + } |
|
1450 | 1516 | |
1451 | 1517 | echo ' |
1452 | 1518 | </h3> |
1453 | 1519 | </div>'; |
1454 | 1520 | |
1455 | 1521 | // Have we some description? |
1456 | - if ($context['page_desc']) |
|
1457 | - echo ' |
|
1522 | + if ($context['page_desc']) { |
|
1523 | + echo ' |
|
1458 | 1524 | <p class="information">', $context['page_desc'], '</p>'; |
1525 | + } |
|
1459 | 1526 | |
1460 | 1527 | echo ' |
1461 | 1528 | <div class="roundframe">'; |
1462 | 1529 | |
1463 | 1530 | // Any bits at the start? |
1464 | - if (!empty($context['profile_prehtml'])) |
|
1465 | - echo ' |
|
1531 | + if (!empty($context['profile_prehtml'])) { |
|
1532 | + echo ' |
|
1466 | 1533 | <div>', $context['profile_prehtml'], '</div>'; |
1534 | + } |
|
1467 | 1535 | |
1468 | - if (!empty($context['profile_fields'])) |
|
1469 | - echo ' |
|
1536 | + if (!empty($context['profile_fields'])) { |
|
1537 | + echo ' |
|
1470 | 1538 | <dl class="settings">'; |
1539 | + } |
|
1471 | 1540 | |
1472 | 1541 | // Start the big old loop 'of love. |
1473 | 1542 | $lastItem = 'hr'; |
1474 | 1543 | foreach ($context['profile_fields'] as $key => $field) |
1475 | 1544 | { |
1476 | 1545 | // We add a little hack to be sure we never get more than one hr in a row! |
1477 | - if ($lastItem == 'hr' && $field['type'] == 'hr') |
|
1478 | - continue; |
|
1546 | + if ($lastItem == 'hr' && $field['type'] == 'hr') { |
|
1547 | + continue; |
|
1548 | + } |
|
1479 | 1549 | |
1480 | 1550 | $lastItem = $field['type']; |
1481 | - if ($field['type'] == 'hr') |
|
1482 | - echo ' |
|
1551 | + if ($field['type'] == 'hr') { |
|
1552 | + echo ' |
|
1483 | 1553 | </dl> |
1484 | 1554 | <hr> |
1485 | 1555 | <dl class="settings">'; |
1486 | - |
|
1487 | - elseif ($field['type'] == 'callback') |
|
1556 | + } elseif ($field['type'] == 'callback') |
|
1488 | 1557 | { |
1489 | 1558 | if (isset($field['callback_func']) && function_exists('template_profile_' . $field['callback_func'])) |
1490 | 1559 | { |
1491 | 1560 | $callback_func = 'template_profile_' . $field['callback_func']; |
1492 | 1561 | $callback_func(); |
1493 | 1562 | } |
1494 | - } |
|
1495 | - else |
|
1563 | + } else |
|
1496 | 1564 | { |
1497 | 1565 | echo ' |
1498 | 1566 | <dt> |
1499 | 1567 | <strong', !empty($field['is_error']) ? ' class="error"' : '', '>', $field['type'] !== 'label' ? '<label for="' . $key . '">' : '', $field['label'], $field['type'] !== 'label' ? '</label>' : '', '</strong>'; |
1500 | 1568 | |
1501 | 1569 | // Does it have any subtext to show? |
1502 | - if (!empty($field['subtext'])) |
|
1503 | - echo ' |
|
1570 | + if (!empty($field['subtext'])) { |
|
1571 | + echo ' |
|
1504 | 1572 | <br> |
1505 | 1573 | <span class="smalltext">', $field['subtext'], '</span>'; |
1574 | + } |
|
1506 | 1575 | |
1507 | 1576 | echo ' |
1508 | 1577 | </dt> |
1509 | 1578 | <dd>'; |
1510 | 1579 | |
1511 | 1580 | // Want to put something infront of the box? |
1512 | - if (!empty($field['preinput'])) |
|
1513 | - echo ' |
|
1581 | + if (!empty($field['preinput'])) { |
|
1582 | + echo ' |
|
1514 | 1583 | ', $field['preinput']; |
1584 | + } |
|
1515 | 1585 | |
1516 | 1586 | // What type of data are we showing? |
1517 | - if ($field['type'] == 'label') |
|
1518 | - echo ' |
|
1587 | + if ($field['type'] == 'label') { |
|
1588 | + echo ' |
|
1519 | 1589 | ', $field['value']; |
1590 | + } |
|
1520 | 1591 | |
1521 | 1592 | // Maybe it's a text box - very likely! |
1522 | 1593 | elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'number', 'time', 'url'))) |
1523 | 1594 | { |
1524 | - if ($field['type'] == 'int' || $field['type'] == 'float') |
|
1525 | - $type = 'number'; |
|
1526 | - else |
|
1527 | - $type = $field['type']; |
|
1595 | + if ($field['type'] == 'int' || $field['type'] == 'float') { |
|
1596 | + $type = 'number'; |
|
1597 | + } else { |
|
1598 | + $type = $field['type']; |
|
1599 | + } |
|
1528 | 1600 | $step = $field['type'] == 'float' ? ' step="0.1"' : ''; |
1529 | 1601 | |
1530 | 1602 | |
@@ -1532,10 +1604,11 @@ discard block |
||
1532 | 1604 | <input type="', $type, '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" ', $field['input_attr'], ' ', $step, '>'; |
1533 | 1605 | } |
1534 | 1606 | // You "checking" me out? ;) |
1535 | - elseif ($field['type'] == 'check') |
|
1536 | - echo ' |
|
1607 | + elseif ($field['type'] == 'check') { |
|
1608 | + echo ' |
|
1537 | 1609 | <input type="hidden" name="', $key, '" value="0"> |
1538 | 1610 | <input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" ', $field['input_attr'], '>'; |
1611 | + } |
|
1539 | 1612 | |
1540 | 1613 | // Always fun - select boxes! |
1541 | 1614 | elseif ($field['type'] == 'select') |
@@ -1546,14 +1619,16 @@ discard block |
||
1546 | 1619 | if (isset($field['options'])) |
1547 | 1620 | { |
1548 | 1621 | // Is this some code to generate the options? |
1549 | - if (!is_array($field['options'])) |
|
1550 | - $field['options'] = $field['options'](); |
|
1622 | + if (!is_array($field['options'])) { |
|
1623 | + $field['options'] = $field['options'](); |
|
1624 | + } |
|
1551 | 1625 | |
1552 | 1626 | // Assuming we now have some! |
1553 | - if (is_array($field['options'])) |
|
1554 | - foreach ($field['options'] as $value => $name) |
|
1627 | + if (is_array($field['options'])) { |
|
1628 | + foreach ($field['options'] as $value => $name) |
|
1555 | 1629 | echo ' |
1556 | 1630 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
1631 | + } |
|
1557 | 1632 | } |
1558 | 1633 | |
1559 | 1634 | echo ' |
@@ -1561,31 +1636,34 @@ discard block |
||
1561 | 1636 | } |
1562 | 1637 | |
1563 | 1638 | // Something to end with? |
1564 | - if (!empty($field['postinput'])) |
|
1565 | - echo ' |
|
1639 | + if (!empty($field['postinput'])) { |
|
1640 | + echo ' |
|
1566 | 1641 | ', $field['postinput']; |
1642 | + } |
|
1567 | 1643 | |
1568 | 1644 | echo ' |
1569 | 1645 | </dd>'; |
1570 | 1646 | } |
1571 | 1647 | } |
1572 | 1648 | |
1573 | - if (!empty($context['profile_fields'])) |
|
1574 | - echo ' |
|
1649 | + if (!empty($context['profile_fields'])) { |
|
1650 | + echo ' |
|
1575 | 1651 | </dl>'; |
1652 | + } |
|
1576 | 1653 | |
1577 | 1654 | // Are there any custom profile fields - if so print them! |
1578 | 1655 | if (!empty($context['custom_fields'])) |
1579 | 1656 | { |
1580 | - if ($lastItem != 'hr') |
|
1581 | - echo ' |
|
1657 | + if ($lastItem != 'hr') { |
|
1658 | + echo ' |
|
1582 | 1659 | <hr>'; |
1660 | + } |
|
1583 | 1661 | |
1584 | 1662 | echo ' |
1585 | 1663 | <dl class="settings">'; |
1586 | 1664 | |
1587 | - foreach ($context['custom_fields'] as $field) |
|
1588 | - echo ' |
|
1665 | + foreach ($context['custom_fields'] as $field) { |
|
1666 | + echo ' |
|
1589 | 1667 | <dt> |
1590 | 1668 | <strong>', $field['name'], ': </strong><br> |
1591 | 1669 | <span class="smalltext">', $field['desc'], '</span> |
@@ -1593,19 +1671,21 @@ discard block |
||
1593 | 1671 | <dd> |
1594 | 1672 | ', $field['input_html'], ' |
1595 | 1673 | </dd>'; |
1674 | + } |
|
1596 | 1675 | |
1597 | 1676 | echo ' |
1598 | 1677 | </dl>'; |
1599 | 1678 | } |
1600 | 1679 | |
1601 | 1680 | // Any closing HTML? |
1602 | - if (!empty($context['profile_posthtml'])) |
|
1603 | - echo ' |
|
1681 | + if (!empty($context['profile_posthtml'])) { |
|
1682 | + echo ' |
|
1604 | 1683 | <div>', $context['profile_posthtml'], '</div>'; |
1684 | + } |
|
1605 | 1685 | |
1606 | 1686 | // Only show the password box if it's actually needed. |
1607 | - if ($context['require_password']) |
|
1608 | - echo ' |
|
1687 | + if ($context['require_password']) { |
|
1688 | + echo ' |
|
1609 | 1689 | <dl class="settings"> |
1610 | 1690 | <dt> |
1611 | 1691 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '><label for="oldpasswrd">', $txt['current_password'], ': </label></strong><br> |
@@ -1615,18 +1695,21 @@ discard block |
||
1615 | 1695 | <input type="password" name="oldpasswrd" id="oldpasswrd" size="20"> |
1616 | 1696 | </dd> |
1617 | 1697 | </dl>'; |
1698 | + } |
|
1618 | 1699 | |
1619 | 1700 | // The button shouldn't say "Change profile" unless we're changing the profile... |
1620 | - if (!empty($context['submit_button_text'])) |
|
1621 | - echo ' |
|
1701 | + if (!empty($context['submit_button_text'])) { |
|
1702 | + echo ' |
|
1622 | 1703 | <input type="submit" name="save" value="', $context['submit_button_text'], '" class="button floatright">'; |
1623 | - else |
|
1624 | - echo ' |
|
1704 | + } else { |
|
1705 | + echo ' |
|
1625 | 1706 | <input type="submit" name="save" value="', $txt['change_profile'], '" class="button floatright">'; |
1707 | + } |
|
1626 | 1708 | |
1627 | - if (!empty($context['token_check'])) |
|
1628 | - echo ' |
|
1709 | + if (!empty($context['token_check'])) { |
|
1710 | + echo ' |
|
1629 | 1711 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
1712 | + } |
|
1630 | 1713 | |
1631 | 1714 | echo ' |
1632 | 1715 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -1636,10 +1719,11 @@ discard block |
||
1636 | 1719 | </form>'; |
1637 | 1720 | |
1638 | 1721 | // Any final spellchecking stuff? |
1639 | - if (!empty($context['show_spellchecking'])) |
|
1640 | - echo ' |
|
1722 | + if (!empty($context['show_spellchecking'])) { |
|
1723 | + echo ' |
|
1641 | 1724 | <form name="spell_form" id="spell_form" method="post" accept-charset="', $context['character_set'], '" target="spellWindow" action="', $scripturl, '?action=spellcheck"><input type="hidden" name="spellstring" value=""></form>'; |
1642 | -} |
|
1725 | + } |
|
1726 | + } |
|
1643 | 1727 | |
1644 | 1728 | /** |
1645 | 1729 | * Personal Message settings. |
@@ -1676,10 +1760,11 @@ discard block |
||
1676 | 1760 | <select name="pm_receive_from" id="pm_receive_from"> |
1677 | 1761 | <option value="0"', empty($context['receive_from']) || (empty($modSettings['enable_buddylist']) && $context['receive_from'] < 3) ? ' selected' : '', '>', $txt['pm_receive_from_everyone'], '</option>'; |
1678 | 1762 | |
1679 | - if (!empty($modSettings['enable_buddylist'])) |
|
1680 | - echo ' |
|
1763 | + if (!empty($modSettings['enable_buddylist'])) { |
|
1764 | + echo ' |
|
1681 | 1765 | <option value="1"', !empty($context['receive_from']) && $context['receive_from'] == 1 ? ' selected' : '', '>', $txt['pm_receive_from_ignore'], '</option> |
1682 | 1766 | <option value="2"', !empty($context['receive_from']) && $context['receive_from'] == 2 ? ' selected' : '', '>', $txt['pm_receive_from_buddies'], '</option>'; |
1767 | + } |
|
1683 | 1768 | |
1684 | 1769 | echo ' |
1685 | 1770 | <option value="3"', !empty($context['receive_from']) && $context['receive_from'] > 2 ? ' selected' : '', '>', $txt['pm_receive_from_admins'], '</option> |
@@ -1722,11 +1807,12 @@ discard block |
||
1722 | 1807 | if (empty($setting) || !is_array($setting)) |
1723 | 1808 | { |
1724 | 1809 | // Insert a separator (unless this is the first item in the list) |
1725 | - if ($i !== $first_option_key) |
|
1726 | - echo ' |
|
1810 | + if ($i !== $first_option_key) { |
|
1811 | + echo ' |
|
1727 | 1812 | </dl> |
1728 | 1813 | <hr> |
1729 | 1814 | <dl class="settings">'; |
1815 | + } |
|
1730 | 1816 | |
1731 | 1817 | // Should we give a name to this section? |
1732 | 1818 | if (is_string($setting) && !empty($setting)) |
@@ -1735,69 +1821,67 @@ discard block |
||
1735 | 1821 | echo ' |
1736 | 1822 | <dt><strong>' . $setting . '</strong></dt> |
1737 | 1823 | <dd></dd>'; |
1824 | + } else { |
|
1825 | + $titled_section = false; |
|
1738 | 1826 | } |
1739 | - else |
|
1740 | - $titled_section = false; |
|
1741 | 1827 | |
1742 | 1828 | continue; |
1743 | 1829 | } |
1744 | 1830 | |
1745 | 1831 | // Is this disabled? |
1746 | - if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
|
1747 | - continue; |
|
1748 | - |
|
1749 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
1750 | - continue; |
|
1751 | - |
|
1752 | - elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) |
|
1753 | - continue; |
|
1754 | - |
|
1755 | - elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) |
|
1756 | - continue; |
|
1757 | - |
|
1758 | - elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) |
|
1759 | - continue; |
|
1760 | - |
|
1761 | - elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1762 | - continue; |
|
1763 | - |
|
1764 | - elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) |
|
1765 | - continue; |
|
1832 | + if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) { |
|
1833 | + continue; |
|
1834 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) { |
|
1835 | + continue; |
|
1836 | + } elseif ($setting['id'] == 'show_no_censored' && empty($modSettings['allow_no_censored'])) { |
|
1837 | + continue; |
|
1838 | + } elseif ($setting['id'] == 'posts_apply_ignore_list' && empty($modSettings['enable_buddylist'])) { |
|
1839 | + continue; |
|
1840 | + } elseif ($setting['id'] == 'wysiwyg_default' && !empty($modSettings['disable_wysiwyg'])) { |
|
1841 | + continue; |
|
1842 | + } elseif ($setting['id'] == 'drafts_autosave_enabled' && (empty($modSettings['drafts_autosave_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1843 | + continue; |
|
1844 | + } elseif ($setting['id'] == 'drafts_show_saved_enabled' && (empty($modSettings['drafts_show_saved_enabled']) || (empty($modSettings['drafts_post_enabled']) && empty($modSettings['drafts_pm_enabled'])))) { |
|
1845 | + continue; |
|
1846 | + } |
|
1766 | 1847 | |
1767 | 1848 | // Some of these may not be set... Set to defaults here |
1768 | 1849 | $opts = array('topics_per_page', 'messages_per_page', 'display_quick_mod'); |
1769 | - if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) |
|
1770 | - $context['member']['options'][$setting['id']] = 0; |
|
1771 | - |
|
1772 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
1773 | - $setting['type'] = 'checkbox'; |
|
1774 | - |
|
1775 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
1776 | - $setting['type'] = 'number'; |
|
1850 | + if (in_array($setting['id'], $opts) && !isset($context['member']['options'][$setting['id']])) { |
|
1851 | + $context['member']['options'][$setting['id']] = 0; |
|
1852 | + } |
|
1777 | 1853 | |
1778 | - elseif ($setting['type'] == 'string') |
|
1779 | - $setting['type'] = 'text'; |
|
1854 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
1855 | + $setting['type'] = 'checkbox'; |
|
1856 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
1857 | + $setting['type'] = 'number'; |
|
1858 | + } elseif ($setting['type'] == 'string') { |
|
1859 | + $setting['type'] = 'text'; |
|
1860 | + } |
|
1780 | 1861 | |
1781 | - if (isset($setting['options'])) |
|
1782 | - $setting['type'] = 'list'; |
|
1862 | + if (isset($setting['options'])) { |
|
1863 | + $setting['type'] = 'list'; |
|
1864 | + } |
|
1783 | 1865 | |
1784 | 1866 | echo ' |
1785 | 1867 | <dt> |
1786 | 1868 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
1787 | 1869 | |
1788 | - if (isset($setting['description'])) |
|
1789 | - echo ' |
|
1870 | + if (isset($setting['description'])) { |
|
1871 | + echo ' |
|
1790 | 1872 | <br> |
1791 | 1873 | <span class="smalltext">', $setting['description'], '</span>'; |
1874 | + } |
|
1792 | 1875 | echo ' |
1793 | 1876 | </dt> |
1794 | 1877 | <dd>'; |
1795 | 1878 | |
1796 | 1879 | // Display checkbox options |
1797 | - if ($setting['type'] == 'checkbox') |
|
1798 | - echo ' |
|
1880 | + if ($setting['type'] == 'checkbox') { |
|
1881 | + echo ' |
|
1799 | 1882 | <input type="hidden" name="default_options[' . $setting['id'] . ']" value="0"> |
1800 | 1883 | <input type="checkbox" name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($context['member']['options'][$setting['id']]) ? ' checked' : '', ' value="1">'; |
1884 | + } |
|
1801 | 1885 | |
1802 | 1886 | // How about selection lists, we all love them |
1803 | 1887 | elseif ($setting['type'] == 'list') |
@@ -1805,9 +1889,10 @@ discard block |
||
1805 | 1889 | echo ' |
1806 | 1890 | <select name="default_options[', $setting['id'], ']" id="', $setting['id'], '"', '>'; |
1807 | 1891 | |
1808 | - foreach ($setting['options'] as $value => $label) |
|
1809 | - echo ' |
|
1892 | + foreach ($setting['options'] as $value => $label) { |
|
1893 | + echo ' |
|
1810 | 1894 | <option value="', $value, '"', $value == $context['member']['options'][$setting['id']] ? ' selected' : '', '>', $label, '</option>'; |
1895 | + } |
|
1811 | 1896 | |
1812 | 1897 | echo ' |
1813 | 1898 | </select>'; |
@@ -1823,14 +1908,13 @@ discard block |
||
1823 | 1908 | |
1824 | 1909 | echo ' |
1825 | 1910 | <input type="number"', $min . $max . $step; |
1826 | - } |
|
1827 | - elseif (isset($setting['type']) && $setting['type'] == 'url') |
|
1828 | - echo' |
|
1911 | + } elseif (isset($setting['type']) && $setting['type'] == 'url') { |
|
1912 | + echo' |
|
1829 | 1913 | <input type="url"'; |
1830 | - |
|
1831 | - else |
|
1832 | - echo ' |
|
1914 | + } else { |
|
1915 | + echo ' |
|
1833 | 1916 | <input type="text"'; |
1917 | + } |
|
1834 | 1918 | |
1835 | 1919 | echo ' name="default_options[', $setting['id'], ']" id="', $setting['id'], '" value="', isset($context['member']['options'][$setting['id']]) ? $context['member']['options'][$setting['id']] : $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', '>'; |
1836 | 1920 | } |
@@ -1867,8 +1951,8 @@ discard block |
||
1867 | 1951 | <dl class="settings">'; |
1868 | 1952 | |
1869 | 1953 | // Allow notification on announcements to be disabled? |
1870 | - if (!empty($modSettings['allow_disableAnnounce'])) |
|
1871 | - echo ' |
|
1954 | + if (!empty($modSettings['allow_disableAnnounce'])) { |
|
1955 | + echo ' |
|
1872 | 1956 | <dt> |
1873 | 1957 | <label for="notify_announcements">', $txt['notify_important_email'], '</label> |
1874 | 1958 | </dt> |
@@ -1876,15 +1960,17 @@ discard block |
||
1876 | 1960 | <input type="hidden" name="notify_announcements" value="0"> |
1877 | 1961 | <input type="checkbox" id="notify_announcements" name="notify_announcements" value="1"', !empty($context['member']['notify_announcements']) ? ' checked' : '', '> |
1878 | 1962 | </dd>'; |
1963 | + } |
|
1879 | 1964 | |
1880 | - if (!empty($modSettings['enable_ajax_alerts'])) |
|
1881 | - echo ' |
|
1965 | + if (!empty($modSettings['enable_ajax_alerts'])) { |
|
1966 | + echo ' |
|
1882 | 1967 | <dt> |
1883 | 1968 | <label for="notify_send_body">', $txt['notify_alert_timeout'], '</label> |
1884 | 1969 | </dt> |
1885 | 1970 | <dd> |
1886 | 1971 | <input type="number" size="4" id="notify_alert_timeout" name="opt_alert_timeout" min="0" value="', $context['member']['alert_timeout'], '"> |
1887 | 1972 | </dd>'; |
1973 | + } |
|
1888 | 1974 | |
1889 | 1975 | echo ' |
1890 | 1976 | </dl> |
@@ -1916,9 +2002,10 @@ discard block |
||
1916 | 2002 | |
1917 | 2003 | $label = $txt['alert_opt_' . $opts[1]]; |
1918 | 2004 | $label_pos = isset($opts['label']) ? $opts['label'] : ''; |
1919 | - if ($label_pos == 'before') |
|
1920 | - echo ' |
|
2005 | + if ($label_pos == 'before') { |
|
2006 | + echo ' |
|
1921 | 2007 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2008 | + } |
|
1922 | 2009 | |
1923 | 2010 | $this_value = isset($context['alert_prefs'][$opts[1]]) ? $context['alert_prefs'][$opts[1]] : 0; |
1924 | 2011 | switch ($opts[0]) |
@@ -1932,17 +2019,19 @@ discard block |
||
1932 | 2019 | echo ' |
1933 | 2020 | <select name="opt_', $opts[1], '" id="opt_', $opts[1], '">'; |
1934 | 2021 | |
1935 | - foreach ($opts['opts'] as $k => $v) |
|
1936 | - echo ' |
|
2022 | + foreach ($opts['opts'] as $k => $v) { |
|
2023 | + echo ' |
|
1937 | 2024 | <option value="', $k, '"', $this_value == $k ? ' selected' : '', '>', $v, '</option>'; |
2025 | + } |
|
1938 | 2026 | echo ' |
1939 | 2027 | </select>'; |
1940 | 2028 | break; |
1941 | 2029 | } |
1942 | 2030 | |
1943 | - if ($label_pos == 'after') |
|
1944 | - echo ' |
|
2031 | + if ($label_pos == 'after') { |
|
2032 | + echo ' |
|
1945 | 2033 | <label for="opt_', $opts[1], '">', $label, '</label>'; |
2034 | + } |
|
1946 | 2035 | |
1947 | 2036 | echo ' |
1948 | 2037 | </td> |
@@ -2059,11 +2148,12 @@ discard block |
||
2059 | 2148 | <p class="information">', $txt['groupMembership_info'], '</p>'; |
2060 | 2149 | |
2061 | 2150 | // Do we have an update message? |
2062 | - if (!empty($context['update_message'])) |
|
2063 | - echo ' |
|
2151 | + if (!empty($context['update_message'])) { |
|
2152 | + echo ' |
|
2064 | 2153 | <div class="infobox"> |
2065 | 2154 | ', $context['update_message'], '. |
2066 | 2155 | </div>'; |
2156 | + } |
|
2067 | 2157 | |
2068 | 2158 | echo ' |
2069 | 2159 | <div id="groups">'; |
@@ -2085,8 +2175,7 @@ discard block |
||
2085 | 2175 | </div> |
2086 | 2176 | </div> |
2087 | 2177 | </div><!-- .groupmembership -->'; |
2088 | - } |
|
2089 | - else |
|
2178 | + } else |
|
2090 | 2179 | { |
2091 | 2180 | echo ' |
2092 | 2181 | <div class="title_bar"> |
@@ -2098,27 +2187,30 @@ discard block |
||
2098 | 2187 | echo ' |
2099 | 2188 | <div class="windowbg" id="primdiv_', $group['id'], '">'; |
2100 | 2189 | |
2101 | - if ($context['can_edit_primary']) |
|
2102 | - echo ' |
|
2190 | + if ($context['can_edit_primary']) { |
|
2191 | + echo ' |
|
2103 | 2192 | <input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '"', $group['is_primary'] ? ' checked' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');"', $group['can_be_primary'] ? '' : ' disabled', '>'; |
2193 | + } |
|
2104 | 2194 | |
2105 | 2195 | echo ' |
2106 | 2196 | <label for="primary_', $group['id'], '"><strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), '</label>'; |
2107 | 2197 | |
2108 | 2198 | // Can they leave their group? |
2109 | - if ($group['can_leave']) |
|
2110 | - echo ' |
|
2199 | + if ($group['can_leave']) { |
|
2200 | + echo ' |
|
2111 | 2201 | <a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>'; |
2202 | + } |
|
2112 | 2203 | |
2113 | 2204 | echo ' |
2114 | 2205 | </div><!-- .windowbg -->'; |
2115 | 2206 | } |
2116 | 2207 | |
2117 | - if ($context['can_edit_primary']) |
|
2118 | - echo ' |
|
2208 | + if ($context['can_edit_primary']) { |
|
2209 | + echo ' |
|
2119 | 2210 | <div class="padding righttext"> |
2120 | 2211 | <input type="submit" value="', $txt['make_primary'], '" class="button"> |
2121 | 2212 | </div>'; |
2213 | + } |
|
2122 | 2214 | |
2123 | 2215 | // Any groups they can join? |
2124 | 2216 | if (!empty($context['groups']['available'])) |
@@ -2134,17 +2226,16 @@ discard block |
||
2134 | 2226 | <div class="windowbg"> |
2135 | 2227 | <strong>', (empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>'), '</strong>', (!empty($group['desc']) ? '<br><span class="smalltext">' . $group['desc'] . '</span>' : ''), ''; |
2136 | 2228 | |
2137 | - if ($group['type'] == 3) |
|
2138 | - echo ' |
|
2229 | + if ($group['type'] == 3) { |
|
2230 | + echo ' |
|
2139 | 2231 | <a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '" class="button floatright">', $txt['join_group'], '</a>'; |
2140 | - |
|
2141 | - elseif ($group['type'] == 2 && $group['pending']) |
|
2142 | - echo ' |
|
2232 | + } elseif ($group['type'] == 2 && $group['pending']) { |
|
2233 | + echo ' |
|
2143 | 2234 | <span class="floatright">', $txt['approval_pending'], '</span>'; |
2144 | - |
|
2145 | - elseif ($group['type'] == 2) |
|
2146 | - echo ' |
|
2235 | + } elseif ($group['type'] == 2) { |
|
2236 | + echo ' |
|
2147 | 2237 | <a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '" class="button floatright">', $txt['request_group'], '</a>'; |
2238 | + } |
|
2148 | 2239 | |
2149 | 2240 | echo ' |
2150 | 2241 | </div><!-- .windowbg -->'; |
@@ -2167,9 +2258,10 @@ discard block |
||
2167 | 2258 | |
2168 | 2259 | prevDiv.className = "windowbg"; |
2169 | 2260 | }'; |
2170 | - if (isset($context['groups']['member'][$context['primary_group']])) |
|
2171 | - echo ' |
|
2261 | + if (isset($context['groups']['member'][$context['primary_group']])) { |
|
2262 | + echo ' |
|
2172 | 2263 | highlightSelected("primdiv_' . $context['primary_group'] . '");'; |
2264 | + } |
|
2173 | 2265 | |
2174 | 2266 | echo ' |
2175 | 2267 | </script>'; |
@@ -2178,9 +2270,10 @@ discard block |
||
2178 | 2270 | echo ' |
2179 | 2271 | </div><!-- #groups -->'; |
2180 | 2272 | |
2181 | - if (!empty($context['token_check'])) |
|
2182 | - echo ' |
|
2273 | + if (!empty($context['token_check'])) { |
|
2274 | + echo ' |
|
2183 | 2275 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2276 | + } |
|
2184 | 2277 | |
2185 | 2278 | echo ' |
2186 | 2279 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2228,14 +2321,15 @@ discard block |
||
2228 | 2321 | |
2229 | 2322 | foreach ($category['boards'] as $board) |
2230 | 2323 | { |
2231 | - if ($i == $limit) |
|
2232 | - echo ' |
|
2324 | + if ($i == $limit) { |
|
2325 | + echo ' |
|
2233 | 2326 | </ul> |
2234 | 2327 | </li> |
2235 | 2328 | </ul> |
2236 | 2329 | <ul class="ignoreboards floatright"> |
2237 | 2330 | <li class="category"> |
2238 | 2331 | <ul>'; |
2332 | + } |
|
2239 | 2333 | |
2240 | 2334 | echo ' |
2241 | 2335 | <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;"> |
@@ -2281,10 +2375,11 @@ discard block |
||
2281 | 2375 | |
2282 | 2376 | // Work out the starting color. |
2283 | 2377 | $context['current_color'] = $context['colors'][0]; |
2284 | - foreach ($context['colors'] as $limit => $color) |
|
2285 | - if ($context['member']['warning'] >= $limit) |
|
2378 | + foreach ($context['colors'] as $limit => $color) { |
|
2379 | + if ($context['member']['warning'] >= $limit) |
|
2286 | 2380 | $context['current_color'] = $color; |
2287 | -} |
|
2381 | + } |
|
2382 | + } |
|
2288 | 2383 | |
2289 | 2384 | // Show all warnings of a user? |
2290 | 2385 | function template_viewWarning() |
@@ -2323,14 +2418,15 @@ discard block |
||
2323 | 2418 | </dd>'; |
2324 | 2419 | |
2325 | 2420 | // There's some impact of this? |
2326 | - if (!empty($context['level_effects'][$context['current_level']])) |
|
2327 | - echo ' |
|
2421 | + if (!empty($context['level_effects'][$context['current_level']])) { |
|
2422 | + echo ' |
|
2328 | 2423 | <dt> |
2329 | 2424 | <strong>', $txt['profile_viewwarning_impact'], ':</strong> |
2330 | 2425 | </dt> |
2331 | 2426 | <dd> |
2332 | 2427 | ', $context['level_effects'][$context['current_level']], ' |
2333 | 2428 | </dd>'; |
2429 | + } |
|
2334 | 2430 | |
2335 | 2431 | echo ' |
2336 | 2432 | </dl> |
@@ -2368,10 +2464,11 @@ discard block |
||
2368 | 2464 | |
2369 | 2465 | // Otherwise see what we can do...'; |
2370 | 2466 | |
2371 | - foreach ($context['notification_templates'] as $k => $type) |
|
2372 | - echo ' |
|
2467 | + foreach ($context['notification_templates'] as $k => $type) { |
|
2468 | + echo ' |
|
2373 | 2469 | if (index == ', $k, ') |
2374 | 2470 | document.getElementById(\'warn_body\').value = "', strtr($type['body'], array('"' => "'", "\n" => '\\n', "\r" => '')), '";'; |
2471 | + } |
|
2375 | 2472 | |
2376 | 2473 | echo ' |
2377 | 2474 | } |
@@ -2381,10 +2478,11 @@ discard block |
||
2381 | 2478 | // Also set the right effect. |
2382 | 2479 | effectText = "";'; |
2383 | 2480 | |
2384 | - foreach ($context['level_effects'] as $limit => $text) |
|
2385 | - echo ' |
|
2481 | + foreach ($context['level_effects'] as $limit => $text) { |
|
2482 | + echo ' |
|
2386 | 2483 | if (slideAmount >= ', $limit, ') |
2387 | 2484 | effectText = "', $text, '";'; |
2485 | + } |
|
2388 | 2486 | |
2389 | 2487 | echo ' |
2390 | 2488 | setInnerHTML(document.getElementById(\'cur_level_div\'), slideAmount + \'% (\' + effectText + \')\'); |
@@ -2399,32 +2497,35 @@ discard block |
||
2399 | 2497 | </h3> |
2400 | 2498 | </div>'; |
2401 | 2499 | |
2402 | - if (!$context['user']['is_owner']) |
|
2403 | - echo ' |
|
2500 | + if (!$context['user']['is_owner']) { |
|
2501 | + echo ' |
|
2404 | 2502 | <p class="information">', $txt['profile_warning_desc'], '</p>'; |
2503 | + } |
|
2405 | 2504 | |
2406 | 2505 | echo ' |
2407 | 2506 | <div class="windowbg"> |
2408 | 2507 | <dl class="settings">'; |
2409 | 2508 | |
2410 | - if (!$context['user']['is_owner']) |
|
2411 | - echo ' |
|
2509 | + if (!$context['user']['is_owner']) { |
|
2510 | + echo ' |
|
2412 | 2511 | <dt> |
2413 | 2512 | <strong>', $txt['profile_warning_name'], ':</strong> |
2414 | 2513 | </dt> |
2415 | 2514 | <dd> |
2416 | 2515 | <strong>', $context['member']['name'], '</strong> |
2417 | 2516 | </dd>'; |
2517 | + } |
|
2418 | 2518 | |
2419 | 2519 | echo ' |
2420 | 2520 | <dt> |
2421 | 2521 | <strong>', $txt['profile_warning_level'], ':</strong>'; |
2422 | 2522 | |
2423 | 2523 | // Is there only so much they can apply? |
2424 | - if ($context['warning_limit']) |
|
2425 | - echo ' |
|
2524 | + if ($context['warning_limit']) { |
|
2525 | + echo ' |
|
2426 | 2526 | <br> |
2427 | 2527 | <span class="smalltext">', sprintf($txt['profile_warning_limit_attribute'], $context['warning_limit']), '</span>'; |
2528 | + } |
|
2428 | 2529 | |
2429 | 2530 | echo ' |
2430 | 2531 | </dt> |
@@ -2479,9 +2580,10 @@ discard block |
||
2479 | 2580 | <option value="-1">', $txt['profile_warning_notify_template'], '</option> |
2480 | 2581 | <option value="-1" disabled>------------------------------</option>'; |
2481 | 2582 | |
2482 | - foreach ($context['notification_templates'] as $id_template => $template) |
|
2483 | - echo ' |
|
2583 | + foreach ($context['notification_templates'] as $id_template => $template) { |
|
2584 | + echo ' |
|
2484 | 2585 | <option value="', $id_template, '">', $template['title'], '</option>'; |
2586 | + } |
|
2485 | 2587 | |
2486 | 2588 | echo ' |
2487 | 2589 | </select> |
@@ -2494,9 +2596,10 @@ discard block |
||
2494 | 2596 | </dl> |
2495 | 2597 | <div class="righttext">'; |
2496 | 2598 | |
2497 | - if (!empty($context['token_check'])) |
|
2498 | - echo ' |
|
2599 | + if (!empty($context['token_check'])) { |
|
2600 | + echo ' |
|
2499 | 2601 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2602 | + } |
|
2500 | 2603 | |
2501 | 2604 | echo ' |
2502 | 2605 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2512,8 +2615,8 @@ discard block |
||
2512 | 2615 | echo ' |
2513 | 2616 | <script>'; |
2514 | 2617 | |
2515 | - if (!$context['user']['is_owner']) |
|
2516 | - echo ' |
|
2618 | + if (!$context['user']['is_owner']) { |
|
2619 | + echo ' |
|
2517 | 2620 | modifyWarnNotify(); |
2518 | 2621 | $(document).ready(function() { |
2519 | 2622 | $("#preview_button").click(function() { |
@@ -2552,6 +2655,7 @@ discard block |
||
2552 | 2655 | }); |
2553 | 2656 | return false; |
2554 | 2657 | }'; |
2658 | + } |
|
2555 | 2659 | |
2556 | 2660 | echo ' |
2557 | 2661 | </script>'; |
@@ -2574,17 +2678,19 @@ discard block |
||
2574 | 2678 | </div>'; |
2575 | 2679 | |
2576 | 2680 | // If deleting another account give them a lovely info box. |
2577 | - if (!$context['user']['is_owner']) |
|
2578 | - echo ' |
|
2681 | + if (!$context['user']['is_owner']) { |
|
2682 | + echo ' |
|
2579 | 2683 | <p class="information">', $txt['deleteAccount_desc'], '</p>'; |
2684 | + } |
|
2580 | 2685 | |
2581 | 2686 | echo ' |
2582 | 2687 | <div class="windowbg2">'; |
2583 | 2688 | |
2584 | 2689 | // If they are deleting their account AND the admin needs to approve it - give them another piece of info ;) |
2585 | - if ($context['needs_approval']) |
|
2586 | - echo ' |
|
2690 | + if ($context['needs_approval']) { |
|
2691 | + echo ' |
|
2587 | 2692 | <div class="errorbox">', $txt['deleteAccount_approval'], '</div>'; |
2693 | + } |
|
2588 | 2694 | |
2589 | 2695 | // If the user is deleting their own account warn them first - and require a password! |
2590 | 2696 | if ($context['user']['is_owner']) |
@@ -2596,9 +2702,10 @@ discard block |
||
2596 | 2702 | <input type="password" name="oldpasswrd" size="20"> |
2597 | 2703 | <input type="submit" value="', $txt['yes'], '" class="button">'; |
2598 | 2704 | |
2599 | - if (!empty($context['token_check'])) |
|
2600 | - echo ' |
|
2705 | + if (!empty($context['token_check'])) { |
|
2706 | + echo ' |
|
2601 | 2707 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2708 | + } |
|
2602 | 2709 | |
2603 | 2710 | echo ' |
2604 | 2711 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2628,10 +2735,11 @@ discard block |
||
2628 | 2735 | <option value="topics">', $txt['deleteAccount_topics'], '</option> |
2629 | 2736 | </select>'; |
2630 | 2737 | |
2631 | - if ($context['show_perma_delete']) |
|
2632 | - echo ' |
|
2738 | + if ($context['show_perma_delete']) { |
|
2739 | + echo ' |
|
2633 | 2740 | <br> |
2634 | 2741 | <label for="perma_delete"><input type="checkbox" name="perma_delete" id="perma_delete" value="1">', $txt['deleteAccount_permanent'], ':</label>'; |
2742 | + } |
|
2635 | 2743 | |
2636 | 2744 | echo ' |
2637 | 2745 | </div>'; |
@@ -2644,9 +2752,10 @@ discard block |
||
2644 | 2752 | <div> |
2645 | 2753 | <input type="submit" value="', $txt['delete'], '" class="button">'; |
2646 | 2754 | |
2647 | - if (!empty($context['token_check'])) |
|
2648 | - echo ' |
|
2755 | + if (!empty($context['token_check'])) { |
|
2756 | + echo ' |
|
2649 | 2757 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2758 | + } |
|
2650 | 2759 | |
2651 | 2760 | echo ' |
2652 | 2761 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -2672,8 +2781,8 @@ discard block |
||
2672 | 2781 | <hr>'; |
2673 | 2782 | |
2674 | 2783 | // Only show the password box if it's actually needed. |
2675 | - if ($context['require_password']) |
|
2676 | - echo ' |
|
2784 | + if ($context['require_password']) { |
|
2785 | + echo ' |
|
2677 | 2786 | <dl class="settings"> |
2678 | 2787 | <dt> |
2679 | 2788 | <strong', isset($context['modify_error']['bad_password']) || isset($context['modify_error']['no_password']) ? ' class="error"' : '', '>', $txt['current_password'], ': </strong><br> |
@@ -2683,13 +2792,15 @@ discard block |
||
2683 | 2792 | <input type="password" name="oldpasswrd" size="20"> |
2684 | 2793 | </dd> |
2685 | 2794 | </dl>'; |
2795 | + } |
|
2686 | 2796 | |
2687 | 2797 | echo ' |
2688 | 2798 | <div class="righttext">'; |
2689 | 2799 | |
2690 | - if (!empty($context['token_check'])) |
|
2691 | - echo ' |
|
2800 | + if (!empty($context['token_check'])) { |
|
2801 | + echo ' |
|
2692 | 2802 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
2803 | + } |
|
2693 | 2804 | |
2694 | 2805 | echo ' |
2695 | 2806 | <input type="submit" value="', $txt['change_profile'], '" class="button"> |
@@ -2716,9 +2827,10 @@ discard block |
||
2716 | 2827 | <ul id="list_errors">'; |
2717 | 2828 | |
2718 | 2829 | // Cycle through each error and display an error message. |
2719 | - foreach ($context['post_errors'] as $error) |
|
2720 | - echo ' |
|
2830 | + foreach ($context['post_errors'] as $error) { |
|
2831 | + echo ' |
|
2721 | 2832 | <li>', isset($txt['profile_error_' . $error]) ? $txt['profile_error_' . $error] : $error, '</li>'; |
2833 | + } |
|
2722 | 2834 | |
2723 | 2835 | echo ' |
2724 | 2836 | </ul>'; |
@@ -2744,12 +2856,13 @@ discard block |
||
2744 | 2856 | <select name="id_group" ', ($context['user']['is_owner'] && $context['member']['group_id'] == 1 ? 'onchange="if (this.value != 1 && !confirm(\'' . $txt['deadmin_confirm'] . '\')) this.value = 1;"' : ''), '>'; |
2745 | 2857 | |
2746 | 2858 | // Fill the select box with all primary member groups that can be assigned to a member. |
2747 | - foreach ($context['member_groups'] as $member_group) |
|
2748 | - if (!empty($member_group['can_be_primary'])) |
|
2859 | + foreach ($context['member_groups'] as $member_group) { |
|
2860 | + if (!empty($member_group['can_be_primary'])) |
|
2749 | 2861 | echo ' |
2750 | 2862 | <option value="', $member_group['id'], '"', $member_group['is_primary'] ? ' selected' : '', '> |
2751 | 2863 | ', $member_group['name'], ' |
2752 | 2864 | </option>'; |
2865 | + } |
|
2753 | 2866 | |
2754 | 2867 | echo ' |
2755 | 2868 | </select> |
@@ -2762,10 +2875,11 @@ discard block |
||
2762 | 2875 | <input type="hidden" name="additional_groups[]" value="0">'; |
2763 | 2876 | |
2764 | 2877 | // For each membergroup show a checkbox so members can be assigned to more than one group. |
2765 | - foreach ($context['member_groups'] as $member_group) |
|
2766 | - if ($member_group['can_be_additional']) |
|
2878 | + foreach ($context['member_groups'] as $member_group) { |
|
2879 | + if ($member_group['can_be_additional']) |
|
2767 | 2880 | echo ' |
2768 | 2881 | <label for="additional_groups-', $member_group['id'], '"><input type="checkbox" name="additional_groups[]" value="', $member_group['id'], '" id="additional_groups-', $member_group['id'], '"', $member_group['is_additional'] ? ' checked' : '', '> ', $member_group['name'], '</label><br>'; |
2882 | + } |
|
2769 | 2883 | |
2770 | 2884 | echo ' |
2771 | 2885 | </span> |
@@ -2825,9 +2939,10 @@ discard block |
||
2825 | 2939 | <span class="smalltext">', $txt['sig_info'], '</span><br> |
2826 | 2940 | <br>'; |
2827 | 2941 | |
2828 | - if ($context['show_spellchecking']) |
|
2829 | - echo ' |
|
2942 | + if ($context['show_spellchecking']) { |
|
2943 | + echo ' |
|
2830 | 2944 | <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'creator\', \'signature\');" class="button">'; |
2945 | + } |
|
2831 | 2946 | |
2832 | 2947 | echo ' |
2833 | 2948 | </dt> |
@@ -2835,17 +2950,20 @@ discard block |
||
2835 | 2950 | <textarea class="editor" onkeyup="calcCharLeft();" id="signature" name="signature" rows="5" cols="50">', $context['member']['signature'], '</textarea><br>'; |
2836 | 2951 | |
2837 | 2952 | // If there is a limit at all! |
2838 | - if (!empty($context['signature_limits']['max_length'])) |
|
2839 | - echo ' |
|
2953 | + if (!empty($context['signature_limits']['max_length'])) { |
|
2954 | + echo ' |
|
2840 | 2955 | <span class="smalltext">', sprintf($txt['max_sig_characters'], $context['signature_limits']['max_length']), ' <span id="signatureLeft">', $context['signature_limits']['max_length'], '</span></span><br>'; |
2956 | + } |
|
2841 | 2957 | |
2842 | - if (!empty($context['show_preview_button'])) |
|
2843 | - echo ' |
|
2958 | + if (!empty($context['show_preview_button'])) { |
|
2959 | + echo ' |
|
2844 | 2960 | <input type="button" name="preview_signature" id="preview_button" value="', $txt['preview_signature'], '" class="button floatright">'; |
2961 | + } |
|
2845 | 2962 | |
2846 | - if ($context['signature_warning']) |
|
2847 | - echo ' |
|
2963 | + if ($context['signature_warning']) { |
|
2964 | + echo ' |
|
2848 | 2965 | <span class="smalltext">', $context['signature_warning'], '</span>'; |
2966 | + } |
|
2849 | 2967 | |
2850 | 2968 | // Some javascript used to count how many characters have been used so far in the signature. |
2851 | 2969 | echo ' |
@@ -2890,9 +3008,10 @@ discard block |
||
2890 | 3008 | <select name="cat" id="cat" size="10" onchange="changeSel(\'\');" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'server_stored\');">'; |
2891 | 3009 | |
2892 | 3010 | // This lists all the file categories. |
2893 | - foreach ($context['avatars'] as $avatar) |
|
2894 | - echo ' |
|
3011 | + foreach ($context['avatars'] as $avatar) { |
|
3012 | + echo ' |
|
2895 | 3013 | <option value="', $avatar['filename'] . ($avatar['is_dir'] ? '/' : ''), '"', ($avatar['checked'] ? ' selected' : ''), '>', $avatar['name'], '</option>'; |
3014 | + } |
|
2896 | 3015 | |
2897 | 3016 | echo ' |
2898 | 3017 | </select> |
@@ -2924,20 +3043,22 @@ discard block |
||
2924 | 3043 | } |
2925 | 3044 | |
2926 | 3045 | // If the user can link to an off server avatar, show them a box to input the address. |
2927 | - if (!empty($context['member']['avatar']['allow_external'])) |
|
2928 | - echo ' |
|
3046 | + if (!empty($context['member']['avatar']['allow_external'])) { |
|
3047 | + echo ' |
|
2929 | 3048 | <div id="avatar_external"> |
2930 | 3049 | <div class="smalltext">', $txt['avatar_by_url'], '</div>', !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_download_and_resize' ? template_max_size('external') : '', ' |
2931 | 3050 | <input type="text" name="userpicpersonal" size="45" value="', ((stristr($context['member']['avatar']['external'], 'http://') || stristr($context['member']['avatar']['external'], 'https://')) ? $context['member']['avatar']['external'] : 'http://'), '" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'external\');" onchange="if (typeof(previewExternalAvatar) != \'undefined\') previewExternalAvatar(this.value);"> |
2932 | 3051 | </div>'; |
3052 | + } |
|
2933 | 3053 | |
2934 | 3054 | // If the user is able to upload avatars to the server show them an upload box. |
2935 | - if (!empty($context['member']['avatar']['allow_upload'])) |
|
2936 | - echo ' |
|
3055 | + if (!empty($context['member']['avatar']['allow_upload'])) { |
|
3056 | + echo ' |
|
2937 | 3057 | <div id="avatar_upload"> |
2938 | 3058 | <input type="file" size="44" name="attachment" id="avatar_upload_box" value="" onchange="readfromUpload(this)" onfocus="selectRadioByName(document.forms.creator.avatar_choice, \'upload\');" accept="image/gif, image/jpeg, image/jpg, image/png">', template_max_size('upload'), ' |
2939 | 3059 | ', (!empty($context['member']['avatar']['id_attach']) ? '<br><img src="' . $context['member']['avatar']['href'] . (strpos($context['member']['avatar']['href'], '?') === false ? '?' : '&') . 'time=' . time() . '" alt="" id="attached_image"><input type="hidden" name="id_attach" value="' . $context['member']['avatar']['id_attach'] . '">' : ''), ' |
2940 | 3060 | </div>'; |
3061 | + } |
|
2941 | 3062 | |
2942 | 3063 | // if the user is able to use Gravatar avatars show then the image preview |
2943 | 3064 | if (!empty($context['member']['avatar']['allow_gravatar'])) |
@@ -2946,16 +3067,17 @@ discard block |
||
2946 | 3067 | <div id="avatar_gravatar"> |
2947 | 3068 | <img src="' . $context['member']['avatar']['href'] . '" alt="">'; |
2948 | 3069 | |
2949 | - if (empty($modSettings['gravatarAllowExtraEmail'])) |
|
2950 | - echo ' |
|
3070 | + if (empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3071 | + echo ' |
|
2951 | 3072 | <div class="smalltext">', $txt['gravatar_noAlternateEmail'], '</div>'; |
2952 | - else |
|
3073 | + } else |
|
2953 | 3074 | { |
2954 | 3075 | // Depending on other stuff, the stored value here might have some odd things in it from other areas. |
2955 | - if ($context['member']['avatar']['external'] == $context['member']['email']) |
|
2956 | - $textbox_value = ''; |
|
2957 | - else |
|
2958 | - $textbox_value = $context['member']['avatar']['external']; |
|
3076 | + if ($context['member']['avatar']['external'] == $context['member']['email']) { |
|
3077 | + $textbox_value = ''; |
|
3078 | + } else { |
|
3079 | + $textbox_value = $context['member']['avatar']['external']; |
|
3080 | + } |
|
2959 | 3081 | |
2960 | 3082 | echo ' |
2961 | 3083 | <div class="smalltext">', $txt['gravatar_alternateEmail'], '</div> |
@@ -3027,8 +3149,9 @@ discard block |
||
3027 | 3149 | $h = !empty($modSettings['avatar_max_height_' . $type]) ? comma_format($modSettings['avatar_max_height_' . $type]) : 0; |
3028 | 3150 | |
3029 | 3151 | $suffix = (!empty($w) ? 'w' : '') . (!empty($h) ? 'h' : ''); |
3030 | - if (empty($suffix)) |
|
3031 | - return; |
|
3152 | + if (empty($suffix)) { |
|
3153 | + return; |
|
3154 | + } |
|
3032 | 3155 | |
3033 | 3156 | echo ' |
3034 | 3157 | <div class="smalltext">', sprintf($txt['avatar_max_size_' . $suffix], $w, $h), '</div>'; |
@@ -3053,9 +3176,10 @@ discard block |
||
3053 | 3176 | <select name="easyformat" id="easyformat" onchange="document.forms.creator.time_format.value = this.options[this.selectedIndex].value;">'; |
3054 | 3177 | |
3055 | 3178 | // Help the user by showing a list of common time formats. |
3056 | - foreach ($context['easy_timeformats'] as $time_format) |
|
3057 | - echo ' |
|
3179 | + foreach ($context['easy_timeformats'] as $time_format) { |
|
3180 | + echo ' |
|
3058 | 3181 | <option value="', $time_format['format'], '"', $time_format['format'] == $context['member']['time_format'] ? ' selected' : '', '>', $time_format['title'], '</option>'; |
3182 | + } |
|
3059 | 3183 | |
3060 | 3184 | echo ' |
3061 | 3185 | </select> |
@@ -3093,9 +3217,10 @@ discard block |
||
3093 | 3217 | <dd> |
3094 | 3218 | <select name="smiley_set" id="smiley_set" onchange="document.getElementById(\'smileypr\').src = this.selectedIndex == 0 ? \'', $settings['images_url'], '/blank.png\' : \'', $modSettings['smileys_url'], '/\' + (this.selectedIndex != 1 ? this.options[this.selectedIndex].value : \'', !empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default'], '\') + \'/smiley.png\';">'; |
3095 | 3219 | |
3096 | - foreach ($context['smiley_sets'] as $set) |
|
3097 | - echo ' |
|
3220 | + foreach ($context['smiley_sets'] as $set) { |
|
3221 | + echo ' |
|
3098 | 3222 | <option value="', $set['id'], '"', $set['selected'] ? ' selected' : '', '>', $set['name'], '</option>'; |
3223 | + } |
|
3099 | 3224 | |
3100 | 3225 | echo ' |
3101 | 3226 | </select> |
@@ -3147,10 +3272,11 @@ discard block |
||
3147 | 3272 | <img src="', $context['tfa_qr_url'], '" alt=""> |
3148 | 3273 | </div>'; |
3149 | 3274 | |
3150 | - if (!empty($context['from_ajax'])) |
|
3151 | - echo ' |
|
3275 | + if (!empty($context['from_ajax'])) { |
|
3276 | + echo ' |
|
3152 | 3277 | <br> |
3153 | 3278 | <a href="javascript:self.close();"></a>'; |
3279 | + } |
|
3154 | 3280 | |
3155 | 3281 | echo ' |
3156 | 3282 | </div> |
@@ -3190,17 +3316,16 @@ discard block |
||
3190 | 3316 | </dt> |
3191 | 3317 | <dd>'; |
3192 | 3318 | |
3193 | - if (!$context['tfa_enabled'] && $context['user']['is_owner']) |
|
3194 | - echo ' |
|
3319 | + if (!$context['tfa_enabled'] && $context['user']['is_owner']) { |
|
3320 | + echo ' |
|
3195 | 3321 | <a href="', !empty($modSettings['force_ssl']) ? strtr($scripturl, array('http://' => 'https://')) : $scripturl, '?action=profile;area=tfasetup" id="enable_tfa">', $txt['tfa_profile_enable'], '</a>'; |
3196 | - |
|
3197 | - elseif (!$context['tfa_enabled']) |
|
3198 | - echo ' |
|
3322 | + } elseif (!$context['tfa_enabled']) { |
|
3323 | + echo ' |
|
3199 | 3324 | ', $txt['tfa_profile_disabled']; |
3200 | - |
|
3201 | - else |
|
3202 | - echo ' |
|
3325 | + } else { |
|
3326 | + echo ' |
|
3203 | 3327 | ', sprintf($txt['tfa_profile_enabled'], $scripturl . '?action=profile;u=' . $context['id_member'] . ';area=tfasetup;disable'); |
3328 | + } |
|
3204 | 3329 | |
3205 | 3330 | echo ' |
3206 | 3331 | </dd>'; |
@@ -24,11 +24,12 @@ discard block |
||
24 | 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
25 | 25 | </div>'; |
26 | 26 | |
27 | - if (!empty($context['disable_groups'])) |
|
28 | - echo ' |
|
27 | + if (!empty($context['disable_groups'])) { |
|
28 | + echo ' |
|
29 | 29 | <div class="information"> |
30 | 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
31 | 31 | </div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | echo ' |
34 | 35 | <div class="windowbg2"> |
@@ -69,9 +70,10 @@ discard block |
||
69 | 70 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
70 | 71 | |
71 | 72 | // Put each group into the box. |
72 | - foreach ($context['groups'] as $id => $name) |
|
73 | - echo ' |
|
73 | + foreach ($context['groups'] as $id => $name) { |
|
74 | + echo ' |
|
74 | 75 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | echo ' |
77 | 79 | </select> |
@@ -83,12 +85,13 @@ discard block |
||
83 | 85 | <dd>'; |
84 | 86 | |
85 | 87 | // Put a checkbox in for each group |
86 | - foreach ($context['groups'] as $id => $name) |
|
87 | - echo ' |
|
88 | + foreach ($context['groups'] as $id => $name) { |
|
89 | + echo ' |
|
88 | 90 | <label for="addgroup_', $id, '"> |
89 | 91 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> |
90 | 92 | <span class="smalltext">', $name, '</span> |
91 | 93 | </label><br>'; |
94 | + } |
|
92 | 95 | |
93 | 96 | echo ' |
94 | 97 | </dd> |
@@ -142,8 +145,8 @@ discard block |
||
142 | 145 | <fieldset>'; |
143 | 146 | |
144 | 147 | //!! Removed until implemented |
145 | - if (!empty($sdflsdhglsdjgs)) |
|
146 | - echo ' |
|
148 | + if (!empty($sdflsdhglsdjgs)) { |
|
149 | + echo ' |
|
147 | 150 | <dl class="settings"> |
148 | 151 | <dt> |
149 | 152 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
@@ -152,6 +155,7 @@ discard block |
||
152 | 155 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '> |
153 | 156 | </dd> |
154 | 157 | </dl>'; |
158 | + } |
|
155 | 159 | |
156 | 160 | echo ' |
157 | 161 | <div class="information"> |
@@ -250,8 +254,8 @@ discard block |
||
250 | 254 | <dl class="settings">'; |
251 | 255 | |
252 | 256 | // Do we need a username? |
253 | - if ($context['action_type'] == 'add') |
|
254 | - echo ' |
|
257 | + if ($context['action_type'] == 'add') { |
|
258 | + echo ' |
|
255 | 259 | <dt> |
256 | 260 | <strong>', $txt['paid_username'], ':</strong><br> |
257 | 261 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -259,6 +263,7 @@ discard block |
||
259 | 263 | <dd> |
260 | 264 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
261 | 265 | </dd>'; |
266 | + } |
|
262 | 267 | |
263 | 268 | echo ' |
264 | 269 | <dt> |
@@ -276,9 +281,10 @@ discard block |
||
276 | 281 | <select name="year" id="year" onchange="generateDays();">'; |
277 | 282 | |
278 | 283 | // Show a list of all the years we allow... |
279 | - for ($year = 2005; $year <= 2030; $year++) |
|
280 | - echo ' |
|
284 | + for ($year = 2005; $year <= 2030; $year++) { |
|
285 | + echo ' |
|
281 | 286 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
287 | + } |
|
282 | 288 | |
283 | 289 | echo ' |
284 | 290 | </select> |
@@ -286,9 +292,10 @@ discard block |
||
286 | 292 | <select name="month" id="month" onchange="generateDays();">'; |
287 | 293 | |
288 | 294 | // There are 12 months per year - ensure that they all get listed. |
289 | - for ($month = 1; $month <= 12; $month++) |
|
290 | - echo ' |
|
295 | + for ($month = 1; $month <= 12; $month++) { |
|
296 | + echo ' |
|
291 | 297 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
298 | + } |
|
292 | 299 | |
293 | 300 | echo ' |
294 | 301 | </select> |
@@ -296,9 +303,10 @@ discard block |
||
296 | 303 | <select name="day" id="day">'; |
297 | 304 | |
298 | 305 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
299 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
300 | - echo ' |
|
306 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
307 | + echo ' |
|
301 | 308 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
309 | + } |
|
302 | 310 | |
303 | 311 | echo ' |
304 | 312 | </select> |
@@ -310,9 +318,10 @@ discard block |
||
310 | 318 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
311 | 319 | |
312 | 320 | // Show a list of all the years we allow... |
313 | - for ($year = 2005; $year <= 2030; $year++) |
|
314 | - echo ' |
|
321 | + for ($year = 2005; $year <= 2030; $year++) { |
|
322 | + echo ' |
|
315 | 323 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
324 | + } |
|
316 | 325 | |
317 | 326 | echo ' |
318 | 327 | </select> |
@@ -320,9 +329,10 @@ discard block |
||
320 | 329 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
321 | 330 | |
322 | 331 | // There are 12 months per year - ensure that they all get listed. |
323 | - for ($month = 1; $month <= 12; $month++) |
|
324 | - echo ' |
|
332 | + for ($month = 1; $month <= 12; $month++) { |
|
333 | + echo ' |
|
325 | 334 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
335 | + } |
|
326 | 336 | |
327 | 337 | echo ' |
328 | 338 | </select> |
@@ -330,9 +340,10 @@ discard block |
||
330 | 340 | <select name="dayend" id="dayend">'; |
331 | 341 | |
332 | 342 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
333 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
334 | - echo ' |
|
343 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
344 | + echo ' |
|
335 | 345 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
346 | + } |
|
336 | 347 | |
337 | 348 | echo ' |
338 | 349 | </select> |
@@ -371,8 +382,8 @@ discard block |
||
371 | 382 | <div class="windowbg"> |
372 | 383 | <ul>'; |
373 | 384 | |
374 | - foreach ($context['pending_payments'] as $id => $payment) |
|
375 | - echo ' |
|
385 | + foreach ($context['pending_payments'] as $id => $payment) { |
|
386 | + echo ' |
|
376 | 387 | <li> |
377 | 388 | ', $payment['desc'], ' |
378 | 389 | <span class="floatleft"> |
@@ -382,6 +393,7 @@ discard block |
||
382 | 393 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a> |
383 | 394 | </span> |
384 | 395 | </li>'; |
396 | + } |
|
385 | 397 | |
386 | 398 | echo ' |
387 | 399 | </ul> |
@@ -406,12 +418,12 @@ discard block |
||
406 | 418 | <h3 class="catbg">', $txt['subscriptions'], '</h3> |
407 | 419 | </div>'; |
408 | 420 | |
409 | - if (empty($context['subscriptions'])) |
|
410 | - echo ' |
|
421 | + if (empty($context['subscriptions'])) { |
|
422 | + echo ' |
|
411 | 423 | <div class="information"> |
412 | 424 | ', $txt['paid_subs_none'], ' |
413 | 425 | </div>'; |
414 | - else |
|
426 | + } else |
|
415 | 427 | { |
416 | 428 | echo ' |
417 | 429 | <div class="information"> |
@@ -422,8 +434,9 @@ discard block |
||
422 | 434 | foreach ($context['subscriptions'] as $id => $subscription) |
423 | 435 | { |
424 | 436 | // Ignore the inactive ones... |
425 | - if (empty($subscription['active'])) |
|
426 | - continue; |
|
437 | + if (empty($subscription['active'])) { |
|
438 | + continue; |
|
439 | + } |
|
427 | 440 | |
428 | 441 | echo ' |
429 | 442 | <div class="cat_bar"> |
@@ -433,9 +446,10 @@ discard block |
||
433 | 446 | <p><strong>', $subscription['name'], '</strong></p> |
434 | 447 | <p class="smalltext">', $subscription['desc'], '</p>'; |
435 | 448 | |
436 | - if (!$subscription['flexible']) |
|
437 | - echo ' |
|
449 | + if (!$subscription['flexible']) { |
|
450 | + echo ' |
|
438 | 451 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
452 | + } |
|
439 | 453 | |
440 | 454 | if ($context['user']['is_owner']) |
441 | 455 | { |
@@ -448,24 +462,25 @@ discard block |
||
448 | 462 | <select name="cur[', $subscription['id'], ']">'; |
449 | 463 | |
450 | 464 | // Print out the costs for this one. |
451 | - foreach ($subscription['costs'] as $duration => $value) |
|
452 | - echo ' |
|
465 | + foreach ($subscription['costs'] as $duration => $value) { |
|
466 | + echo ' |
|
453 | 467 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
468 | + } |
|
454 | 469 | |
455 | 470 | echo ' |
456 | 471 | </select>'; |
457 | - } |
|
458 | - else |
|
459 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
460 | 474 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
475 | + } |
|
461 | 476 | |
462 | 477 | echo ' |
463 | 478 | <hr> |
464 | 479 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
465 | - } |
|
466 | - else |
|
467 | - echo ' |
|
480 | + } else { |
|
481 | + echo ' |
|
468 | 482 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
483 | + } |
|
469 | 484 | |
470 | 485 | echo ' |
471 | 486 | </div><!-- .windowbg -->'; |
@@ -492,18 +507,19 @@ discard block |
||
492 | 507 | </thead> |
493 | 508 | <tbody>'; |
494 | 509 | |
495 | - if (empty($context['current'])) |
|
496 | - echo ' |
|
510 | + if (empty($context['current'])) { |
|
511 | + echo ' |
|
497 | 512 | <tr class="windowbg"> |
498 | 513 | <td colspan="4"> |
499 | 514 | ', $txt['paid_none_yet'], ' |
500 | 515 | </td> |
501 | 516 | </tr>'; |
517 | + } |
|
502 | 518 | |
503 | 519 | foreach ($context['current'] as $sub) |
504 | 520 | { |
505 | - if (!$sub['hide']) |
|
506 | - echo ' |
|
521 | + if (!$sub['hide']) { |
|
522 | + echo ' |
|
507 | 523 | <tr class="windowbg"> |
508 | 524 | <td> |
509 | 525 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -514,6 +530,7 @@ discard block |
||
514 | 530 | <td>', $sub['start'], '</td> |
515 | 531 | <td>', $sub['end'], '</td> |
516 | 532 | </tr>'; |
533 | + } |
|
517 | 534 | } |
518 | 535 | |
519 | 536 | echo ' |
@@ -565,15 +582,17 @@ discard block |
||
565 | 582 | ', $gateway['desc'], '<br> |
566 | 583 | <form action="', $gateway['form'], '" method="post">'; |
567 | 584 | |
568 | - if (!empty($gateway['javascript'])) |
|
569 | - echo ' |
|
585 | + if (!empty($gateway['javascript'])) { |
|
586 | + echo ' |
|
570 | 587 | <script> |
571 | 588 | ', $gateway['javascript'], ' |
572 | 589 | </script>'; |
590 | + } |
|
573 | 591 | |
574 | - foreach ($gateway['hidden'] as $name => $value) |
|
575 | - echo ' |
|
592 | + foreach ($gateway['hidden'] as $name => $value) { |
|
593 | + echo ' |
|
576 | 594 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
595 | + } |
|
577 | 596 | |
578 | 597 | echo ' |
579 | 598 | <br> |
@@ -65,9 +65,10 @@ discard block |
||
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | |
67 | 67 | // If we have lots of admins... don't show them all. |
68 | - if (!empty($context['more_admins_link'])) |
|
69 | - echo ' |
|
68 | + if (!empty($context['more_admins_link'])) { |
|
69 | + echo ' |
|
70 | 70 | (', $context['more_admins_link'], ')'; |
71 | + } |
|
71 | 72 | |
72 | 73 | echo ' |
73 | 74 | </div><!-- #version_details --> |
@@ -84,17 +85,19 @@ discard block |
||
84 | 85 | foreach ($area['areas'] as $item_id => $item) |
85 | 86 | { |
86 | 87 | // No point showing the 'home' page here, we're already on it! |
87 | - if ($area_id == 'forum' && $item_id == 'index') |
|
88 | - continue; |
|
88 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
91 | 93 | |
92 | - if (!empty($item['icon_file'])) |
|
93 | - echo ' |
|
94 | + if (!empty($item['icon_file'])) { |
|
95 | + echo ' |
|
94 | 96 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
95 | - else |
|
96 | - echo ' |
|
97 | + } else { |
|
98 | + echo ' |
|
97 | 99 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
100 | + } |
|
98 | 101 | } |
99 | 102 | |
100 | 103 | echo ' |
@@ -105,10 +108,11 @@ discard block |
||
105 | 108 | </div><!-- #admincenter -->'; |
106 | 109 | |
107 | 110 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
108 | - if (empty($modSettings['disable_smf_js'])) |
|
109 | - echo ' |
|
111 | + if (empty($modSettings['disable_smf_js'])) { |
|
112 | + echo ' |
|
110 | 113 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
111 | 114 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
115 | + } |
|
112 | 116 | |
113 | 117 | // This sets the announcements and current versions themselves ;). |
114 | 118 | echo ' |
@@ -186,9 +190,10 @@ discard block |
||
186 | 190 | <em>', $version['version'], '</em>'; |
187 | 191 | |
188 | 192 | // more details for this item, show them a link |
189 | - if ($context['can_admin'] && isset($version['more'])) |
|
190 | - echo |
|
193 | + if ($context['can_admin'] && isset($version['more'])) { |
|
194 | + echo |
|
191 | 195 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
196 | + } |
|
192 | 197 | echo ' |
193 | 198 | <br>'; |
194 | 199 | } |
@@ -219,21 +224,23 @@ discard block |
||
219 | 224 | |
220 | 225 | foreach ($context['credits'] as $section) |
221 | 226 | { |
222 | - if (isset($section['pretext'])) |
|
223 | - echo ' |
|
227 | + if (isset($section['pretext'])) { |
|
228 | + echo ' |
|
224 | 229 | <p>', $section['pretext'], '</p> |
225 | 230 | <hr>'; |
231 | + } |
|
226 | 232 | |
227 | 233 | echo ' |
228 | 234 | <dl>'; |
229 | 235 | |
230 | 236 | foreach ($section['groups'] as $group) |
231 | 237 | { |
232 | - if (isset($group['title'])) |
|
233 | - echo ' |
|
238 | + if (isset($group['title'])) { |
|
239 | + echo ' |
|
234 | 240 | <dt> |
235 | 241 | <strong>', $group['title'], ':</strong> |
236 | 242 | </dt>'; |
243 | + } |
|
237 | 244 | |
238 | 245 | echo ' |
239 | 246 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -242,10 +249,11 @@ discard block |
||
242 | 249 | echo ' |
243 | 250 | </dl>'; |
244 | 251 | |
245 | - if (isset($section['posttext'])) |
|
246 | - echo ' |
|
252 | + if (isset($section['posttext'])) { |
|
253 | + echo ' |
|
247 | 254 | <hr> |
248 | 255 | <p>', $section['posttext'], '</p>'; |
256 | + } |
|
249 | 257 | } |
250 | 258 | |
251 | 259 | echo ' |
@@ -261,9 +269,10 @@ discard block |
||
261 | 269 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
262 | 270 | |
263 | 271 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
264 | - foreach ($context['current_versions'] as $variable => $version) |
|
265 | - echo ' |
|
272 | + foreach ($context['current_versions'] as $variable => $version) { |
|
273 | + echo ' |
|
266 | 274 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
275 | + } |
|
267 | 276 | |
268 | 277 | // Now we just have to include the script and wait ;). |
269 | 278 | echo ' |
@@ -360,8 +369,8 @@ discard block |
||
360 | 369 | <tbody>'; |
361 | 370 | |
362 | 371 | // Loop through every source file displaying its version - using javascript. |
363 | - foreach ($context['file_versions'] as $filename => $version) |
|
364 | - echo ' |
|
372 | + foreach ($context['file_versions'] as $filename => $version) { |
|
373 | + echo ' |
|
365 | 374 | <tr class="windowbg"> |
366 | 375 | <td class="half_table"> |
367 | 376 | ', $filename, ' |
@@ -373,6 +382,7 @@ discard block |
||
373 | 382 | <em id="currentSources', $filename, '">??</em> |
374 | 383 | </td> |
375 | 384 | </tr>'; |
385 | + } |
|
376 | 386 | |
377 | 387 | // Default template files. |
378 | 388 | echo ' |
@@ -398,8 +408,8 @@ discard block |
||
398 | 408 | <table id="Default" class="table_grid"> |
399 | 409 | <tbody>'; |
400 | 410 | |
401 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
402 | - echo ' |
|
411 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
412 | + echo ' |
|
403 | 413 | <tr class="windowbg"> |
404 | 414 | <td class="half_table"> |
405 | 415 | ', $filename, ' |
@@ -411,6 +421,7 @@ discard block |
||
411 | 421 | <em id="currentDefault', $filename, '">??</em> |
412 | 422 | </td> |
413 | 423 | </tr>'; |
424 | + } |
|
414 | 425 | |
415 | 426 | // Now the language files... |
416 | 427 | echo ' |
@@ -438,8 +449,8 @@ discard block |
||
438 | 449 | |
439 | 450 | foreach ($context['default_language_versions'] as $language => $files) |
440 | 451 | { |
441 | - foreach ($files as $filename => $version) |
|
442 | - echo ' |
|
452 | + foreach ($files as $filename => $version) { |
|
453 | + echo ' |
|
443 | 454 | <tr class="windowbg"> |
444 | 455 | <td class="half_table"> |
445 | 456 | ', $filename, '.<em>', $language, '</em>.php |
@@ -451,6 +462,7 @@ discard block |
||
451 | 462 | <em id="current', $filename, '.', $language, '">??</em> |
452 | 463 | </td> |
453 | 464 | </tr>'; |
465 | + } |
|
454 | 466 | } |
455 | 467 | |
456 | 468 | echo ' |
@@ -480,8 +492,8 @@ discard block |
||
480 | 492 | <table id="Templates" class="table_grid"> |
481 | 493 | <tbody>'; |
482 | 494 | |
483 | - foreach ($context['template_versions'] as $filename => $version) |
|
484 | - echo ' |
|
495 | + foreach ($context['template_versions'] as $filename => $version) { |
|
496 | + echo ' |
|
485 | 497 | <tr class="windowbg"> |
486 | 498 | <td class="half_table"> |
487 | 499 | ', $filename, ' |
@@ -493,6 +505,7 @@ discard block |
||
493 | 505 | <em id="currentTemplates', $filename, '">??</em> |
494 | 506 | </td> |
495 | 507 | </tr>'; |
508 | + } |
|
496 | 509 | |
497 | 510 | echo ' |
498 | 511 | </tbody> |
@@ -522,8 +535,8 @@ discard block |
||
522 | 535 | <table id="Tasks" class="table_grid"> |
523 | 536 | <tbody>'; |
524 | 537 | |
525 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
526 | - echo ' |
|
538 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
539 | + echo ' |
|
527 | 540 | <tr class="windowbg"> |
528 | 541 | <td class="half_table"> |
529 | 542 | ', $filename, ' |
@@ -535,6 +548,7 @@ discard block |
||
535 | 548 | <em id="currentTasks', $filename, '">??</em> |
536 | 549 | </td> |
537 | 550 | </tr>'; |
551 | + } |
|
538 | 552 | |
539 | 553 | echo ' |
540 | 554 | </tbody> |
@@ -576,9 +590,10 @@ discard block |
||
576 | 590 | { |
577 | 591 | global $context, $scripturl, $txt, $modSettings; |
578 | 592 | |
579 | - if (!empty($context['saved_successful'])) |
|
580 | - echo ' |
|
593 | + if (!empty($context['saved_successful'])) { |
|
594 | + echo ' |
|
581 | 595 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
596 | + } |
|
582 | 597 | |
583 | 598 | // First section is for adding/removing words from the censored list. |
584 | 599 | echo ' |
@@ -593,11 +608,12 @@ discard block |
||
593 | 608 | <p>', $txt['admin_censored_where'], '</p>'; |
594 | 609 | |
595 | 610 | // Show text boxes for censoring [bad ] => [good ]. |
596 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
597 | - echo ' |
|
611 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
612 | + echo ' |
|
598 | 613 | <div class="block"> |
599 | 614 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
600 | 615 | </div>'; |
616 | + } |
|
601 | 617 | |
602 | 618 | // Now provide a way to censor more words. |
603 | 619 | echo ' |
@@ -672,19 +688,21 @@ discard block |
||
672 | 688 | <div class="windowbg2 noup"> |
673 | 689 | ', $txt['not_done_reason']; |
674 | 690 | |
675 | - if (!empty($context['continue_percent'])) |
|
676 | - echo ' |
|
691 | + if (!empty($context['continue_percent'])) { |
|
692 | + echo ' |
|
677 | 693 | <div class="progress_bar"> |
678 | 694 | <div class="full_bar">', $context['continue_percent'], '%</div> |
679 | 695 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"></div> |
680 | 696 | </div>'; |
697 | + } |
|
681 | 698 | |
682 | - if (!empty($context['substep_enabled'])) |
|
683 | - echo ' |
|
699 | + if (!empty($context['substep_enabled'])) { |
|
700 | + echo ' |
|
684 | 701 | <div class="progress_bar"> |
685 | 702 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
686 | 703 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"></div> |
687 | 704 | </div>'; |
705 | + } |
|
688 | 706 | |
689 | 707 | echo ' |
690 | 708 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -719,35 +737,40 @@ discard block |
||
719 | 737 | { |
720 | 738 | global $context, $txt, $scripturl; |
721 | 739 | |
722 | - if (!empty($context['saved_successful'])) |
|
723 | - echo ' |
|
740 | + if (!empty($context['saved_successful'])) { |
|
741 | + echo ' |
|
724 | 742 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
725 | - elseif (!empty($context['saved_failed'])) |
|
726 | - echo ' |
|
743 | + } elseif (!empty($context['saved_failed'])) { |
|
744 | + echo ' |
|
727 | 745 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
746 | + } |
|
728 | 747 | |
729 | - if (!empty($context['settings_pre_javascript'])) |
|
730 | - echo ' |
|
748 | + if (!empty($context['settings_pre_javascript'])) { |
|
749 | + echo ' |
|
731 | 750 | <script>', $context['settings_pre_javascript'], '</script>'; |
751 | + } |
|
732 | 752 | |
733 | - if (!empty($context['settings_insert_above'])) |
|
734 | - echo $context['settings_insert_above']; |
|
753 | + if (!empty($context['settings_insert_above'])) { |
|
754 | + echo $context['settings_insert_above']; |
|
755 | + } |
|
735 | 756 | |
736 | 757 | echo ' |
737 | 758 | <div id="admincenter"> |
738 | 759 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
739 | 760 | |
740 | 761 | // Is there a custom title? |
741 | - if (isset($context['settings_title'])) |
|
742 | - echo ' |
|
762 | + if (isset($context['settings_title'])) { |
|
763 | + echo ' |
|
743 | 764 | <div class="cat_bar"> |
744 | 765 | <h3 class="catbg">', $context['settings_title'], '</h3> |
745 | 766 | </div>'; |
767 | + } |
|
746 | 768 | |
747 | 769 | // Have we got a message to display? |
748 | - if (!empty($context['settings_message'])) |
|
749 | - echo ' |
|
770 | + if (!empty($context['settings_message'])) { |
|
771 | + echo ' |
|
750 | 772 | <div class="information">', $context['settings_message'], '</div>'; |
773 | + } |
|
751 | 774 | |
752 | 775 | // Now actually loop through all the variables. |
753 | 776 | $is_open = false; |
@@ -800,8 +823,9 @@ discard block |
||
800 | 823 | // Hang about? Are you pulling my leg - a callback?! |
801 | 824 | if (is_array($config_var) && $config_var['type'] == 'callback') |
802 | 825 | { |
803 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
804 | - call_user_func('template_callback_' . $config_var['name']); |
|
826 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
827 | + call_user_func('template_callback_' . $config_var['name']); |
|
828 | + } |
|
805 | 829 | |
806 | 830 | continue; |
807 | 831 | } |
@@ -831,9 +855,10 @@ discard block |
||
831 | 855 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
832 | 856 | |
833 | 857 | // Show the [?] button. |
834 | - if ($config_var['help']) |
|
835 | - echo ' |
|
858 | + if ($config_var['help']) { |
|
859 | + echo ' |
|
836 | 860 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
861 | + } |
|
837 | 862 | |
838 | 863 | echo ' |
839 | 864 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -842,23 +867,26 @@ discard block |
||
842 | 867 | $config_var['preinput']; |
843 | 868 | |
844 | 869 | // Show a check box. |
845 | - if ($config_var['type'] == 'check') |
|
846 | - echo ' |
|
870 | + if ($config_var['type'] == 'check') { |
|
871 | + echo ' |
|
847 | 872 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
873 | + } |
|
848 | 874 | // Escape (via htmlspecialchars.) the text box. |
849 | - elseif ($config_var['type'] == 'password') |
|
850 | - echo ' |
|
875 | + elseif ($config_var['type'] == 'password') { |
|
876 | + echo ' |
|
851 | 877 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
852 | 878 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
879 | + } |
|
853 | 880 | // Show a selection box. |
854 | 881 | elseif ($config_var['type'] == 'select') |
855 | 882 | { |
856 | 883 | echo ' |
857 | 884 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
858 | 885 | |
859 | - foreach ($config_var['data'] as $option) |
|
860 | - echo ' |
|
886 | + foreach ($config_var['data'] as $option) { |
|
887 | + echo ' |
|
861 | 888 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
889 | + } |
|
862 | 890 | echo ' |
863 | 891 | </select>'; |
864 | 892 | } |
@@ -875,16 +903,18 @@ discard block |
||
875 | 903 | |
876 | 904 | foreach ($context['board_list'] as $id_cat => $cat) |
877 | 905 | { |
878 | - if (!$first) |
|
879 | - echo ' |
|
906 | + if (!$first) { |
|
907 | + echo ' |
|
880 | 908 | <hr>'; |
909 | + } |
|
881 | 910 | echo ' |
882 | 911 | <strong>', $cat['name'], '</strong> |
883 | 912 | <ul>'; |
884 | 913 | |
885 | - foreach ($cat['boards'] as $id_board => $brd) |
|
886 | - echo ' |
|
914 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
915 | + echo ' |
|
887 | 916 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
917 | + } |
|
888 | 918 | |
889 | 919 | echo ' |
890 | 920 | </ul>'; |
@@ -894,12 +924,14 @@ discard block |
||
894 | 924 | </fieldset>'; |
895 | 925 | } |
896 | 926 | // Text area? |
897 | - elseif ($config_var['type'] == 'large_text') |
|
898 | - echo ' |
|
927 | + elseif ($config_var['type'] == 'large_text') { |
|
928 | + echo ' |
|
899 | 929 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
930 | + } |
|
900 | 931 | // Permission group? |
901 | - elseif ($config_var['type'] == 'permissions') |
|
902 | - theme_inline_permissions($config_var['name']); |
|
932 | + elseif ($config_var['type'] == 'permissions') { |
|
933 | + theme_inline_permissions($config_var['name']); |
|
934 | + } |
|
903 | 935 | |
904 | 936 | // BBC selection? |
905 | 937 | elseif ($config_var['type'] == 'bbc') |
@@ -911,22 +943,24 @@ discard block |
||
911 | 943 | |
912 | 944 | foreach ($context['bbc_columns'] as $bbcColumn) |
913 | 945 | { |
914 | - foreach ($bbcColumn as $bbcTag) |
|
915 | - echo ' |
|
946 | + foreach ($bbcColumn as $bbcTag) { |
|
947 | + echo ' |
|
916 | 948 | <li class="list_bbc floatleft"> |
917 | 949 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
918 | 950 | </li>'; |
951 | + } |
|
919 | 952 | } |
920 | 953 | echo ' </ul> |
921 | 954 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
922 | 955 | </fieldset>'; |
923 | 956 | } |
924 | 957 | // A simple message? |
925 | - elseif ($config_var['type'] == 'var_message') |
|
926 | - echo ' |
|
958 | + elseif ($config_var['type'] == 'var_message') { |
|
959 | + echo ' |
|
927 | 960 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
928 | 961 | ', $config_var['var_message'], ' |
929 | 962 | </div>'; |
963 | + } |
|
930 | 964 | // Assume it must be a text box |
931 | 965 | else |
932 | 966 | { |
@@ -951,62 +985,70 @@ discard block |
||
951 | 985 | ' . $config_var['postinput'] : '',' |
952 | 986 | </dd>'; |
953 | 987 | } |
954 | - } |
|
955 | - else |
|
988 | + } else |
|
956 | 989 | { |
957 | 990 | // Just show a separator. |
958 | - if ($config_var == '') |
|
959 | - echo ' |
|
991 | + if ($config_var == '') { |
|
992 | + echo ' |
|
960 | 993 | </dl> |
961 | 994 | <hr> |
962 | 995 | <dl class="settings">'; |
963 | - else |
|
964 | - echo ' |
|
996 | + } else { |
|
997 | + echo ' |
|
965 | 998 | <dd> |
966 | 999 | <strong>' . $config_var . '</strong> |
967 | 1000 | </dd>'; |
1001 | + } |
|
968 | 1002 | } |
969 | 1003 | } |
970 | 1004 | |
971 | - if ($is_open) |
|
972 | - echo ' |
|
1005 | + if ($is_open) { |
|
1006 | + echo ' |
|
973 | 1007 | </dl>'; |
1008 | + } |
|
974 | 1009 | |
975 | - if (empty($context['settings_save_dont_show'])) |
|
976 | - echo ' |
|
1010 | + if (empty($context['settings_save_dont_show'])) { |
|
1011 | + echo ' |
|
977 | 1012 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
1013 | + } |
|
978 | 1014 | |
979 | - if ($is_open) |
|
980 | - echo ' |
|
1015 | + if ($is_open) { |
|
1016 | + echo ' |
|
981 | 1017 | </div><!-- .windowbg2 -->'; |
1018 | + } |
|
982 | 1019 | |
983 | 1020 | |
984 | 1021 | // At least one token has to be used! |
985 | - if (isset($context['admin-ssc_token'])) |
|
986 | - echo ' |
|
1022 | + if (isset($context['admin-ssc_token'])) { |
|
1023 | + echo ' |
|
987 | 1024 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1025 | + } |
|
988 | 1026 | |
989 | - if (isset($context['admin-dbsc_token'])) |
|
990 | - echo ' |
|
1027 | + if (isset($context['admin-dbsc_token'])) { |
|
1028 | + echo ' |
|
991 | 1029 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1030 | + } |
|
992 | 1031 | |
993 | - if (isset($context['admin-mp_token'])) |
|
994 | - echo ' |
|
1032 | + if (isset($context['admin-mp_token'])) { |
|
1033 | + echo ' |
|
995 | 1034 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1035 | + } |
|
996 | 1036 | |
997 | 1037 | echo ' |
998 | 1038 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
999 | 1039 | </form> |
1000 | 1040 | </div><!-- #admincenter -->'; |
1001 | 1041 | |
1002 | - if (!empty($context['settings_post_javascript'])) |
|
1003 | - echo ' |
|
1042 | + if (!empty($context['settings_post_javascript'])) { |
|
1043 | + echo ' |
|
1004 | 1044 | <script> |
1005 | 1045 | ', $context['settings_post_javascript'], ' |
1006 | 1046 | </script>'; |
1047 | + } |
|
1007 | 1048 | |
1008 | - if (!empty($context['settings_insert_below'])) |
|
1009 | - echo $context['settings_insert_below']; |
|
1049 | + if (!empty($context['settings_insert_below'])) { |
|
1050 | + echo $context['settings_insert_below']; |
|
1051 | + } |
|
1010 | 1052 | |
1011 | 1053 | // We may have added a board listing. If we did, we need to make it work. |
1012 | 1054 | addInlineJavascript(' |
@@ -1029,9 +1071,10 @@ discard block |
||
1029 | 1071 | { |
1030 | 1072 | global $context, $txt; |
1031 | 1073 | |
1032 | - if (!empty($context['saved_successful'])) |
|
1033 | - echo ' |
|
1074 | + if (!empty($context['saved_successful'])) { |
|
1075 | + echo ' |
|
1034 | 1076 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1077 | + } |
|
1035 | 1078 | |
1036 | 1079 | // Standard fields. |
1037 | 1080 | template_show_list('standard_profile_fields'); |
@@ -1065,11 +1108,12 @@ discard block |
||
1065 | 1108 | { |
1066 | 1109 | loadLanguage('Errors'); |
1067 | 1110 | |
1068 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1069 | - echo ' |
|
1111 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1112 | + echo ' |
|
1070 | 1113 | <div class="errorbox">', |
1071 | 1114 | $txt['custom_option_' . $_GET['msg']], ' |
1072 | 1115 | </div>'; |
1116 | + } |
|
1073 | 1117 | } |
1074 | 1118 | |
1075 | 1119 | echo ' |
@@ -1136,9 +1180,10 @@ discard block |
||
1136 | 1180 | <dd> |
1137 | 1181 | <select name="placement" id="placement">'; |
1138 | 1182 | |
1139 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1140 | - echo ' |
|
1183 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1184 | + echo ' |
|
1141 | 1185 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1186 | + } |
|
1142 | 1187 | |
1143 | 1188 | echo ' |
1144 | 1189 | </select> |
@@ -1162,9 +1207,10 @@ discard block |
||
1162 | 1207 | <dd> |
1163 | 1208 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1164 | 1209 | |
1165 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1166 | - echo ' |
|
1210 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1211 | + echo ' |
|
1167 | 1212 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1213 | + } |
|
1168 | 1214 | |
1169 | 1215 | echo ' |
1170 | 1216 | </select> |
@@ -1196,9 +1242,10 @@ discard block |
||
1196 | 1242 | </dt> |
1197 | 1243 | <dd id="options_dd">'; |
1198 | 1244 | |
1199 | - foreach ($context['field']['options'] as $k => $option) |
|
1200 | - echo ' |
|
1245 | + foreach ($context['field']['options'] as $k => $option) { |
|
1246 | + echo ' |
|
1201 | 1247 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
1248 | + } |
|
1202 | 1249 | |
1203 | 1250 | echo ' |
1204 | 1251 | <span id="addopt"></span> |
@@ -1262,9 +1309,10 @@ discard block |
||
1262 | 1309 | </fieldset> |
1263 | 1310 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
1264 | 1311 | |
1265 | - if ($context['fid']) |
|
1266 | - echo ' |
|
1312 | + if ($context['fid']) { |
|
1313 | + echo ' |
|
1267 | 1314 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
1315 | + } |
|
1268 | 1316 | |
1269 | 1317 | echo ' |
1270 | 1318 | </div><!-- .windowbg2 --> |
@@ -1311,8 +1359,7 @@ discard block |
||
1311 | 1359 | <p class="centertext"> |
1312 | 1360 | <strong>', $txt['admin_search_results_none'], '</strong> |
1313 | 1361 | </p>'; |
1314 | - } |
|
1315 | - else |
|
1362 | + } else |
|
1316 | 1363 | { |
1317 | 1364 | echo ' |
1318 | 1365 | <ol class="search_results">'; |
@@ -1339,9 +1386,10 @@ discard block |
||
1339 | 1386 | <li> |
1340 | 1387 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1341 | 1388 | |
1342 | - if ($result['help']) |
|
1343 | - echo ' |
|
1389 | + if ($result['help']) { |
|
1390 | + echo ' |
|
1344 | 1391 | <p class="double_height">', $result['help'], '</p>'; |
1392 | + } |
|
1345 | 1393 | |
1346 | 1394 | echo ' |
1347 | 1395 | </li>'; |
@@ -1381,10 +1429,11 @@ discard block |
||
1381 | 1429 | <strong>', $txt['setup_verification_answer'], '</strong> |
1382 | 1430 | </dd>'; |
1383 | 1431 | |
1384 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1385 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1432 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1433 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1386 | 1434 | { |
1387 | 1435 | $question = $context['question_answers'][$q_id]; |
1436 | + } |
|
1388 | 1437 | |
1389 | 1438 | echo ' |
1390 | 1439 | <dt> |
@@ -1392,9 +1441,10 @@ discard block |
||
1392 | 1441 | </dt> |
1393 | 1442 | <dd>'; |
1394 | 1443 | |
1395 | - foreach ($question['answers'] as $answer) |
|
1396 | - echo ' |
|
1444 | + foreach ($question['answers'] as $answer) { |
|
1445 | + echo ' |
|
1397 | 1446 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
1447 | + } |
|
1398 | 1448 | |
1399 | 1449 | echo ' |
1400 | 1450 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1433,11 +1483,12 @@ discard block |
||
1433 | 1483 | ', $txt['errors_found'], ': |
1434 | 1484 | <ul>'; |
1435 | 1485 | |
1436 | - foreach ($context['repair_errors'] as $error) |
|
1437 | - echo ' |
|
1486 | + foreach ($context['repair_errors'] as $error) { |
|
1487 | + echo ' |
|
1438 | 1488 | <li> |
1439 | 1489 | ', $error, ' |
1440 | 1490 | </li>'; |
1491 | + } |
|
1441 | 1492 | |
1442 | 1493 | echo ' |
1443 | 1494 | </ul> |
@@ -1447,15 +1498,14 @@ discard block |
||
1447 | 1498 | <p class="padding"> |
1448 | 1499 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1449 | 1500 | </p>'; |
1450 | - } |
|
1451 | - else |
|
1452 | - echo ' |
|
1501 | + } else { |
|
1502 | + echo ' |
|
1453 | 1503 | <p>', $txt['maintain_no_errors'], '</p> |
1454 | 1504 | <p class="padding"> |
1455 | 1505 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1456 | 1506 | </p>'; |
1457 | - } |
|
1458 | - else |
|
1507 | + } |
|
1508 | + } else |
|
1459 | 1509 | { |
1460 | 1510 | if (!empty($context['redirect_to_recount'])) |
1461 | 1511 | { |
@@ -1467,8 +1517,7 @@ discard block |
||
1467 | 1517 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1468 | 1518 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1469 | 1519 | </form>'; |
1470 | - } |
|
1471 | - else |
|
1520 | + } else |
|
1472 | 1521 | { |
1473 | 1522 | echo ' |
1474 | 1523 | <p>', $txt['errors_fixed'], '</p> |
@@ -1559,9 +1608,10 @@ discard block |
||
1559 | 1608 | <tr class="windowbg"> |
1560 | 1609 | <td class="equal_table">', $key, '</td>'; |
1561 | 1610 | |
1562 | - foreach ($setting as $key_lm => $value) |
|
1563 | - echo ' |
|
1611 | + foreach ($setting as $key_lm => $value) { |
|
1612 | + echo ' |
|
1564 | 1613 | <td class="equal_table">', $value, '</td>'; |
1614 | + } |
|
1565 | 1615 | |
1566 | 1616 | echo ' |
1567 | 1617 | </tr>'; |
@@ -1621,8 +1671,8 @@ discard block |
||
1621 | 1671 | { |
1622 | 1672 | global $context, $txt; |
1623 | 1673 | |
1624 | - if ($context['user']['is_admin']) |
|
1625 | - echo ' |
|
1674 | + if ($context['user']['is_admin']) { |
|
1675 | + echo ' |
|
1626 | 1676 | <span class="floatright admin_search"> |
1627 | 1677 | <span class="generic_icons filter centericon"></span> |
1628 | 1678 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';"> |
@@ -1633,6 +1683,7 @@ discard block |
||
1633 | 1683 | </select> |
1634 | 1684 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
1635 | 1685 | </span>'; |
1636 | -} |
|
1686 | + } |
|
1687 | + } |
|
1637 | 1688 | |
1638 | 1689 | ?> |
1639 | 1690 | \ No newline at end of file |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | <subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> |
74 | 74 | <body><![CDATA[', $context['message']['body'], ']]></body> |
75 | 75 | <success><![CDATA[', $txt['quick_modify_message'], ']]></success>'; |
76 | - } |
|
77 | - else |
|
78 | - echo ' |
|
76 | + } else { |
|
77 | + echo ' |
|
79 | 78 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '" in_body="', cleanXml($context['message']['error_in_body']) ? '1' : '0', '"><![CDATA[', implode('<br />', $context['message']['errors']), ']]></error>'; |
79 | + } |
|
80 | 80 | echo ' |
81 | 81 | </message> |
82 | 82 | </smf>'; |
@@ -101,13 +101,14 @@ discard block |
||
101 | 101 | echo ' |
102 | 102 | <modified><![CDATA[', empty($modified) ? '' : cleanXml('« <em>' . $modified . '</em>»'), ']]></modified>'; |
103 | 103 | |
104 | - if (!empty($context['message']['subject'])) |
|
105 | - echo ' |
|
104 | + if (!empty($context['message']['subject'])) { |
|
105 | + echo ' |
|
106 | 106 | <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>'; |
107 | - } |
|
108 | - else |
|
109 | - echo ' |
|
107 | + } |
|
108 | + } else { |
|
109 | + echo ' |
|
110 | 110 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>'; |
111 | + } |
|
111 | 112 | echo ' |
112 | 113 | </message> |
113 | 114 | </smf>'; |
@@ -128,10 +129,11 @@ discard block |
||
128 | 129 | </preview> |
129 | 130 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">'; |
130 | 131 | |
131 | - if (!empty($context['post_error'])) |
|
132 | - foreach ($context['post_error'] as $message) |
|
132 | + if (!empty($context['post_error'])) { |
|
133 | + foreach ($context['post_error'] as $message) |
|
133 | 134 | echo ' |
134 | 135 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
136 | + } |
|
135 | 137 | |
136 | 138 | echo ' |
137 | 139 | <caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" /> |
@@ -148,14 +150,15 @@ discard block |
||
148 | 150 | echo ' |
149 | 151 | <new_posts>'; |
150 | 152 | |
151 | - foreach ($context['previous_posts'] as $post) |
|
152 | - echo ' |
|
153 | + foreach ($context['previous_posts'] as $post) { |
|
154 | + echo ' |
|
153 | 155 | <post id="', $post['id'], '"> |
154 | 156 | <time><![CDATA[', $post['time'], ']]></time> |
155 | 157 | <poster><![CDATA[', cleanXml($post['poster']), ']]></poster> |
156 | 158 | <message><![CDATA[', cleanXml($post['message']), ']]></message> |
157 | 159 | <is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored> |
158 | 160 | </post>'; |
161 | + } |
|
159 | 162 | |
160 | 163 | echo ' |
161 | 164 | </new_posts>'; |
@@ -181,10 +184,11 @@ discard block |
||
181 | 184 | </preview> |
182 | 185 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
183 | 186 | |
184 | - if (!empty($context['post_error']['messages'])) |
|
185 | - foreach ($context['post_error']['messages'] as $message) |
|
187 | + if (!empty($context['post_error']['messages'])) { |
|
188 | + foreach ($context['post_error']['messages'] as $message) |
|
186 | 189 | echo ' |
187 | 190 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
191 | + } |
|
188 | 192 | |
189 | 193 | echo ' |
190 | 194 | <caption name="to" class="', isset($context['post_error']['no_to']) ? 'error' : '', '" /> |
@@ -214,10 +218,11 @@ discard block |
||
214 | 218 | </preview> |
215 | 219 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
216 | 220 | |
217 | - if (!empty($context['post_error']['messages'])) |
|
218 | - foreach ($context['post_error']['messages'] as $message) |
|
221 | + if (!empty($context['post_error']['messages'])) { |
|
222 | + foreach ($context['post_error']['messages'] as $message) |
|
219 | 223 | echo ' |
220 | 224 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
225 | + } |
|
221 | 226 | |
222 | 227 | echo ' |
223 | 228 | </errors>'; |
@@ -233,20 +238,23 @@ discard block |
||
233 | 238 | { |
234 | 239 | global $context, $modSettings; |
235 | 240 | |
236 | - if (empty($context['yearly'])) |
|
237 | - return; |
|
241 | + if (empty($context['yearly'])) { |
|
242 | + return; |
|
243 | + } |
|
238 | 244 | |
239 | 245 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
240 | 246 | <smf>'; |
241 | - foreach ($context['yearly'] as $year) |
|
242 | - foreach ($year['months'] as $month) |
|
247 | + foreach ($context['yearly'] as $year) { |
|
248 | + foreach ($year['months'] as $month) |
|
243 | 249 | { |
244 | 250 | echo ' |
245 | 251 | <month id="', $month['date']['year'], $month['date']['month'], '">'; |
252 | + } |
|
246 | 253 | |
247 | - foreach ($month['days'] as $day) |
|
248 | - echo ' |
|
254 | + foreach ($month['days'] as $day) { |
|
255 | + echo ' |
|
249 | 256 | <day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />'; |
257 | + } |
|
250 | 258 | |
251 | 259 | echo ' |
252 | 260 | </month>'; |
@@ -269,17 +277,18 @@ discard block |
||
269 | 277 | <pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>'; |
270 | 278 | foreach ($context['changes'] as $change) |
271 | 279 | { |
272 | - if ($change['type'] == 'remove') |
|
273 | - echo ' |
|
280 | + if ($change['type'] == 'remove') { |
|
281 | + echo ' |
|
274 | 282 | <change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />'; |
275 | - else |
|
276 | - echo ' |
|
283 | + } else { |
|
284 | + echo ' |
|
277 | 285 | <change id="', $change['id'], '" curAction="insert" section="', $change['section'], '"> |
278 | 286 | <subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject> |
279 | 287 | <time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time> |
280 | 288 | <body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body> |
281 | 289 | <poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster> |
282 | 290 | </change>'; |
291 | + } |
|
283 | 292 | } |
284 | 293 | echo ' |
285 | 294 | </smf>'; |
@@ -310,10 +319,10 @@ discard block |
||
310 | 319 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
311 | 320 | <smf>'; |
312 | 321 | |
313 | - if (empty($context['topics'])) |
|
314 | - echo ' |
|
322 | + if (empty($context['topics'])) { |
|
323 | + echo ' |
|
315 | 324 | <noresults>', $txt['search_no_results'], '</noresults>'; |
316 | - else |
|
325 | + } else |
|
317 | 326 | { |
318 | 327 | echo ' |
319 | 328 | <results>'; |
@@ -382,9 +391,10 @@ discard block |
||
382 | 391 | echo ' |
383 | 392 | <item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>'; |
384 | 393 | |
385 | - foreach ($category['boards'] as $board) |
|
386 | - echo ' |
|
394 | + foreach ($category['boards'] as $board) { |
|
395 | + echo ' |
|
387 | 396 | <item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '"><![CDATA[', cleanXml($board['name']), ']]></item>'; |
397 | + } |
|
388 | 398 | } |
389 | 399 | echo ' |
390 | 400 | </smf>'; |
@@ -400,9 +410,10 @@ discard block |
||
400 | 410 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
401 | 411 | <smf>'; |
402 | 412 | |
403 | - foreach ($context['icons'] as $icon) |
|
404 | - echo ' |
|
413 | + foreach ($context['icons'] as $icon) { |
|
414 | + echo ' |
|
405 | 415 | <icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>'; |
416 | + } |
|
406 | 417 | |
407 | 418 | echo ' |
408 | 419 | </smf>'; |
@@ -452,16 +463,18 @@ discard block |
||
452 | 463 | foreach ($xml_data as $key => $data) |
453 | 464 | { |
454 | 465 | // A group? |
455 | - if (is_array($data) && isset($data['identifier'])) |
|
456 | - template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
466 | + if (is_array($data) && isset($data['identifier'])) { |
|
467 | + template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
|
468 | + } |
|
457 | 469 | // An item... |
458 | 470 | elseif (is_array($data) && isset($data['value'])) |
459 | 471 | { |
460 | 472 | echo "\n", str_repeat("\t", $level), '<', $child_ident; |
461 | 473 | |
462 | - if (!empty($data['attributes'])) |
|
463 | - foreach ($data['attributes'] as $k => $v) |
|
474 | + if (!empty($data['attributes'])) { |
|
475 | + foreach ($data['attributes'] as $k => $v) |
|
464 | 476 | echo ' ' . $k . '="' . $v . '"'; |
477 | + } |
|
465 | 478 | echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>'; |
466 | 479 | } |
467 | 480 | } |
@@ -20,17 +20,19 @@ discard block |
||
20 | 20 | echo ' |
21 | 21 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">'; |
22 | 22 | |
23 | - if (!empty($context['search_errors'])) |
|
24 | - echo ' |
|
23 | + if (!empty($context['search_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="errorbox"> |
26 | 26 | ', implode('<br>', $context['search_errors']['messages']), ' |
27 | 27 | </div>'; |
28 | + } |
|
28 | 29 | |
29 | - if (!empty($context['search_ignored'])) |
|
30 | - echo ' |
|
30 | + if (!empty($context['search_ignored'])) { |
|
31 | + echo ' |
|
31 | 32 | <div class="noticebox"> |
32 | 33 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
33 | 34 | </div>'; |
35 | + } |
|
34 | 36 | |
35 | 37 | echo ' |
36 | 38 | <div class="cat_bar"> |
@@ -48,9 +50,10 @@ discard block |
||
48 | 50 | <dd> |
49 | 51 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
50 | 52 | |
51 | - if (empty($modSettings['search_simple_fulltext'])) |
|
52 | - echo ' |
|
53 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
54 | + echo ' |
|
53 | 55 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
56 | + } |
|
54 | 57 | |
55 | 58 | echo ' |
56 | 59 | </dd> |
@@ -114,21 +117,23 @@ discard block |
||
114 | 117 | <input type="hidden" name="advanced" value="1">'; |
115 | 118 | |
116 | 119 | // Require an image to be typed to save spamming? |
117 | - if ($context['require_verification']) |
|
118 | - echo ' |
|
120 | + if ($context['require_verification']) { |
|
121 | + echo ' |
|
119 | 122 | <p> |
120 | 123 | <strong>', $txt['verification'], ':</strong> |
121 | 124 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
122 | 125 | </p>'; |
126 | + } |
|
123 | 127 | |
124 | 128 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
125 | - if (!empty($context['search_params']['topic'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['search_params']['topic'])) { |
|
130 | + echo ' |
|
127 | 131 | <p> |
128 | 132 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
129 | 133 | </p> |
130 | 134 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
131 | 135 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
136 | + } |
|
132 | 137 | |
133 | 138 | echo ' |
134 | 139 | </div>'; |
@@ -158,14 +163,15 @@ discard block |
||
158 | 163 | |
159 | 164 | foreach ($category['boards'] as $board) |
160 | 165 | { |
161 | - if ($i == $limit) |
|
162 | - echo ' |
|
166 | + if ($i == $limit) { |
|
167 | + echo ' |
|
163 | 168 | </ul> |
164 | 169 | </li> |
165 | 170 | </ul> |
166 | 171 | <ul class="ignoreboards floatright"> |
167 | 172 | <li class="category"> |
168 | 173 | <ul>'; |
174 | + } |
|
169 | 175 | |
170 | 176 | echo ' |
171 | 177 | <li class="board"> |
@@ -253,17 +259,19 @@ discard block |
||
253 | 259 | <div class="roundframe noup">'; |
254 | 260 | |
255 | 261 | // Did they make any typos or mistakes, perhaps? |
256 | - if (isset($context['did_you_mean'])) |
|
257 | - echo ' |
|
262 | + if (isset($context['did_you_mean'])) { |
|
263 | + echo ' |
|
258 | 264 | <p> |
259 | 265 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
260 | 266 | </p>'; |
267 | + } |
|
261 | 268 | |
262 | - if (!empty($context['search_ignored'])) |
|
263 | - echo ' |
|
269 | + if (!empty($context['search_ignored'])) { |
|
270 | + echo ' |
|
264 | 271 | <p> |
265 | 272 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
266 | 273 | </p>'; |
274 | + } |
|
267 | 275 | |
268 | 276 | echo ' |
269 | 277 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -286,10 +294,11 @@ discard block |
||
286 | 294 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
287 | 295 | </div>'; |
288 | 296 | |
289 | - if (!empty($context['search_params']['brd'])) |
|
290 | - foreach ($context['search_params']['brd'] as $board_id) |
|
297 | + if (!empty($context['search_params']['brd'])) { |
|
298 | + foreach ($context['search_params']['brd'] as $board_id) |
|
291 | 299 | echo ' |
292 | 300 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
301 | + } |
|
293 | 302 | |
294 | 303 | echo ' |
295 | 304 | </form> |
@@ -300,18 +309,20 @@ discard block |
||
300 | 309 | if ($context['compact']) |
301 | 310 | { |
302 | 311 | // Quick moderation set to checkboxes? Oh, how fun :/ |
303 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
304 | - echo ' |
|
312 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
313 | + echo ' |
|
305 | 314 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
315 | + } |
|
306 | 316 | |
307 | 317 | echo ' |
308 | 318 | <div class="cat_bar"> |
309 | 319 | <h3 class="catbg"> |
310 | 320 | <span class="floatright">'; |
311 | 321 | |
312 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
313 | - echo ' |
|
322 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
323 | + echo ' |
|
314 | 324 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
325 | + } |
|
315 | 326 | echo ' |
316 | 327 | </span> |
317 | 328 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -319,15 +330,15 @@ discard block |
||
319 | 330 | </div>'; |
320 | 331 | |
321 | 332 | // Was anything even found? |
322 | - if (!empty($context['topics'])) |
|
323 | - echo ' |
|
333 | + if (!empty($context['topics'])) { |
|
334 | + echo ' |
|
324 | 335 | <div class="pagesection"> |
325 | 336 | <span>', $context['page_index'], '</span> |
326 | 337 | </div>'; |
327 | - |
|
328 | - else |
|
329 | - echo ' |
|
338 | + } else { |
|
339 | + echo ' |
|
330 | 340 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
341 | + } |
|
331 | 342 | |
332 | 343 | // While we have results to show ... |
333 | 344 | while ($topic = $context['get_topics']()) |
@@ -350,31 +361,35 @@ discard block |
||
350 | 361 | echo ' |
351 | 362 | <span class="floatright">'; |
352 | 363 | |
353 | - if ($options['display_quick_mod'] == 1) |
|
354 | - echo ' |
|
364 | + if ($options['display_quick_mod'] == 1) { |
|
365 | + echo ' |
|
355 | 366 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
356 | - |
|
357 | - else |
|
367 | + } else |
|
358 | 368 | { |
359 | - if ($topic['quick_mod']['remove']) |
|
360 | - echo ' |
|
369 | + if ($topic['quick_mod']['remove']) { |
|
370 | + echo ' |
|
361 | 371 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;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>'; |
372 | + } |
|
362 | 373 | |
363 | - if ($topic['quick_mod']['lock']) |
|
364 | - echo ' |
|
374 | + if ($topic['quick_mod']['lock']) { |
|
375 | + echo ' |
|
365 | 376 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;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>'; |
377 | + } |
|
366 | 378 | |
367 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
368 | - echo ' |
|
379 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
380 | + echo ' |
|
369 | 381 | <br>'; |
382 | + } |
|
370 | 383 | |
371 | - if ($topic['quick_mod']['sticky']) |
|
372 | - echo ' |
|
384 | + if ($topic['quick_mod']['sticky']) { |
|
385 | + echo ' |
|
373 | 386 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;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>'; |
387 | + } |
|
374 | 388 | |
375 | - if ($topic['quick_mod']['move']) |
|
376 | - echo ' |
|
389 | + if ($topic['quick_mod']['move']) { |
|
390 | + echo ' |
|
377 | 391 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
392 | + } |
|
378 | 393 | } |
379 | 394 | |
380 | 395 | echo ' |
@@ -384,20 +399,22 @@ discard block |
||
384 | 399 | echo ' |
385 | 400 | </div><!-- .block -->'; |
386 | 401 | |
387 | - if ($message['body_highlighted'] != '') |
|
388 | - echo ' |
|
402 | + if ($message['body_highlighted'] != '') { |
|
403 | + echo ' |
|
389 | 404 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
405 | + } |
|
390 | 406 | } |
391 | 407 | |
392 | 408 | echo ' |
393 | 409 | </div><!-- $topic[css_class] -->'; |
394 | 410 | } |
395 | 411 | |
396 | - if (!empty($context['topics'])) |
|
397 | - echo ' |
|
412 | + if (!empty($context['topics'])) { |
|
413 | + echo ' |
|
398 | 414 | <div class="pagesection"> |
399 | 415 | <span>', $context['page_index'], '</span> |
400 | 416 | </div>'; |
417 | + } |
|
401 | 418 | |
402 | 419 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
403 | 420 | { |
@@ -406,17 +423,19 @@ discard block |
||
406 | 423 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
407 | 424 | <option value="">--------</option>'; |
408 | 425 | |
409 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
410 | - if ($context['can_' . $qmod_action]) |
|
426 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
427 | + if ($context['can_' . $qmod_action]) |
|
411 | 428 | echo ' |
412 | 429 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
430 | + } |
|
413 | 431 | |
414 | 432 | echo ' |
415 | 433 | </select>'; |
416 | 434 | |
417 | - if ($context['can_move']) |
|
418 | - echo ' |
|
435 | + if ($context['can_move']) { |
|
436 | + echo ' |
|
419 | 437 | <span id="quick_mod_jump_to"></span>'; |
438 | + } |
|
420 | 439 | |
421 | 440 | echo ' |
422 | 441 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -425,12 +444,12 @@ discard block |
||
425 | 444 | } |
426 | 445 | |
427 | 446 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
429 | - echo ' |
|
447 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
448 | + echo ' |
|
430 | 449 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
431 | 450 | </form>'; |
432 | - } |
|
433 | - else |
|
451 | + } |
|
452 | + } else |
|
434 | 453 | { |
435 | 454 | echo ' |
436 | 455 | <div class="cat_bar"> |
@@ -442,9 +461,10 @@ discard block |
||
442 | 461 | <span>', $context['page_index'], '</span> |
443 | 462 | </div>'; |
444 | 463 | |
445 | - if (empty($context['topics'])) |
|
446 | - echo ' |
|
464 | + if (empty($context['topics'])) { |
|
465 | + echo ' |
|
447 | 466 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
467 | + } |
|
448 | 468 | |
449 | 469 | while ($topic = $context['get_topics']()) |
450 | 470 | { |
@@ -461,23 +481,27 @@ discard block |
||
461 | 481 | </div> |
462 | 482 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
463 | 483 | |
464 | - if ($topic['can_reply']) |
|
465 | - echo ' |
|
484 | + if ($topic['can_reply']) { |
|
485 | + echo ' |
|
466 | 486 | <ul class="quickbuttons">'; |
487 | + } |
|
467 | 488 | |
468 | 489 | // If they *can* reply? |
469 | - if ($topic['can_reply']) |
|
470 | - echo ' |
|
490 | + if ($topic['can_reply']) { |
|
491 | + echo ' |
|
471 | 492 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
493 | + } |
|
472 | 494 | |
473 | 495 | // If they *can* quote? |
474 | - if ($topic['can_quote']) |
|
475 | - echo ' |
|
496 | + if ($topic['can_quote']) { |
|
497 | + echo ' |
|
476 | 498 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
499 | + } |
|
477 | 500 | |
478 | - if ($topic['can_reply']) |
|
479 | - echo ' |
|
501 | + if ($topic['can_reply']) { |
|
502 | + echo ' |
|
480 | 503 | </ul>'; |
504 | + } |
|
481 | 505 | echo ' |
482 | 506 | <br class="clear"> |
483 | 507 | </div><!-- $topic[css_class] -->'; |
@@ -496,8 +520,8 @@ discard block |
||
496 | 520 | <div class="smalltext righttext" id="search_jump_to"></div> |
497 | 521 | <script>'; |
498 | 522 | |
499 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
500 | - echo ' |
|
523 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
524 | + echo ' |
|
501 | 525 | if (typeof(window.XMLHttpRequest) != "undefined") |
502 | 526 | aJumpTo[aJumpTo.length] = new JumpTo({ |
503 | 527 | sContainerId: "quick_mod_jump_to", |
@@ -512,6 +536,7 @@ discard block |
||
512 | 536 | bDisabled: true, |
513 | 537 | sCustomName: "move_to" |
514 | 538 | });'; |
539 | + } |
|
515 | 540 | |
516 | 541 | echo ' |
517 | 542 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -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 | * Update some basic statistics. |
@@ -122,10 +123,11 @@ discard block |
||
122 | 123 | $smcFunc['db_free_result']($result); |
123 | 124 | |
124 | 125 | // Add this to the number of unapproved members |
125 | - if (!empty($changes['unapprovedMembers'])) |
|
126 | - $changes['unapprovedMembers'] += $coppa_approvals; |
|
127 | - else |
|
128 | - $changes['unapprovedMembers'] = $coppa_approvals; |
|
126 | + if (!empty($changes['unapprovedMembers'])) { |
|
127 | + $changes['unapprovedMembers'] += $coppa_approvals; |
|
128 | + } else { |
|
129 | + $changes['unapprovedMembers'] = $coppa_approvals; |
|
130 | + } |
|
129 | 131 | } |
130 | 132 | } |
131 | 133 | } |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | break; |
134 | 136 | |
135 | 137 | case 'message': |
136 | - if ($parameter1 === true && $parameter2 !== null) |
|
137 | - updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
138 | - else |
|
138 | + if ($parameter1 === true && $parameter2 !== null) { |
|
139 | + updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true); |
|
140 | + } else |
|
139 | 141 | { |
140 | 142 | // SUM and MAX on a smaller table is better for InnoDB tables. |
141 | 143 | $result = $smcFunc['db_query']('', ' |
@@ -175,23 +177,25 @@ discard block |
||
175 | 177 | $parameter2 = text2words($parameter2); |
176 | 178 | |
177 | 179 | $inserts = array(); |
178 | - foreach ($parameter2 as $word) |
|
179 | - $inserts[] = array($word, $parameter1); |
|
180 | + foreach ($parameter2 as $word) { |
|
181 | + $inserts[] = array($word, $parameter1); |
|
182 | + } |
|
180 | 183 | |
181 | - if (!empty($inserts)) |
|
182 | - $smcFunc['db_insert']('ignore', |
|
184 | + if (!empty($inserts)) { |
|
185 | + $smcFunc['db_insert']('ignore', |
|
183 | 186 | '{db_prefix}log_search_subjects', |
184 | 187 | array('word' => 'string', 'id_topic' => 'int'), |
185 | 188 | $inserts, |
186 | 189 | array('word', 'id_topic') |
187 | 190 | ); |
191 | + } |
|
188 | 192 | } |
189 | 193 | break; |
190 | 194 | |
191 | 195 | case 'topic': |
192 | - if ($parameter1 === true) |
|
193 | - updateSettings(array('totalTopics' => true), true); |
|
194 | - else |
|
196 | + if ($parameter1 === true) { |
|
197 | + updateSettings(array('totalTopics' => true), true); |
|
198 | + } else |
|
195 | 199 | { |
196 | 200 | // Get the number of topics - a SUM is better for InnoDB tables. |
197 | 201 | // We also ignore the recycle bin here because there will probably be a bunch of one-post topics there. |
@@ -212,8 +216,9 @@ discard block |
||
212 | 216 | |
213 | 217 | case 'postgroups': |
214 | 218 | // Parameter two is the updated columns: we should check to see if we base groups off any of these. |
215 | - if ($parameter2 !== null && !in_array('posts', $parameter2)) |
|
216 | - return; |
|
219 | + if ($parameter2 !== null && !in_array('posts', $parameter2)) { |
|
220 | + return; |
|
221 | + } |
|
217 | 222 | |
218 | 223 | $postgroups = cache_get_data('updateStats:postgroups', 360); |
219 | 224 | if ($postgroups == null || $parameter1 == null) |
@@ -228,8 +233,9 @@ discard block |
||
228 | 233 | ) |
229 | 234 | ); |
230 | 235 | $postgroups = array(); |
231 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
232 | - $postgroups[$row['id_group']] = $row['min_posts']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $postgroups[$row['id_group']] = $row['min_posts']; |
|
238 | + } |
|
233 | 239 | $smcFunc['db_free_result']($request); |
234 | 240 | |
235 | 241 | // Sort them this way because if it's done with MySQL it causes a filesort :(. |
@@ -239,8 +245,9 @@ discard block |
||
239 | 245 | } |
240 | 246 | |
241 | 247 | // Oh great, they've screwed their post groups. |
242 | - if (empty($postgroups)) |
|
243 | - return; |
|
248 | + if (empty($postgroups)) { |
|
249 | + return; |
|
250 | + } |
|
244 | 251 | |
245 | 252 | // Set all membergroups from most posts to least posts. |
246 | 253 | $conditions = ''; |
@@ -298,10 +305,9 @@ discard block |
||
298 | 305 | { |
299 | 306 | $condition = 'id_member IN ({array_int:members})'; |
300 | 307 | $parameters['members'] = $members; |
301 | - } |
|
302 | - elseif ($members === null) |
|
303 | - $condition = '1=1'; |
|
304 | - else |
|
308 | + } elseif ($members === null) { |
|
309 | + $condition = '1=1'; |
|
310 | + } else |
|
305 | 311 | { |
306 | 312 | $condition = 'id_member = {int:member}'; |
307 | 313 | $parameters['member'] = $members; |
@@ -341,9 +347,9 @@ discard block |
||
341 | 347 | if (count($vars_to_integrate) != 0) |
342 | 348 | { |
343 | 349 | // Fetch a list of member_names if necessary |
344 | - if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) |
|
345 | - $member_names = array($user_info['username']); |
|
346 | - else |
|
350 | + if ((!is_array($members) && $members === $user_info['id']) || (is_array($members) && count($members) == 1 && in_array($user_info['id'], $members))) { |
|
351 | + $member_names = array($user_info['username']); |
|
352 | + } else |
|
347 | 353 | { |
348 | 354 | $member_names = array(); |
349 | 355 | $request = $smcFunc['db_query']('', ' |
@@ -352,14 +358,16 @@ discard block |
||
352 | 358 | WHERE ' . $condition, |
353 | 359 | $parameters |
354 | 360 | ); |
355 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
356 | - $member_names[] = $row['member_name']; |
|
361 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
362 | + $member_names[] = $row['member_name']; |
|
363 | + } |
|
357 | 364 | $smcFunc['db_free_result']($request); |
358 | 365 | } |
359 | 366 | |
360 | - if (!empty($member_names)) |
|
361 | - foreach ($vars_to_integrate as $var) |
|
367 | + if (!empty($member_names)) { |
|
368 | + foreach ($vars_to_integrate as $var) |
|
362 | 369 | call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &$knownInts, &$knownFloats)); |
370 | + } |
|
363 | 371 | } |
364 | 372 | } |
365 | 373 | |
@@ -367,16 +375,17 @@ discard block |
||
367 | 375 | foreach ($data as $var => $val) |
368 | 376 | { |
369 | 377 | $type = 'string'; |
370 | - if (in_array($var, $knownInts)) |
|
371 | - $type = 'int'; |
|
372 | - elseif (in_array($var, $knownFloats)) |
|
373 | - $type = 'float'; |
|
374 | - elseif ($var == 'birthdate') |
|
375 | - $type = 'date'; |
|
376 | - elseif ($var == 'member_ip') |
|
377 | - $type = 'inet'; |
|
378 | - elseif ($var == 'member_ip2') |
|
379 | - $type = 'inet'; |
|
378 | + if (in_array($var, $knownInts)) { |
|
379 | + $type = 'int'; |
|
380 | + } elseif (in_array($var, $knownFloats)) { |
|
381 | + $type = 'float'; |
|
382 | + } elseif ($var == 'birthdate') { |
|
383 | + $type = 'date'; |
|
384 | + } elseif ($var == 'member_ip') { |
|
385 | + $type = 'inet'; |
|
386 | + } elseif ($var == 'member_ip2') { |
|
387 | + $type = 'inet'; |
|
388 | + } |
|
380 | 389 | |
381 | 390 | // Doing an increment? |
382 | 391 | if ($var == 'alerts' && ($val === '+' || $val === '-')) |
@@ -385,18 +394,17 @@ discard block |
||
385 | 394 | if (is_array($members)) |
386 | 395 | { |
387 | 396 | $val = 'CASE '; |
388 | - foreach ($members as $k => $v) |
|
389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
397 | + foreach ($members as $k => $v) { |
|
398 | + $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
399 | + } |
|
390 | 400 | $val = $val . ' END'; |
391 | 401 | $type = 'raw'; |
392 | - } |
|
393 | - else |
|
402 | + } else |
|
394 | 403 | { |
395 | 404 | $blub = fetch_alerts($members, false, 0, array(), false); |
396 | 405 | $val = count($blub); |
397 | 406 | } |
398 | - } |
|
399 | - else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
407 | + } else if ($type == 'int' && ($val === '+' || $val === '-')) |
|
400 | 408 | { |
401 | 409 | $val = $var . ' ' . $val . ' 1'; |
402 | 410 | $type = 'raw'; |
@@ -407,8 +415,9 @@ discard block |
||
407 | 415 | { |
408 | 416 | if (preg_match('~^' . $var . ' (\+ |- |\+ -)([\d]+)~', $val, $match)) |
409 | 417 | { |
410 | - if ($match[1] != '+ ') |
|
411 | - $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
418 | + if ($match[1] != '+ ') { |
|
419 | + $val = 'CASE WHEN ' . $var . ' <= ' . abs($match[2]) . ' THEN 0 ELSE ' . $val . ' END'; |
|
420 | + } |
|
412 | 421 | $type = 'raw'; |
413 | 422 | } |
414 | 423 | } |
@@ -429,8 +438,9 @@ discard block |
||
429 | 438 | // Clear any caching? |
430 | 439 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && !empty($members)) |
431 | 440 | { |
432 | - if (!is_array($members)) |
|
433 | - $members = array($members); |
|
441 | + if (!is_array($members)) { |
|
442 | + $members = array($members); |
|
443 | + } |
|
434 | 444 | |
435 | 445 | foreach ($members as $member) |
436 | 446 | { |
@@ -463,29 +473,32 @@ discard block |
||
463 | 473 | { |
464 | 474 | global $modSettings, $smcFunc; |
465 | 475 | |
466 | - if (empty($changeArray) || !is_array($changeArray)) |
|
467 | - return; |
|
476 | + if (empty($changeArray) || !is_array($changeArray)) { |
|
477 | + return; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | $toRemove = array(); |
470 | 481 | |
471 | 482 | // Go check if there is any setting to be removed. |
472 | - foreach ($changeArray as $k => $v) |
|
473 | - if ($v === null) |
|
483 | + foreach ($changeArray as $k => $v) { |
|
484 | + if ($v === null) |
|
474 | 485 | { |
475 | 486 | // Found some, remove them from the original array and add them to ours. |
476 | 487 | unset($changeArray[$k]); |
488 | + } |
|
477 | 489 | $toRemove[] = $k; |
478 | 490 | } |
479 | 491 | |
480 | 492 | // Proceed with the deletion. |
481 | - if (!empty($toRemove)) |
|
482 | - $smcFunc['db_query']('', ' |
|
493 | + if (!empty($toRemove)) { |
|
494 | + $smcFunc['db_query']('', ' |
|
483 | 495 | DELETE FROM {db_prefix}settings |
484 | 496 | WHERE variable IN ({array_string:remove})', |
485 | 497 | array( |
486 | 498 | 'remove' => $toRemove, |
487 | 499 | ) |
488 | 500 | ); |
501 | + } |
|
489 | 502 | |
490 | 503 | // In some cases, this may be better and faster, but for large sets we don't want so many UPDATEs. |
491 | 504 | if ($update) |
@@ -514,19 +527,22 @@ discard block |
||
514 | 527 | foreach ($changeArray as $variable => $value) |
515 | 528 | { |
516 | 529 | // Don't bother if it's already like that ;). |
517 | - if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) |
|
518 | - continue; |
|
530 | + if (isset($modSettings[$variable]) && $modSettings[$variable] == $value) { |
|
531 | + continue; |
|
532 | + } |
|
519 | 533 | // If the variable isn't set, but would only be set to nothing'ness, then don't bother setting it. |
520 | - elseif (!isset($modSettings[$variable]) && empty($value)) |
|
521 | - continue; |
|
534 | + elseif (!isset($modSettings[$variable]) && empty($value)) { |
|
535 | + continue; |
|
536 | + } |
|
522 | 537 | |
523 | 538 | $replaceArray[] = array($variable, $value); |
524 | 539 | |
525 | 540 | $modSettings[$variable] = $value; |
526 | 541 | } |
527 | 542 | |
528 | - if (empty($replaceArray)) |
|
529 | - return; |
|
543 | + if (empty($replaceArray)) { |
|
544 | + return; |
|
545 | + } |
|
530 | 546 | |
531 | 547 | $smcFunc['db_insert']('replace', |
532 | 548 | '{db_prefix}settings', |
@@ -572,14 +588,17 @@ discard block |
||
572 | 588 | $start_invalid = $start < 0; |
573 | 589 | |
574 | 590 | // Make sure $start is a proper variable - not less than 0. |
575 | - if ($start_invalid) |
|
576 | - $start = 0; |
|
591 | + if ($start_invalid) { |
|
592 | + $start = 0; |
|
593 | + } |
|
577 | 594 | // Not greater than the upper bound. |
578 | - elseif ($start >= $max_value) |
|
579 | - $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
595 | + elseif ($start >= $max_value) { |
|
596 | + $start = max(0, (int) $max_value - (((int) $max_value % (int) $num_per_page) == 0 ? $num_per_page : ((int) $max_value % (int) $num_per_page))); |
|
597 | + } |
|
580 | 598 | // And it has to be a multiple of $num_per_page! |
581 | - else |
|
582 | - $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
599 | + else { |
|
600 | + $start = max(0, (int) $start - ((int) $start % (int) $num_per_page)); |
|
601 | + } |
|
583 | 602 | |
584 | 603 | $context['current_page'] = $start / $num_per_page; |
585 | 604 | |
@@ -609,77 +628,87 @@ discard block |
||
609 | 628 | |
610 | 629 | // Show all the pages. |
611 | 630 | $display_page = 1; |
612 | - for ($counter = 0; $counter < $max_value; $counter += $num_per_page) |
|
613 | - $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
631 | + for ($counter = 0; $counter < $max_value; $counter += $num_per_page) { |
|
632 | + $pageindex .= $start == $counter && !$start_invalid ? sprintf($settings['page_index']['current_page'], $display_page++) : sprintf($base_link, $counter, $display_page++); |
|
633 | + } |
|
614 | 634 | |
615 | 635 | // Show the right arrow. |
616 | 636 | $display_page = ($start + $num_per_page) > $max_value ? $max_value : ($start + $num_per_page); |
617 | - if ($start != $counter - $max_value && !$start_invalid) |
|
618 | - $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
619 | - } |
|
620 | - else |
|
637 | + if ($start != $counter - $max_value && !$start_invalid) { |
|
638 | + $pageindex .= $display_page > $counter - $num_per_page ? ' ' : sprintf($base_link, $display_page, $settings['page_index']['next_page']); |
|
639 | + } |
|
640 | + } else |
|
621 | 641 | { |
622 | 642 | // If they didn't enter an odd value, pretend they did. |
623 | 643 | $PageContiguous = (int) ($modSettings['compactTopicPagesContiguous'] - ($modSettings['compactTopicPagesContiguous'] % 2)) / 2; |
624 | 644 | |
625 | 645 | // Show the "prev page" link. (>prev page< 1 ... 6 7 [8] 9 10 ... 15 next page) |
626 | - if (!empty($start) && $show_prevnext) |
|
627 | - $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
628 | - else |
|
629 | - $pageindex .= ''; |
|
646 | + if (!empty($start) && $show_prevnext) { |
|
647 | + $pageindex .= sprintf($base_link, $start - $num_per_page, $settings['page_index']['previous_page']); |
|
648 | + } else { |
|
649 | + $pageindex .= ''; |
|
650 | + } |
|
630 | 651 | |
631 | 652 | // Show the first page. (prev page >1< ... 6 7 [8] 9 10 ... 15) |
632 | - if ($start > $num_per_page * $PageContiguous) |
|
633 | - $pageindex .= sprintf($base_link, 0, '1'); |
|
653 | + if ($start > $num_per_page * $PageContiguous) { |
|
654 | + $pageindex .= sprintf($base_link, 0, '1'); |
|
655 | + } |
|
634 | 656 | |
635 | 657 | // Show the ... after the first page. (prev page 1 >...< 6 7 [8] 9 10 ... 15 next page) |
636 | - if ($start > $num_per_page * ($PageContiguous + 1)) |
|
637 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
658 | + if ($start > $num_per_page * ($PageContiguous + 1)) { |
|
659 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
638 | 660 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
639 | 661 | '{FIRST_PAGE}' => $num_per_page, |
640 | 662 | '{LAST_PAGE}' => $start - $num_per_page * $PageContiguous, |
641 | 663 | '{PER_PAGE}' => $num_per_page, |
642 | 664 | )); |
665 | + } |
|
643 | 666 | |
644 | 667 | // Show the pages before the current one. (prev page 1 ... >6 7< [8] 9 10 ... 15 next page) |
645 | - for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) |
|
646 | - if ($start >= $num_per_page * $nCont) |
|
668 | + for ($nCont = $PageContiguous; $nCont >= 1; $nCont--) { |
|
669 | + if ($start >= $num_per_page * $nCont) |
|
647 | 670 | { |
648 | 671 | $tmpStart = $start - $num_per_page * $nCont; |
672 | + } |
|
649 | 673 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
650 | 674 | } |
651 | 675 | |
652 | 676 | // Show the current page. (prev page 1 ... 6 7 >[8]< 9 10 ... 15 next page) |
653 | - if (!$start_invalid) |
|
654 | - $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
655 | - else |
|
656 | - $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
677 | + if (!$start_invalid) { |
|
678 | + $pageindex .= sprintf($settings['page_index']['current_page'], $start / $num_per_page + 1); |
|
679 | + } else { |
|
680 | + $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1); |
|
681 | + } |
|
657 | 682 | |
658 | 683 | // Show the pages after the current one... (prev page 1 ... 6 7 [8] >9 10< ... 15 next page) |
659 | 684 | $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page; |
660 | - for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) |
|
661 | - if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
685 | + for ($nCont = 1; $nCont <= $PageContiguous; $nCont++) { |
|
686 | + if ($start + $num_per_page * $nCont <= $tmpMaxPages) |
|
662 | 687 | { |
663 | 688 | $tmpStart = $start + $num_per_page * $nCont; |
689 | + } |
|
664 | 690 | $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1); |
665 | 691 | } |
666 | 692 | |
667 | 693 | // Show the '...' part near the end. (prev page 1 ... 6 7 [8] 9 10 >...< 15 next page) |
668 | - if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) |
|
669 | - $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
694 | + if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages) { |
|
695 | + $pageindex .= strtr($settings['page_index']['expand_pages'], array( |
|
670 | 696 | '{LINK}' => JavaScriptEscape($smcFunc['htmlspecialchars']($base_link)), |
671 | 697 | '{FIRST_PAGE}' => $start + $num_per_page * ($PageContiguous + 1), |
672 | 698 | '{LAST_PAGE}' => $tmpMaxPages, |
673 | 699 | '{PER_PAGE}' => $num_per_page, |
674 | 700 | )); |
701 | + } |
|
675 | 702 | |
676 | 703 | // Show the last number in the list. (prev page 1 ... 6 7 [8] 9 10 ... >15< next page) |
677 | - if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) |
|
678 | - $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
704 | + if ($start + $num_per_page * $PageContiguous < $tmpMaxPages) { |
|
705 | + $pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1); |
|
706 | + } |
|
679 | 707 | |
680 | 708 | // Show the "next page" link. (prev page 1 ... 6 7 [8] 9 10 ... 15 >next page<) |
681 | - if ($start != $tmpMaxPages && $show_prevnext) |
|
682 | - $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
709 | + if ($start != $tmpMaxPages && $show_prevnext) { |
|
710 | + $pageindex .= sprintf($base_link, $start + $num_per_page, $settings['page_index']['next_page']); |
|
711 | + } |
|
683 | 712 | } |
684 | 713 | $pageindex .= $settings['page_index']['extra_after']; |
685 | 714 | |
@@ -705,8 +734,9 @@ discard block |
||
705 | 734 | if ($decimal_separator === null) |
706 | 735 | { |
707 | 736 | // Not set for whatever reason? |
708 | - if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) |
|
709 | - return $number; |
|
737 | + if (empty($txt['number_format']) || preg_match('~^1([^\d]*)?234([^\d]*)(0*?)$~', $txt['number_format'], $matches) != 1) { |
|
738 | + return $number; |
|
739 | + } |
|
710 | 740 | |
711 | 741 | // Cache these each load... |
712 | 742 | $thousands_separator = $matches[1]; |
@@ -740,17 +770,20 @@ discard block |
||
740 | 770 | static $unsupportedFormats, $finalizedFormats; |
741 | 771 | |
742 | 772 | // Offset the time. |
743 | - if (!$offset_type) |
|
744 | - $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
773 | + if (!$offset_type) { |
|
774 | + $time = $log_time + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
775 | + } |
|
745 | 776 | // Just the forum offset? |
746 | - elseif ($offset_type == 'forum') |
|
747 | - $time = $log_time + $modSettings['time_offset'] * 3600; |
|
748 | - else |
|
749 | - $time = $log_time; |
|
777 | + elseif ($offset_type == 'forum') { |
|
778 | + $time = $log_time + $modSettings['time_offset'] * 3600; |
|
779 | + } else { |
|
780 | + $time = $log_time; |
|
781 | + } |
|
750 | 782 | |
751 | 783 | // We can't have a negative date (on Windows, at least.) |
752 | - if ($log_time < 0) |
|
753 | - $log_time = 0; |
|
784 | + if ($log_time < 0) { |
|
785 | + $log_time = 0; |
|
786 | + } |
|
754 | 787 | |
755 | 788 | // Today and Yesterday? |
756 | 789 | if ($modSettings['todayMod'] >= 1 && $show_today === true) |
@@ -767,24 +800,27 @@ discard block |
||
767 | 800 | { |
768 | 801 | $h = strpos($user_info['time_format'], '%l') === false ? '%I' : '%l'; |
769 | 802 | $today_fmt = $h . ':%M' . $s . ' %p'; |
803 | + } else { |
|
804 | + $today_fmt = '%H:%M' . $s; |
|
770 | 805 | } |
771 | - else |
|
772 | - $today_fmt = '%H:%M' . $s; |
|
773 | 806 | |
774 | 807 | // Same day of the year, same year.... Today! |
775 | - if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) |
|
776 | - return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
808 | + if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) { |
|
809 | + return $txt['today'] . timeformat($log_time, $today_fmt, $offset_type); |
|
810 | + } |
|
777 | 811 | |
778 | 812 | // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year... |
779 | - if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) |
|
780 | - return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
813 | + if ($modSettings['todayMod'] == '2' && (($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year']) || ($now['yday'] == 0 && $then['year'] == $now['year'] - 1) && $then['mon'] == 12 && $then['mday'] == 31)) { |
|
814 | + return $txt['yesterday'] . timeformat($log_time, $today_fmt, $offset_type); |
|
815 | + } |
|
781 | 816 | } |
782 | 817 | |
783 | 818 | $str = !is_bool($show_today) ? $show_today : $user_info['time_format']; |
784 | 819 | |
785 | 820 | // Use the cached formats if available |
786 | - if (is_null($finalizedFormats)) |
|
787 | - $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
821 | + if (is_null($finalizedFormats)) { |
|
822 | + $finalizedFormats = (array) cache_get_data('timeformatstrings', 86400); |
|
823 | + } |
|
788 | 824 | |
789 | 825 | // Make a supported version for this format if we don't already have one |
790 | 826 | if (empty($finalizedFormats[$str])) |
@@ -813,8 +849,9 @@ discard block |
||
813 | 849 | ); |
814 | 850 | |
815 | 851 | // No need to do this part again if we already did it once |
816 | - if (is_null($unsupportedFormats)) |
|
817 | - $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
852 | + if (is_null($unsupportedFormats)) { |
|
853 | + $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
|
854 | + } |
|
818 | 855 | if (empty($unsupportedFormats)) |
819 | 856 | { |
820 | 857 | foreach($strftimeFormatSubstitutions as $format => $substitution) |
@@ -823,20 +860,23 @@ discard block |
||
823 | 860 | |
824 | 861 | // Windows will return false for unsupported formats |
825 | 862 | // Other operating systems return the format string as a literal |
826 | - if ($value === false || $value === $format) |
|
827 | - $unsupportedFormats[] = $format; |
|
863 | + if ($value === false || $value === $format) { |
|
864 | + $unsupportedFormats[] = $format; |
|
865 | + } |
|
828 | 866 | } |
829 | 867 | cache_put_data('unsupportedtimeformats', $unsupportedFormats, 86400); |
830 | 868 | } |
831 | 869 | |
832 | 870 | // Windows needs extra help if $timeformat contains something completely invalid, e.g. '%Q' |
833 | - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') |
|
834 | - $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
871 | + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { |
|
872 | + $timeformat = preg_replace('~%(?!' . implode('|', array_keys($strftimeFormatSubstitutions)) . ')~', '%', $timeformat); |
|
873 | + } |
|
835 | 874 | |
836 | 875 | // Substitute unsupported formats with supported ones |
837 | - if (!empty($unsupportedFormats)) |
|
838 | - while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
876 | + if (!empty($unsupportedFormats)) { |
|
877 | + while (preg_match('~%(' . implode('|', $unsupportedFormats) . ')~', $timeformat, $matches)) |
|
839 | 878 | $timeformat = str_replace($matches[0], $strftimeFormatSubstitutions[$matches[1]], $timeformat); |
879 | + } |
|
840 | 880 | |
841 | 881 | // Remember this so we don't need to do it again |
842 | 882 | $finalizedFormats[$str] = $timeformat; |
@@ -845,33 +885,39 @@ discard block |
||
845 | 885 | |
846 | 886 | $str = $finalizedFormats[$str]; |
847 | 887 | |
848 | - if (!isset($locale_cache)) |
|
849 | - $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
888 | + if (!isset($locale_cache)) { |
|
889 | + $locale_cache = setlocale(LC_TIME, $txt['lang_locale']); |
|
890 | + } |
|
850 | 891 | |
851 | 892 | if ($locale_cache !== false) |
852 | 893 | { |
853 | 894 | // Check if another process changed the locale |
854 | - if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) |
|
855 | - setlocale(LC_TIME, $txt['lang_locale']); |
|
895 | + if ($process_safe === true && setlocale(LC_TIME, '0') != $locale_cache) { |
|
896 | + setlocale(LC_TIME, $txt['lang_locale']); |
|
897 | + } |
|
856 | 898 | |
857 | - if (!isset($non_twelve_hour)) |
|
858 | - $non_twelve_hour = trim(strftime('%p')) === ''; |
|
859 | - if ($non_twelve_hour && strpos($str, '%p') !== false) |
|
860 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
899 | + if (!isset($non_twelve_hour)) { |
|
900 | + $non_twelve_hour = trim(strftime('%p')) === ''; |
|
901 | + } |
|
902 | + if ($non_twelve_hour && strpos($str, '%p') !== false) { |
|
903 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
904 | + } |
|
861 | 905 | |
862 | - foreach (array('%a', '%A', '%b', '%B') as $token) |
|
863 | - if (strpos($str, $token) !== false) |
|
906 | + foreach (array('%a', '%A', '%b', '%B') as $token) { |
|
907 | + if (strpos($str, $token) !== false) |
|
864 | 908 | $str = str_replace($token, strftime($token, $time), $str); |
865 | - } |
|
866 | - else |
|
909 | + } |
|
910 | + } else |
|
867 | 911 | { |
868 | 912 | // Do-it-yourself time localization. Fun. |
869 | - foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) |
|
870 | - if (strpos($str, $token) !== false) |
|
913 | + foreach (array('%a' => 'days_short', '%A' => 'days', '%b' => 'months_short', '%B' => 'months') as $token => $text_label) { |
|
914 | + if (strpos($str, $token) !== false) |
|
871 | 915 | $str = str_replace($token, $txt[$text_label][(int) strftime($token === '%a' || $token === '%A' ? '%w' : '%m', $time)], $str); |
916 | + } |
|
872 | 917 | |
873 | - if (strpos($str, '%p') !== false) |
|
874 | - $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
918 | + if (strpos($str, '%p') !== false) { |
|
919 | + $str = str_replace('%p', (strftime('%H', $time) < 12 ? $txt['time_am'] : $txt['time_pm']), $str); |
|
920 | + } |
|
875 | 921 | } |
876 | 922 | |
877 | 923 | // Format the time and then restore any literal percent characters |
@@ -894,16 +940,19 @@ discard block |
||
894 | 940 | static $translation = array(); |
895 | 941 | |
896 | 942 | // Determine the character set... Default to UTF-8 |
897 | - if (empty($context['character_set'])) |
|
898 | - $charset = 'UTF-8'; |
|
943 | + if (empty($context['character_set'])) { |
|
944 | + $charset = 'UTF-8'; |
|
945 | + } |
|
899 | 946 | // Use ISO-8859-1 in place of non-supported ISO-8859 charsets... |
900 | - elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) |
|
901 | - $charset = 'ISO-8859-1'; |
|
902 | - else |
|
903 | - $charset = $context['character_set']; |
|
947 | + elseif (strpos($context['character_set'], 'ISO-8859-') !== false && !in_array($context['character_set'], array('ISO-8859-5', 'ISO-8859-15'))) { |
|
948 | + $charset = 'ISO-8859-1'; |
|
949 | + } else { |
|
950 | + $charset = $context['character_set']; |
|
951 | + } |
|
904 | 952 | |
905 | - if (empty($translation)) |
|
906 | - $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
953 | + if (empty($translation)) { |
|
954 | + $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES, $charset)) + array(''' => '\'', ''' => '\'', ' ' => ' '); |
|
955 | + } |
|
907 | 956 | |
908 | 957 | return strtr($string, $translation); |
909 | 958 | } |
@@ -925,8 +974,9 @@ discard block |
||
925 | 974 | global $smcFunc; |
926 | 975 | |
927 | 976 | // It was already short enough! |
928 | - if ($smcFunc['strlen']($subject) <= $len) |
|
929 | - return $subject; |
|
977 | + if ($smcFunc['strlen']($subject) <= $len) { |
|
978 | + return $subject; |
|
979 | + } |
|
930 | 980 | |
931 | 981 | // Shorten it by the length it was too long, and strip off junk from the end. |
932 | 982 | return $smcFunc['substr']($subject, 0, $len) . '...'; |
@@ -945,10 +995,11 @@ discard block |
||
945 | 995 | { |
946 | 996 | global $user_info, $modSettings; |
947 | 997 | |
948 | - if ($timestamp === null) |
|
949 | - $timestamp = time(); |
|
950 | - elseif ($timestamp == 0) |
|
951 | - return 0; |
|
998 | + if ($timestamp === null) { |
|
999 | + $timestamp = time(); |
|
1000 | + } elseif ($timestamp == 0) { |
|
1001 | + return 0; |
|
1002 | + } |
|
952 | 1003 | |
953 | 1004 | return $timestamp + ($modSettings['time_offset'] + ($use_user_offset ? $user_info['time_offset'] : 0)) * 3600; |
954 | 1005 | } |
@@ -977,8 +1028,9 @@ discard block |
||
977 | 1028 | $array[$i] = $array[$j]; |
978 | 1029 | $array[$j] = $temp; |
979 | 1030 | |
980 | - for ($i = 1; $p[$i] == 0; $i++) |
|
981 | - $p[$i] = 1; |
|
1031 | + for ($i = 1; $p[$i] == 0; $i++) { |
|
1032 | + $p[$i] = 1; |
|
1033 | + } |
|
982 | 1034 | |
983 | 1035 | $orders[] = $array; |
984 | 1036 | } |
@@ -1010,12 +1062,14 @@ discard block |
||
1010 | 1062 | static $disabled; |
1011 | 1063 | |
1012 | 1064 | // Don't waste cycles |
1013 | - if ($message === '') |
|
1014 | - return ''; |
|
1065 | + if ($message === '') { |
|
1066 | + return ''; |
|
1067 | + } |
|
1015 | 1068 | |
1016 | 1069 | // Just in case it wasn't determined yet whether UTF-8 is enabled. |
1017 | - if (!isset($context['utf8'])) |
|
1018 | - $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1070 | + if (!isset($context['utf8'])) { |
|
1071 | + $context['utf8'] = (empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']) === 'UTF-8'; |
|
1072 | + } |
|
1019 | 1073 | |
1020 | 1074 | // Clean up any cut/paste issues we may have |
1021 | 1075 | $message = sanitizeMSCutPaste($message); |
@@ -1027,13 +1081,15 @@ discard block |
||
1027 | 1081 | return $message; |
1028 | 1082 | } |
1029 | 1083 | |
1030 | - if ($smileys !== null && ($smileys == '1' || $smileys == '0')) |
|
1031 | - $smileys = (bool) $smileys; |
|
1084 | + if ($smileys !== null && ($smileys == '1' || $smileys == '0')) { |
|
1085 | + $smileys = (bool) $smileys; |
|
1086 | + } |
|
1032 | 1087 | |
1033 | 1088 | if (empty($modSettings['enableBBC']) && $message !== false) |
1034 | 1089 | { |
1035 | - if ($smileys === true) |
|
1036 | - parsesmileys($message); |
|
1090 | + if ($smileys === true) { |
|
1091 | + parsesmileys($message); |
|
1092 | + } |
|
1037 | 1093 | |
1038 | 1094 | return $message; |
1039 | 1095 | } |
@@ -1046,8 +1102,9 @@ discard block |
||
1046 | 1102 | } |
1047 | 1103 | |
1048 | 1104 | // Ensure $modSettings['tld_regex'] contains a valid regex for the autolinker |
1049 | - if (!empty($modSettings['autoLinkUrls'])) |
|
1050 | - set_tld_regex(); |
|
1105 | + if (!empty($modSettings['autoLinkUrls'])) { |
|
1106 | + set_tld_regex(); |
|
1107 | + } |
|
1051 | 1108 | |
1052 | 1109 | // Allow mods access before entering the main parse_bbc loop |
1053 | 1110 | call_integration_hook('integrate_pre_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
@@ -1061,12 +1118,14 @@ discard block |
||
1061 | 1118 | |
1062 | 1119 | $temp = explode(',', strtolower($modSettings['disabledBBC'])); |
1063 | 1120 | |
1064 | - foreach ($temp as $tag) |
|
1065 | - $disabled[trim($tag)] = true; |
|
1121 | + foreach ($temp as $tag) { |
|
1122 | + $disabled[trim($tag)] = true; |
|
1123 | + } |
|
1066 | 1124 | } |
1067 | 1125 | |
1068 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1069 | - $disabled['flash'] = true; |
|
1126 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1127 | + $disabled['flash'] = true; |
|
1128 | + } |
|
1070 | 1129 | |
1071 | 1130 | /* The following bbc are formatted as an array, with keys as follows: |
1072 | 1131 | |
@@ -1187,8 +1246,9 @@ discard block |
||
1187 | 1246 | $returnContext = ''; |
1188 | 1247 | |
1189 | 1248 | // BBC or the entire attachments feature is disabled |
1190 | - if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) |
|
1191 | - return $data; |
|
1249 | + if (empty($modSettings['attachmentEnable']) || !empty($disabled['attach'])) { |
|
1250 | + return $data; |
|
1251 | + } |
|
1192 | 1252 | |
1193 | 1253 | // Save the attach ID. |
1194 | 1254 | $attachID = $data; |
@@ -1199,8 +1259,9 @@ discard block |
||
1199 | 1259 | $currentAttachment = parseAttachBBC($attachID); |
1200 | 1260 | |
1201 | 1261 | // parseAttachBBC will return a string ($txt key) rather than diying with a fatal_error. Up to you to decide what to do. |
1202 | - if (is_string($currentAttachment)) |
|
1203 | - return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1262 | + if (is_string($currentAttachment)) { |
|
1263 | + return $data = !empty($txt[$currentAttachment]) ? $txt[$currentAttachment] : $currentAttachment; |
|
1264 | + } |
|
1204 | 1265 | |
1205 | 1266 | if (!empty($currentAttachment['is_image'])) |
1206 | 1267 | { |
@@ -1216,15 +1277,17 @@ discard block |
||
1216 | 1277 | $height = ' height="' . $currentAttachment['height'] . '"'; |
1217 | 1278 | } |
1218 | 1279 | |
1219 | - if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) |
|
1220 | - $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1221 | - else |
|
1222 | - $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1280 | + if ($currentAttachment['thumbnail']['has_thumb'] && empty($params['{width}']) && empty($params['{height}'])) { |
|
1281 | + $returnContext .= '<a href="'. $currentAttachment['href']. ';image" id="link_'. $currentAttachment['id']. '" onclick="'. $currentAttachment['thumbnail']['javascript']. '"><img src="'. $currentAttachment['thumbnail']['href']. '"' . $alt . $title . ' id="thumb_'. $currentAttachment['id']. '" class="atc_img"></a>'; |
|
1282 | + } else { |
|
1283 | + $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
|
1284 | + } |
|
1223 | 1285 | } |
1224 | 1286 | |
1225 | 1287 | // No image. Show a link. |
1226 | - else |
|
1227 | - $returnContext .= $currentAttachment['link']; |
|
1288 | + else { |
|
1289 | + $returnContext .= $currentAttachment['link']; |
|
1290 | + } |
|
1228 | 1291 | |
1229 | 1292 | // Gotta append what we just did. |
1230 | 1293 | $data = $returnContext; |
@@ -1255,8 +1318,9 @@ discard block |
||
1255 | 1318 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1256 | 1319 | { |
1257 | 1320 | // Do PHP code coloring? |
1258 | - if ($php_parts[$php_i] != '<?php') |
|
1259 | - continue; |
|
1321 | + if ($php_parts[$php_i] != '<?php') { |
|
1322 | + continue; |
|
1323 | + } |
|
1260 | 1324 | |
1261 | 1325 | $php_string = ''; |
1262 | 1326 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1272,8 +1336,9 @@ discard block |
||
1272 | 1336 | $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data); |
1273 | 1337 | |
1274 | 1338 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1275 | - if ($context['browser']['is_opera']) |
|
1276 | - $data .= ' '; |
|
1339 | + if ($context['browser']['is_opera']) { |
|
1340 | + $data .= ' '; |
|
1341 | + } |
|
1277 | 1342 | } |
1278 | 1343 | }, |
1279 | 1344 | 'block_level' => true, |
@@ -1292,8 +1357,9 @@ discard block |
||
1292 | 1357 | for ($php_i = 0, $php_n = count($php_parts); $php_i < $php_n; $php_i++) |
1293 | 1358 | { |
1294 | 1359 | // Do PHP code coloring? |
1295 | - if ($php_parts[$php_i] != '<?php') |
|
1296 | - continue; |
|
1360 | + if ($php_parts[$php_i] != '<?php') { |
|
1361 | + continue; |
|
1362 | + } |
|
1297 | 1363 | |
1298 | 1364 | $php_string = ''; |
1299 | 1365 | while ($php_i + 1 < count($php_parts) && $php_parts[$php_i] != '?>') |
@@ -1309,8 +1375,9 @@ discard block |
||
1309 | 1375 | $data[0] = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data[0]); |
1310 | 1376 | |
1311 | 1377 | // Recent Opera bug requiring temporary fix. &nsbp; is needed before </code> to avoid broken selection. |
1312 | - if ($context['browser']['is_opera']) |
|
1313 | - $data[0] .= ' '; |
|
1378 | + if ($context['browser']['is_opera']) { |
|
1379 | + $data[0] .= ' '; |
|
1380 | + } |
|
1314 | 1381 | } |
1315 | 1382 | }, |
1316 | 1383 | 'block_level' => true, |
@@ -1348,11 +1415,13 @@ discard block |
||
1348 | 1415 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | 1416 | 'validate' => function (&$tag, &$data, $disabled) |
1350 | 1417 | { |
1351 | - if (isset($disabled['url'])) |
|
1352 | - $tag['content'] = '$1'; |
|
1418 | + if (isset($disabled['url'])) { |
|
1419 | + $tag['content'] = '$1'; |
|
1420 | + } |
|
1353 | 1421 | $scheme = parse_url($data[0], PHP_URL_SCHEME); |
1354 | - if (empty($scheme)) |
|
1355 | - $data[0] = '//' . ltrim($data[0], ':/'); |
|
1422 | + if (empty($scheme)) { |
|
1423 | + $data[0] = '//' . ltrim($data[0], ':/'); |
|
1424 | + } |
|
1356 | 1425 | }, |
1357 | 1426 | 'disabled_content' => '<a href="$1" target="_blank" rel="noopener">$1</a>', |
1358 | 1427 | ), |
@@ -1366,10 +1435,11 @@ discard block |
||
1366 | 1435 | { |
1367 | 1436 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1437 | |
1369 | - if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) |
|
1370 | - $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1371 | - else |
|
1372 | - $css = ''; |
|
1438 | + if (preg_match('~\bmax=(\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)~', $data, $matches)) { |
|
1439 | + $css = ' style="max-width:' . $matches[1] . (is_numeric($matches[1]) ? 'px' : '') . '"'; |
|
1440 | + } else { |
|
1441 | + $css = ''; |
|
1442 | + } |
|
1373 | 1443 | |
1374 | 1444 | $data = $class . $css; |
1375 | 1445 | }, |
@@ -1419,17 +1489,20 @@ discard block |
||
1419 | 1489 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1420 | 1490 | if ($image_proxy_enabled) |
1421 | 1491 | { |
1422 | - if (!empty($user_info['possibly_robot'])) |
|
1423 | - return; |
|
1492 | + if (!empty($user_info['possibly_robot'])) { |
|
1493 | + return; |
|
1494 | + } |
|
1424 | 1495 | |
1425 | - if (empty($scheme)) |
|
1426 | - $data = 'http://' . ltrim($data, ':/'); |
|
1496 | + if (empty($scheme)) { |
|
1497 | + $data = 'http://' . ltrim($data, ':/'); |
|
1498 | + } |
|
1427 | 1499 | |
1428 | - if ($scheme != 'https') |
|
1429 | - $data = get_proxied_url($data); |
|
1500 | + if ($scheme != 'https') { |
|
1501 | + $data = get_proxied_url($data); |
|
1502 | + } |
|
1503 | + } elseif (empty($scheme)) { |
|
1504 | + $data = '//' . ltrim($data, ':/'); |
|
1430 | 1505 | } |
1431 | - elseif (empty($scheme)) |
|
1432 | - $data = '//' . ltrim($data, ':/'); |
|
1433 | 1506 | }, |
1434 | 1507 | 'disabled_content' => '($1)', |
1435 | 1508 | ), |
@@ -1445,17 +1518,20 @@ discard block |
||
1445 | 1518 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1446 | 1519 | if ($image_proxy_enabled) |
1447 | 1520 | { |
1448 | - if (!empty($user_info['possibly_robot'])) |
|
1449 | - return; |
|
1521 | + if (!empty($user_info['possibly_robot'])) { |
|
1522 | + return; |
|
1523 | + } |
|
1450 | 1524 | |
1451 | - if (empty($scheme)) |
|
1452 | - $data = 'http://' . ltrim($data, ':/'); |
|
1525 | + if (empty($scheme)) { |
|
1526 | + $data = 'http://' . ltrim($data, ':/'); |
|
1527 | + } |
|
1453 | 1528 | |
1454 | - if ($scheme != 'https') |
|
1455 | - $data = get_proxied_url($data); |
|
1529 | + if ($scheme != 'https') { |
|
1530 | + $data = get_proxied_url($data); |
|
1531 | + } |
|
1532 | + } elseif (empty($scheme)) { |
|
1533 | + $data = '//' . ltrim($data, ':/'); |
|
1456 | 1534 | } |
1457 | - elseif (empty($scheme)) |
|
1458 | - $data = '//' . ltrim($data, ':/'); |
|
1459 | 1535 | }, |
1460 | 1536 | 'disabled_content' => '($1)', |
1461 | 1537 | ), |
@@ -1467,8 +1543,9 @@ discard block |
||
1467 | 1543 | { |
1468 | 1544 | $data = strtr($data, array('<br>' => '')); |
1469 | 1545 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1470 | - if (empty($scheme)) |
|
1471 | - $data = '//' . ltrim($data, ':/'); |
|
1546 | + if (empty($scheme)) { |
|
1547 | + $data = '//' . ltrim($data, ':/'); |
|
1548 | + } |
|
1472 | 1549 | }, |
1473 | 1550 | ), |
1474 | 1551 | array( |
@@ -1479,13 +1556,14 @@ discard block |
||
1479 | 1556 | 'after' => '</a>', |
1480 | 1557 | 'validate' => function (&$tag, &$data, $disabled) |
1481 | 1558 | { |
1482 | - if (substr($data, 0, 1) == '#') |
|
1483 | - $data = '#post_' . substr($data, 1); |
|
1484 | - else |
|
1559 | + if (substr($data, 0, 1) == '#') { |
|
1560 | + $data = '#post_' . substr($data, 1); |
|
1561 | + } else |
|
1485 | 1562 | { |
1486 | 1563 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1487 | - if (empty($scheme)) |
|
1488 | - $data = '//' . ltrim($data, ':/'); |
|
1564 | + if (empty($scheme)) { |
|
1565 | + $data = '//' . ltrim($data, ':/'); |
|
1566 | + } |
|
1489 | 1567 | } |
1490 | 1568 | }, |
1491 | 1569 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
@@ -1569,8 +1647,9 @@ discard block |
||
1569 | 1647 | { |
1570 | 1648 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1571 | 1649 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1572 | - if ($add_begin) |
|
1573 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1650 | + if ($add_begin) { |
|
1651 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1652 | + } |
|
1574 | 1653 | } |
1575 | 1654 | }, |
1576 | 1655 | 'block_level' => false, |
@@ -1701,10 +1780,11 @@ discard block |
||
1701 | 1780 | 'content' => '$1', |
1702 | 1781 | 'validate' => function (&$tag, &$data, $disabled) |
1703 | 1782 | { |
1704 | - if (is_numeric($data)) |
|
1705 | - $data = timeformat($data); |
|
1706 | - else |
|
1707 | - $tag['content'] = '[time]$1[/time]'; |
|
1783 | + if (is_numeric($data)) { |
|
1784 | + $data = timeformat($data); |
|
1785 | + } else { |
|
1786 | + $tag['content'] = '[time]$1[/time]'; |
|
1787 | + } |
|
1708 | 1788 | }, |
1709 | 1789 | ), |
1710 | 1790 | array( |
@@ -1731,8 +1811,9 @@ discard block |
||
1731 | 1811 | { |
1732 | 1812 | $data = strtr($data, array('<br>' => '')); |
1733 | 1813 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1734 | - if (empty($scheme)) |
|
1735 | - $data = '//' . ltrim($data, ':/'); |
|
1814 | + if (empty($scheme)) { |
|
1815 | + $data = '//' . ltrim($data, ':/'); |
|
1816 | + } |
|
1736 | 1817 | }, |
1737 | 1818 | ), |
1738 | 1819 | array( |
@@ -1744,8 +1825,9 @@ discard block |
||
1744 | 1825 | 'validate' => function (&$tag, &$data, $disabled) |
1745 | 1826 | { |
1746 | 1827 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1747 | - if (empty($scheme)) |
|
1748 | - $data = '//' . ltrim($data, ':/'); |
|
1828 | + if (empty($scheme)) { |
|
1829 | + $data = '//' . ltrim($data, ':/'); |
|
1830 | + } |
|
1749 | 1831 | }, |
1750 | 1832 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1751 | 1833 | 'disabled_after' => ' ($1)', |
@@ -1771,8 +1853,9 @@ discard block |
||
1771 | 1853 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1772 | 1854 | if ($message === false) |
1773 | 1855 | { |
1774 | - if (isset($temp_bbc)) |
|
1775 | - $bbc_codes = $temp_bbc; |
|
1856 | + if (isset($temp_bbc)) { |
|
1857 | + $bbc_codes = $temp_bbc; |
|
1858 | + } |
|
1776 | 1859 | usort($codes, function ($a, $b) { |
1777 | 1860 | return strcmp($a['tag'], $b['tag']); |
1778 | 1861 | }); |
@@ -1792,8 +1875,9 @@ discard block |
||
1792 | 1875 | ); |
1793 | 1876 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1794 | 1877 | { |
1795 | - foreach ($itemcodes as $c => $dummy) |
|
1796 | - $bbc_codes[$c] = array(); |
|
1878 | + foreach ($itemcodes as $c => $dummy) { |
|
1879 | + $bbc_codes[$c] = array(); |
|
1880 | + } |
|
1797 | 1881 | } |
1798 | 1882 | |
1799 | 1883 | // Shhhh! |
@@ -1814,12 +1898,14 @@ discard block |
||
1814 | 1898 | foreach ($codes as $code) |
1815 | 1899 | { |
1816 | 1900 | // Make it easier to process parameters later |
1817 | - if (!empty($code['parameters'])) |
|
1818 | - ksort($code['parameters'], SORT_STRING); |
|
1901 | + if (!empty($code['parameters'])) { |
|
1902 | + ksort($code['parameters'], SORT_STRING); |
|
1903 | + } |
|
1819 | 1904 | |
1820 | 1905 | // If we are not doing every tag only do ones we are interested in. |
1821 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1822 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1906 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1907 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1908 | + } |
|
1823 | 1909 | } |
1824 | 1910 | $codes = null; |
1825 | 1911 | } |
@@ -1830,8 +1916,9 @@ discard block |
||
1830 | 1916 | // It's likely this will change if the message is modified. |
1831 | 1917 | $cache_key = 'parse:' . $cache_id . '-' . md5(md5($message) . '-' . $smileys . (empty($disabled) ? '' : implode(',', array_keys($disabled))) . $smcFunc['json_encode']($context['browser']) . $txt['lang_locale'] . $user_info['time_offset'] . $user_info['time_format']); |
1832 | 1918 | |
1833 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1834 | - return $temp; |
|
1919 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1920 | + return $temp; |
|
1921 | + } |
|
1835 | 1922 | |
1836 | 1923 | $cache_t = microtime(); |
1837 | 1924 | } |
@@ -1863,8 +1950,9 @@ discard block |
||
1863 | 1950 | $disabled['flash'] = true; |
1864 | 1951 | |
1865 | 1952 | // @todo Change maybe? |
1866 | - if (!isset($_GET['images'])) |
|
1867 | - $disabled['img'] = true; |
|
1953 | + if (!isset($_GET['images'])) { |
|
1954 | + $disabled['img'] = true; |
|
1955 | + } |
|
1868 | 1956 | |
1869 | 1957 | // @todo Interface/setting to add more? |
1870 | 1958 | } |
@@ -1875,8 +1963,9 @@ discard block |
||
1875 | 1963 | $alltags = array(); |
1876 | 1964 | foreach ($bbc_codes as $section) |
1877 | 1965 | { |
1878 | - foreach ($section as $code) |
|
1879 | - $alltags[] = $code['tag']; |
|
1966 | + foreach ($section as $code) { |
|
1967 | + $alltags[] = $code['tag']; |
|
1968 | + } |
|
1880 | 1969 | } |
1881 | 1970 | $alltags_regex = '\b' . implode("\b|\b", array_unique($alltags)) . '\b'; |
1882 | 1971 | |
@@ -1888,8 +1977,9 @@ discard block |
||
1888 | 1977 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1889 | 1978 | |
1890 | 1979 | // Failsafe. |
1891 | - if ($pos === false || $last_pos > $pos) |
|
1892 | - $pos = strlen($message) + 1; |
|
1980 | + if ($pos === false || $last_pos > $pos) { |
|
1981 | + $pos = strlen($message) + 1; |
|
1982 | + } |
|
1893 | 1983 | |
1894 | 1984 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1895 | 1985 | if ($last_pos < $pos - 1) |
@@ -1907,8 +1997,9 @@ discard block |
||
1907 | 1997 | |
1908 | 1998 | // <br> should be empty. |
1909 | 1999 | $empty_tags = array('br', 'hr'); |
1910 | - foreach ($empty_tags as $tag) |
|
1911 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
2000 | + foreach ($empty_tags as $tag) { |
|
2001 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
2002 | + } |
|
1912 | 2003 | |
1913 | 2004 | // b, u, i, s, pre... basic tags. |
1914 | 2005 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1917,8 +2008,9 @@ discard block |
||
1917 | 2008 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1918 | 2009 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1919 | 2010 | |
1920 | - if ($diff > 0) |
|
1921 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2011 | + if ($diff > 0) { |
|
2012 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2013 | + } |
|
1922 | 2014 | } |
1923 | 2015 | |
1924 | 2016 | // Do <img ...> - with security... action= -> action-. |
@@ -1931,8 +2023,9 @@ discard block |
||
1931 | 2023 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1932 | 2024 | |
1933 | 2025 | // Remove action= from the URL - no funny business, now. |
1934 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1935 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2026 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
2027 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2028 | + } |
|
1936 | 2029 | |
1937 | 2030 | $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
1938 | 2031 | } |
@@ -1947,16 +2040,18 @@ discard block |
||
1947 | 2040 | $no_autolink_area = false; |
1948 | 2041 | if (!empty($open_tags)) |
1949 | 2042 | { |
1950 | - foreach ($open_tags as $open_tag) |
|
1951 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2043 | + foreach ($open_tags as $open_tag) { |
|
2044 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1952 | 2045 | $no_autolink_area = true; |
2046 | + } |
|
1953 | 2047 | } |
1954 | 2048 | |
1955 | 2049 | // Don't go backwards. |
1956 | 2050 | // @todo Don't think is the real solution.... |
1957 | 2051 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1958 | - if ($pos < $lastAutoPos) |
|
1959 | - $no_autolink_area = true; |
|
2052 | + if ($pos < $lastAutoPos) { |
|
2053 | + $no_autolink_area = true; |
|
2054 | + } |
|
1960 | 2055 | $lastAutoPos = $pos; |
1961 | 2056 | |
1962 | 2057 | if (!$no_autolink_area) |
@@ -2061,29 +2156,33 @@ discard block |
||
2061 | 2156 | $url = array_shift($matches); |
2062 | 2157 | |
2063 | 2158 | // If this isn't a clean URL, bail out |
2064 | - if ($url != sanitize_iri($url)) |
|
2065 | - return $url; |
|
2159 | + if ($url != sanitize_iri($url)) { |
|
2160 | + return $url; |
|
2161 | + } |
|
2066 | 2162 | |
2067 | 2163 | $scheme = parse_url($url, PHP_URL_SCHEME); |
2068 | 2164 | |
2069 | 2165 | if ($scheme == 'mailto') |
2070 | 2166 | { |
2071 | 2167 | $email_address = str_replace('mailto:', '', $url); |
2072 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2073 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2074 | - else |
|
2075 | - return $url; |
|
2168 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2169 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2170 | + } else { |
|
2171 | + return $url; |
|
2172 | + } |
|
2076 | 2173 | } |
2077 | 2174 | |
2078 | 2175 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2079 | - if (empty($scheme)) |
|
2080 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2081 | - else |
|
2082 | - $fullUrl = $url; |
|
2176 | + if (empty($scheme)) { |
|
2177 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2178 | + } else { |
|
2179 | + $fullUrl = $url; |
|
2180 | + } |
|
2083 | 2181 | |
2084 | 2182 | // Make sure that $fullUrl really is valid |
2085 | - if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) |
|
2086 | - return $url; |
|
2183 | + if (validate_iri((strpos($fullUrl, '//') === 0 ? 'http:' : '' ) . $fullUrl) === false) { |
|
2184 | + return $url; |
|
2185 | + } |
|
2087 | 2186 | |
2088 | 2187 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2089 | 2188 | }, $data); |
@@ -2132,22 +2231,25 @@ discard block |
||
2132 | 2231 | } |
2133 | 2232 | |
2134 | 2233 | // Are we there yet? Are we there yet? |
2135 | - if ($pos >= strlen($message) - 1) |
|
2136 | - break; |
|
2234 | + if ($pos >= strlen($message) - 1) { |
|
2235 | + break; |
|
2236 | + } |
|
2137 | 2237 | |
2138 | 2238 | $tags = strtolower($message[$pos + 1]); |
2139 | 2239 | |
2140 | 2240 | if ($tags == '/' && !empty($open_tags)) |
2141 | 2241 | { |
2142 | 2242 | $pos2 = strpos($message, ']', $pos + 1); |
2143 | - if ($pos2 == $pos + 2) |
|
2144 | - continue; |
|
2243 | + if ($pos2 == $pos + 2) { |
|
2244 | + continue; |
|
2245 | + } |
|
2145 | 2246 | |
2146 | 2247 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2147 | 2248 | |
2148 | 2249 | // A closing tag that doesn't match any open tags? Skip it. |
2149 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2150 | - continue; |
|
2250 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
2251 | + continue; |
|
2252 | + } |
|
2151 | 2253 | |
2152 | 2254 | $to_close = array(); |
2153 | 2255 | $block_level = null; |
@@ -2155,8 +2257,9 @@ discard block |
||
2155 | 2257 | do |
2156 | 2258 | { |
2157 | 2259 | $tag = array_pop($open_tags); |
2158 | - if (!$tag) |
|
2159 | - break; |
|
2260 | + if (!$tag) { |
|
2261 | + break; |
|
2262 | + } |
|
2160 | 2263 | |
2161 | 2264 | if (!empty($tag['block_level'])) |
2162 | 2265 | { |
@@ -2170,10 +2273,11 @@ discard block |
||
2170 | 2273 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2171 | 2274 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2172 | 2275 | { |
2173 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2174 | - if ($temp['tag'] == $look_for) |
|
2276 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2277 | + if ($temp['tag'] == $look_for) |
|
2175 | 2278 | { |
2176 | 2279 | $block_level = !empty($temp['block_level']); |
2280 | + } |
|
2177 | 2281 | break; |
2178 | 2282 | } |
2179 | 2283 | } |
@@ -2195,15 +2299,15 @@ discard block |
||
2195 | 2299 | { |
2196 | 2300 | $open_tags = $to_close; |
2197 | 2301 | continue; |
2198 | - } |
|
2199 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2302 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2200 | 2303 | { |
2201 | 2304 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2202 | 2305 | { |
2203 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2204 | - if ($temp['tag'] == $look_for) |
|
2306 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2307 | + if ($temp['tag'] == $look_for) |
|
2205 | 2308 | { |
2206 | 2309 | $block_level = !empty($temp['block_level']); |
2310 | + } |
|
2207 | 2311 | break; |
2208 | 2312 | } |
2209 | 2313 | } |
@@ -2211,8 +2315,9 @@ discard block |
||
2211 | 2315 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2212 | 2316 | if (!$block_level) |
2213 | 2317 | { |
2214 | - foreach ($to_close as $tag) |
|
2215 | - array_push($open_tags, $tag); |
|
2318 | + foreach ($to_close as $tag) { |
|
2319 | + array_push($open_tags, $tag); |
|
2320 | + } |
|
2216 | 2321 | continue; |
2217 | 2322 | } |
2218 | 2323 | } |
@@ -2225,14 +2330,17 @@ discard block |
||
2225 | 2330 | |
2226 | 2331 | // See the comment at the end of the big loop - just eating whitespace ;). |
2227 | 2332 | $whitespace_regex = ''; |
2228 | - if (!empty($tag['block_level'])) |
|
2229 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2333 | + if (!empty($tag['block_level'])) { |
|
2334 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2335 | + } |
|
2230 | 2336 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2231 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2232 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2337 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2338 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2339 | + } |
|
2233 | 2340 | |
2234 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2235 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2341 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2342 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2343 | + } |
|
2236 | 2344 | } |
2237 | 2345 | |
2238 | 2346 | if (!empty($to_close)) |
@@ -2245,8 +2353,9 @@ discard block |
||
2245 | 2353 | } |
2246 | 2354 | |
2247 | 2355 | // No tags for this character, so just keep going (fastest possible course.) |
2248 | - if (!isset($bbc_codes[$tags])) |
|
2249 | - continue; |
|
2356 | + if (!isset($bbc_codes[$tags])) { |
|
2357 | + continue; |
|
2358 | + } |
|
2250 | 2359 | |
2251 | 2360 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2252 | 2361 | $tag = null; |
@@ -2255,48 +2364,57 @@ discard block |
||
2255 | 2364 | $pt_strlen = strlen($possible['tag']); |
2256 | 2365 | |
2257 | 2366 | // Not a match? |
2258 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2259 | - continue; |
|
2367 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2368 | + continue; |
|
2369 | + } |
|
2260 | 2370 | |
2261 | 2371 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
2262 | 2372 | |
2263 | 2373 | // A tag is the last char maybe |
2264 | - if ($next_c == '') |
|
2265 | - break; |
|
2374 | + if ($next_c == '') { |
|
2375 | + break; |
|
2376 | + } |
|
2266 | 2377 | |
2267 | 2378 | // A test validation? |
2268 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2269 | - continue; |
|
2379 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2380 | + continue; |
|
2381 | + } |
|
2270 | 2382 | // Do we want parameters? |
2271 | 2383 | elseif (!empty($possible['parameters'])) |
2272 | 2384 | { |
2273 | - if ($next_c != ' ') |
|
2274 | - continue; |
|
2275 | - } |
|
2276 | - elseif (isset($possible['type'])) |
|
2385 | + if ($next_c != ' ') { |
|
2386 | + continue; |
|
2387 | + } |
|
2388 | + } elseif (isset($possible['type'])) |
|
2277 | 2389 | { |
2278 | 2390 | // Do we need an equal sign? |
2279 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2280 | - continue; |
|
2391 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2392 | + continue; |
|
2393 | + } |
|
2281 | 2394 | // Maybe we just want a /... |
2282 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2283 | - continue; |
|
2395 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2396 | + continue; |
|
2397 | + } |
|
2284 | 2398 | // An immediate ]? |
2285 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2286 | - continue; |
|
2399 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2400 | + continue; |
|
2401 | + } |
|
2287 | 2402 | } |
2288 | 2403 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2289 | - elseif ($next_c != ']') |
|
2290 | - continue; |
|
2404 | + elseif ($next_c != ']') { |
|
2405 | + continue; |
|
2406 | + } |
|
2291 | 2407 | |
2292 | 2408 | // Check allowed tree? |
2293 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2294 | - continue; |
|
2295 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2296 | - continue; |
|
2409 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2410 | + continue; |
|
2411 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2412 | + continue; |
|
2413 | + } |
|
2297 | 2414 | // If this is in the list of disallowed child tags, don't parse it. |
2298 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2299 | - continue; |
|
2415 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2416 | + continue; |
|
2417 | + } |
|
2300 | 2418 | |
2301 | 2419 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2302 | 2420 | |
@@ -2308,8 +2426,9 @@ discard block |
||
2308 | 2426 | foreach ($open_tags as $open_quote) |
2309 | 2427 | { |
2310 | 2428 | // Every parent quote this quote has flips the styling |
2311 | - if ($open_quote['tag'] == 'quote') |
|
2312 | - $quote_alt = !$quote_alt; |
|
2429 | + if ($open_quote['tag'] == 'quote') { |
|
2430 | + $quote_alt = !$quote_alt; |
|
2431 | + } |
|
2313 | 2432 | } |
2314 | 2433 | // Add a class to the quote to style alternating blockquotes |
2315 | 2434 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2320,8 +2439,9 @@ discard block |
||
2320 | 2439 | { |
2321 | 2440 | // Build a regular expression for each parameter for the current tag. |
2322 | 2441 | $preg = array(); |
2323 | - foreach ($possible['parameters'] as $p => $info) |
|
2324 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2442 | + foreach ($possible['parameters'] as $p => $info) { |
|
2443 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2444 | + } |
|
2325 | 2445 | |
2326 | 2446 | // Extract the string that potentially holds our parameters. |
2327 | 2447 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2340,24 +2460,27 @@ discard block |
||
2340 | 2460 | |
2341 | 2461 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2342 | 2462 | |
2343 | - if ($match) |
|
2344 | - $blob_counter = count($blobs) + 1; |
|
2463 | + if ($match) { |
|
2464 | + $blob_counter = count($blobs) + 1; |
|
2465 | + } |
|
2345 | 2466 | } |
2346 | 2467 | |
2347 | 2468 | // Didn't match our parameter list, try the next possible. |
2348 | - if (!$match) |
|
2349 | - continue; |
|
2469 | + if (!$match) { |
|
2470 | + continue; |
|
2471 | + } |
|
2350 | 2472 | |
2351 | 2473 | $params = array(); |
2352 | 2474 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2353 | 2475 | { |
2354 | 2476 | $key = strtok(ltrim($matches[$i]), '='); |
2355 | - if (isset($possible['parameters'][$key]['value'])) |
|
2356 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2357 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2358 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2359 | - else |
|
2360 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2477 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2478 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2479 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2480 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2481 | + } else { |
|
2482 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2483 | + } |
|
2361 | 2484 | |
2362 | 2485 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2363 | 2486 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2365,23 +2488,26 @@ discard block |
||
2365 | 2488 | |
2366 | 2489 | foreach ($possible['parameters'] as $p => $info) |
2367 | 2490 | { |
2368 | - if (!isset($params['{' . $p . '}'])) |
|
2369 | - $params['{' . $p . '}'] = ''; |
|
2491 | + if (!isset($params['{' . $p . '}'])) { |
|
2492 | + $params['{' . $p . '}'] = ''; |
|
2493 | + } |
|
2370 | 2494 | } |
2371 | 2495 | |
2372 | 2496 | $tag = $possible; |
2373 | 2497 | |
2374 | 2498 | // Put the parameters into the string. |
2375 | - if (isset($tag['before'])) |
|
2376 | - $tag['before'] = strtr($tag['before'], $params); |
|
2377 | - if (isset($tag['after'])) |
|
2378 | - $tag['after'] = strtr($tag['after'], $params); |
|
2379 | - if (isset($tag['content'])) |
|
2380 | - $tag['content'] = strtr($tag['content'], $params); |
|
2499 | + if (isset($tag['before'])) { |
|
2500 | + $tag['before'] = strtr($tag['before'], $params); |
|
2501 | + } |
|
2502 | + if (isset($tag['after'])) { |
|
2503 | + $tag['after'] = strtr($tag['after'], $params); |
|
2504 | + } |
|
2505 | + if (isset($tag['content'])) { |
|
2506 | + $tag['content'] = strtr($tag['content'], $params); |
|
2507 | + } |
|
2381 | 2508 | |
2382 | 2509 | $pos1 += strlen($given_param_string); |
2383 | - } |
|
2384 | - else |
|
2510 | + } else |
|
2385 | 2511 | { |
2386 | 2512 | $tag = $possible; |
2387 | 2513 | $params = array(); |
@@ -2392,8 +2518,9 @@ discard block |
||
2392 | 2518 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2393 | 2519 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2394 | 2520 | { |
2395 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2396 | - continue; |
|
2521 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2522 | + continue; |
|
2523 | + } |
|
2397 | 2524 | |
2398 | 2525 | $tag = $itemcodes[$message[$pos + 1]]; |
2399 | 2526 | |
@@ -2414,9 +2541,9 @@ discard block |
||
2414 | 2541 | { |
2415 | 2542 | array_pop($open_tags); |
2416 | 2543 | $code = '</li>'; |
2544 | + } else { |
|
2545 | + $code = ''; |
|
2417 | 2546 | } |
2418 | - else |
|
2419 | - $code = ''; |
|
2420 | 2547 | |
2421 | 2548 | // Now we open a new tag. |
2422 | 2549 | $open_tags[] = array( |
@@ -2463,12 +2590,14 @@ discard block |
||
2463 | 2590 | } |
2464 | 2591 | |
2465 | 2592 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2466 | - if ($tag === null) |
|
2467 | - continue; |
|
2593 | + if ($tag === null) { |
|
2594 | + continue; |
|
2595 | + } |
|
2468 | 2596 | |
2469 | 2597 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2470 | - if (isset($inside['disallow_children'])) |
|
2471 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2598 | + if (isset($inside['disallow_children'])) { |
|
2599 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2600 | + } |
|
2472 | 2601 | |
2473 | 2602 | // Is this tag disabled? |
2474 | 2603 | if (isset($disabled[$tag['tag']])) |
@@ -2478,14 +2607,13 @@ discard block |
||
2478 | 2607 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2479 | 2608 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2480 | 2609 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2481 | - } |
|
2482 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2610 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2483 | 2611 | { |
2484 | 2612 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2485 | 2613 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2614 | + } else { |
|
2615 | + $tag['content'] = $tag['disabled_content']; |
|
2486 | 2616 | } |
2487 | - else |
|
2488 | - $tag['content'] = $tag['disabled_content']; |
|
2489 | 2617 | } |
2490 | 2618 | |
2491 | 2619 | // we use this a lot |
@@ -2495,8 +2623,9 @@ discard block |
||
2495 | 2623 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2496 | 2624 | { |
2497 | 2625 | $n = count($open_tags) - 1; |
2498 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2499 | - $n--; |
|
2626 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2627 | + $n--; |
|
2628 | + } |
|
2500 | 2629 | |
2501 | 2630 | // Close all the non block level tags so this tag isn't surrounded by them. |
2502 | 2631 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2508,12 +2637,15 @@ discard block |
||
2508 | 2637 | |
2509 | 2638 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2510 | 2639 | $whitespace_regex = ''; |
2511 | - if (!empty($tag['block_level'])) |
|
2512 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2513 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2514 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2515 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2516 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2640 | + if (!empty($tag['block_level'])) { |
|
2641 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2642 | + } |
|
2643 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2644 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2645 | + } |
|
2646 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2647 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2648 | + } |
|
2517 | 2649 | |
2518 | 2650 | array_pop($open_tags); |
2519 | 2651 | } |
@@ -2534,16 +2666,19 @@ discard block |
||
2534 | 2666 | elseif ($tag['type'] == 'unparsed_content') |
2535 | 2667 | { |
2536 | 2668 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2537 | - if ($pos2 === false) |
|
2538 | - continue; |
|
2669 | + if ($pos2 === false) { |
|
2670 | + continue; |
|
2671 | + } |
|
2539 | 2672 | |
2540 | 2673 | $data = substr($message, $pos1, $pos2 - $pos1); |
2541 | 2674 | |
2542 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2543 | - $data = substr($data, 4); |
|
2675 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2676 | + $data = substr($data, 4); |
|
2677 | + } |
|
2544 | 2678 | |
2545 | - if (isset($tag['validate'])) |
|
2546 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2679 | + if (isset($tag['validate'])) { |
|
2680 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2681 | + } |
|
2547 | 2682 | |
2548 | 2683 | $code = strtr($tag['content'], array('$1' => $data)); |
2549 | 2684 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2558,34 +2693,40 @@ discard block |
||
2558 | 2693 | if (isset($tag['quoted'])) |
2559 | 2694 | { |
2560 | 2695 | $quoted = substr($message, $pos1, 6) == '"'; |
2561 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2562 | - continue; |
|
2696 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2697 | + continue; |
|
2698 | + } |
|
2563 | 2699 | |
2564 | - if ($quoted) |
|
2565 | - $pos1 += 6; |
|
2700 | + if ($quoted) { |
|
2701 | + $pos1 += 6; |
|
2702 | + } |
|
2703 | + } else { |
|
2704 | + $quoted = false; |
|
2566 | 2705 | } |
2567 | - else |
|
2568 | - $quoted = false; |
|
2569 | 2706 | |
2570 | 2707 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2571 | - if ($pos2 === false) |
|
2572 | - continue; |
|
2708 | + if ($pos2 === false) { |
|
2709 | + continue; |
|
2710 | + } |
|
2573 | 2711 | |
2574 | 2712 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2575 | - if ($pos3 === false) |
|
2576 | - continue; |
|
2713 | + if ($pos3 === false) { |
|
2714 | + continue; |
|
2715 | + } |
|
2577 | 2716 | |
2578 | 2717 | $data = array( |
2579 | 2718 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2580 | 2719 | substr($message, $pos1, $pos2 - $pos1) |
2581 | 2720 | ); |
2582 | 2721 | |
2583 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2584 | - $data[0] = substr($data[0], 4); |
|
2722 | + if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') { |
|
2723 | + $data[0] = substr($data[0], 4); |
|
2724 | + } |
|
2585 | 2725 | |
2586 | 2726 | // Validation for my parking, please! |
2587 | - if (isset($tag['validate'])) |
|
2588 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2727 | + if (isset($tag['validate'])) { |
|
2728 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2729 | + } |
|
2589 | 2730 | |
2590 | 2731 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2591 | 2732 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2602,23 +2743,27 @@ discard block |
||
2602 | 2743 | elseif ($tag['type'] == 'unparsed_commas_content') |
2603 | 2744 | { |
2604 | 2745 | $pos2 = strpos($message, ']', $pos1); |
2605 | - if ($pos2 === false) |
|
2606 | - continue; |
|
2746 | + if ($pos2 === false) { |
|
2747 | + continue; |
|
2748 | + } |
|
2607 | 2749 | |
2608 | 2750 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2609 | - if ($pos3 === false) |
|
2610 | - continue; |
|
2751 | + if ($pos3 === false) { |
|
2752 | + continue; |
|
2753 | + } |
|
2611 | 2754 | |
2612 | 2755 | // We want $1 to be the content, and the rest to be csv. |
2613 | 2756 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2614 | 2757 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2615 | 2758 | |
2616 | - if (isset($tag['validate'])) |
|
2617 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2759 | + if (isset($tag['validate'])) { |
|
2760 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2761 | + } |
|
2618 | 2762 | |
2619 | 2763 | $code = $tag['content']; |
2620 | - foreach ($data as $k => $d) |
|
2621 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2764 | + foreach ($data as $k => $d) { |
|
2765 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2766 | + } |
|
2622 | 2767 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2623 | 2768 | $pos += strlen($code) - 1 + 2; |
2624 | 2769 | } |
@@ -2626,24 +2771,28 @@ discard block |
||
2626 | 2771 | elseif ($tag['type'] == 'unparsed_commas') |
2627 | 2772 | { |
2628 | 2773 | $pos2 = strpos($message, ']', $pos1); |
2629 | - if ($pos2 === false) |
|
2630 | - continue; |
|
2774 | + if ($pos2 === false) { |
|
2775 | + continue; |
|
2776 | + } |
|
2631 | 2777 | |
2632 | 2778 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2633 | 2779 | |
2634 | - if (isset($tag['validate'])) |
|
2635 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2780 | + if (isset($tag['validate'])) { |
|
2781 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2782 | + } |
|
2636 | 2783 | |
2637 | 2784 | // Fix after, for disabled code mainly. |
2638 | - foreach ($data as $k => $d) |
|
2639 | - $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2785 | + foreach ($data as $k => $d) { |
|
2786 | + $tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d))); |
|
2787 | + } |
|
2640 | 2788 | |
2641 | 2789 | $open_tags[] = $tag; |
2642 | 2790 | |
2643 | 2791 | // Replace them out, $1, $2, $3, $4, etc. |
2644 | 2792 | $code = $tag['before']; |
2645 | - foreach ($data as $k => $d) |
|
2646 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2793 | + foreach ($data as $k => $d) { |
|
2794 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2795 | + } |
|
2647 | 2796 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2648 | 2797 | $pos += strlen($code) - 1 + 2; |
2649 | 2798 | } |
@@ -2654,28 +2803,33 @@ discard block |
||
2654 | 2803 | if (isset($tag['quoted'])) |
2655 | 2804 | { |
2656 | 2805 | $quoted = substr($message, $pos1, 6) == '"'; |
2657 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2658 | - continue; |
|
2806 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2807 | + continue; |
|
2808 | + } |
|
2659 | 2809 | |
2660 | - if ($quoted) |
|
2661 | - $pos1 += 6; |
|
2810 | + if ($quoted) { |
|
2811 | + $pos1 += 6; |
|
2812 | + } |
|
2813 | + } else { |
|
2814 | + $quoted = false; |
|
2662 | 2815 | } |
2663 | - else |
|
2664 | - $quoted = false; |
|
2665 | 2816 | |
2666 | 2817 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2667 | - if ($pos2 === false) |
|
2668 | - continue; |
|
2818 | + if ($pos2 === false) { |
|
2819 | + continue; |
|
2820 | + } |
|
2669 | 2821 | |
2670 | 2822 | $data = substr($message, $pos1, $pos2 - $pos1); |
2671 | 2823 | |
2672 | 2824 | // Validation for my parking, please! |
2673 | - if (isset($tag['validate'])) |
|
2674 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2825 | + if (isset($tag['validate'])) { |
|
2826 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2827 | + } |
|
2675 | 2828 | |
2676 | 2829 | // For parsed content, we must recurse to avoid security problems. |
2677 | - if ($tag['type'] != 'unparsed_equals') |
|
2678 | - $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2830 | + if ($tag['type'] != 'unparsed_equals') { |
|
2831 | + $data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array()); |
|
2832 | + } |
|
2679 | 2833 | |
2680 | 2834 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2681 | 2835 | |
@@ -2687,34 +2841,40 @@ discard block |
||
2687 | 2841 | } |
2688 | 2842 | |
2689 | 2843 | // If this is block level, eat any breaks after it. |
2690 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2691 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2844 | + if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') { |
|
2845 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 5); |
|
2846 | + } |
|
2692 | 2847 | |
2693 | 2848 | // Are we trimming outside this tag? |
2694 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2695 | - $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2849 | + if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) { |
|
2850 | + $message = substr($message, 0, $pos + 1) . substr($message, $pos + 1 + strlen($matches[0])); |
|
2851 | + } |
|
2696 | 2852 | } |
2697 | 2853 | |
2698 | 2854 | // Close any remaining tags. |
2699 | - while ($tag = array_pop($open_tags)) |
|
2700 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2855 | + while ($tag = array_pop($open_tags)) { |
|
2856 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2857 | + } |
|
2701 | 2858 | |
2702 | 2859 | // Parse the smileys within the parts where it can be done safely. |
2703 | 2860 | if ($smileys === true) |
2704 | 2861 | { |
2705 | 2862 | $message_parts = explode("\n", $message); |
2706 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2707 | - parsesmileys($message_parts[$i]); |
|
2863 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2864 | + parsesmileys($message_parts[$i]); |
|
2865 | + } |
|
2708 | 2866 | |
2709 | 2867 | $message = implode('', $message_parts); |
2710 | 2868 | } |
2711 | 2869 | |
2712 | 2870 | // No smileys, just get rid of the markers. |
2713 | - else |
|
2714 | - $message = strtr($message, array("\n" => '')); |
|
2871 | + else { |
|
2872 | + $message = strtr($message, array("\n" => '')); |
|
2873 | + } |
|
2715 | 2874 | |
2716 | - if ($message !== '' && $message[0] === ' ') |
|
2717 | - $message = ' ' . substr($message, 1); |
|
2875 | + if ($message !== '' && $message[0] === ' ') { |
|
2876 | + $message = ' ' . substr($message, 1); |
|
2877 | + } |
|
2718 | 2878 | |
2719 | 2879 | // Cleanup whitespace. |
2720 | 2880 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2723,15 +2883,16 @@ discard block |
||
2723 | 2883 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2724 | 2884 | |
2725 | 2885 | // Cache the output if it took some time... |
2726 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2727 | - cache_put_data($cache_key, $message, 240); |
|
2886 | + if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) { |
|
2887 | + cache_put_data($cache_key, $message, 240); |
|
2888 | + } |
|
2728 | 2889 | |
2729 | 2890 | // If this was a force parse revert if needed. |
2730 | 2891 | if (!empty($parse_tags)) |
2731 | 2892 | { |
2732 | - if (empty($temp_bbc)) |
|
2733 | - $bbc_codes = array(); |
|
2734 | - else |
|
2893 | + if (empty($temp_bbc)) { |
|
2894 | + $bbc_codes = array(); |
|
2895 | + } else |
|
2735 | 2896 | { |
2736 | 2897 | $bbc_codes = $temp_bbc; |
2737 | 2898 | unset($temp_bbc); |
@@ -2758,8 +2919,9 @@ discard block |
||
2758 | 2919 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2759 | 2920 | |
2760 | 2921 | // No smiley set at all?! |
2761 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2762 | - return; |
|
2922 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2923 | + return; |
|
2924 | + } |
|
2763 | 2925 | |
2764 | 2926 | // If smileyPregSearch hasn't been set, do it now. |
2765 | 2927 | if (empty($smileyPregSearch)) |
@@ -2770,8 +2932,7 @@ discard block |
||
2770 | 2932 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2771 | 2933 | $smileysto = array('evil.png', 'cheesy.png', 'rolleyes.png', 'angry.png', 'laugh.png', 'smiley.png', 'wink.png', 'grin.png', 'sad.png', 'shocked.png', 'cool.png', 'tongue.png', 'huh.png', 'embarrassed.png', 'lipsrsealed.png', 'kiss.png', 'cry.png', 'undecided.png', 'azn.png', 'afro.png', 'police.png', 'angel.png'); |
2772 | 2934 | $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', ''); |
2773 | - } |
|
2774 | - else |
|
2935 | + } else |
|
2775 | 2936 | { |
2776 | 2937 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2777 | 2938 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2795,9 +2956,9 @@ discard block |
||
2795 | 2956 | $smcFunc['db_free_result']($result); |
2796 | 2957 | |
2797 | 2958 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2959 | + } else { |
|
2960 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2798 | 2961 | } |
2799 | - else |
|
2800 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2801 | 2962 | } |
2802 | 2963 | |
2803 | 2964 | // The non-breaking-space is a complex thing... |
@@ -2875,12 +3036,14 @@ discard block |
||
2875 | 3036 | global $boardurl, $image_proxy_enabled, $image_proxy_secret; |
2876 | 3037 | |
2877 | 3038 | // Only use the proxy if enabled and necessary |
2878 | - if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') |
|
2879 | - return $url; |
|
3039 | + if (empty($image_proxy_enabled) || parse_url($url, PHP_URL_SCHEME) === 'https') { |
|
3040 | + return $url; |
|
3041 | + } |
|
2880 | 3042 | |
2881 | 3043 | // We don't need to proxy our own resources |
2882 | - if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) |
|
2883 | - return strtr($url, array('http://' => 'https://')); |
|
3044 | + if (strpos(strtr($url, array('http://' => 'https://')), strtr($boardurl, array('http://' => 'https://'))) === 0) { |
|
3045 | + return strtr($url, array('http://' => 'https://')); |
|
3046 | + } |
|
2884 | 3047 | |
2885 | 3048 | // By default, use SMF's own image proxy script |
2886 | 3049 | $proxied_url = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($url) . '&hash=' . md5($url . $image_proxy_secret); |
@@ -2905,35 +3068,41 @@ discard block |
||
2905 | 3068 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2906 | 3069 | |
2907 | 3070 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2908 | - if (!empty($context['flush_mail'])) |
|
2909 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3071 | + if (!empty($context['flush_mail'])) { |
|
3072 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2910 | 3073 | AddMailQueue(true); |
3074 | + } |
|
2911 | 3075 | |
2912 | 3076 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2913 | 3077 | |
2914 | - if ($add) |
|
2915 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3078 | + if ($add) { |
|
3079 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3080 | + } |
|
2916 | 3081 | |
2917 | 3082 | // Put the session ID in. |
2918 | - if (defined('SID') && SID != '') |
|
2919 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3083 | + if (defined('SID') && SID != '') { |
|
3084 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3085 | + } |
|
2920 | 3086 | // Keep that debug in their for template debugging! |
2921 | - elseif (isset($_GET['debug'])) |
|
2922 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3087 | + elseif (isset($_GET['debug'])) { |
|
3088 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3089 | + } |
|
2923 | 3090 | |
2924 | 3091 | if (!empty($modSettings['queryless_urls']) && (empty($context['server']['is_cgi']) || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && (!empty($context['server']['is_apache']) || !empty($context['server']['is_lighttpd']) || !empty($context['server']['is_litespeed']))) |
2925 | 3092 | { |
2926 | - if (defined('SID') && SID != '') |
|
2927 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3093 | + if (defined('SID') && SID != '') { |
|
3094 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2928 | 3095 | function ($m) use ($scripturl) |
2929 | 3096 | { |
2930 | 3097 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3098 | + } |
|
2931 | 3099 | }, $setLocation); |
2932 | - else |
|
2933 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3100 | + else { |
|
3101 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '~') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2934 | 3102 | function ($m) use ($scripturl) |
2935 | 3103 | { |
2936 | 3104 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3105 | + } |
|
2937 | 3106 | }, $setLocation); |
2938 | 3107 | } |
2939 | 3108 | |
@@ -2944,8 +3113,9 @@ discard block |
||
2944 | 3113 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2945 | 3114 | |
2946 | 3115 | // Debugging. |
2947 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2948 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3116 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3117 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3118 | + } |
|
2949 | 3119 | |
2950 | 3120 | obExit(false); |
2951 | 3121 | } |
@@ -2964,51 +3134,60 @@ discard block |
||
2964 | 3134 | |
2965 | 3135 | // Attempt to prevent a recursive loop. |
2966 | 3136 | ++$level; |
2967 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2968 | - exit; |
|
2969 | - if ($from_fatal_error) |
|
2970 | - $has_fatal_error = true; |
|
3137 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3138 | + exit; |
|
3139 | + } |
|
3140 | + if ($from_fatal_error) { |
|
3141 | + $has_fatal_error = true; |
|
3142 | + } |
|
2971 | 3143 | |
2972 | 3144 | // Clear out the stat cache. |
2973 | 3145 | trackStats(); |
2974 | 3146 | |
2975 | 3147 | // If we have mail to send, send it. |
2976 | - if (!empty($context['flush_mail'])) |
|
2977 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3148 | + if (!empty($context['flush_mail'])) { |
|
3149 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2978 | 3150 | AddMailQueue(true); |
3151 | + } |
|
2979 | 3152 | |
2980 | 3153 | $do_header = $header === null ? !$header_done : $header; |
2981 | - if ($do_footer === null) |
|
2982 | - $do_footer = $do_header; |
|
3154 | + if ($do_footer === null) { |
|
3155 | + $do_footer = $do_header; |
|
3156 | + } |
|
2983 | 3157 | |
2984 | 3158 | // Has the template/header been done yet? |
2985 | 3159 | if ($do_header) |
2986 | 3160 | { |
2987 | 3161 | // Was the page title set last minute? Also update the HTML safe one. |
2988 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2989 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3162 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3163 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3164 | + } |
|
2990 | 3165 | |
2991 | 3166 | // Start up the session URL fixer. |
2992 | 3167 | ob_start('ob_sessrewrite'); |
2993 | 3168 | |
2994 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2995 | - $buffers = explode(',', $settings['output_buffers']); |
|
2996 | - elseif (!empty($settings['output_buffers'])) |
|
2997 | - $buffers = $settings['output_buffers']; |
|
2998 | - else |
|
2999 | - $buffers = array(); |
|
3169 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3170 | + $buffers = explode(',', $settings['output_buffers']); |
|
3171 | + } elseif (!empty($settings['output_buffers'])) { |
|
3172 | + $buffers = $settings['output_buffers']; |
|
3173 | + } else { |
|
3174 | + $buffers = array(); |
|
3175 | + } |
|
3000 | 3176 | |
3001 | - if (isset($modSettings['integrate_buffer'])) |
|
3002 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3177 | + if (isset($modSettings['integrate_buffer'])) { |
|
3178 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3179 | + } |
|
3003 | 3180 | |
3004 | - if (!empty($buffers)) |
|
3005 | - foreach ($buffers as $function) |
|
3181 | + if (!empty($buffers)) { |
|
3182 | + foreach ($buffers as $function) |
|
3006 | 3183 | { |
3007 | 3184 | $call = call_helper($function, true); |
3185 | + } |
|
3008 | 3186 | |
3009 | 3187 | // Is it valid? |
3010 | - if (!empty($call)) |
|
3011 | - ob_start($call); |
|
3188 | + if (!empty($call)) { |
|
3189 | + ob_start($call); |
|
3190 | + } |
|
3012 | 3191 | } |
3013 | 3192 | |
3014 | 3193 | // Display the screen in the logical order. |
@@ -3020,8 +3199,9 @@ discard block |
||
3020 | 3199 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
3021 | 3200 | |
3022 | 3201 | // Anything special to put out? |
3023 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
3024 | - echo $context['insert_after_template']; |
|
3202 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3203 | + echo $context['insert_after_template']; |
|
3204 | + } |
|
3025 | 3205 | |
3026 | 3206 | // Just so we don't get caught in an endless loop of errors from the footer... |
3027 | 3207 | if (!$footer_done) |
@@ -3030,14 +3210,16 @@ discard block |
||
3030 | 3210 | template_footer(); |
3031 | 3211 | |
3032 | 3212 | // (since this is just debugging... it's okay that it's after </html>.) |
3033 | - if (!isset($_REQUEST['xml'])) |
|
3034 | - displayDebug(); |
|
3213 | + if (!isset($_REQUEST['xml'])) { |
|
3214 | + displayDebug(); |
|
3215 | + } |
|
3035 | 3216 | } |
3036 | 3217 | } |
3037 | 3218 | |
3038 | 3219 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
3039 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
3040 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3220 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3221 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3222 | + } |
|
3041 | 3223 | |
3042 | 3224 | // For session check verification.... don't switch browsers... |
3043 | 3225 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3046,9 +3228,10 @@ discard block |
||
3046 | 3228 | call_integration_hook('integrate_exit', array($do_footer)); |
3047 | 3229 | |
3048 | 3230 | // Don't exit if we're coming from index.php; that will pass through normally. |
3049 | - if (!$from_index) |
|
3050 | - exit; |
|
3051 | -} |
|
3231 | + if (!$from_index) { |
|
3232 | + exit; |
|
3233 | + } |
|
3234 | + } |
|
3052 | 3235 | |
3053 | 3236 | /** |
3054 | 3237 | * Get the size of a specified image with better error handling. |
@@ -3067,8 +3250,9 @@ discard block |
||
3067 | 3250 | $url = str_replace(' ', '%20', $url); |
3068 | 3251 | |
3069 | 3252 | // Can we pull this from the cache... please please? |
3070 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3071 | - return $temp; |
|
3253 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3254 | + return $temp; |
|
3255 | + } |
|
3072 | 3256 | $t = microtime(); |
3073 | 3257 | |
3074 | 3258 | // Get the host to pester... |
@@ -3078,12 +3262,10 @@ discard block |
||
3078 | 3262 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3079 | 3263 | { |
3080 | 3264 | return false; |
3081 | - } |
|
3082 | - elseif (!isset($match[1])) |
|
3265 | + } elseif (!isset($match[1])) |
|
3083 | 3266 | { |
3084 | 3267 | $size = @getimagesize($url); |
3085 | - } |
|
3086 | - else |
|
3268 | + } else |
|
3087 | 3269 | { |
3088 | 3270 | // Try to connect to the server... give it half a second. |
3089 | 3271 | $temp = 0; |
@@ -3120,12 +3302,14 @@ discard block |
||
3120 | 3302 | } |
3121 | 3303 | |
3122 | 3304 | // If we didn't get it, we failed. |
3123 | - if (!isset($size)) |
|
3124 | - $size = false; |
|
3305 | + if (!isset($size)) { |
|
3306 | + $size = false; |
|
3307 | + } |
|
3125 | 3308 | |
3126 | 3309 | // If this took a long time, we may never have to do it again, but then again we might... |
3127 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3128 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3310 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3311 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3312 | + } |
|
3129 | 3313 | |
3130 | 3314 | // Didn't work. |
3131 | 3315 | return $size; |
@@ -3143,8 +3327,9 @@ discard block |
||
3143 | 3327 | |
3144 | 3328 | // Under SSI this function can be called more then once. That can cause some problems. |
3145 | 3329 | // So only run the function once unless we are forced to run it again. |
3146 | - if ($loaded && !$forceload) |
|
3147 | - return; |
|
3330 | + if ($loaded && !$forceload) { |
|
3331 | + return; |
|
3332 | + } |
|
3148 | 3333 | |
3149 | 3334 | $loaded = true; |
3150 | 3335 | |
@@ -3156,14 +3341,16 @@ discard block |
||
3156 | 3341 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3157 | 3342 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3158 | 3343 | { |
3159 | - if (trim($context['news_lines'][$i]) == '') |
|
3160 | - continue; |
|
3344 | + if (trim($context['news_lines'][$i]) == '') { |
|
3345 | + continue; |
|
3346 | + } |
|
3161 | 3347 | |
3162 | 3348 | // Clean it up for presentation ;). |
3163 | 3349 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3164 | 3350 | } |
3165 | - if (!empty($context['news_lines'])) |
|
3166 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3351 | + if (!empty($context['news_lines'])) { |
|
3352 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3353 | + } |
|
3167 | 3354 | |
3168 | 3355 | if (!$user_info['is_guest']) |
3169 | 3356 | { |
@@ -3172,40 +3359,48 @@ discard block |
||
3172 | 3359 | $context['user']['alerts'] = &$user_info['alerts']; |
3173 | 3360 | |
3174 | 3361 | // Personal message popup... |
3175 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3176 | - $context['user']['popup_messages'] = true; |
|
3177 | - else |
|
3178 | - $context['user']['popup_messages'] = false; |
|
3362 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3363 | + $context['user']['popup_messages'] = true; |
|
3364 | + } else { |
|
3365 | + $context['user']['popup_messages'] = false; |
|
3366 | + } |
|
3179 | 3367 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3180 | 3368 | |
3181 | - if (allowedTo('moderate_forum')) |
|
3182 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3369 | + if (allowedTo('moderate_forum')) { |
|
3370 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3371 | + } |
|
3183 | 3372 | |
3184 | 3373 | $context['user']['avatar'] = array(); |
3185 | 3374 | |
3186 | 3375 | // Check for gravatar first since we might be forcing them... |
3187 | 3376 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3188 | 3377 | { |
3189 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3190 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3191 | - else |
|
3192 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3378 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3379 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3380 | + } else { |
|
3381 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3382 | + } |
|
3193 | 3383 | } |
3194 | 3384 | // Uploaded? |
3195 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3196 | - $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3385 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3386 | + $context['user']['avatar']['href'] = $user_info['avatar']['custom_dir'] ? $modSettings['custom_avatar_url'] . '/' . $user_info['avatar']['filename'] : $scripturl . '?action=dlattach;attach=' . $user_info['avatar']['id_attach'] . ';type=avatar'; |
|
3387 | + } |
|
3197 | 3388 | // Full URL? |
3198 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3199 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3389 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3390 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3391 | + } |
|
3200 | 3392 | // Otherwise we assume it's server stored. |
3201 | - elseif ($user_info['avatar']['url'] != '') |
|
3202 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3393 | + elseif ($user_info['avatar']['url'] != '') { |
|
3394 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3395 | + } |
|
3203 | 3396 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3204 | - else |
|
3205 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3397 | + else { |
|
3398 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3399 | + } |
|
3206 | 3400 | |
3207 | - if (!empty($context['user']['avatar'])) |
|
3208 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3401 | + if (!empty($context['user']['avatar'])) { |
|
3402 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3403 | + } |
|
3209 | 3404 | |
3210 | 3405 | // Figure out how long they've been logged in. |
3211 | 3406 | $context['user']['total_time_logged_in'] = array( |
@@ -3213,8 +3408,7 @@ discard block |
||
3213 | 3408 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3214 | 3409 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3215 | 3410 | ); |
3216 | - } |
|
3217 | - else |
|
3411 | + } else |
|
3218 | 3412 | { |
3219 | 3413 | $context['user']['messages'] = 0; |
3220 | 3414 | $context['user']['unread_messages'] = 0; |
@@ -3222,12 +3416,14 @@ discard block |
||
3222 | 3416 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3223 | 3417 | $context['user']['popup_messages'] = false; |
3224 | 3418 | |
3225 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3226 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3419 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3420 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3421 | + } |
|
3227 | 3422 | |
3228 | 3423 | // If we've upgraded recently, go easy on the passwords. |
3229 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3230 | - $context['disable_login_hashing'] = true; |
|
3424 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3425 | + $context['disable_login_hashing'] = true; |
|
3426 | + } |
|
3231 | 3427 | } |
3232 | 3428 | |
3233 | 3429 | // Setup the main menu items. |
@@ -3240,8 +3436,8 @@ discard block |
||
3240 | 3436 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3241 | 3437 | |
3242 | 3438 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3243 | - if ($context['show_pm_popup']) |
|
3244 | - addInlineJavaScript(' |
|
3439 | + if ($context['show_pm_popup']) { |
|
3440 | + addInlineJavaScript(' |
|
3245 | 3441 | jQuery(document).ready(function($) { |
3246 | 3442 | new smc_Popup({ |
3247 | 3443 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3249,24 +3445,28 @@ discard block |
||
3249 | 3445 | icon_class: \'generic_icons mail_new\' |
3250 | 3446 | }); |
3251 | 3447 | });'); |
3448 | + } |
|
3252 | 3449 | |
3253 | 3450 | // Add a generic "Are you sure?" confirmation message. |
3254 | 3451 | addInlineJavaScript(' |
3255 | 3452 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3256 | 3453 | |
3257 | 3454 | // Now add the capping code for avatars. |
3258 | - if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') |
|
3259 | - addInlineCss(' |
|
3455 | + if (!empty($modSettings['avatar_max_width_external']) && !empty($modSettings['avatar_max_height_external']) && !empty($modSettings['avatar_action_too_large']) && $modSettings['avatar_action_too_large'] == 'option_css_resize') { |
|
3456 | + addInlineCss(' |
|
3260 | 3457 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3458 | + } |
|
3261 | 3459 | |
3262 | 3460 | // Add max image limits |
3263 | - if (!empty($modSettings['max_image_width'])) |
|
3264 | - addInlineCss(' |
|
3461 | + if (!empty($modSettings['max_image_width'])) { |
|
3462 | + addInlineCss(' |
|
3265 | 3463 | .postarea .bbc_img { max-width: ' . $modSettings['max_image_width'] . 'px; }'); |
3464 | + } |
|
3266 | 3465 | |
3267 | - if (!empty($modSettings['max_image_height'])) |
|
3268 | - addInlineCss(' |
|
3466 | + if (!empty($modSettings['max_image_height'])) { |
|
3467 | + addInlineCss(' |
|
3269 | 3468 | .postarea .bbc_img { max-height: ' . $modSettings['max_image_height'] . 'px; }'); |
3469 | + } |
|
3270 | 3470 | |
3271 | 3471 | // This looks weird, but it's because BoardIndex.php references the variable. |
3272 | 3472 | $context['common_stats']['latest_member'] = array( |
@@ -3283,11 +3483,13 @@ discard block |
||
3283 | 3483 | ); |
3284 | 3484 | $context['common_stats']['boardindex_total_posts'] = sprintf($txt['boardindex_total_posts'], $context['common_stats']['total_posts'], $context['common_stats']['total_topics'], $context['common_stats']['total_members']); |
3285 | 3485 | |
3286 | - if (empty($settings['theme_version'])) |
|
3287 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3486 | + if (empty($settings['theme_version'])) { |
|
3487 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3488 | + } |
|
3288 | 3489 | |
3289 | - if (!isset($context['page_title'])) |
|
3290 | - $context['page_title'] = ''; |
|
3490 | + if (!isset($context['page_title'])) { |
|
3491 | + $context['page_title'] = ''; |
|
3492 | + } |
|
3291 | 3493 | |
3292 | 3494 | // Set some specific vars. |
3293 | 3495 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3297,21 +3499,23 @@ discard block |
||
3297 | 3499 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3298 | 3500 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3299 | 3501 | |
3300 | - if (!empty($context['meta_keywords'])) |
|
3301 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3502 | + if (!empty($context['meta_keywords'])) { |
|
3503 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3504 | + } |
|
3302 | 3505 | |
3303 | - if (!empty($context['canonical_url'])) |
|
3304 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3506 | + if (!empty($context['canonical_url'])) { |
|
3507 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3508 | + } |
|
3305 | 3509 | |
3306 | - if (!empty($settings['og_image'])) |
|
3307 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3510 | + if (!empty($settings['og_image'])) { |
|
3511 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3512 | + } |
|
3308 | 3513 | |
3309 | 3514 | if (!empty($context['meta_description'])) |
3310 | 3515 | { |
3311 | 3516 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3312 | 3517 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3313 | - } |
|
3314 | - else |
|
3518 | + } else |
|
3315 | 3519 | { |
3316 | 3520 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3317 | 3521 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3336,8 +3540,9 @@ discard block |
||
3336 | 3540 | $memory_needed = memoryReturnBytes($needed); |
3337 | 3541 | |
3338 | 3542 | // should we account for how much is currently being used? |
3339 | - if ($in_use) |
|
3340 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3543 | + if ($in_use) { |
|
3544 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3545 | + } |
|
3341 | 3546 | |
3342 | 3547 | // if more is needed, request it |
3343 | 3548 | if ($memory_current < $memory_needed) |
@@ -3360,8 +3565,9 @@ discard block |
||
3360 | 3565 | */ |
3361 | 3566 | function memoryReturnBytes($val) |
3362 | 3567 | { |
3363 | - if (is_integer($val)) |
|
3364 | - return $val; |
|
3568 | + if (is_integer($val)) { |
|
3569 | + return $val; |
|
3570 | + } |
|
3365 | 3571 | |
3366 | 3572 | // Separate the number from the designator |
3367 | 3573 | $val = trim($val); |
@@ -3397,10 +3603,11 @@ discard block |
||
3397 | 3603 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3398 | 3604 | |
3399 | 3605 | // Are we debugging the template/html content? |
3400 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3401 | - header('content-type: application/xhtml+xml'); |
|
3402 | - elseif (!isset($_REQUEST['xml'])) |
|
3403 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3606 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3607 | + header('content-type: application/xhtml+xml'); |
|
3608 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3609 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3610 | + } |
|
3404 | 3611 | } |
3405 | 3612 | |
3406 | 3613 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3409,8 +3616,9 @@ discard block |
||
3409 | 3616 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3410 | 3617 | { |
3411 | 3618 | $position = array_search('body', $context['template_layers']); |
3412 | - if ($position === false) |
|
3413 | - $position = array_search('main', $context['template_layers']); |
|
3619 | + if ($position === false) { |
|
3620 | + $position = array_search('main', $context['template_layers']); |
|
3621 | + } |
|
3414 | 3622 | |
3415 | 3623 | if ($position !== false) |
3416 | 3624 | { |
@@ -3438,23 +3646,25 @@ discard block |
||
3438 | 3646 | |
3439 | 3647 | foreach ($securityFiles as $i => $securityFile) |
3440 | 3648 | { |
3441 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3442 | - unset($securityFiles[$i]); |
|
3649 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3650 | + unset($securityFiles[$i]); |
|
3651 | + } |
|
3443 | 3652 | } |
3444 | 3653 | |
3445 | 3654 | // We are already checking so many files...just few more doesn't make any difference! :P |
3446 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3447 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3448 | - |
|
3449 | - else |
|
3450 | - $path = $modSettings['attachmentUploadDir']; |
|
3655 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3656 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3657 | + } else { |
|
3658 | + $path = $modSettings['attachmentUploadDir']; |
|
3659 | + } |
|
3451 | 3660 | |
3452 | 3661 | secureDirectory($path, true); |
3453 | 3662 | secureDirectory($cachedir); |
3454 | 3663 | |
3455 | 3664 | // If agreement is enabled, at least the english version shall exists |
3456 | - if ($modSettings['requireAgreement']) |
|
3457 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3665 | + if ($modSettings['requireAgreement']) { |
|
3666 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3667 | + } |
|
3458 | 3668 | |
3459 | 3669 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3460 | 3670 | { |
@@ -3469,18 +3679,21 @@ discard block |
||
3469 | 3679 | echo ' |
3470 | 3680 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3471 | 3681 | |
3472 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3473 | - echo ' |
|
3682 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3683 | + echo ' |
|
3474 | 3684 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3685 | + } |
|
3475 | 3686 | } |
3476 | 3687 | |
3477 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3478 | - echo ' |
|
3688 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3689 | + echo ' |
|
3479 | 3690 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3691 | + } |
|
3480 | 3692 | |
3481 | - if (!empty($agreement)) |
|
3482 | - echo ' |
|
3693 | + if (!empty($agreement)) { |
|
3694 | + echo ' |
|
3483 | 3695 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3696 | + } |
|
3484 | 3697 | |
3485 | 3698 | echo ' |
3486 | 3699 | </p> |
@@ -3495,16 +3708,18 @@ discard block |
||
3495 | 3708 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3496 | 3709 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3497 | 3710 | |
3498 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3499 | - echo ' |
|
3711 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3712 | + echo ' |
|
3500 | 3713 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3714 | + } |
|
3501 | 3715 | |
3502 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3503 | - echo ' |
|
3716 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3717 | + echo ' |
|
3504 | 3718 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3505 | - else |
|
3506 | - echo ' |
|
3719 | + } else { |
|
3720 | + echo ' |
|
3507 | 3721 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3722 | + } |
|
3508 | 3723 | |
3509 | 3724 | echo ' |
3510 | 3725 | </div>'; |
@@ -3520,8 +3735,9 @@ discard block |
||
3520 | 3735 | global $forum_copyright, $software_year, $forum_version; |
3521 | 3736 | |
3522 | 3737 | // Don't display copyright for things like SSI. |
3523 | - if (!isset($forum_version) || !isset($software_year)) |
|
3524 | - return; |
|
3738 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3739 | + return; |
|
3740 | + } |
|
3525 | 3741 | |
3526 | 3742 | // Put in the version... |
3527 | 3743 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3539,9 +3755,10 @@ discard block |
||
3539 | 3755 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
3540 | 3756 | $context['load_queries'] = $db_count; |
3541 | 3757 | |
3542 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3543 | - loadSubTemplate($layer . '_below', true); |
|
3544 | -} |
|
3758 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3759 | + loadSubTemplate($layer . '_below', true); |
|
3760 | + } |
|
3761 | + } |
|
3545 | 3762 | |
3546 | 3763 | /** |
3547 | 3764 | * Output the Javascript files |
@@ -3575,8 +3792,7 @@ discard block |
||
3575 | 3792 | { |
3576 | 3793 | echo ' |
3577 | 3794 | var ', $key, ';'; |
3578 | - } |
|
3579 | - else |
|
3795 | + } else |
|
3580 | 3796 | { |
3581 | 3797 | echo ' |
3582 | 3798 | var ', $key, ' = ', $value, ';'; |
@@ -3595,27 +3811,29 @@ discard block |
||
3595 | 3811 | foreach ($context['javascript_files'] as $id => $js_file) |
3596 | 3812 | { |
3597 | 3813 | // Last minute call! allow theme authors to disable single files. |
3598 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3599 | - continue; |
|
3814 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3815 | + continue; |
|
3816 | + } |
|
3600 | 3817 | |
3601 | 3818 | // By default files don't get minimized unless the file explicitly says so! |
3602 | 3819 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3603 | 3820 | { |
3604 | - if (!empty($js_file['options']['async'])) |
|
3605 | - $toMinify['async'][] = $js_file; |
|
3606 | - elseif (!empty($js_file['options']['defer'])) |
|
3607 | - $toMinify['defer'][] = $js_file; |
|
3608 | - else |
|
3609 | - $toMinify['standard'][] = $js_file; |
|
3821 | + if (!empty($js_file['options']['async'])) { |
|
3822 | + $toMinify['async'][] = $js_file; |
|
3823 | + } elseif (!empty($js_file['options']['defer'])) { |
|
3824 | + $toMinify['defer'][] = $js_file; |
|
3825 | + } else { |
|
3826 | + $toMinify['standard'][] = $js_file; |
|
3827 | + } |
|
3610 | 3828 | |
3611 | 3829 | // Grab a random seed. |
3612 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
3613 | - $minSeed = $js_file['options']['seed']; |
|
3614 | - } |
|
3615 | - |
|
3616 | - else |
|
3617 | - echo ' |
|
3830 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
3831 | + $minSeed = $js_file['options']['seed']; |
|
3832 | + } |
|
3833 | + } else { |
|
3834 | + echo ' |
|
3618 | 3835 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async' : '', !empty($js_file['options']['defer']) ? ' defer' : '', '></script>'; |
3836 | + } |
|
3619 | 3837 | } |
3620 | 3838 | |
3621 | 3839 | foreach ($toMinify as $js_files) |
@@ -3626,9 +3844,10 @@ discard block |
||
3626 | 3844 | |
3627 | 3845 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3628 | 3846 | |
3629 | - foreach ($result as $minFile) |
|
3630 | - echo ' |
|
3847 | + foreach ($result as $minFile) { |
|
3848 | + echo ' |
|
3631 | 3849 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async' : '', !empty($minFile['options']['defer']) ? ' defer' : '', '></script>'; |
3850 | + } |
|
3632 | 3851 | } |
3633 | 3852 | } |
3634 | 3853 | } |
@@ -3642,8 +3861,9 @@ discard block |
||
3642 | 3861 | <script> |
3643 | 3862 | window.addEventListener("DOMContentLoaded", function() {'; |
3644 | 3863 | |
3645 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3646 | - echo $js_code; |
|
3864 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3865 | + echo $js_code; |
|
3866 | + } |
|
3647 | 3867 | |
3648 | 3868 | echo ' |
3649 | 3869 | }); |
@@ -3655,8 +3875,9 @@ discard block |
||
3655 | 3875 | echo ' |
3656 | 3876 | <script>'; |
3657 | 3877 | |
3658 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3659 | - echo $js_code; |
|
3878 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3879 | + echo $js_code; |
|
3880 | + } |
|
3660 | 3881 | |
3661 | 3882 | echo ' |
3662 | 3883 | </script>'; |
@@ -3684,23 +3905,26 @@ discard block |
||
3684 | 3905 | foreach ($context['css_files'] as $id => $file) |
3685 | 3906 | { |
3686 | 3907 | // Last minute call! allow theme authors to disable single files. |
3687 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3688 | - continue; |
|
3908 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3909 | + continue; |
|
3910 | + } |
|
3689 | 3911 | |
3690 | 3912 | // Files are minimized unless they explicitly opt out. |
3691 | - if (!isset($file['options']['minimize'])) |
|
3692 | - $file['options']['minimize'] = true; |
|
3913 | + if (!isset($file['options']['minimize'])) { |
|
3914 | + $file['options']['minimize'] = true; |
|
3915 | + } |
|
3693 | 3916 | |
3694 | 3917 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3695 | 3918 | { |
3696 | 3919 | $toMinify[] = $file; |
3697 | 3920 | |
3698 | 3921 | // Grab a random seed. |
3699 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
3700 | - $minSeed = $file['options']['seed']; |
|
3922 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
3923 | + $minSeed = $file['options']['seed']; |
|
3924 | + } |
|
3925 | + } else { |
|
3926 | + $normal[] = $file['fileUrl']; |
|
3701 | 3927 | } |
3702 | - else |
|
3703 | - $normal[] = $file['fileUrl']; |
|
3704 | 3928 | } |
3705 | 3929 | |
3706 | 3930 | if (!empty($toMinify)) |
@@ -3709,23 +3933,26 @@ discard block |
||
3709 | 3933 | |
3710 | 3934 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3711 | 3935 | |
3712 | - foreach ($result as $minFile) |
|
3713 | - echo ' |
|
3936 | + foreach ($result as $minFile) { |
|
3937 | + echo ' |
|
3714 | 3938 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
3939 | + } |
|
3715 | 3940 | } |
3716 | 3941 | |
3717 | 3942 | // Print the rest after the minified files. |
3718 | - if (!empty($normal)) |
|
3719 | - foreach ($normal as $nf) |
|
3943 | + if (!empty($normal)) { |
|
3944 | + foreach ($normal as $nf) |
|
3720 | 3945 | echo ' |
3721 | 3946 | <link rel="stylesheet" href="', $nf ,'">'; |
3947 | + } |
|
3722 | 3948 | |
3723 | 3949 | if ($db_show_debug === true) |
3724 | 3950 | { |
3725 | 3951 | // Try to keep only what's useful. |
3726 | 3952 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3727 | - foreach ($context['css_files'] as $file) |
|
3728 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3953 | + foreach ($context['css_files'] as $file) { |
|
3954 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3955 | + } |
|
3729 | 3956 | } |
3730 | 3957 | |
3731 | 3958 | if (!empty($context['css_header'])) |
@@ -3733,9 +3960,10 @@ discard block |
||
3733 | 3960 | echo ' |
3734 | 3961 | <style>'; |
3735 | 3962 | |
3736 | - foreach ($context['css_header'] as $css) |
|
3737 | - echo $css .' |
|
3963 | + foreach ($context['css_header'] as $css) { |
|
3964 | + echo $css .' |
|
3738 | 3965 | '; |
3966 | + } |
|
3739 | 3967 | |
3740 | 3968 | echo' |
3741 | 3969 | </style>'; |
@@ -3758,8 +3986,9 @@ discard block |
||
3758 | 3986 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3759 | 3987 | $data = is_array($data) ? $data : array(); |
3760 | 3988 | |
3761 | - if (empty($type) || empty($data)) |
|
3762 | - return $data; |
|
3989 | + if (empty($type) || empty($data)) { |
|
3990 | + return $data; |
|
3991 | + } |
|
3763 | 3992 | |
3764 | 3993 | // Different pages include different files, so we use a hash to label the different combinations |
3765 | 3994 | $hash = md5(implode(' ', array_map(function($file) { return $file['filePath'] . (int) @filesize($file['filePath']) . (int) @filemtime($file['filePath']); }, $data))); |
@@ -3768,13 +3997,14 @@ discard block |
||
3768 | 3997 | list($toCache, $async, $defer) = array_pad((array) cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400), 3, null); |
3769 | 3998 | |
3770 | 3999 | // Already done? |
3771 | - if (!empty($toCache)) |
|
3772 | - return array('smf_minified' => array( |
|
4000 | + if (!empty($toCache)) { |
|
4001 | + return array('smf_minified' => array( |
|
3773 | 4002 | 'fileUrl' => $settings['theme_url'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/' . basename($toCache), |
3774 | 4003 | 'filePath' => $toCache, |
3775 | 4004 | 'fileName' => basename($toCache), |
3776 | 4005 | 'options' => array('async' => !empty($async), 'defer' => !empty($defer)), |
3777 | 4006 | )); |
4007 | + } |
|
3778 | 4008 | |
3779 | 4009 | |
3780 | 4010 | // No namespaces, sorry! |
@@ -3804,9 +4034,9 @@ discard block |
||
3804 | 4034 | |
3805 | 4035 | foreach ($data as $id => $file) |
3806 | 4036 | { |
3807 | - if (empty($file['filePath'])) |
|
3808 | - $toAdd = false; |
|
3809 | - else |
|
4037 | + if (empty($file['filePath'])) { |
|
4038 | + $toAdd = false; |
|
4039 | + } else |
|
3810 | 4040 | { |
3811 | 4041 | $seed = isset($file['options']['seed']) ? $file['options']['seed'] : ''; |
3812 | 4042 | $tempFile = str_replace($seed, '', $file['filePath']); |
@@ -3814,12 +4044,14 @@ discard block |
||
3814 | 4044 | } |
3815 | 4045 | |
3816 | 4046 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
3817 | - if (empty($file['options']['async'])) |
|
3818 | - $async = false; |
|
4047 | + if (empty($file['options']['async'])) { |
|
4048 | + $async = false; |
|
4049 | + } |
|
3819 | 4050 | |
3820 | 4051 | // A minified script should only be deferred if all its components wanted to be. |
3821 | - if (empty($file['options']['defer'])) |
|
3822 | - $defer = false; |
|
4052 | + if (empty($file['options']['defer'])) { |
|
4053 | + $defer = false; |
|
4054 | + } |
|
3823 | 4055 | |
3824 | 4056 | // The file couldn't be located so it won't be added. Log this error. |
3825 | 4057 | if (empty($toAdd)) |
@@ -3885,12 +4117,14 @@ discard block |
||
3885 | 4117 | foreach (glob(rtrim($theme['dir'], '/') . '/' . ($type == 'css' ? 'css' : 'scripts') . '/minified*.' . $type) as $filename) |
3886 | 4118 | { |
3887 | 4119 | // Remove the cache entry |
3888 | - if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) |
|
3889 | - cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
4120 | + if (preg_match('~([a-zA-Z0-9]+)\.' . $type . '$~', $filename, $matches)) { |
|
4121 | + cache_put_data('minimized_' . $theme['id'] . '_' . $type . '_' . $matches[1], null); |
|
4122 | + } |
|
3890 | 4123 | |
3891 | 4124 | // Try to delete the file. Add it to our error list if it fails. |
3892 | - if (!@unlink($filename)) |
|
3893 | - $not_deleted[] = $filename; |
|
4125 | + if (!@unlink($filename)) { |
|
4126 | + $not_deleted[] = $filename; |
|
4127 | + } |
|
3894 | 4128 | } |
3895 | 4129 | } |
3896 | 4130 | } |
@@ -3922,8 +4156,9 @@ discard block |
||
3922 | 4156 | global $modSettings, $smcFunc; |
3923 | 4157 | |
3924 | 4158 | // Just make up a nice hash... |
3925 | - if ($new) |
|
3926 | - return sha1(md5($filename . time()) . mt_rand()); |
|
4159 | + if ($new) { |
|
4160 | + return sha1(md5($filename . time()) . mt_rand()); |
|
4161 | + } |
|
3927 | 4162 | |
3928 | 4163 | // Just make sure that attachment id is only a int |
3929 | 4164 | $attachment_id = (int) $attachment_id; |
@@ -3940,23 +4175,25 @@ discard block |
||
3940 | 4175 | 'id_attach' => $attachment_id, |
3941 | 4176 | )); |
3942 | 4177 | |
3943 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3944 | - return false; |
|
4178 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4179 | + return false; |
|
4180 | + } |
|
3945 | 4181 | |
3946 | 4182 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3947 | 4183 | $smcFunc['db_free_result']($request); |
3948 | 4184 | } |
3949 | 4185 | |
3950 | 4186 | // Still no hash? mmm... |
3951 | - if (empty($file_hash)) |
|
3952 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4187 | + if (empty($file_hash)) { |
|
4188 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4189 | + } |
|
3953 | 4190 | |
3954 | 4191 | // Are we using multiple directories? |
3955 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3956 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3957 | - |
|
3958 | - else |
|
3959 | - $path = $modSettings['attachmentUploadDir']; |
|
4192 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4193 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4194 | + } else { |
|
4195 | + $path = $modSettings['attachmentUploadDir']; |
|
4196 | + } |
|
3960 | 4197 | |
3961 | 4198 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3962 | 4199 | } |
@@ -3971,8 +4208,9 @@ discard block |
||
3971 | 4208 | function ip2range($fullip) |
3972 | 4209 | { |
3973 | 4210 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3974 | - if ($fullip == 'unknown') |
|
3975 | - $fullip = '255.255.255.255'; |
|
4211 | + if ($fullip == 'unknown') { |
|
4212 | + $fullip = '255.255.255.255'; |
|
4213 | + } |
|
3976 | 4214 | |
3977 | 4215 | $ip_parts = explode('-', $fullip); |
3978 | 4216 | $ip_array = array(); |
@@ -3996,10 +4234,11 @@ discard block |
||
3996 | 4234 | $ip_array['low'] = $ip_parts[0]; |
3997 | 4235 | $ip_array['high'] = $ip_parts[1]; |
3998 | 4236 | return $ip_array; |
3999 | - } |
|
4000 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4237 | + } elseif (count($ip_parts) == 2) { |
|
4238 | + // if ip 22.22.*-22.22.* |
|
4001 | 4239 | { |
4002 | 4240 | $valid_low = isValidIP($ip_parts[0]); |
4241 | + } |
|
4003 | 4242 | $valid_high = isValidIP($ip_parts[1]); |
4004 | 4243 | $count = 0; |
4005 | 4244 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -4014,7 +4253,9 @@ discard block |
||
4014 | 4253 | $ip_parts[0] .= $mode . $min; |
4015 | 4254 | $valid_low = isValidIP($ip_parts[0]); |
4016 | 4255 | $count++; |
4017 | - if ($count > 9) break; |
|
4256 | + if ($count > 9) { |
|
4257 | + break; |
|
4258 | + } |
|
4018 | 4259 | } |
4019 | 4260 | } |
4020 | 4261 | |
@@ -4028,7 +4269,9 @@ discard block |
||
4028 | 4269 | $ip_parts[1] .= $mode . $max; |
4029 | 4270 | $valid_high = isValidIP($ip_parts[1]); |
4030 | 4271 | $count++; |
4031 | - if ($count > 9) break; |
|
4272 | + if ($count > 9) { |
|
4273 | + break; |
|
4274 | + } |
|
4032 | 4275 | } |
4033 | 4276 | } |
4034 | 4277 | |
@@ -4052,46 +4295,54 @@ discard block |
||
4052 | 4295 | { |
4053 | 4296 | global $modSettings; |
4054 | 4297 | |
4055 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
4056 | - return $host; |
|
4298 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4299 | + return $host; |
|
4300 | + } |
|
4057 | 4301 | $t = microtime(); |
4058 | 4302 | |
4059 | 4303 | // Try the Linux host command, perhaps? |
4060 | 4304 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
4061 | 4305 | { |
4062 | - if (!isset($modSettings['host_to_dis'])) |
|
4063 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4064 | - else |
|
4065 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4306 | + if (!isset($modSettings['host_to_dis'])) { |
|
4307 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4308 | + } else { |
|
4309 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4310 | + } |
|
4066 | 4311 | |
4067 | 4312 | // Did host say it didn't find anything? |
4068 | - if (strpos($test, 'not found') !== false) |
|
4069 | - $host = ''; |
|
4313 | + if (strpos($test, 'not found') !== false) { |
|
4314 | + $host = ''; |
|
4315 | + } |
|
4070 | 4316 | // Invalid server option? |
4071 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
4072 | - updateSettings(array('host_to_dis' => 1)); |
|
4317 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4318 | + updateSettings(array('host_to_dis' => 1)); |
|
4319 | + } |
|
4073 | 4320 | // Maybe it found something, after all? |
4074 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
4075 | - $host = $match[1]; |
|
4321 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4322 | + $host = $match[1]; |
|
4323 | + } |
|
4076 | 4324 | } |
4077 | 4325 | |
4078 | 4326 | // This is nslookup; usually only Windows, but possibly some Unix? |
4079 | 4327 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
4080 | 4328 | { |
4081 | 4329 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
4082 | - if (strpos($test, 'Non-existent domain') !== false) |
|
4083 | - $host = ''; |
|
4084 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
4085 | - $host = $match[1]; |
|
4330 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4331 | + $host = ''; |
|
4332 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4333 | + $host = $match[1]; |
|
4334 | + } |
|
4086 | 4335 | } |
4087 | 4336 | |
4088 | 4337 | // This is the last try :/. |
4089 | - if (!isset($host) || $host === false) |
|
4090 | - $host = @gethostbyaddr($ip); |
|
4338 | + if (!isset($host) || $host === false) { |
|
4339 | + $host = @gethostbyaddr($ip); |
|
4340 | + } |
|
4091 | 4341 | |
4092 | 4342 | // It took a long time, so let's cache it! |
4093 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
4094 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4343 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4344 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4345 | + } |
|
4095 | 4346 | |
4096 | 4347 | return $host; |
4097 | 4348 | } |
@@ -4127,20 +4378,21 @@ discard block |
||
4127 | 4378 | { |
4128 | 4379 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
4129 | 4380 | $total = 0; |
4130 | - for ($i = 0; $i < $max_chars; $i++) |
|
4131 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4381 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4382 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4383 | + } |
|
4132 | 4384 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
4133 | 4385 | } |
4134 | 4386 | } |
4135 | 4387 | return array_unique($returned_ints); |
4136 | - } |
|
4137 | - else |
|
4388 | + } else |
|
4138 | 4389 | { |
4139 | 4390 | // Trim characters before and after and add slashes for database insertion. |
4140 | 4391 | $returned_words = array(); |
4141 | - foreach ($words as $word) |
|
4142 | - if (($word = trim($word, '-_\'')) !== '') |
|
4392 | + foreach ($words as $word) { |
|
4393 | + if (($word = trim($word, '-_\'')) !== '') |
|
4143 | 4394 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4395 | + } |
|
4144 | 4396 | |
4145 | 4397 | // Filter out all words that occur more than once. |
4146 | 4398 | return array_unique($returned_words); |
@@ -4162,16 +4414,18 @@ discard block |
||
4162 | 4414 | global $settings, $txt; |
4163 | 4415 | |
4164 | 4416 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4165 | - if (function_exists('template_create_button') && !$force_use) |
|
4166 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4417 | + if (function_exists('template_create_button') && !$force_use) { |
|
4418 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4419 | + } |
|
4167 | 4420 | |
4168 | - if (!$settings['use_image_buttons']) |
|
4169 | - return $txt[$alt]; |
|
4170 | - elseif (!empty($settings['use_buttons'])) |
|
4171 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4172 | - else |
|
4173 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4174 | -} |
|
4421 | + if (!$settings['use_image_buttons']) { |
|
4422 | + return $txt[$alt]; |
|
4423 | + } elseif (!empty($settings['use_buttons'])) { |
|
4424 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4425 | + } else { |
|
4426 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4427 | + } |
|
4428 | + } |
|
4175 | 4429 | |
4176 | 4430 | /** |
4177 | 4431 | * Sets up all of the top menu buttons |
@@ -4214,9 +4468,10 @@ discard block |
||
4214 | 4468 | var user_menus = new smc_PopupMenu(); |
4215 | 4469 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4216 | 4470 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4217 | - if ($context['allow_pm']) |
|
4218 | - addInlineJavaScript(' |
|
4471 | + if ($context['allow_pm']) { |
|
4472 | + addInlineJavaScript(' |
|
4219 | 4473 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4474 | + } |
|
4220 | 4475 | |
4221 | 4476 | if (!empty($modSettings['enable_ajax_alerts'])) |
4222 | 4477 | { |
@@ -4376,88 +4631,96 @@ discard block |
||
4376 | 4631 | |
4377 | 4632 | // Now we put the buttons in the context so the theme can use them. |
4378 | 4633 | $menu_buttons = array(); |
4379 | - foreach ($buttons as $act => $button) |
|
4380 | - if (!empty($button['show'])) |
|
4634 | + foreach ($buttons as $act => $button) { |
|
4635 | + if (!empty($button['show'])) |
|
4381 | 4636 | { |
4382 | 4637 | $button['active_button'] = false; |
4638 | + } |
|
4383 | 4639 | |
4384 | 4640 | // This button needs some action. |
4385 | - if (isset($button['action_hook'])) |
|
4386 | - $needs_action_hook = true; |
|
4641 | + if (isset($button['action_hook'])) { |
|
4642 | + $needs_action_hook = true; |
|
4643 | + } |
|
4387 | 4644 | |
4388 | 4645 | // Make sure the last button truly is the last button. |
4389 | 4646 | if (!empty($button['is_last'])) |
4390 | 4647 | { |
4391 | - if (isset($last_button)) |
|
4392 | - unset($menu_buttons[$last_button]['is_last']); |
|
4648 | + if (isset($last_button)) { |
|
4649 | + unset($menu_buttons[$last_button]['is_last']); |
|
4650 | + } |
|
4393 | 4651 | $last_button = $act; |
4394 | 4652 | } |
4395 | 4653 | |
4396 | 4654 | // Go through the sub buttons if there are any. |
4397 | - if (!empty($button['sub_buttons'])) |
|
4398 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4655 | + if (!empty($button['sub_buttons'])) { |
|
4656 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4399 | 4657 | { |
4400 | 4658 | if (empty($subbutton['show'])) |
4401 | 4659 | unset($button['sub_buttons'][$key]); |
4660 | + } |
|
4402 | 4661 | |
4403 | 4662 | // 2nd level sub buttons next... |
4404 | 4663 | if (!empty($subbutton['sub_buttons'])) |
4405 | 4664 | { |
4406 | 4665 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4407 | 4666 | { |
4408 | - if (empty($sub_button2['show'])) |
|
4409 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4667 | + if (empty($sub_button2['show'])) { |
|
4668 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4669 | + } |
|
4410 | 4670 | } |
4411 | 4671 | } |
4412 | 4672 | } |
4413 | 4673 | |
4414 | 4674 | // Does this button have its own icon? |
4415 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4416 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4417 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4418 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4419 | - elseif (isset($button['icon'])) |
|
4420 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4421 | - else |
|
4422 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4675 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4676 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4677 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4678 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4679 | + } elseif (isset($button['icon'])) { |
|
4680 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4681 | + } else { |
|
4682 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4683 | + } |
|
4423 | 4684 | |
4424 | 4685 | $menu_buttons[$act] = $button; |
4425 | 4686 | } |
4426 | 4687 | |
4427 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4428 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4688 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4689 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4690 | + } |
|
4429 | 4691 | } |
4430 | 4692 | |
4431 | 4693 | $context['menu_buttons'] = $menu_buttons; |
4432 | 4694 | |
4433 | 4695 | // Logging out requires the session id in the url. |
4434 | - if (isset($context['menu_buttons']['logout'])) |
|
4435 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4696 | + if (isset($context['menu_buttons']['logout'])) { |
|
4697 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4698 | + } |
|
4436 | 4699 | |
4437 | 4700 | // Figure out which action we are doing so we can set the active tab. |
4438 | 4701 | // Default to home. |
4439 | 4702 | $current_action = 'home'; |
4440 | 4703 | |
4441 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4442 | - $current_action = $context['current_action']; |
|
4443 | - elseif ($context['current_action'] == 'search2') |
|
4444 | - $current_action = 'search'; |
|
4445 | - elseif ($context['current_action'] == 'theme') |
|
4446 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4447 | - elseif ($context['current_action'] == 'register2') |
|
4448 | - $current_action = 'register'; |
|
4449 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4450 | - $current_action = 'login'; |
|
4451 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4452 | - $current_action = 'moderate'; |
|
4704 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4705 | + $current_action = $context['current_action']; |
|
4706 | + } elseif ($context['current_action'] == 'search2') { |
|
4707 | + $current_action = 'search'; |
|
4708 | + } elseif ($context['current_action'] == 'theme') { |
|
4709 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4710 | + } elseif ($context['current_action'] == 'register2') { |
|
4711 | + $current_action = 'register'; |
|
4712 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4713 | + $current_action = 'login'; |
|
4714 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4715 | + $current_action = 'moderate'; |
|
4716 | + } |
|
4453 | 4717 | |
4454 | 4718 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4455 | 4719 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4456 | 4720 | { |
4457 | 4721 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4458 | 4722 | $context[$current_action] = true; |
4459 | - } |
|
4460 | - elseif ($context['current_action'] == 'pm') |
|
4723 | + } elseif ($context['current_action'] == 'pm') |
|
4461 | 4724 | { |
4462 | 4725 | $current_action = 'self_pm'; |
4463 | 4726 | $context['self_pm'] = true; |
@@ -4514,12 +4777,14 @@ discard block |
||
4514 | 4777 | } |
4515 | 4778 | |
4516 | 4779 | // Not all actions are simple. |
4517 | - if (!empty($needs_action_hook)) |
|
4518 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4780 | + if (!empty($needs_action_hook)) { |
|
4781 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4782 | + } |
|
4519 | 4783 | |
4520 | - if (isset($context['menu_buttons'][$current_action])) |
|
4521 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4522 | -} |
|
4784 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4785 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4786 | + } |
|
4787 | + } |
|
4523 | 4788 | |
4524 | 4789 | /** |
4525 | 4790 | * Generate a random seed and ensure it's stored in settings. |
@@ -4543,30 +4808,35 @@ discard block |
||
4543 | 4808 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4544 | 4809 | global $context, $txt; |
4545 | 4810 | |
4546 | - if ($db_show_debug === true) |
|
4547 | - $context['debug']['hooks'][] = $hook; |
|
4811 | + if ($db_show_debug === true) { |
|
4812 | + $context['debug']['hooks'][] = $hook; |
|
4813 | + } |
|
4548 | 4814 | |
4549 | 4815 | // Need to have some control. |
4550 | - if (!isset($context['instances'])) |
|
4551 | - $context['instances'] = array(); |
|
4816 | + if (!isset($context['instances'])) { |
|
4817 | + $context['instances'] = array(); |
|
4818 | + } |
|
4552 | 4819 | |
4553 | 4820 | $results = array(); |
4554 | - if (empty($modSettings[$hook])) |
|
4555 | - return $results; |
|
4821 | + if (empty($modSettings[$hook])) { |
|
4822 | + return $results; |
|
4823 | + } |
|
4556 | 4824 | |
4557 | 4825 | $functions = explode(',', $modSettings[$hook]); |
4558 | 4826 | // Loop through each function. |
4559 | 4827 | foreach ($functions as $function) |
4560 | 4828 | { |
4561 | 4829 | // Hook has been marked as "disabled". Skip it! |
4562 | - if (strpos($function, '!') !== false) |
|
4563 | - continue; |
|
4830 | + if (strpos($function, '!') !== false) { |
|
4831 | + continue; |
|
4832 | + } |
|
4564 | 4833 | |
4565 | 4834 | $call = call_helper($function, true); |
4566 | 4835 | |
4567 | 4836 | // Is it valid? |
4568 | - if (!empty($call)) |
|
4569 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4837 | + if (!empty($call)) { |
|
4838 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4839 | + } |
|
4570 | 4840 | |
4571 | 4841 | // Whatever it was suppose to call, it failed :( |
4572 | 4842 | elseif (!empty($function)) |
@@ -4582,8 +4852,9 @@ discard block |
||
4582 | 4852 | } |
4583 | 4853 | |
4584 | 4854 | // "Assume" the file resides on $boarddir somewhere... |
4585 | - else |
|
4586 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4855 | + else { |
|
4856 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4857 | + } |
|
4587 | 4858 | } |
4588 | 4859 | } |
4589 | 4860 | |
@@ -4605,12 +4876,14 @@ discard block |
||
4605 | 4876 | global $smcFunc, $modSettings; |
4606 | 4877 | |
4607 | 4878 | // Any objects? |
4608 | - if ($object) |
|
4609 | - $function = $function . '#'; |
|
4879 | + if ($object) { |
|
4880 | + $function = $function . '#'; |
|
4881 | + } |
|
4610 | 4882 | |
4611 | 4883 | // Any files to load? |
4612 | - if (!empty($file) && is_string($file)) |
|
4613 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4884 | + if (!empty($file) && is_string($file)) { |
|
4885 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4886 | + } |
|
4614 | 4887 | |
4615 | 4888 | // Get the correct string. |
4616 | 4889 | $integration_call = $function; |
@@ -4632,13 +4905,14 @@ discard block |
||
4632 | 4905 | if (!empty($current_functions)) |
4633 | 4906 | { |
4634 | 4907 | $current_functions = explode(',', $current_functions); |
4635 | - if (in_array($integration_call, $current_functions)) |
|
4636 | - return; |
|
4908 | + if (in_array($integration_call, $current_functions)) { |
|
4909 | + return; |
|
4910 | + } |
|
4637 | 4911 | |
4638 | 4912 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4913 | + } else { |
|
4914 | + $permanent_functions = array($integration_call); |
|
4639 | 4915 | } |
4640 | - else |
|
4641 | - $permanent_functions = array($integration_call); |
|
4642 | 4916 | |
4643 | 4917 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4644 | 4918 | } |
@@ -4647,8 +4921,9 @@ discard block |
||
4647 | 4921 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4648 | 4922 | |
4649 | 4923 | // Do nothing, if it's already there. |
4650 | - if (in_array($integration_call, $functions)) |
|
4651 | - return; |
|
4924 | + if (in_array($integration_call, $functions)) { |
|
4925 | + return; |
|
4926 | + } |
|
4652 | 4927 | |
4653 | 4928 | $functions[] = $integration_call; |
4654 | 4929 | $modSettings[$hook] = implode(',', $functions); |
@@ -4671,12 +4946,14 @@ discard block |
||
4671 | 4946 | global $smcFunc, $modSettings; |
4672 | 4947 | |
4673 | 4948 | // Any objects? |
4674 | - if ($object) |
|
4675 | - $function = $function . '#'; |
|
4949 | + if ($object) { |
|
4950 | + $function = $function . '#'; |
|
4951 | + } |
|
4676 | 4952 | |
4677 | 4953 | // Any files to load? |
4678 | - if (!empty($file) && is_string($file)) |
|
4679 | - $function = $file . '|' . $function; |
|
4954 | + if (!empty($file) && is_string($file)) { |
|
4955 | + $function = $file . '|' . $function; |
|
4956 | + } |
|
4680 | 4957 | |
4681 | 4958 | // Get the correct string. |
4682 | 4959 | $integration_call = $function; |
@@ -4697,16 +4974,18 @@ discard block |
||
4697 | 4974 | { |
4698 | 4975 | $current_functions = explode(',', $current_functions); |
4699 | 4976 | |
4700 | - if (in_array($integration_call, $current_functions)) |
|
4701 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4977 | + if (in_array($integration_call, $current_functions)) { |
|
4978 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4979 | + } |
|
4702 | 4980 | } |
4703 | 4981 | |
4704 | 4982 | // Turn the function list into something usable. |
4705 | 4983 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4706 | 4984 | |
4707 | 4985 | // You can only remove it if it's available. |
4708 | - if (!in_array($integration_call, $functions)) |
|
4709 | - return; |
|
4986 | + if (!in_array($integration_call, $functions)) { |
|
4987 | + return; |
|
4988 | + } |
|
4710 | 4989 | |
4711 | 4990 | $functions = array_diff($functions, array($integration_call)); |
4712 | 4991 | $modSettings[$hook] = implode(',', $functions); |
@@ -4727,17 +5006,20 @@ discard block |
||
4727 | 5006 | global $context, $smcFunc, $txt, $db_show_debug; |
4728 | 5007 | |
4729 | 5008 | // Really? |
4730 | - if (empty($string)) |
|
4731 | - return false; |
|
5009 | + if (empty($string)) { |
|
5010 | + return false; |
|
5011 | + } |
|
4732 | 5012 | |
4733 | 5013 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4734 | 5014 | // A closure? should be a callable one. |
4735 | - if (is_array($string) || $string instanceof Closure) |
|
4736 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
5015 | + if (is_array($string) || $string instanceof Closure) { |
|
5016 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
5017 | + } |
|
4737 | 5018 | |
4738 | 5019 | // No full objects, sorry! pass a method or a property instead! |
4739 | - if (is_object($string)) |
|
4740 | - return false; |
|
5020 | + if (is_object($string)) { |
|
5021 | + return false; |
|
5022 | + } |
|
4741 | 5023 | |
4742 | 5024 | // Stay vitaminized my friends... |
4743 | 5025 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4746,8 +5028,9 @@ discard block |
||
4746 | 5028 | $string = load_file($string); |
4747 | 5029 | |
4748 | 5030 | // Loaded file failed |
4749 | - if (empty($string)) |
|
4750 | - return false; |
|
5031 | + if (empty($string)) { |
|
5032 | + return false; |
|
5033 | + } |
|
4751 | 5034 | |
4752 | 5035 | // Found a method. |
4753 | 5036 | if (strpos($string, '::') !== false) |
@@ -4768,8 +5051,9 @@ discard block |
||
4768 | 5051 | // Add another one to the list. |
4769 | 5052 | if ($db_show_debug === true) |
4770 | 5053 | { |
4771 | - if (!isset($context['debug']['instances'])) |
|
4772 | - $context['debug']['instances'] = array(); |
|
5054 | + if (!isset($context['debug']['instances'])) { |
|
5055 | + $context['debug']['instances'] = array(); |
|
5056 | + } |
|
4773 | 5057 | |
4774 | 5058 | $context['debug']['instances'][$class] = $class; |
4775 | 5059 | } |
@@ -4779,13 +5063,15 @@ discard block |
||
4779 | 5063 | } |
4780 | 5064 | |
4781 | 5065 | // Right then. This is a call to a static method. |
4782 | - else |
|
4783 | - $func = array($class, $method); |
|
5066 | + else { |
|
5067 | + $func = array($class, $method); |
|
5068 | + } |
|
4784 | 5069 | } |
4785 | 5070 | |
4786 | 5071 | // Nope! just a plain regular function. |
4787 | - else |
|
4788 | - $func = $string; |
|
5072 | + else { |
|
5073 | + $func = $string; |
|
5074 | + } |
|
4789 | 5075 | |
4790 | 5076 | // Right, we got what we need, time to do some checks. |
4791 | 5077 | if (!is_callable($func, false, $callable_name)) |
@@ -4801,17 +5087,18 @@ discard block |
||
4801 | 5087 | else |
4802 | 5088 | { |
4803 | 5089 | // What are we gonna do about it? |
4804 | - if ($return) |
|
4805 | - return $func; |
|
5090 | + if ($return) { |
|
5091 | + return $func; |
|
5092 | + } |
|
4806 | 5093 | |
4807 | 5094 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4808 | 5095 | else |
4809 | 5096 | { |
4810 | - if (is_array($func)) |
|
4811 | - call_user_func($func); |
|
4812 | - |
|
4813 | - else |
|
4814 | - $func(); |
|
5097 | + if (is_array($func)) { |
|
5098 | + call_user_func($func); |
|
5099 | + } else { |
|
5100 | + $func(); |
|
5101 | + } |
|
4815 | 5102 | } |
4816 | 5103 | } |
4817 | 5104 | } |
@@ -4828,31 +5115,34 @@ discard block |
||
4828 | 5115 | { |
4829 | 5116 | global $sourcedir, $txt, $boarddir, $settings; |
4830 | 5117 | |
4831 | - if (empty($string)) |
|
4832 | - return false; |
|
5118 | + if (empty($string)) { |
|
5119 | + return false; |
|
5120 | + } |
|
4833 | 5121 | |
4834 | 5122 | if (strpos($string, '|') !== false) |
4835 | 5123 | { |
4836 | 5124 | list ($file, $string) = explode('|', $string); |
4837 | 5125 | |
4838 | 5126 | // Match the wildcards to their regular vars. |
4839 | - if (empty($settings['theme_dir'])) |
|
4840 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4841 | - |
|
4842 | - else |
|
4843 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5127 | + if (empty($settings['theme_dir'])) { |
|
5128 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
5129 | + } else { |
|
5130 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5131 | + } |
|
4844 | 5132 | |
4845 | 5133 | // Load the file if it can be loaded. |
4846 | - if (file_exists($absPath)) |
|
4847 | - require_once($absPath); |
|
5134 | + if (file_exists($absPath)) { |
|
5135 | + require_once($absPath); |
|
5136 | + } |
|
4848 | 5137 | |
4849 | 5138 | // No? try a fallback to $sourcedir |
4850 | 5139 | else |
4851 | 5140 | { |
4852 | 5141 | $absPath = $sourcedir .'/'. $file; |
4853 | 5142 | |
4854 | - if (file_exists($absPath)) |
|
4855 | - require_once($absPath); |
|
5143 | + if (file_exists($absPath)) { |
|
5144 | + require_once($absPath); |
|
5145 | + } |
|
4856 | 5146 | |
4857 | 5147 | // Sorry, can't do much for you at this point. |
4858 | 5148 | else |
@@ -4891,8 +5181,9 @@ discard block |
||
4891 | 5181 | preg_match('~^(http|ftp)(s)?://([^/:]+)(:(\d+))?(.+)$~', $url, $match); |
4892 | 5182 | |
4893 | 5183 | // No scheme? No data for you! |
4894 | - if (empty($match[1])) |
|
4895 | - return false; |
|
5184 | + if (empty($match[1])) { |
|
5185 | + return false; |
|
5186 | + } |
|
4896 | 5187 | |
4897 | 5188 | // An FTP url. We should try connecting and RETRieving it... |
4898 | 5189 | elseif ($match[1] == 'ftp') |
@@ -4902,23 +5193,26 @@ discard block |
||
4902 | 5193 | |
4903 | 5194 | // Establish a connection and attempt to enable passive mode. |
4904 | 5195 | $ftp = new ftp_connection(($match[2] ? 'ssl://' : '') . $match[3], empty($match[5]) ? 21 : $match[5], 'anonymous', $webmaster_email); |
4905 | - if ($ftp->error !== false || !$ftp->passive()) |
|
4906 | - return false; |
|
5196 | + if ($ftp->error !== false || !$ftp->passive()) { |
|
5197 | + return false; |
|
5198 | + } |
|
4907 | 5199 | |
4908 | 5200 | // I want that one *points*! |
4909 | 5201 | fwrite($ftp->connection, 'RETR ' . $match[6] . "\r\n"); |
4910 | 5202 | |
4911 | 5203 | // Since passive mode worked (or we would have returned already!) open the connection. |
4912 | 5204 | $fp = @fsockopen($ftp->pasv['ip'], $ftp->pasv['port'], $err, $err, 5); |
4913 | - if (!$fp) |
|
4914 | - return false; |
|
5205 | + if (!$fp) { |
|
5206 | + return false; |
|
5207 | + } |
|
4915 | 5208 | |
4916 | 5209 | // The server should now say something in acknowledgement. |
4917 | 5210 | $ftp->check_response(150); |
4918 | 5211 | |
4919 | 5212 | $data = ''; |
4920 | - while (!feof($fp)) |
|
4921 | - $data .= fread($fp, 4096); |
|
5213 | + while (!feof($fp)) { |
|
5214 | + $data .= fread($fp, 4096); |
|
5215 | + } |
|
4922 | 5216 | fclose($fp); |
4923 | 5217 | |
4924 | 5218 | // All done, right? Good. |
@@ -4930,8 +5224,9 @@ discard block |
||
4930 | 5224 | elseif (isset($match[1]) && $match[1] == 'http') |
4931 | 5225 | { |
4932 | 5226 | // First try to use fsockopen, because it is fastest. |
4933 | - if ($keep_alive && $match[3] == $keep_alive_dom) |
|
4934 | - $fp = $keep_alive_fp; |
|
5227 | + if ($keep_alive && $match[3] == $keep_alive_dom) { |
|
5228 | + $fp = $keep_alive_fp; |
|
5229 | + } |
|
4935 | 5230 | if (empty($fp)) |
4936 | 5231 | { |
4937 | 5232 | // Open the socket on the port we want... |
@@ -4951,20 +5246,21 @@ discard block |
||
4951 | 5246 | fwrite($fp, 'GET ' . ($match[6] !== '/' ? str_replace(' ', '%20', $match[6]) : '') . ' HTTP/1.0' . "\r\n"); |
4952 | 5247 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4953 | 5248 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4954 | - if ($keep_alive) |
|
4955 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
4956 | - else |
|
4957 | - fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
4958 | - } |
|
4959 | - else |
|
5249 | + if ($keep_alive) { |
|
5250 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n\r\n"); |
|
5251 | + } else { |
|
5252 | + fwrite($fp, 'connection: close' . "\r\n\r\n"); |
|
5253 | + } |
|
5254 | + } else |
|
4960 | 5255 | { |
4961 | 5256 | fwrite($fp, 'POST ' . ($match[6] !== '/' ? $match[6] : '') . ' HTTP/1.0' . "\r\n"); |
4962 | 5257 | fwrite($fp, 'Host: ' . $match[3] . (empty($match[5]) ? ($match[2] ? ':443' : '') : ':' . $match[5]) . "\r\n"); |
4963 | 5258 | fwrite($fp, 'user-agent: PHP/SMF' . "\r\n"); |
4964 | - if ($keep_alive) |
|
4965 | - fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
4966 | - else |
|
4967 | - fwrite($fp, 'connection: close' . "\r\n"); |
|
5259 | + if ($keep_alive) { |
|
5260 | + fwrite($fp, 'connection: Keep-Alive' . "\r\n"); |
|
5261 | + } else { |
|
5262 | + fwrite($fp, 'connection: close' . "\r\n"); |
|
5263 | + } |
|
4968 | 5264 | fwrite($fp, 'content-type: application/x-www-form-urlencoded' . "\r\n"); |
4969 | 5265 | fwrite($fp, 'content-length: ' . strlen($post_data) . "\r\n\r\n"); |
4970 | 5266 | fwrite($fp, $post_data); |
@@ -4977,30 +5273,33 @@ discard block |
||
4977 | 5273 | { |
4978 | 5274 | $header = ''; |
4979 | 5275 | $location = ''; |
4980 | - while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
|
4981 | - if (strpos($header, 'location:') !== false) |
|
5276 | + while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') { |
|
5277 | + if (strpos($header, 'location:') !== false) |
|
4982 | 5278 | $location = trim(substr($header, strpos($header, ':') + 1)); |
5279 | + } |
|
4983 | 5280 | |
4984 | - if (empty($location)) |
|
4985 | - return false; |
|
4986 | - else |
|
5281 | + if (empty($location)) { |
|
5282 | + return false; |
|
5283 | + } else |
|
4987 | 5284 | { |
4988 | - if (!$keep_alive) |
|
4989 | - fclose($fp); |
|
5285 | + if (!$keep_alive) { |
|
5286 | + fclose($fp); |
|
5287 | + } |
|
4990 | 5288 | return fetch_web_data($location, $post_data, $keep_alive, $redirection_level + 1); |
4991 | 5289 | } |
4992 | 5290 | } |
4993 | 5291 | |
4994 | 5292 | // Make sure we get a 200 OK. |
4995 | - elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) |
|
4996 | - return false; |
|
5293 | + elseif (preg_match('~^HTTP/\S+\s+20[01]~i', $response) === 0) { |
|
5294 | + return false; |
|
5295 | + } |
|
4997 | 5296 | |
4998 | 5297 | // Skip the headers... |
4999 | 5298 | while (!feof($fp) && trim($header = fgets($fp, 4096)) != '') |
5000 | 5299 | { |
5001 | - if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) |
|
5002 | - $content_length = $match[1]; |
|
5003 | - elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
5300 | + if (preg_match('~content-length:\s*(\d+)~i', $header, $match) != 0) { |
|
5301 | + $content_length = $match[1]; |
|
5302 | + } elseif (preg_match('~connection:\s*close~i', $header) != 0) |
|
5004 | 5303 | { |
5005 | 5304 | $keep_alive_dom = null; |
5006 | 5305 | $keep_alive = false; |
@@ -5012,17 +5311,19 @@ discard block |
||
5012 | 5311 | $data = ''; |
5013 | 5312 | if (isset($content_length)) |
5014 | 5313 | { |
5015 | - while (!feof($fp) && strlen($data) < $content_length) |
|
5016 | - $data .= fread($fp, $content_length - strlen($data)); |
|
5017 | - } |
|
5018 | - else |
|
5314 | + while (!feof($fp) && strlen($data) < $content_length) { |
|
5315 | + $data .= fread($fp, $content_length - strlen($data)); |
|
5316 | + } |
|
5317 | + } else |
|
5019 | 5318 | { |
5020 | - while (!feof($fp)) |
|
5021 | - $data .= fread($fp, 4096); |
|
5319 | + while (!feof($fp)) { |
|
5320 | + $data .= fread($fp, 4096); |
|
5321 | + } |
|
5022 | 5322 | } |
5023 | 5323 | |
5024 | - if (!$keep_alive) |
|
5025 | - fclose($fp); |
|
5324 | + if (!$keep_alive) { |
|
5325 | + fclose($fp); |
|
5326 | + } |
|
5026 | 5327 | } |
5027 | 5328 | |
5028 | 5329 | // If using fsockopen didn't work, try to use cURL if available. |
@@ -5035,17 +5336,18 @@ discard block |
||
5035 | 5336 | $fetch_data->get_url_data($url, $post_data); |
5036 | 5337 | |
5037 | 5338 | // no errors and a 200 result, then we have a good dataset, well we at least have data. ;) |
5038 | - if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) |
|
5039 | - $data = $fetch_data->result('body'); |
|
5040 | - else |
|
5041 | - return false; |
|
5339 | + if ($fetch_data->result('code') == 200 && !$fetch_data->result('error')) { |
|
5340 | + $data = $fetch_data->result('body'); |
|
5341 | + } else { |
|
5342 | + return false; |
|
5343 | + } |
|
5042 | 5344 | } |
5043 | 5345 | |
5044 | 5346 | // Neither fsockopen nor curl are available. Well, phooey. |
5045 | - else |
|
5046 | - return false; |
|
5047 | - } |
|
5048 | - else |
|
5347 | + else { |
|
5348 | + return false; |
|
5349 | + } |
|
5350 | + } else |
|
5049 | 5351 | { |
5050 | 5352 | // Umm, this shouldn't happen? |
5051 | 5353 | trigger_error('fetch_web_data(): Bad URL', E_USER_NOTICE); |
@@ -5065,8 +5367,9 @@ discard block |
||
5065 | 5367 | global $user_info, $smcFunc; |
5066 | 5368 | |
5067 | 5369 | // Make sure we have something to work with. |
5068 | - if (empty($topic)) |
|
5069 | - return array(); |
|
5370 | + if (empty($topic)) { |
|
5371 | + return array(); |
|
5372 | + } |
|
5070 | 5373 | |
5071 | 5374 | |
5072 | 5375 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -5089,8 +5392,9 @@ discard block |
||
5089 | 5392 | 'topic' => $topic, |
5090 | 5393 | ) |
5091 | 5394 | ); |
5092 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
5093 | - $temp[] = (int) $row['content_id']; |
|
5395 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5396 | + $temp[] = (int) $row['content_id']; |
|
5397 | + } |
|
5094 | 5398 | |
5095 | 5399 | cache_put_data($cache_key, $temp, $ttl); |
5096 | 5400 | } |
@@ -5111,8 +5415,9 @@ discard block |
||
5111 | 5415 | { |
5112 | 5416 | global $context; |
5113 | 5417 | |
5114 | - if (empty($string)) |
|
5115 | - return $string; |
|
5418 | + if (empty($string)) { |
|
5419 | + return $string; |
|
5420 | + } |
|
5116 | 5421 | |
5117 | 5422 | // UTF-8 occurences of MS special characters |
5118 | 5423 | $findchars_utf8 = array( |
@@ -5153,10 +5458,11 @@ discard block |
||
5153 | 5458 | '--', // — |
5154 | 5459 | ); |
5155 | 5460 | |
5156 | - if ($context['utf8']) |
|
5157 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5158 | - else |
|
5159 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5461 | + if ($context['utf8']) { |
|
5462 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5463 | + } else { |
|
5464 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5465 | + } |
|
5160 | 5466 | |
5161 | 5467 | return $string; |
5162 | 5468 | } |
@@ -5175,49 +5481,59 @@ discard block |
||
5175 | 5481 | { |
5176 | 5482 | global $context; |
5177 | 5483 | |
5178 | - if (!isset($matches[2])) |
|
5179 | - return ''; |
|
5484 | + if (!isset($matches[2])) { |
|
5485 | + return ''; |
|
5486 | + } |
|
5180 | 5487 | |
5181 | 5488 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5182 | 5489 | |
5183 | 5490 | // remove left to right / right to left overrides |
5184 | - if ($num === 0x202D || $num === 0x202E) |
|
5185 | - return ''; |
|
5491 | + if ($num === 0x202D || $num === 0x202E) { |
|
5492 | + return ''; |
|
5493 | + } |
|
5186 | 5494 | |
5187 | 5495 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
5188 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
5189 | - return '&#' . $num . ';'; |
|
5496 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5497 | + return '&#' . $num . ';'; |
|
5498 | + } |
|
5190 | 5499 | |
5191 | 5500 | if (empty($context['utf8'])) |
5192 | 5501 | { |
5193 | 5502 | // no control characters |
5194 | - if ($num < 0x20) |
|
5195 | - return ''; |
|
5503 | + if ($num < 0x20) { |
|
5504 | + return ''; |
|
5505 | + } |
|
5196 | 5506 | // text is text |
5197 | - elseif ($num < 0x80) |
|
5198 | - return chr($num); |
|
5507 | + elseif ($num < 0x80) { |
|
5508 | + return chr($num); |
|
5509 | + } |
|
5199 | 5510 | // all others get html-ised |
5200 | - else |
|
5201 | - return '&#' . $matches[2] . ';'; |
|
5202 | - } |
|
5203 | - else |
|
5511 | + else { |
|
5512 | + return '&#' . $matches[2] . ';'; |
|
5513 | + } |
|
5514 | + } else |
|
5204 | 5515 | { |
5205 | 5516 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
5206 | 5517 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
5207 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
5208 | - return ''; |
|
5518 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5519 | + return ''; |
|
5520 | + } |
|
5209 | 5521 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5210 | - elseif ($num < 0x80) |
|
5211 | - return chr($num); |
|
5522 | + elseif ($num < 0x80) { |
|
5523 | + return chr($num); |
|
5524 | + } |
|
5212 | 5525 | // <0x800 (2048) |
5213 | - elseif ($num < 0x800) |
|
5214 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5526 | + elseif ($num < 0x800) { |
|
5527 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5528 | + } |
|
5215 | 5529 | // < 0x10000 (65536) |
5216 | - elseif ($num < 0x10000) |
|
5217 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5530 | + elseif ($num < 0x10000) { |
|
5531 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5532 | + } |
|
5218 | 5533 | // <= 0x10FFFF (1114111) |
5219 | - else |
|
5220 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5534 | + else { |
|
5535 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5536 | + } |
|
5221 | 5537 | } |
5222 | 5538 | } |
5223 | 5539 | |
@@ -5233,28 +5549,34 @@ discard block |
||
5233 | 5549 | */ |
5234 | 5550 | function fixchar__callback($matches) |
5235 | 5551 | { |
5236 | - if (!isset($matches[1])) |
|
5237 | - return ''; |
|
5552 | + if (!isset($matches[1])) { |
|
5553 | + return ''; |
|
5554 | + } |
|
5238 | 5555 | |
5239 | 5556 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
5240 | 5557 | |
5241 | 5558 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
5242 | 5559 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
5243 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
5244 | - return ''; |
|
5560 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5561 | + return ''; |
|
5562 | + } |
|
5245 | 5563 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
5246 | - elseif ($num < 0x80) |
|
5247 | - return chr($num); |
|
5564 | + elseif ($num < 0x80) { |
|
5565 | + return chr($num); |
|
5566 | + } |
|
5248 | 5567 | // <0x800 (2048) |
5249 | - elseif ($num < 0x800) |
|
5250 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5568 | + elseif ($num < 0x800) { |
|
5569 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5570 | + } |
|
5251 | 5571 | // < 0x10000 (65536) |
5252 | - elseif ($num < 0x10000) |
|
5253 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5572 | + elseif ($num < 0x10000) { |
|
5573 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5574 | + } |
|
5254 | 5575 | // <= 0x10FFFF (1114111) |
5255 | - else |
|
5256 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5257 | -} |
|
5576 | + else { |
|
5577 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5578 | + } |
|
5579 | + } |
|
5258 | 5580 | |
5259 | 5581 | /** |
5260 | 5582 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -5267,17 +5589,19 @@ discard block |
||
5267 | 5589 | */ |
5268 | 5590 | function entity_fix__callback($matches) |
5269 | 5591 | { |
5270 | - if (!isset($matches[2])) |
|
5271 | - return ''; |
|
5592 | + if (!isset($matches[2])) { |
|
5593 | + return ''; |
|
5594 | + } |
|
5272 | 5595 | |
5273 | 5596 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
5274 | 5597 | |
5275 | 5598 | // we don't allow control characters, characters out of range, byte markers, etc |
5276 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
5277 | - return ''; |
|
5278 | - else |
|
5279 | - return '&#' . $num . ';'; |
|
5280 | -} |
|
5599 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5600 | + return ''; |
|
5601 | + } else { |
|
5602 | + return '&#' . $num . ';'; |
|
5603 | + } |
|
5604 | + } |
|
5281 | 5605 | |
5282 | 5606 | /** |
5283 | 5607 | * Return a Gravatar URL based on |
@@ -5301,18 +5625,23 @@ discard block |
||
5301 | 5625 | $ratings = array('G', 'PG', 'R', 'X'); |
5302 | 5626 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
5303 | 5627 | $url_params = array(); |
5304 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
5305 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5306 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
5307 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5308 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
5309 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5310 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
5311 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5628 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5629 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5630 | + } |
|
5631 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5632 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5633 | + } |
|
5634 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5635 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5636 | + } |
|
5637 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5638 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5312 | 5639 | $size_string = $modSettings['avatar_max_height_external']; |
5640 | + } |
|
5313 | 5641 | |
5314 | - if (!empty($size_string)) |
|
5315 | - $url_params[] = 's=' . $size_string; |
|
5642 | + if (!empty($size_string)) { |
|
5643 | + $url_params[] = 's=' . $size_string; |
|
5644 | + } |
|
5316 | 5645 | } |
5317 | 5646 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
5318 | 5647 | |
@@ -5331,22 +5660,26 @@ discard block |
||
5331 | 5660 | static $timezones = null, $lastwhen = null; |
5332 | 5661 | |
5333 | 5662 | // No point doing this over if we already did it once |
5334 | - if (!empty($timezones) && $when == $lastwhen) |
|
5335 | - return $timezones; |
|
5336 | - else |
|
5337 | - $lastwhen = $when; |
|
5663 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5664 | + return $timezones; |
|
5665 | + } else { |
|
5666 | + $lastwhen = $when; |
|
5667 | + } |
|
5338 | 5668 | |
5339 | 5669 | // Parseable datetime string? |
5340 | - if (is_int($timestamp = strtotime($when))) |
|
5341 | - $when = $timestamp; |
|
5670 | + if (is_int($timestamp = strtotime($when))) { |
|
5671 | + $when = $timestamp; |
|
5672 | + } |
|
5342 | 5673 | |
5343 | 5674 | // A Unix timestamp? |
5344 | - elseif (is_numeric($when)) |
|
5345 | - $when = intval($when); |
|
5675 | + elseif (is_numeric($when)) { |
|
5676 | + $when = intval($when); |
|
5677 | + } |
|
5346 | 5678 | |
5347 | 5679 | // Invalid value? Just get current Unix timestamp. |
5348 | - else |
|
5349 | - $when = time(); |
|
5680 | + else { |
|
5681 | + $when = time(); |
|
5682 | + } |
|
5350 | 5683 | |
5351 | 5684 | // We'll need these too |
5352 | 5685 | $date_when = date_create('@' . $when); |
@@ -5410,8 +5743,9 @@ discard block |
||
5410 | 5743 | foreach ($priority_countries as $country) |
5411 | 5744 | { |
5412 | 5745 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5413 | - if (!empty($country_tzids)) |
|
5414 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5746 | + if (!empty($country_tzids)) { |
|
5747 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5748 | + } |
|
5415 | 5749 | } |
5416 | 5750 | |
5417 | 5751 | // Process the preferred timezones first, then the rest. |
@@ -5421,8 +5755,9 @@ discard block |
||
5421 | 5755 | foreach ($tzids as $tzid) |
5422 | 5756 | { |
5423 | 5757 | // We don't want UTC right now |
5424 | - if ($tzid == 'UTC') |
|
5425 | - continue; |
|
5758 | + if ($tzid == 'UTC') { |
|
5759 | + continue; |
|
5760 | + } |
|
5426 | 5761 | |
5427 | 5762 | $tz = timezone_open($tzid); |
5428 | 5763 | |
@@ -5443,8 +5778,9 @@ discard block |
||
5443 | 5778 | } |
5444 | 5779 | |
5445 | 5780 | // A time zone from a prioritized country? |
5446 | - if (in_array($tzid, $priority_tzids)) |
|
5447 | - $priority_zones[$tzkey] = true; |
|
5781 | + if (in_array($tzid, $priority_tzids)) { |
|
5782 | + $priority_zones[$tzkey] = true; |
|
5783 | + } |
|
5448 | 5784 | |
5449 | 5785 | // Keep track of the location and offset for this tzid |
5450 | 5786 | $tzid_parts = explode('/', $tzid); |
@@ -5463,15 +5799,17 @@ discard block |
||
5463 | 5799 | { |
5464 | 5800 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5465 | 5801 | |
5466 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5467 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5468 | - else |
|
5469 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5802 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5803 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5804 | + } else { |
|
5805 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5806 | + } |
|
5470 | 5807 | |
5471 | - if (isset($priority_zones[$tzkey])) |
|
5472 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5473 | - else |
|
5474 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5808 | + if (isset($priority_zones[$tzkey])) { |
|
5809 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5810 | + } else { |
|
5811 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5812 | + } |
|
5475 | 5813 | } |
5476 | 5814 | |
5477 | 5815 | $timezones = array_merge( |
@@ -5525,9 +5863,9 @@ discard block |
||
5525 | 5863 | 'Indian/Kerguelen' => 'TFT', |
5526 | 5864 | ); |
5527 | 5865 | |
5528 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5529 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5530 | - else |
|
5866 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5867 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5868 | + } else |
|
5531 | 5869 | { |
5532 | 5870 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5533 | 5871 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5555,8 +5893,9 @@ discard block |
||
5555 | 5893 | */ |
5556 | 5894 | function inet_ptod($ip_address) |
5557 | 5895 | { |
5558 | - if (!isValidIP($ip_address)) |
|
5559 | - return $ip_address; |
|
5896 | + if (!isValidIP($ip_address)) { |
|
5897 | + return $ip_address; |
|
5898 | + } |
|
5560 | 5899 | |
5561 | 5900 | $bin = inet_pton($ip_address); |
5562 | 5901 | return $bin; |
@@ -5568,13 +5907,15 @@ discard block |
||
5568 | 5907 | */ |
5569 | 5908 | function inet_dtop($bin) |
5570 | 5909 | { |
5571 | - if(empty($bin)) |
|
5572 | - return ''; |
|
5910 | + if(empty($bin)) { |
|
5911 | + return ''; |
|
5912 | + } |
|
5573 | 5913 | |
5574 | 5914 | global $db_type; |
5575 | 5915 | |
5576 | - if ($db_type == 'postgresql') |
|
5577 | - return $bin; |
|
5916 | + if ($db_type == 'postgresql') { |
|
5917 | + return $bin; |
|
5918 | + } |
|
5578 | 5919 | |
5579 | 5920 | $ip_address = inet_ntop($bin); |
5580 | 5921 | |
@@ -5599,26 +5940,32 @@ discard block |
||
5599 | 5940 | */ |
5600 | 5941 | function _safe_serialize($value) |
5601 | 5942 | { |
5602 | - if(is_null($value)) |
|
5603 | - return 'N;'; |
|
5943 | + if(is_null($value)) { |
|
5944 | + return 'N;'; |
|
5945 | + } |
|
5604 | 5946 | |
5605 | - if(is_bool($value)) |
|
5606 | - return 'b:'. (int) $value .';'; |
|
5947 | + if(is_bool($value)) { |
|
5948 | + return 'b:'. (int) $value .';'; |
|
5949 | + } |
|
5607 | 5950 | |
5608 | - if(is_int($value)) |
|
5609 | - return 'i:'. $value .';'; |
|
5951 | + if(is_int($value)) { |
|
5952 | + return 'i:'. $value .';'; |
|
5953 | + } |
|
5610 | 5954 | |
5611 | - if(is_float($value)) |
|
5612 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5955 | + if(is_float($value)) { |
|
5956 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5957 | + } |
|
5613 | 5958 | |
5614 | - if(is_string($value)) |
|
5615 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5959 | + if(is_string($value)) { |
|
5960 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5961 | + } |
|
5616 | 5962 | |
5617 | 5963 | if(is_array($value)) |
5618 | 5964 | { |
5619 | 5965 | $out = ''; |
5620 | - foreach($value as $k => $v) |
|
5621 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5966 | + foreach($value as $k => $v) { |
|
5967 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5968 | + } |
|
5622 | 5969 | |
5623 | 5970 | return 'a:'. count($value) .':{'. $out .'}'; |
5624 | 5971 | } |
@@ -5644,8 +5991,9 @@ discard block |
||
5644 | 5991 | |
5645 | 5992 | $out = _safe_serialize($value); |
5646 | 5993 | |
5647 | - if (isset($mbIntEnc)) |
|
5648 | - mb_internal_encoding($mbIntEnc); |
|
5994 | + if (isset($mbIntEnc)) { |
|
5995 | + mb_internal_encoding($mbIntEnc); |
|
5996 | + } |
|
5649 | 5997 | |
5650 | 5998 | return $out; |
5651 | 5999 | } |
@@ -5662,8 +6010,9 @@ discard block |
||
5662 | 6010 | function _safe_unserialize($str) |
5663 | 6011 | { |
5664 | 6012 | // Input is not a string. |
5665 | - if(empty($str) || !is_string($str)) |
|
5666 | - return false; |
|
6013 | + if(empty($str) || !is_string($str)) { |
|
6014 | + return false; |
|
6015 | + } |
|
5667 | 6016 | |
5668 | 6017 | $stack = array(); |
5669 | 6018 | $expected = array(); |
@@ -5679,43 +6028,38 @@ discard block |
||
5679 | 6028 | while($state != 1) |
5680 | 6029 | { |
5681 | 6030 | $type = isset($str[0]) ? $str[0] : ''; |
5682 | - if($type == '}') |
|
5683 | - $str = substr($str, 1); |
|
5684 | - |
|
5685 | - else if($type == 'N' && $str[1] == ';') |
|
6031 | + if($type == '}') { |
|
6032 | + $str = substr($str, 1); |
|
6033 | + } else if($type == 'N' && $str[1] == ';') |
|
5686 | 6034 | { |
5687 | 6035 | $value = null; |
5688 | 6036 | $str = substr($str, 2); |
5689 | - } |
|
5690 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
6037 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5691 | 6038 | { |
5692 | 6039 | $value = $matches[1] == '1' ? true : false; |
5693 | 6040 | $str = substr($str, 4); |
5694 | - } |
|
5695 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
6041 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5696 | 6042 | { |
5697 | 6043 | $value = (int)$matches[1]; |
5698 | 6044 | $str = $matches[2]; |
5699 | - } |
|
5700 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
6045 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5701 | 6046 | { |
5702 | 6047 | $value = (float)$matches[1]; |
5703 | 6048 | $str = $matches[3]; |
5704 | - } |
|
5705 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
6049 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5706 | 6050 | { |
5707 | 6051 | $value = substr($matches[2], 0, (int)$matches[1]); |
5708 | 6052 | $str = substr($matches[2], (int)$matches[1] + 2); |
5709 | - } |
|
5710 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
6053 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5711 | 6054 | { |
5712 | 6055 | $expectedLength = (int)$matches[1]; |
5713 | 6056 | $str = $matches[2]; |
5714 | 6057 | } |
5715 | 6058 | |
5716 | 6059 | // Object or unknown/malformed type. |
5717 | - else |
|
5718 | - return false; |
|
6060 | + else { |
|
6061 | + return false; |
|
6062 | + } |
|
5719 | 6063 | |
5720 | 6064 | switch($state) |
5721 | 6065 | { |
@@ -5743,8 +6087,9 @@ discard block |
||
5743 | 6087 | if($type == '}') |
5744 | 6088 | { |
5745 | 6089 | // Array size is less than expected. |
5746 | - if(count($list) < end($expected)) |
|
5747 | - return false; |
|
6090 | + if(count($list) < end($expected)) { |
|
6091 | + return false; |
|
6092 | + } |
|
5748 | 6093 | |
5749 | 6094 | unset($list); |
5750 | 6095 | $list = &$stack[count($stack)-1]; |
@@ -5753,8 +6098,9 @@ discard block |
||
5753 | 6098 | // Go to terminal state if we're at the end of the root array. |
5754 | 6099 | array_pop($expected); |
5755 | 6100 | |
5756 | - if(count($expected) == 0) |
|
5757 | - $state = 1; |
|
6101 | + if(count($expected) == 0) { |
|
6102 | + $state = 1; |
|
6103 | + } |
|
5758 | 6104 | |
5759 | 6105 | break; |
5760 | 6106 | } |
@@ -5762,8 +6108,9 @@ discard block |
||
5762 | 6108 | if($type == 'i' || $type == 's') |
5763 | 6109 | { |
5764 | 6110 | // Array size exceeds expected length. |
5765 | - if(count($list) >= end($expected)) |
|
5766 | - return false; |
|
6111 | + if(count($list) >= end($expected)) { |
|
6112 | + return false; |
|
6113 | + } |
|
5767 | 6114 | |
5768 | 6115 | $key = $value; |
5769 | 6116 | $state = 3; |
@@ -5797,8 +6144,9 @@ discard block |
||
5797 | 6144 | } |
5798 | 6145 | |
5799 | 6146 | // Trailing data in input. |
5800 | - if(!empty($str)) |
|
5801 | - return false; |
|
6147 | + if(!empty($str)) { |
|
6148 | + return false; |
|
6149 | + } |
|
5802 | 6150 | |
5803 | 6151 | return $data; |
5804 | 6152 | } |
@@ -5821,8 +6169,9 @@ discard block |
||
5821 | 6169 | |
5822 | 6170 | $out = _safe_unserialize($str); |
5823 | 6171 | |
5824 | - if (isset($mbIntEnc)) |
|
5825 | - mb_internal_encoding($mbIntEnc); |
|
6172 | + if (isset($mbIntEnc)) { |
|
6173 | + mb_internal_encoding($mbIntEnc); |
|
6174 | + } |
|
5826 | 6175 | |
5827 | 6176 | return $out; |
5828 | 6177 | } |
@@ -5837,12 +6186,14 @@ discard block |
||
5837 | 6186 | function smf_chmod($file, $value = 0) |
5838 | 6187 | { |
5839 | 6188 | // No file? no checks! |
5840 | - if (empty($file)) |
|
5841 | - return false; |
|
6189 | + if (empty($file)) { |
|
6190 | + return false; |
|
6191 | + } |
|
5842 | 6192 | |
5843 | 6193 | // Already writable? |
5844 | - if (is_writable($file)) |
|
5845 | - return true; |
|
6194 | + if (is_writable($file)) { |
|
6195 | + return true; |
|
6196 | + } |
|
5846 | 6197 | |
5847 | 6198 | // Do we have a file or a dir? |
5848 | 6199 | $isDir = is_dir($file); |
@@ -5858,10 +6209,9 @@ discard block |
||
5858 | 6209 | { |
5859 | 6210 | $isWritable = true; |
5860 | 6211 | break; |
6212 | + } else { |
|
6213 | + @chmod($file, $val); |
|
5861 | 6214 | } |
5862 | - |
|
5863 | - else |
|
5864 | - @chmod($file, $val); |
|
5865 | 6215 | } |
5866 | 6216 | |
5867 | 6217 | return $isWritable; |
@@ -5880,8 +6230,9 @@ discard block |
||
5880 | 6230 | global $txt; |
5881 | 6231 | |
5882 | 6232 | // Come on... |
5883 | - if (empty($json) || !is_string($json)) |
|
5884 | - return array(); |
|
6233 | + if (empty($json) || !is_string($json)) { |
|
6234 | + return array(); |
|
6235 | + } |
|
5885 | 6236 | |
5886 | 6237 | $returnArray = @json_decode($json, $returnAsArray); |
5887 | 6238 | |
@@ -5919,11 +6270,11 @@ discard block |
||
5919 | 6270 | $jsonDebug = $jsonDebug[0]; |
5920 | 6271 | loadLanguage('Errors'); |
5921 | 6272 | |
5922 | - if (!empty($jsonDebug)) |
|
5923 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5924 | - |
|
5925 | - else |
|
5926 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
6273 | + if (!empty($jsonDebug)) { |
|
6274 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
6275 | + } else { |
|
6276 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
6277 | + } |
|
5927 | 6278 | |
5928 | 6279 | // Everyone expects an array. |
5929 | 6280 | return array(); |
@@ -5957,8 +6308,9 @@ discard block |
||
5957 | 6308 | global $db_show_debug, $modSettings; |
5958 | 6309 | |
5959 | 6310 | // Defensive programming anyone? |
5960 | - if (empty($data)) |
|
5961 | - return false; |
|
6311 | + if (empty($data)) { |
|
6312 | + return false; |
|
6313 | + } |
|
5962 | 6314 | |
5963 | 6315 | // Don't need extra stuff... |
5964 | 6316 | $db_show_debug = false; |
@@ -5966,11 +6318,11 @@ discard block |
||
5966 | 6318 | // Kill anything else. |
5967 | 6319 | ob_end_clean(); |
5968 | 6320 | |
5969 | - if (!empty($modSettings['CompressedOutput'])) |
|
5970 | - @ob_start('ob_gzhandler'); |
|
5971 | - |
|
5972 | - else |
|
5973 | - ob_start(); |
|
6321 | + if (!empty($modSettings['CompressedOutput'])) { |
|
6322 | + @ob_start('ob_gzhandler'); |
|
6323 | + } else { |
|
6324 | + ob_start(); |
|
6325 | + } |
|
5974 | 6326 | |
5975 | 6327 | // Set the header. |
5976 | 6328 | header($type); |
@@ -6002,8 +6354,9 @@ discard block |
||
6002 | 6354 | static $done = false; |
6003 | 6355 | |
6004 | 6356 | // If we don't need to do anything, don't |
6005 | - if (!$update && $done) |
|
6006 | - return; |
|
6357 | + if (!$update && $done) { |
|
6358 | + return; |
|
6359 | + } |
|
6007 | 6360 | |
6008 | 6361 | // Should we get a new copy of the official list of TLDs? |
6009 | 6362 | if ($update) |
@@ -6015,8 +6368,9 @@ discard block |
||
6015 | 6368 | // marauding bandits roaming on the surface. We don't want to waste precious electricity on |
6016 | 6369 | // pointlessly repeating background tasks, so we'll wait until the next regularly scheduled |
6017 | 6370 | // update to see if civilization has been restored. |
6018 | - if ($tlds === false) |
|
6019 | - $postapocalypticNightmare = true; |
|
6371 | + if ($tlds === false) { |
|
6372 | + $postapocalypticNightmare = true; |
|
6373 | + } |
|
6020 | 6374 | } |
6021 | 6375 | // If we aren't updating and the regex is valid, we're done |
6022 | 6376 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -6031,10 +6385,11 @@ discard block |
||
6031 | 6385 | // Clean $tlds and convert it to an array |
6032 | 6386 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
6033 | 6387 | $line = trim($line); |
6034 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
6035 | - return false; |
|
6036 | - else |
|
6037 | - return true; |
|
6388 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6389 | + return false; |
|
6390 | + } else { |
|
6391 | + return true; |
|
6392 | + } |
|
6038 | 6393 | }); |
6039 | 6394 | |
6040 | 6395 | // Convert Punycode to Unicode |
@@ -6126,8 +6481,7 @@ discard block |
||
6126 | 6481 | |
6127 | 6482 | $strlen = 'mb_strlen'; |
6128 | 6483 | $substr = 'mb_substr'; |
6129 | - } |
|
6130 | - else |
|
6484 | + } else |
|
6131 | 6485 | { |
6132 | 6486 | $strlen = $smcFunc['strlen']; |
6133 | 6487 | $substr = $smcFunc['substr']; |
@@ -6141,20 +6495,21 @@ discard block |
||
6141 | 6495 | |
6142 | 6496 | $first = $substr($string, 0, 1); |
6143 | 6497 | |
6144 | - if (empty($index[$first])) |
|
6145 | - $index[$first] = array(); |
|
6498 | + if (empty($index[$first])) { |
|
6499 | + $index[$first] = array(); |
|
6500 | + } |
|
6146 | 6501 | |
6147 | 6502 | if ($strlen($string) > 1) |
6148 | 6503 | { |
6149 | 6504 | // Sanity check on recursion |
6150 | - if ($depth > 99) |
|
6151 | - $index[$first][$substr($string, 1)] = ''; |
|
6152 | - |
|
6153 | - else |
|
6154 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6505 | + if ($depth > 99) { |
|
6506 | + $index[$first][$substr($string, 1)] = ''; |
|
6507 | + } else { |
|
6508 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6509 | + } |
|
6510 | + } else { |
|
6511 | + $index[$first][''] = ''; |
|
6155 | 6512 | } |
6156 | - else |
|
6157 | - $index[$first][''] = ''; |
|
6158 | 6513 | |
6159 | 6514 | $depth--; |
6160 | 6515 | return $index; |
@@ -6177,9 +6532,9 @@ discard block |
||
6177 | 6532 | $key_regex = preg_quote($key, $delim); |
6178 | 6533 | $new_key = $key; |
6179 | 6534 | |
6180 | - if (empty($value)) |
|
6181 | - $sub_regex = ''; |
|
6182 | - else |
|
6535 | + if (empty($value)) { |
|
6536 | + $sub_regex = ''; |
|
6537 | + } else |
|
6183 | 6538 | { |
6184 | 6539 | $sub_regex = $index_to_regex($value, $delim); |
6185 | 6540 | |
@@ -6187,22 +6542,22 @@ discard block |
||
6187 | 6542 | { |
6188 | 6543 | $new_key_array = explode('(?'.'>', $sub_regex); |
6189 | 6544 | $new_key .= $new_key_array[0]; |
6545 | + } else { |
|
6546 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6190 | 6547 | } |
6191 | - else |
|
6192 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6193 | 6548 | } |
6194 | 6549 | |
6195 | - if ($depth > 1) |
|
6196 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
6197 | - else |
|
6550 | + if ($depth > 1) { |
|
6551 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6552 | + } else |
|
6198 | 6553 | { |
6199 | 6554 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
6200 | 6555 | { |
6201 | 6556 | $regex[$new_key] = $key_regex . $sub_regex; |
6202 | 6557 | unset($index[$key]); |
6558 | + } else { |
|
6559 | + break; |
|
6203 | 6560 | } |
6204 | - else |
|
6205 | - break; |
|
6206 | 6561 | } |
6207 | 6562 | } |
6208 | 6563 | |
@@ -6211,10 +6566,11 @@ discard block |
||
6211 | 6566 | $l1 = $strlen($k1); |
6212 | 6567 | $l2 = $strlen($k2); |
6213 | 6568 | |
6214 | - if ($l1 == $l2) |
|
6215 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6216 | - else |
|
6217 | - return $l1 > $l2 ? -1 : 1; |
|
6569 | + if ($l1 == $l2) { |
|
6570 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6571 | + } else { |
|
6572 | + return $l1 > $l2 ? -1 : 1; |
|
6573 | + } |
|
6218 | 6574 | }); |
6219 | 6575 | |
6220 | 6576 | $depth--; |
@@ -6225,21 +6581,24 @@ discard block |
||
6225 | 6581 | $index = array(); |
6226 | 6582 | $regex = ''; |
6227 | 6583 | |
6228 | - foreach ($strings as $string) |
|
6229 | - $index = $add_string_to_index($string, $index); |
|
6584 | + foreach ($strings as $string) { |
|
6585 | + $index = $add_string_to_index($string, $index); |
|
6586 | + } |
|
6230 | 6587 | |
6231 | 6588 | if ($returnArray === true) |
6232 | 6589 | { |
6233 | 6590 | $regex = array(); |
6234 | - while (!empty($index)) |
|
6235 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6591 | + while (!empty($index)) { |
|
6592 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6593 | + } |
|
6594 | + } else { |
|
6595 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6236 | 6596 | } |
6237 | - else |
|
6238 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6239 | 6597 | |
6240 | 6598 | // Restore PHP's internal character encoding to whatever it was originally |
6241 | - if (!empty($current_encoding)) |
|
6242 | - mb_internal_encoding($current_encoding); |
|
6599 | + if (!empty($current_encoding)) { |
|
6600 | + mb_internal_encoding($current_encoding); |
|
6601 | + } |
|
6243 | 6602 | |
6244 | 6603 | return $regex; |
6245 | 6604 | } |
@@ -6282,13 +6641,15 @@ discard block |
||
6282 | 6641 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
6283 | 6642 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
6284 | 6643 | $headers = @get_headers($url); |
6285 | - if ($headers === false) |
|
6286 | - return false; |
|
6644 | + if ($headers === false) { |
|
6645 | + return false; |
|
6646 | + } |
|
6287 | 6647 | |
6288 | 6648 | // Now to see if it came back https... |
6289 | 6649 | // First check for a redirect status code in first row (301, 302, 307) |
6290 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
6291 | - return false; |
|
6650 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
6651 | + return false; |
|
6652 | + } |
|
6292 | 6653 | |
6293 | 6654 | // Search for the location entry to confirm https |
6294 | 6655 | $result = false; |
@@ -6326,8 +6687,7 @@ discard block |
||
6326 | 6687 | $is_admin = $user_info['is_admin']; |
6327 | 6688 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
6328 | 6689 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
6329 | - } |
|
6330 | - else |
|
6690 | + } else |
|
6331 | 6691 | { |
6332 | 6692 | $request = $smcFunc['db_query']('', ' |
6333 | 6693 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6341,17 +6701,19 @@ discard block |
||
6341 | 6701 | |
6342 | 6702 | $row = $smcFunc['db_fetch_assoc']($request); |
6343 | 6703 | |
6344 | - if (empty($row['additional_groups'])) |
|
6345 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
6346 | - else |
|
6347 | - $groups = array_merge( |
|
6704 | + if (empty($row['additional_groups'])) { |
|
6705 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
6706 | + } else { |
|
6707 | + $groups = array_merge( |
|
6348 | 6708 | array($row['id_group'], $row['id_post_group']), |
6349 | 6709 | explode(',', $row['additional_groups']) |
6350 | 6710 | ); |
6711 | + } |
|
6351 | 6712 | |
6352 | 6713 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
6353 | - foreach ($groups as $k => $v) |
|
6354 | - $groups[$k] = (int) $v; |
|
6714 | + foreach ($groups as $k => $v) { |
|
6715 | + $groups[$k] = (int) $v; |
|
6716 | + } |
|
6355 | 6717 | |
6356 | 6718 | $is_admin = in_array(1, $groups); |
6357 | 6719 | |
@@ -6368,8 +6730,9 @@ discard block |
||
6368 | 6730 | 'current_member' => $userid, |
6369 | 6731 | ) |
6370 | 6732 | ); |
6371 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6372 | - $boards_mod[] = $row['id_board']; |
|
6733 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6734 | + $boards_mod[] = $row['id_board']; |
|
6735 | + } |
|
6373 | 6736 | $smcFunc['db_free_result']($request); |
6374 | 6737 | |
6375 | 6738 | // Can any of the groups they're in moderate any of the boards? |
@@ -6381,8 +6744,9 @@ discard block |
||
6381 | 6744 | 'groups' => $groups, |
6382 | 6745 | ) |
6383 | 6746 | ); |
6384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6385 | - $boards_mod[] = $row['id_board']; |
|
6747 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6748 | + $boards_mod[] = $row['id_board']; |
|
6749 | + } |
|
6386 | 6750 | $smcFunc['db_free_result']($request); |
6387 | 6751 | |
6388 | 6752 | // Just in case we've got duplicates here... |
@@ -6392,21 +6756,25 @@ discard block |
||
6392 | 6756 | } |
6393 | 6757 | |
6394 | 6758 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
6395 | - if ($is_admin) |
|
6396 | - $query_part['query_see_board'] = '1=1'; |
|
6759 | + if ($is_admin) { |
|
6760 | + $query_part['query_see_board'] = '1=1'; |
|
6761 | + } |
|
6397 | 6762 | // Otherwise just the groups in $user_info['groups']. |
6398 | - else |
|
6399 | - $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
6763 | + else { |
|
6764 | + $query_part['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $groups) . ', b.member_groups) != 0)' . (!empty($deny_boards_access) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $groups) . ', b.deny_member_groups) = 0)' : '') . (isset($mod_cache) ? ' OR ' . $mod_cache['mq'] : '') . ')'; |
|
6765 | + } |
|
6400 | 6766 | |
6401 | 6767 | // Build the list of boards they WANT to see. |
6402 | 6768 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
6403 | 6769 | |
6404 | 6770 | // If they aren't ignoring any boards then they want to see all the boards they can see |
6405 | - if (empty($ignoreboards)) |
|
6406 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6771 | + if (empty($ignoreboards)) { |
|
6772 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6773 | + } |
|
6407 | 6774 | // Ok I guess they don't want to see all the boards |
6408 | - else |
|
6409 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6775 | + else { |
|
6776 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6777 | + } |
|
6410 | 6778 | |
6411 | 6779 | return $query_part; |
6412 | 6780 | } |
@@ -6420,10 +6788,11 @@ discard block |
||
6420 | 6788 | { |
6421 | 6789 | $secure = false; |
6422 | 6790 | |
6423 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
6424 | - $secure = true; |
|
6425 | - elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') |
|
6426 | - $secure = true; |
|
6791 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
6792 | + $secure = true; |
|
6793 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') { |
|
6794 | + $secure = true; |
|
6795 | + } |
|
6427 | 6796 | |
6428 | 6797 | return $secure; |
6429 | 6798 | } |
@@ -6440,11 +6809,12 @@ discard block |
||
6440 | 6809 | { |
6441 | 6810 | $url = iri_to_url($iri); |
6442 | 6811 | |
6443 | - if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) |
|
6444 | - return $iri; |
|
6445 | - else |
|
6446 | - return false; |
|
6447 | -} |
|
6812 | + if (filter_var($url, FILTER_VALIDATE_URL, $flags) !== false) { |
|
6813 | + return $iri; |
|
6814 | + } else { |
|
6815 | + return false; |
|
6816 | + } |
|
6817 | + } |
|
6448 | 6818 | |
6449 | 6819 | /** |
6450 | 6820 | * A wrapper for `filter_var($url, FILTER_SANITIZE_URL)` that can handle URLs |
@@ -6487,8 +6857,9 @@ discard block |
||
6487 | 6857 | |
6488 | 6858 | $host = parse_url((strpos($iri, '://') === false ? 'http://' : '') . ltrim($iri, ':/'), PHP_URL_HOST); |
6489 | 6859 | |
6490 | - if (empty($host)) |
|
6491 | - return $iri; |
|
6860 | + if (empty($host)) { |
|
6861 | + return $iri; |
|
6862 | + } |
|
6492 | 6863 | |
6493 | 6864 | // Convert the domain using the Punycode algorithm |
6494 | 6865 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -6524,8 +6895,9 @@ discard block |
||
6524 | 6895 | |
6525 | 6896 | $host = parse_url((strpos($url, '://') === false ? 'http://' : '') . ltrim($url, ':/'), PHP_URL_HOST); |
6526 | 6897 | |
6527 | - if (empty($host)) |
|
6528 | - return $url; |
|
6898 | + if (empty($host)) { |
|
6899 | + return $url; |
|
6900 | + } |
|
6529 | 6901 | |
6530 | 6902 | // Decode the domain from Punycode |
6531 | 6903 | require_once($sourcedir . '/Class-Punycode.php'); |
@@ -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']) |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | // if we have bool terms to search, add them in |
247 | 247 | if ($query_params['boolean_match']) |
248 | 248 | { |
249 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
249 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
250 | 250 | { |
251 | 251 | $language_ftx = $smcFunc['db_search_language'](); |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
261 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
262 | 262 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
263 | 263 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
264 | 264 | SELECT ' . implode(', ', $query_select) . ' |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | * @version 2.1 Beta 4 |
19 | 19 | */ |
20 | 20 | |
21 | -if (!defined('SMF')) |
|
21 | +if (!defined('SMF')) { |
|
22 | 22 | die('No direct access...'); |
23 | +} |
|
23 | 24 | |
24 | 25 | /** |
25 | 26 | * downloads a file from a url and stores it locally for avatar use by id_member. |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $destName = 'avatar_' . $memID . '_' . time() . '.' . $ext; |
45 | 46 | |
46 | 47 | // Just making sure there is a non-zero member. |
47 | - if (empty($memID)) |
|
48 | - return false; |
|
48 | + if (empty($memID)) { |
|
49 | + return false; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | require_once($sourcedir . '/ManageAttachments.php'); |
51 | 53 | removeAttachments(array('id_member' => $memID)); |
@@ -76,10 +78,11 @@ discard block |
||
76 | 78 | $destName = $modSettings['custom_avatar_dir'] . '/' . $destName . '.tmp'; |
77 | 79 | |
78 | 80 | // Resize it. |
79 | - if (!empty($modSettings['avatar_download_png'])) |
|
80 | - $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
81 | - else |
|
82 | - $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
81 | + if (!empty($modSettings['avatar_download_png'])) { |
|
82 | + $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
83 | + } else { |
|
84 | + $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
85 | + } |
|
83 | 86 | |
84 | 87 | // Remove the .tmp extension. |
85 | 88 | $destName = substr($destName, 0, -4); |
@@ -108,11 +111,10 @@ discard block |
||
108 | 111 | ) |
109 | 112 | ); |
110 | 113 | return true; |
114 | + } else { |
|
115 | + return false; |
|
111 | 116 | } |
112 | - else |
|
113 | - return false; |
|
114 | - } |
|
115 | - else |
|
117 | + } else |
|
116 | 118 | { |
117 | 119 | $smcFunc['db_query']('', ' |
118 | 120 | DELETE FROM {db_prefix}attachments |
@@ -144,17 +146,18 @@ discard block |
||
144 | 146 | $destName = $source . '_thumb.tmp'; |
145 | 147 | |
146 | 148 | // Do the actual resize. |
147 | - if (!empty($modSettings['attachment_thumb_png'])) |
|
148 | - $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
149 | - else |
|
150 | - $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
149 | + if (!empty($modSettings['attachment_thumb_png'])) { |
|
150 | + $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
151 | + } else { |
|
152 | + $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | // Okay, we're done with the temporary stuff. |
153 | 156 | $destName = substr($destName, 0, -4); |
154 | 157 | |
155 | - if ($success && @rename($destName . '.tmp', $destName)) |
|
156 | - return true; |
|
157 | - else |
|
158 | + if ($success && @rename($destName . '.tmp', $destName)) { |
|
159 | + return true; |
|
160 | + } else |
|
158 | 161 | { |
159 | 162 | @unlink($destName . '.tmp'); |
160 | 163 | @touch($destName); |
@@ -176,18 +179,21 @@ discard block |
||
176 | 179 | { |
177 | 180 | if (!resizeImageFile($fileName, $fileName . '.tmp', null, null, $preferred_format)) |
178 | 181 | { |
179 | - if (file_exists($fileName . '.tmp')) |
|
180 | - unlink($fileName . '.tmp'); |
|
182 | + if (file_exists($fileName . '.tmp')) { |
|
183 | + unlink($fileName . '.tmp'); |
|
184 | + } |
|
181 | 185 | |
182 | 186 | return false; |
183 | 187 | } |
184 | 188 | |
185 | - if (!unlink($fileName)) |
|
186 | - return false; |
|
189 | + if (!unlink($fileName)) { |
|
190 | + return false; |
|
191 | + } |
|
187 | 192 | |
188 | - if (!rename($fileName . '.tmp', $fileName)) |
|
189 | - return false; |
|
190 | -} |
|
193 | + if (!rename($fileName . '.tmp', $fileName)) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + } |
|
191 | 197 | |
192 | 198 | /** |
193 | 199 | * Searches through the file to see if there's potentially harmful non-binary content. |
@@ -200,8 +206,9 @@ discard block |
||
200 | 206 | function checkImageContents($fileName, $extensiveCheck = false) |
201 | 207 | { |
202 | 208 | $fp = fopen($fileName, 'rb'); |
203 | - if (!$fp) |
|
204 | - fatal_lang_error('attach_timeout'); |
|
209 | + if (!$fp) { |
|
210 | + fatal_lang_error('attach_timeout'); |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $prev_chunk = ''; |
207 | 214 | while (!feof($fp)) |
@@ -218,8 +225,7 @@ discard block |
||
218 | 225 | fclose($fp); |
219 | 226 | return false; |
220 | 227 | } |
221 | - } |
|
222 | - else |
|
228 | + } else |
|
223 | 229 | { |
224 | 230 | // Check for potential infection - focus on clues for inline php & flash. |
225 | 231 | // Will result in significantly fewer false positives than the paranoid check. |
@@ -247,8 +253,9 @@ discard block |
||
247 | 253 | global $gd2; |
248 | 254 | |
249 | 255 | // Check to see if GD is installed and what version. |
250 | - if (($extensionFunctions = get_extension_funcs('gd')) === false) |
|
251 | - return false; |
|
256 | + if (($extensionFunctions = get_extension_funcs('gd')) === false) { |
|
257 | + return false; |
|
258 | + } |
|
252 | 259 | |
253 | 260 | // Also determine if GD2 is installed and store it in a global. |
254 | 261 | $gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor'); |
@@ -320,8 +327,9 @@ discard block |
||
320 | 327 | global $sourcedir; |
321 | 328 | |
322 | 329 | // Nothing to do without GD or IM/MW |
323 | - if (!checkGD() && !checkImagick() && !checkMagickWand()) |
|
324 | - return false; |
|
330 | + if (!checkGD() && !checkImagick() && !checkMagickWand()) { |
|
331 | + return false; |
|
332 | + } |
|
325 | 333 | |
326 | 334 | static $default_formats = array( |
327 | 335 | '1' => 'gif', |
@@ -341,38 +349,39 @@ discard block |
||
341 | 349 | fclose($fp_destination); |
342 | 350 | |
343 | 351 | $sizes = @getimagesize($destination); |
344 | - } |
|
345 | - elseif ($fp_destination) |
|
352 | + } elseif ($fp_destination) |
|
346 | 353 | { |
347 | 354 | $sizes = @getimagesize($source); |
348 | 355 | |
349 | 356 | $fp_source = fopen($source, 'rb'); |
350 | 357 | if ($fp_source !== false) |
351 | 358 | { |
352 | - while (!feof($fp_source)) |
|
353 | - fwrite($fp_destination, fread($fp_source, 8192)); |
|
359 | + while (!feof($fp_source)) { |
|
360 | + fwrite($fp_destination, fread($fp_source, 8192)); |
|
361 | + } |
|
354 | 362 | fclose($fp_source); |
363 | + } else { |
|
364 | + $sizes = array(-1, -1, -1); |
|
355 | 365 | } |
356 | - else |
|
357 | - $sizes = array(-1, -1, -1); |
|
358 | 366 | fclose($fp_destination); |
359 | 367 | } |
360 | 368 | // We can't get to the file. |
361 | - else |
|
362 | - $sizes = array(-1, -1, -1); |
|
369 | + else { |
|
370 | + $sizes = array(-1, -1, -1); |
|
371 | + } |
|
363 | 372 | |
364 | 373 | // See if we have -or- can get the needed memory for this operation |
365 | 374 | // ImageMagick isn't subject to PHP's memory limits :) |
366 | - if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) |
|
367 | - return false; |
|
375 | + if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) { |
|
376 | + return false; |
|
377 | + } |
|
368 | 378 | |
369 | 379 | // A known and supported format? |
370 | 380 | // @todo test PSD and gif. |
371 | 381 | if ((checkImagick() || checkMagickWand()) && isset($default_formats[$sizes[2]])) |
372 | 382 | { |
373 | 383 | return resizeImage(null, $destination, null, null, $max_width, $max_height, true, $preferred_format); |
374 | - } |
|
375 | - elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
384 | + } elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
376 | 385 | { |
377 | 386 | $imagecreatefrom = 'imagecreatefrom' . $default_formats[$sizes[2]]; |
378 | 387 | if ($src_img = @$imagecreatefrom($destination)) |
@@ -425,14 +434,14 @@ discard block |
||
425 | 434 | $dest_width = empty($max_width) ? $src_width : $max_width; |
426 | 435 | $dest_height = empty($max_height) ? $src_height : $max_height; |
427 | 436 | |
428 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
429 | - $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
437 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
438 | + $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
439 | + } |
|
430 | 440 | |
431 | 441 | $imagick->setImageFormat($default_formats[$preferred_format]); |
432 | 442 | $imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true); |
433 | 443 | $success = $imagick->writeImage($destName); |
434 | - } |
|
435 | - else |
|
444 | + } else |
|
436 | 445 | { |
437 | 446 | $magick_wand = newMagickWand(); |
438 | 447 | MagickReadImage($magick_wand, $destName); |
@@ -441,8 +450,9 @@ discard block |
||
441 | 450 | $dest_width = empty($max_width) ? $src_width : $max_width; |
442 | 451 | $dest_height = empty($max_height) ? $src_height : $max_height; |
443 | 452 | |
444 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
445 | - MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
453 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
454 | + MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
455 | + } |
|
446 | 456 | |
447 | 457 | MagickSetImageFormat($magick_wand, $default_formats[$preferred_format]); |
448 | 458 | MagickResizeImage($magick_wand, $dest_width, $dest_height, MW_LanczosFilter, 1, true); |
@@ -450,8 +460,7 @@ discard block |
||
450 | 460 | } |
451 | 461 | |
452 | 462 | return !empty($success); |
453 | - } |
|
454 | - elseif (checkGD()) |
|
463 | + } elseif (checkGD()) |
|
455 | 464 | { |
456 | 465 | $success = false; |
457 | 466 | |
@@ -462,8 +471,7 @@ discard block |
||
462 | 471 | { |
463 | 472 | $dst_width = $max_width; |
464 | 473 | $dst_height = round($src_height * $max_width / $src_width); |
465 | - } |
|
466 | - elseif (!empty($max_height)) |
|
474 | + } elseif (!empty($max_height)) |
|
467 | 475 | { |
468 | 476 | $dst_width = round($src_width * $max_height / $src_height); |
469 | 477 | $dst_height = $max_height; |
@@ -481,44 +489,48 @@ discard block |
||
481 | 489 | if ((!empty($preferred_format)) && ($preferred_format == 3)) |
482 | 490 | { |
483 | 491 | imagealphablending($dst_img, false); |
484 | - if (function_exists('imagesavealpha')) |
|
485 | - imagesavealpha($dst_img, true); |
|
492 | + if (function_exists('imagesavealpha')) { |
|
493 | + imagesavealpha($dst_img, true); |
|
494 | + } |
|
486 | 495 | } |
496 | + } else { |
|
497 | + $dst_img = imagecreate($dst_width, $dst_height); |
|
487 | 498 | } |
488 | - else |
|
489 | - $dst_img = imagecreate($dst_width, $dst_height); |
|
490 | 499 | |
491 | 500 | // Resize it! |
492 | - if ($gd2) |
|
493 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
494 | - else |
|
495 | - imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
501 | + if ($gd2) { |
|
502 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
503 | + } else { |
|
504 | + imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
505 | + } |
|
506 | + } else { |
|
507 | + $dst_img = $src_img; |
|
496 | 508 | } |
497 | - else |
|
498 | - $dst_img = $src_img; |
|
509 | + } else { |
|
510 | + $dst_img = $src_img; |
|
499 | 511 | } |
500 | - else |
|
501 | - $dst_img = $src_img; |
|
502 | 512 | |
503 | 513 | // Save the image as ... |
504 | - if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) |
|
505 | - $success = imagepng($dst_img, $destName); |
|
506 | - elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) |
|
507 | - $success = imagegif($dst_img, $destName); |
|
508 | - elseif (function_exists('imagejpeg')) |
|
509 | - $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
514 | + if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) { |
|
515 | + $success = imagepng($dst_img, $destName); |
|
516 | + } elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) { |
|
517 | + $success = imagegif($dst_img, $destName); |
|
518 | + } elseif (function_exists('imagejpeg')) { |
|
519 | + $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
520 | + } |
|
510 | 521 | |
511 | 522 | // Free the memory. |
512 | 523 | imagedestroy($src_img); |
513 | - if ($dst_img != $src_img) |
|
514 | - imagedestroy($dst_img); |
|
524 | + if ($dst_img != $src_img) { |
|
525 | + imagedestroy($dst_img); |
|
526 | + } |
|
515 | 527 | |
516 | 528 | return $success; |
517 | - } |
|
518 | - else |
|
519 | - // Without GD, no image resizing at all. |
|
529 | + } else { |
|
530 | + // Without GD, no image resizing at all. |
|
520 | 531 | return false; |
521 | -} |
|
532 | + } |
|
533 | + } |
|
522 | 534 | |
523 | 535 | /** |
524 | 536 | * Copy image. |
@@ -572,8 +584,9 @@ discard block |
||
572 | 584 | $color = imagecolorresolve($dst_img, $red, $green, $blue); |
573 | 585 | if ($color == -1) |
574 | 586 | { |
575 | - if ($palsize++ < 256) |
|
576 | - imagecolorallocate($dst_img, $red, $green, $blue); |
|
587 | + if ($palsize++ < 256) { |
|
588 | + imagecolorallocate($dst_img, $red, $green, $blue); |
|
589 | + } |
|
577 | 590 | $color = imagecolorclosest($dst_img, $red, $green, $blue); |
578 | 591 | } |
579 | 592 | |
@@ -603,13 +616,15 @@ discard block |
||
603 | 616 | $header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14)); |
604 | 617 | $info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40)); |
605 | 618 | |
606 | - if ($header['type'] != 0x4D42) |
|
607 | - return false; |
|
619 | + if ($header['type'] != 0x4D42) { |
|
620 | + return false; |
|
621 | + } |
|
608 | 622 | |
609 | - if ($gd2) |
|
610 | - $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
611 | - else |
|
612 | - $dst_img = imagecreate($info['width'], $info['height']); |
|
623 | + if ($gd2) { |
|
624 | + $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
625 | + } else { |
|
626 | + $dst_img = imagecreate($info['width'], $info['height']); |
|
627 | + } |
|
613 | 628 | |
614 | 629 | $palette_size = $header['offset'] - 54; |
615 | 630 | $info['ncolor'] = $palette_size / 4; |
@@ -635,8 +650,9 @@ discard block |
||
635 | 650 | fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l); |
636 | 651 | $scan_line = fread($fp, $scan_line_size); |
637 | 652 | |
638 | - if (strlen($scan_line) < $scan_line_size) |
|
639 | - continue; |
|
653 | + if (strlen($scan_line) < $scan_line_size) { |
|
654 | + continue; |
|
655 | + } |
|
640 | 656 | |
641 | 657 | if ($info['bits'] == 32) |
642 | 658 | { |
@@ -654,14 +670,14 @@ discard block |
||
654 | 670 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
655 | 671 | |
656 | 672 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
657 | - if ($color == -1) |
|
658 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
673 | + if ($color == -1) { |
|
674 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
675 | + } |
|
659 | 676 | } |
660 | 677 | |
661 | 678 | imagesetpixel($dst_img, $x, $y, $color); |
662 | 679 | } |
663 | - } |
|
664 | - elseif ($info['bits'] == 24) |
|
680 | + } elseif ($info['bits'] == 24) |
|
665 | 681 | { |
666 | 682 | $x = 0; |
667 | 683 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -676,14 +692,14 @@ discard block |
||
676 | 692 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
677 | 693 | |
678 | 694 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
679 | - if ($color == -1) |
|
680 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
695 | + if ($color == -1) { |
|
696 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
697 | + } |
|
681 | 698 | } |
682 | 699 | |
683 | 700 | imagesetpixel($dst_img, $x, $y, $color); |
684 | 701 | } |
685 | - } |
|
686 | - elseif ($info['bits'] == 16) |
|
702 | + } elseif ($info['bits'] == 16) |
|
687 | 703 | { |
688 | 704 | $x = 0; |
689 | 705 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -704,20 +720,20 @@ discard block |
||
704 | 720 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
705 | 721 | |
706 | 722 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
707 | - if ($color == -1) |
|
708 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
723 | + if ($color == -1) { |
|
724 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
725 | + } |
|
709 | 726 | } |
710 | 727 | |
711 | 728 | imagesetpixel($dst_img, $x, $y, $color); |
712 | 729 | } |
713 | - } |
|
714 | - elseif ($info['bits'] == 8) |
|
730 | + } elseif ($info['bits'] == 8) |
|
715 | 731 | { |
716 | 732 | $x = 0; |
717 | - for ($j = 0; $j < $scan_line_size; $x++) |
|
718 | - imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
719 | - } |
|
720 | - elseif ($info['bits'] == 4) |
|
733 | + for ($j = 0; $j < $scan_line_size; $x++) { |
|
734 | + imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
735 | + } |
|
736 | + } elseif ($info['bits'] == 4) |
|
721 | 737 | { |
722 | 738 | $x = 0; |
723 | 739 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -726,11 +742,11 @@ discard block |
||
726 | 742 | |
727 | 743 | imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]); |
728 | 744 | |
729 | - if (++$x < $info['width']) |
|
730 | - imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
745 | + if (++$x < $info['width']) { |
|
746 | + imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
747 | + } |
|
731 | 748 | } |
732 | - } |
|
733 | - elseif ($info['bits'] == 1) |
|
749 | + } elseif ($info['bits'] == 1) |
|
734 | 750 | { |
735 | 751 | $x = 0; |
736 | 752 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -741,8 +757,9 @@ discard block |
||
741 | 757 | |
742 | 758 | for ($shift = 1; $shift < 8; $shift++) |
743 | 759 | { |
744 | - if (++$x < $info['width']) |
|
745 | - imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
760 | + if (++$x < $info['width']) { |
|
761 | + imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
762 | + } |
|
746 | 763 | } |
747 | 764 | } |
748 | 765 | } |
@@ -766,15 +783,18 @@ discard block |
||
766 | 783 | */ |
767 | 784 | function gif_outputAsPng($gif, $lpszFileName, $background_color = -1) |
768 | 785 | { |
769 | - if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') |
|
770 | - return false; |
|
786 | + if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') { |
|
787 | + return false; |
|
788 | + } |
|
771 | 789 | |
772 | 790 | $fd = $gif->get_png_data($background_color); |
773 | - if (strlen($fd) <= 0) |
|
774 | - return false; |
|
791 | + if (strlen($fd) <= 0) { |
|
792 | + return false; |
|
793 | + } |
|
775 | 794 | |
776 | - if (!($fh = @fopen($lpszFileName, 'wb'))) |
|
777 | - return false; |
|
795 | + if (!($fh = @fopen($lpszFileName, 'wb'))) { |
|
796 | + return false; |
|
797 | + } |
|
778 | 798 | |
779 | 799 | @fwrite($fh, $fd, strlen($fd)); |
780 | 800 | @fflush($fh); |
@@ -801,8 +821,9 @@ discard block |
||
801 | 821 | // What type are we going to be doing? |
802 | 822 | $imageType = $modSettings['visual_verification_type']; |
803 | 823 | // Special case to allow the admin center to show samples. |
804 | - if ($user_info['is_admin'] && isset($_GET['type'])) |
|
805 | - $imageType = (int) $_GET['type']; |
|
824 | + if ($user_info['is_admin'] && isset($_GET['type'])) { |
|
825 | + $imageType = (int) $_GET['type']; |
|
826 | + } |
|
806 | 827 | |
807 | 828 | // Some quick references for what we do. |
808 | 829 | // Do we show no, low or high noise? |
@@ -836,25 +857,28 @@ discard block |
||
836 | 857 | $character_spacing = 1; |
837 | 858 | |
838 | 859 | // What color is the background - generally white unless we're on "hard". |
839 | - if ($simpleBGColor) |
|
840 | - $background_color = array(255, 255, 255); |
|
841 | - else |
|
842 | - $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
860 | + if ($simpleBGColor) { |
|
861 | + $background_color = array(255, 255, 255); |
|
862 | + } else { |
|
863 | + $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
864 | + } |
|
843 | 865 | |
844 | 866 | // The color of the characters shown (red, green, blue). |
845 | - if ($simpleFGColor) |
|
846 | - $foreground_color = array(0, 0, 0); |
|
847 | - else |
|
867 | + if ($simpleFGColor) { |
|
868 | + $foreground_color = array(0, 0, 0); |
|
869 | + } else |
|
848 | 870 | { |
849 | 871 | $foreground_color = array(64, 101, 136); |
850 | 872 | |
851 | 873 | // Has the theme author requested a custom color? |
852 | - if (isset($settings['verification_foreground'])) |
|
853 | - $foreground_color = $settings['verification_foreground']; |
|
874 | + if (isset($settings['verification_foreground'])) { |
|
875 | + $foreground_color = $settings['verification_foreground']; |
|
876 | + } |
|
854 | 877 | } |
855 | 878 | |
856 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
857 | - return false; |
|
879 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
880 | + return false; |
|
881 | + } |
|
858 | 882 | |
859 | 883 | // Get a list of the available fonts. |
860 | 884 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
@@ -865,25 +889,28 @@ discard block |
||
865 | 889 | { |
866 | 890 | if (preg_match('~^(.+)\.gdf$~', $entry, $matches) === 1) |
867 | 891 | { |
868 | - if ($endian ^ (strpos($entry, '_end.gdf') === false)) |
|
869 | - $font_list[] = $entry; |
|
892 | + if ($endian ^ (strpos($entry, '_end.gdf') === false)) { |
|
893 | + $font_list[] = $entry; |
|
894 | + } |
|
895 | + } elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) { |
|
896 | + $ttfont_list[] = $entry; |
|
870 | 897 | } |
871 | - elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) |
|
872 | - $ttfont_list[] = $entry; |
|
873 | 898 | } |
874 | 899 | |
875 | - if (empty($font_list)) |
|
876 | - return false; |
|
900 | + if (empty($font_list)) { |
|
901 | + return false; |
|
902 | + } |
|
877 | 903 | |
878 | 904 | // For non-hard things don't even change fonts. |
879 | 905 | if (!$varyFonts) |
880 | 906 | { |
881 | 907 | $font_list = array($font_list[0]); |
882 | 908 | // Try use Screenge if we can - it looks good! |
883 | - if (in_array('AnonymousPro.ttf', $ttfont_list)) |
|
884 | - $ttfont_list = array('AnonymousPro.ttf'); |
|
885 | - else |
|
886 | - $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
909 | + if (in_array('AnonymousPro.ttf', $ttfont_list)) { |
|
910 | + $ttfont_list = array('AnonymousPro.ttf'); |
|
911 | + } else { |
|
912 | + $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
913 | + } |
|
887 | 914 | } |
888 | 915 | |
889 | 916 | // Create a list of characters to be shown. |
@@ -900,14 +927,16 @@ discard block |
||
900 | 927 | } |
901 | 928 | |
902 | 929 | // Load all fonts and determine the maximum font height. |
903 | - foreach ($loaded_fonts as $font_index => $dummy) |
|
904 | - $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
930 | + foreach ($loaded_fonts as $font_index => $dummy) { |
|
931 | + $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
932 | + } |
|
905 | 933 | |
906 | 934 | // Determine the dimensions of each character. |
907 | - if ($imageType == 4 || $imageType == 5) |
|
908 | - $extra = 80; |
|
909 | - else |
|
910 | - $extra = 45; |
|
935 | + if ($imageType == 4 || $imageType == 5) { |
|
936 | + $extra = 80; |
|
937 | + } else { |
|
938 | + $extra = 45; |
|
939 | + } |
|
911 | 940 | |
912 | 941 | $total_width = $character_spacing * strlen($code) + $extra; |
913 | 942 | $max_height = 0; |
@@ -928,13 +957,15 @@ discard block |
||
928 | 957 | imagefilledrectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $bg_color); |
929 | 958 | |
930 | 959 | // Randomize the foreground color a little. |
931 | - for ($i = 0; $i < 3; $i++) |
|
932 | - $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
960 | + for ($i = 0; $i < 3; $i++) { |
|
961 | + $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
962 | + } |
|
933 | 963 | $fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]); |
934 | 964 | |
935 | 965 | // Color for the dots. |
936 | - for ($i = 0; $i < 3; $i++) |
|
937 | - $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
966 | + for ($i = 0; $i < 3; $i++) { |
|
967 | + $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
968 | + } |
|
938 | 969 | $randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]); |
939 | 970 | |
940 | 971 | // Some squares/rectanges for new extreme level |
@@ -960,10 +991,11 @@ discard block |
||
960 | 991 | $can_do_ttf = function_exists('imagettftext'); |
961 | 992 | |
962 | 993 | // How much rotation will we give? |
963 | - if ($rotationType == 'none') |
|
964 | - $angle = 0; |
|
965 | - else |
|
966 | - $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
994 | + if ($rotationType == 'none') { |
|
995 | + $angle = 0; |
|
996 | + } else { |
|
997 | + $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
998 | + } |
|
967 | 999 | |
968 | 1000 | // What color shall we do it? |
969 | 1001 | if ($fontColorType == 'cyclic') |
@@ -977,51 +1009,56 @@ discard block |
||
977 | 1009 | array(0, 0, 0), |
978 | 1010 | array(143, 39, 31), |
979 | 1011 | ); |
980 | - if (!isset($last_index)) |
|
981 | - $last_index = -1; |
|
1012 | + if (!isset($last_index)) { |
|
1013 | + $last_index = -1; |
|
1014 | + } |
|
982 | 1015 | $new_index = $last_index; |
983 | - while ($last_index == $new_index) |
|
984 | - $new_index = mt_rand(0, count($colors) - 1); |
|
1016 | + while ($last_index == $new_index) { |
|
1017 | + $new_index = mt_rand(0, count($colors) - 1); |
|
1018 | + } |
|
985 | 1019 | $char_fg_color = $colors[$new_index]; |
986 | 1020 | $last_index = $new_index; |
1021 | + } elseif ($fontColorType == 'random') { |
|
1022 | + $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
1023 | + } else { |
|
1024 | + $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
987 | 1025 | } |
988 | - elseif ($fontColorType == 'random') |
|
989 | - $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
990 | - else |
|
991 | - $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
992 | 1026 | |
993 | 1027 | if (!empty($can_do_ttf)) |
994 | 1028 | { |
995 | 1029 | // GD2 handles font size differently. |
996 | - if ($fontSizeRandom) |
|
997 | - $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
998 | - else |
|
999 | - $font_size = $gd2 ? 18 : 24; |
|
1030 | + if ($fontSizeRandom) { |
|
1031 | + $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
1032 | + } else { |
|
1033 | + $font_size = $gd2 ? 18 : 24; |
|
1034 | + } |
|
1000 | 1035 | |
1001 | 1036 | // Work out the sizes - also fix the character width cause TTF not quite so wide! |
1002 | 1037 | $font_x = $fontHorSpace == 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5; |
1003 | 1038 | $font_y = $max_height - ($fontVerPos == 'vrandom' ? mt_rand(2, 8) : ($fontVerPos == 'random' ? mt_rand(3, 5) : 5)); |
1004 | 1039 | |
1005 | 1040 | // What font face? |
1006 | - if (!empty($ttfont_list)) |
|
1007 | - $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1041 | + if (!empty($ttfont_list)) { |
|
1042 | + $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1043 | + } |
|
1008 | 1044 | |
1009 | 1045 | // What color are we to do it in? |
1010 | 1046 | $is_reverse = $showReverseChars ? mt_rand(0, 1) : false; |
1011 | 1047 | $char_color = function_exists('imagecolorallocatealpha') && $fontTrans ? imagecolorallocatealpha($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2], 50) : imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]); |
1012 | 1048 | |
1013 | 1049 | $fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']); |
1014 | - if (empty($fontcord)) |
|
1015 | - $can_do_ttf = false; |
|
1016 | - elseif ($is_reverse) |
|
1050 | + if (empty($fontcord)) { |
|
1051 | + $can_do_ttf = false; |
|
1052 | + } elseif ($is_reverse) |
|
1017 | 1053 | { |
1018 | 1054 | imagefilledpolygon($code_image, $fontcord, 4, $fg_color); |
1019 | 1055 | // Put the character back! |
1020 | 1056 | imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']); |
1021 | 1057 | } |
1022 | 1058 | |
1023 | - if ($can_do_ttf) |
|
1024 | - $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1059 | + if ($can_do_ttf) { |
|
1060 | + $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1061 | + } |
|
1025 | 1062 | } |
1026 | 1063 | |
1027 | 1064 | if (!$can_do_ttf) |
@@ -1040,8 +1077,9 @@ discard block |
||
1040 | 1077 | } |
1041 | 1078 | |
1042 | 1079 | // Sorry, no rotation available. |
1043 | - else |
|
1044 | - imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1080 | + else { |
|
1081 | + imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1082 | + } |
|
1045 | 1083 | $cur_x += $character['width'] + $character_spacing; |
1046 | 1084 | } |
1047 | 1085 | } |
@@ -1054,17 +1092,22 @@ discard block |
||
1054 | 1092 | } |
1055 | 1093 | |
1056 | 1094 | // Make the background color transparent on the hard image. |
1057 | - if (!$simpleBGColor) |
|
1058 | - imagecolortransparent($code_image, $bg_color); |
|
1059 | - if ($hasBorder) |
|
1060 | - imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1095 | + if (!$simpleBGColor) { |
|
1096 | + imagecolortransparent($code_image, $bg_color); |
|
1097 | + } |
|
1098 | + if ($hasBorder) { |
|
1099 | + imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1100 | + } |
|
1061 | 1101 | |
1062 | 1102 | // Add some noise to the background? |
1063 | 1103 | if ($noiseType != 'none') |
1064 | 1104 | { |
1065 | - for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) |
|
1066 | - for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10)) |
|
1067 | - imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1105 | + for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) { |
|
1106 | + for ($j = mt_rand(0, 10); |
|
1107 | + } |
|
1108 | + $j < $total_width; $j += mt_rand(1, 10)) { |
|
1109 | + imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1110 | + } |
|
1068 | 1111 | |
1069 | 1112 | // Put in some lines too? |
1070 | 1113 | if ($noiseType != 'extreme') |
@@ -1077,8 +1120,7 @@ discard block |
||
1077 | 1120 | $x1 = mt_rand(0, $total_width); |
1078 | 1121 | $x2 = mt_rand(0, $total_width); |
1079 | 1122 | $y1 = 0; $y2 = $max_height; |
1080 | - } |
|
1081 | - else |
|
1123 | + } else |
|
1082 | 1124 | { |
1083 | 1125 | $y1 = mt_rand(0, $max_height); |
1084 | 1126 | $y2 = mt_rand(0, $max_height); |
@@ -1087,8 +1129,7 @@ discard block |
||
1087 | 1129 | imagesetthickness($code_image, mt_rand(1, 2)); |
1088 | 1130 | imageline($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color); |
1089 | 1131 | } |
1090 | - } |
|
1091 | - else |
|
1132 | + } else |
|
1092 | 1133 | { |
1093 | 1134 | // Put in some ellipse |
1094 | 1135 | $num_ellipse = $noiseType == 'extreme' ? mt_rand(6, 12) : mt_rand(2, 6); |
@@ -1108,8 +1149,7 @@ discard block |
||
1108 | 1149 | { |
1109 | 1150 | header('content-type: image/gif'); |
1110 | 1151 | imagegif($code_image); |
1111 | - } |
|
1112 | - else |
|
1152 | + } else |
|
1113 | 1153 | { |
1114 | 1154 | header('content-type: image/png'); |
1115 | 1155 | imagepng($code_image); |
@@ -1132,25 +1172,29 @@ discard block |
||
1132 | 1172 | { |
1133 | 1173 | global $settings; |
1134 | 1174 | |
1135 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
1136 | - return false; |
|
1175 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
1176 | + return false; |
|
1177 | + } |
|
1137 | 1178 | |
1138 | 1179 | // Get a list of the available font directories. |
1139 | 1180 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
1140 | 1181 | $font_list = array(); |
1141 | - while ($entry = $font_dir->read()) |
|
1142 | - if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1182 | + while ($entry = $font_dir->read()) { |
|
1183 | + if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1143 | 1184 | $font_list[] = $entry; |
1185 | + } |
|
1144 | 1186 | |
1145 | - if (empty($font_list)) |
|
1146 | - return false; |
|
1187 | + if (empty($font_list)) { |
|
1188 | + return false; |
|
1189 | + } |
|
1147 | 1190 | |
1148 | 1191 | // Pick a random font. |
1149 | 1192 | $random_font = $font_list[array_rand($font_list)]; |
1150 | 1193 | |
1151 | 1194 | // Check if the given letter exists. |
1152 | - if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) |
|
1153 | - return false; |
|
1195 | + if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) { |
|
1196 | + return false; |
|
1197 | + } |
|
1154 | 1198 | |
1155 | 1199 | // Include it! |
1156 | 1200 | header('content-type: image/png'); |