@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | <div class="windowbg2 noup"> |
128 | 128 | <dl class="settings">'; |
129 | 129 | |
130 | - if (!empty($context['table_info'])) |
|
131 | - echo ' |
|
130 | + if (!empty($context['table_info'])) { |
|
131 | + echo ' |
|
132 | 132 | <dt> |
133 | 133 | <strong>', $txt['search_method_messages_table_space'], ':</strong> |
134 | 134 | </dt> |
@@ -141,6 +141,7 @@ discard block |
||
141 | 141 | <dd> |
142 | 142 | ', $context['table_info']['index_length'], ' |
143 | 143 | </dd>'; |
144 | + } |
|
144 | 145 | echo ' |
145 | 146 | </dl> |
146 | 147 | ', $context['double_index'] ? '<div class="noticebox"> |
@@ -163,17 +164,17 @@ discard block |
||
163 | 164 | <dd> |
164 | 165 | <span class="smalltext">'; |
165 | 166 | |
166 | - if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) |
|
167 | - echo ' |
|
167 | + if (empty($context['fulltext_index']) && empty($context['cannot_create_fulltext'])) { |
|
168 | + echo ' |
|
168 | 169 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createfulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_create'], '</a>]'; |
169 | - |
|
170 | - elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) |
|
171 | - echo ' |
|
170 | + } elseif (empty($context['fulltext_index']) && !empty($context['cannot_create_fulltext'])) { |
|
171 | + echo ' |
|
172 | 172 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_fulltext_cannot_create']; |
173 | - else |
|
174 | - echo ' |
|
173 | + } else { |
|
174 | + echo ' |
|
175 | 175 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removefulltext;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_method_fulltext_remove'], '</a>]<br> |
176 | 176 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['fulltext_length']; |
177 | + } |
|
177 | 178 | echo ' |
178 | 179 | </span> |
179 | 180 | </dd>'; |
@@ -187,26 +188,27 @@ discard block |
||
187 | 188 | <dd> |
188 | 189 | <span class="smalltext">'; |
189 | 190 | |
190 | - if ($context['custom_index']) |
|
191 | - echo ' |
|
191 | + if ($context['custom_index']) { |
|
192 | + echo ' |
|
192 | 193 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_already_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>]<br> |
193 | 194 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
194 | - |
|
195 | - elseif ($context['partial_custom_index']) |
|
196 | - echo ' |
|
195 | + } elseif ($context['partial_custom_index']) { |
|
196 | + echo ' |
|
197 | 197 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_index_partial'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=removecustom;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_remove'], '</a>] [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex;resume;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-msm_token_var'], '=', $context['admin-msm_token'], '">', $txt['search_index_custom_resume'], '</a>]<br> |
198 | 198 | <strong>', $txt['search_index_size'], ':</strong> ', $context['table_info']['custom_index_length']; |
199 | - else |
|
200 | - echo ' |
|
199 | + } else { |
|
200 | + echo ' |
|
201 | 201 | <strong>', $txt['search_index_label'], ':</strong> ', $txt['search_method_no_index_exists'], ' [<a href="', $scripturl, '?action=admin;area=managesearch;sa=createmsgindex">', $txt['search_index_create_custom'], '</a>]'; |
202 | + } |
|
202 | 203 | echo ' |
203 | 204 | </span> |
204 | 205 | </dd>'; |
205 | 206 | |
206 | 207 | foreach ($context['search_apis'] as $api) |
207 | 208 | { |
208 | - if (empty($api['label']) || $api['has_template']) |
|
209 | - continue; |
|
209 | + if (empty($api['label']) || $api['has_template']) { |
|
210 | + continue; |
|
211 | + } |
|
210 | 212 | |
211 | 213 | echo ' |
212 | 214 | <dt> |
@@ -214,11 +216,12 @@ discard block |
||
214 | 216 | ', $api['label'], ' |
215 | 217 | </dt>'; |
216 | 218 | |
217 | - if ($api['desc']) |
|
218 | - echo ' |
|
219 | + if ($api['desc']) { |
|
220 | + echo ' |
|
219 | 221 | <dd> |
220 | 222 | <span class="smalltext">', $api['desc'], '</span> |
221 | 223 | </dd>'; |
224 | + } |
|
222 | 225 | } |
223 | 226 | |
224 | 227 | echo ' |
@@ -19,26 +19,28 @@ discard block |
||
19 | 19 | global $context, $settings, $scripturl, $txt, $modSettings; |
20 | 20 | |
21 | 21 | // Not allowed to edit? |
22 | - if (!$context['can_modify']) |
|
23 | - echo ' |
|
22 | + if (!$context['can_modify']) { |
|
23 | + echo ' |
|
24 | 24 | <div class="errorbox"> |
25 | 25 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
26 | 26 | </div>'; |
27 | + } |
|
27 | 28 | |
28 | 29 | echo ' |
29 | 30 | <div id="admin_form_wrapper"> |
30 | 31 | <form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">'; |
31 | 32 | |
32 | - if (!empty($context['profile'])) |
|
33 | - echo ' |
|
33 | + if (!empty($context['profile'])) { |
|
34 | + echo ' |
|
34 | 35 | <div class="cat_bar"> |
35 | 36 | <h3 class="catbg">', $txt['permissions_for_profile'], ': "', $context['profile']['name'], '"</h3> |
36 | 37 | </div>'; |
37 | - else |
|
38 | - echo ' |
|
38 | + } else { |
|
39 | + echo ' |
|
39 | 40 | <div class="cat_bar"> |
40 | 41 | <h3 class="catbg">', $txt['permissions_title'], '</h3> |
41 | 42 | </div>'; |
43 | + } |
|
42 | 44 | |
43 | 45 | echo ' |
44 | 46 | <table class="table_grid"> |
@@ -47,13 +49,14 @@ discard block |
||
47 | 49 | <th>', $txt['membergroups_name'], '</th> |
48 | 50 | <th class="small_table">', $txt['membergroups_members_top'], '</th>'; |
49 | 51 | |
50 | - if (empty($modSettings['permission_enable_deny'])) |
|
51 | - echo ' |
|
52 | + if (empty($modSettings['permission_enable_deny'])) { |
|
53 | + echo ' |
|
52 | 54 | <th class="small_table">', $txt['membergroups_permissions'], '</th>'; |
53 | - else |
|
54 | - echo ' |
|
55 | + } else { |
|
56 | + echo ' |
|
55 | 57 | <th class="small_table">', $txt['permissions_allowed'], '</th> |
56 | 58 | <th class="small_table">', $txt['permissions_denied'], '</th>'; |
59 | + } |
|
57 | 60 | |
58 | 61 | echo ' |
59 | 62 | <th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th> |
@@ -71,26 +74,28 @@ discard block |
||
71 | 74 | <td> |
72 | 75 | ', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a> ' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '<span>', $group['name'], '</span>'; |
73 | 76 | |
74 | - if (!empty($group['children'])) |
|
75 | - echo ' |
|
77 | + if (!empty($group['children'])) { |
|
78 | + echo ' |
|
76 | 79 | <br> |
77 | 80 | <span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
81 | + } |
|
78 | 82 | |
79 | 83 | echo ' |
80 | 84 | </td> |
81 | 85 | <td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>'; |
82 | 86 | |
83 | - if (empty($modSettings['permission_enable_deny'])) |
|
84 | - echo ' |
|
87 | + if (empty($modSettings['permission_enable_deny'])) { |
|
88 | + echo ' |
|
85 | 89 | <td>', $group['num_permissions']['allowed'], '</td>'; |
86 | - else |
|
87 | - echo ' |
|
90 | + } else { |
|
91 | + echo ' |
|
88 | 92 | <td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '> |
89 | 93 | ', $group['num_permissions']['allowed'], ' |
90 | 94 | </td> |
91 | 95 | <td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '> |
92 | 96 | ', $group['num_permissions']['denied'], ' |
93 | 97 | </td>'; |
98 | + } |
|
94 | 99 | |
95 | 100 | echo ' |
96 | 101 | <td> |
@@ -141,10 +146,11 @@ discard block |
||
141 | 146 | <select name="copy_from"> |
142 | 147 | <option value="empty">(', $txt['permissions_select_membergroup'], ')</option>'; |
143 | 148 | |
144 | - foreach ($context['groups'] as $group) |
|
145 | - if ($group['id'] != 1) |
|
149 | + foreach ($context['groups'] as $group) { |
|
150 | + if ($group['id'] != 1) |
|
146 | 151 | echo ' |
147 | 152 | <option value="', $group['id'], '">', $group['name'], '</option>'; |
153 | + } |
|
148 | 154 | |
149 | 155 | echo ' |
150 | 156 | </select> |
@@ -154,9 +160,10 @@ discard block |
||
154 | 160 | <option value="add">', $txt['permissions_add'], '...</option> |
155 | 161 | <option value="clear">', $txt['permissions_remove'], '...</option>'; |
156 | 162 | |
157 | - if (!empty($modSettings['permission_enable_deny'])) |
|
158 | - echo ' |
|
163 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
164 | + echo ' |
|
159 | 165 | <option value="deny">', $txt['permissions_deny'], '...</option>'; |
166 | + } |
|
160 | 167 | |
161 | 168 | echo ' |
162 | 169 | </select> |
@@ -167,31 +174,35 @@ discard block |
||
167 | 174 | |
168 | 175 | foreach ($context['permissions'] as $permissionType) |
169 | 176 | { |
170 | - if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) |
|
171 | - continue; |
|
177 | + if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) { |
|
178 | + continue; |
|
179 | + } |
|
172 | 180 | |
173 | 181 | foreach ($permissionType['columns'] as $column) |
174 | 182 | { |
175 | 183 | foreach ($column as $permissionGroup) |
176 | 184 | { |
177 | - if ($permissionGroup['hidden']) |
|
178 | - continue; |
|
185 | + if ($permissionGroup['hidden']) { |
|
186 | + continue; |
|
187 | + } |
|
179 | 188 | |
180 | 189 | echo ' |
181 | 190 | <option value="" disabled>[', $permissionGroup['name'], ']</option>'; |
182 | 191 | |
183 | 192 | foreach ($permissionGroup['permissions'] as $perm) |
184 | 193 | { |
185 | - if ($perm['hidden']) |
|
186 | - continue; |
|
194 | + if ($perm['hidden']) { |
|
195 | + continue; |
|
196 | + } |
|
187 | 197 | |
188 | - if ($perm['has_own_any']) |
|
189 | - echo ' |
|
198 | + if ($perm['has_own_any']) { |
|
199 | + echo ' |
|
190 | 200 | <option value="', $permissionType['id'], '/', $perm['own']['id'], '"> ', $perm['name'], ' (', $perm['own']['name'], ')</option> |
191 | 201 | <option value="', $permissionType['id'], '/', $perm['any']['id'], '"> ', $perm['name'], ' (', $perm['any']['name'], ')</option>'; |
192 | - else |
|
193 | - echo ' |
|
202 | + } else { |
|
203 | + echo ' |
|
194 | 204 | <option value="', $permissionType['id'], '/', $perm['id'], '"> ', $perm['name'], '</option>'; |
205 | + } |
|
195 | 206 | } |
196 | 207 | } |
197 | 208 | } |
@@ -256,9 +267,10 @@ discard block |
||
256 | 267 | } |
257 | 268 | </script>'; |
258 | 269 | |
259 | - if (!empty($context['profile'])) |
|
260 | - echo ' |
|
270 | + if (!empty($context['profile'])) { |
|
271 | + echo ' |
|
261 | 272 | <input type="hidden" name="pid" value="', $context['profile']['id'], '">'; |
273 | + } |
|
262 | 274 | |
263 | 275 | echo ' |
264 | 276 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -303,9 +315,10 @@ discard block |
||
303 | 315 | <h3 class="subbg">', $category['name'], '</h3> |
304 | 316 | </div>'; |
305 | 317 | |
306 | - if (!empty($category['boards'])) |
|
307 | - echo ' |
|
318 | + if (!empty($category['boards'])) { |
|
319 | + echo ' |
|
308 | 320 | <ul class="perm_boards flow_hidden">'; |
321 | + } |
|
309 | 322 | |
310 | 323 | foreach ($category['boards'] as $board) |
311 | 324 | { |
@@ -321,33 +334,36 @@ discard block |
||
321 | 334 | echo ' |
322 | 335 | <select name="boardprofile[', $board['id'], ']">'; |
323 | 336 | |
324 | - foreach ($context['profiles'] as $id => $profile) |
|
325 | - echo ' |
|
337 | + foreach ($context['profiles'] as $id => $profile) { |
|
338 | + echo ' |
|
326 | 339 | <option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
340 | + } |
|
327 | 341 | |
328 | 342 | echo ' |
329 | 343 | </select>'; |
330 | - } |
|
331 | - else |
|
332 | - echo ' |
|
344 | + } else { |
|
345 | + echo ' |
|
333 | 346 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>'; |
347 | + } |
|
334 | 348 | |
335 | 349 | echo ' |
336 | 350 | </span> |
337 | 351 | </li>'; |
338 | 352 | } |
339 | 353 | |
340 | - if (!empty($category['boards'])) |
|
341 | - echo ' |
|
354 | + if (!empty($category['boards'])) { |
|
355 | + echo ' |
|
342 | 356 | </ul>'; |
357 | + } |
|
343 | 358 | } |
344 | 359 | |
345 | - if ($context['edit_all']) |
|
346 | - echo ' |
|
360 | + if ($context['edit_all']) { |
|
361 | + echo ' |
|
347 | 362 | <input type="submit" name="save_changes" value="', $txt['save'], '" class="button">'; |
348 | - else |
|
349 | - echo ' |
|
363 | + } else { |
|
364 | + echo ' |
|
350 | 365 | <a class="button" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>'; |
366 | + } |
|
351 | 367 | |
352 | 368 | echo ' |
353 | 369 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -387,12 +403,13 @@ discard block |
||
387 | 403 | <tr class="windowbg"> |
388 | 404 | <td>'; |
389 | 405 | |
390 | - if (!empty($context['show_rename_boxes']) && $profile['can_edit']) |
|
391 | - echo ' |
|
406 | + if (!empty($context['show_rename_boxes']) && $profile['can_edit']) { |
|
407 | + echo ' |
|
392 | 408 | <input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '">'; |
393 | - else |
|
394 | - echo ' |
|
409 | + } else { |
|
410 | + echo ' |
|
395 | 411 | <a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>'; |
412 | + } |
|
396 | 413 | |
397 | 414 | echo ' |
398 | 415 | </td> |
@@ -412,9 +429,10 @@ discard block |
||
412 | 429 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
413 | 430 | <input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">'; |
414 | 431 | |
415 | - if ($context['can_edit_something']) |
|
416 | - echo ' |
|
432 | + if ($context['can_edit_something']) { |
|
433 | + echo ' |
|
417 | 434 | <input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button">'; |
435 | + } |
|
418 | 436 | |
419 | 437 | echo ' |
420 | 438 | <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '> |
@@ -439,9 +457,10 @@ discard block |
||
439 | 457 | <dd> |
440 | 458 | <select name="copy_from">'; |
441 | 459 | |
442 | - foreach ($context['profiles'] as $id => $profile) |
|
443 | - echo ' |
|
460 | + foreach ($context['profiles'] as $id => $profile) { |
|
461 | + echo ' |
|
444 | 462 | <option value="', $id, '">', $profile['name'], '</option>'; |
463 | + } |
|
445 | 464 | |
446 | 465 | echo ' |
447 | 466 | </select> |
@@ -463,13 +482,13 @@ discard block |
||
463 | 482 | global $context, $scripturl, $txt, $modSettings; |
464 | 483 | |
465 | 484 | // Cannot be edited? |
466 | - if (!$context['profile']['can_modify']) |
|
467 | - echo ' |
|
485 | + if (!$context['profile']['can_modify']) { |
|
486 | + echo ' |
|
468 | 487 | <div class="errorbox"> |
469 | 488 | ', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), ' |
470 | 489 | </div>'; |
471 | - else |
|
472 | - echo ' |
|
490 | + } else { |
|
491 | + echo ' |
|
473 | 492 | <script> |
474 | 493 | window.smf_usedDeny = false; |
475 | 494 | |
@@ -481,27 +500,30 @@ discard block |
||
481 | 500 | return true; |
482 | 501 | } |
483 | 502 | </script>'; |
503 | + } |
|
484 | 504 | |
485 | 505 | echo ' |
486 | 506 | <div id="admincenter"> |
487 | 507 | <form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">'; |
488 | 508 | |
489 | - if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) |
|
490 | - echo ' |
|
509 | + if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) { |
|
510 | + echo ' |
|
491 | 511 | <div class="information"> |
492 | 512 | ', $txt['permissions_option_desc'], ' |
493 | 513 | </div>'; |
514 | + } |
|
494 | 515 | |
495 | 516 | echo ' |
496 | 517 | <div class="cat_bar"> |
497 | 518 | <h3 class="catbg">'; |
498 | 519 | |
499 | - if ($context['permission_type'] == 'board') |
|
500 | - echo ' |
|
520 | + if ($context['permission_type'] == 'board') { |
|
521 | + echo ' |
|
501 | 522 | ', $txt['permissions_local_for'], ' "', $context['group']['name'], '" ', $txt['permissions_on'], ' "', $context['profile']['name'], '"'; |
502 | - else |
|
503 | - echo ' |
|
523 | + } else { |
|
524 | + echo ' |
|
504 | 525 | ', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - "', $context['group']['name'], '"'; |
526 | + } |
|
505 | 527 | echo ' |
506 | 528 | </h3> |
507 | 529 | </div>'; |
@@ -524,15 +546,17 @@ discard block |
||
524 | 546 | template_modify_group_display('board'); |
525 | 547 | } |
526 | 548 | |
527 | - if ($context['profile']['can_modify']) |
|
528 | - echo ' |
|
549 | + if ($context['profile']['can_modify']) { |
|
550 | + echo ' |
|
529 | 551 | <div class="padding"> |
530 | 552 | <input type="submit" value="', $txt['permissions_commit'], '" class="button"> |
531 | 553 | </div>'; |
554 | + } |
|
532 | 555 | |
533 | - foreach ($context['hidden_perms'] as $hidden_perm) |
|
534 | - echo ' |
|
556 | + foreach ($context['hidden_perms'] as $hidden_perm) { |
|
557 | + echo ' |
|
535 | 558 | <input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">'; |
559 | + } |
|
536 | 560 | |
537 | 561 | echo ' |
538 | 562 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -560,17 +584,19 @@ discard block |
||
560 | 584 | |
561 | 585 | foreach ($column as $permissionGroup) |
562 | 586 | { |
563 | - if (empty($permissionGroup['permissions'])) |
|
564 | - continue; |
|
587 | + if (empty($permissionGroup['permissions'])) { |
|
588 | + continue; |
|
589 | + } |
|
565 | 590 | |
566 | 591 | // Are we likely to have something in this group to display or is it all hidden? |
567 | 592 | $has_display_content = false; |
568 | 593 | if (!$permissionGroup['hidden']) |
569 | 594 | { |
570 | 595 | // Before we go any further check we are going to have some data to print otherwise we just have a silly heading. |
571 | - foreach ($permissionGroup['permissions'] as $permission) |
|
572 | - if (!$permission['hidden']) |
|
596 | + foreach ($permissionGroup['permissions'] as $permission) { |
|
597 | + if (!$permission['hidden']) |
|
573 | 598 | $has_display_content = true; |
599 | + } |
|
574 | 600 | |
575 | 601 | if ($has_display_content) |
576 | 602 | { |
@@ -579,10 +605,11 @@ discard block |
||
579 | 605 | <th></th> |
580 | 606 | <th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>'; |
581 | 607 | |
582 | - if ($context['group']['id'] != -1) |
|
583 | - echo ' |
|
608 | + if ($context['group']['id'] != -1) { |
|
609 | + echo ' |
|
584 | 610 | <th>', $txt['permissions_option_own'], '</th> |
585 | 611 | <th>', $txt['permissions_option_any'], '</th>'; |
612 | + } |
|
586 | 613 | |
587 | 614 | echo ' |
588 | 615 | </tr>'; |
@@ -605,17 +632,18 @@ discard block |
||
605 | 632 | // Guests can't do their own thing. |
606 | 633 | if ($context['group']['id'] != -1) |
607 | 634 | { |
608 | - if (empty($modSettings['permission_enable_deny'])) |
|
609 | - echo ' |
|
635 | + if (empty($modSettings['permission_enable_deny'])) { |
|
636 | + echo ' |
|
610 | 637 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" ', $disable_field, '>'; |
611 | - else |
|
638 | + } else |
|
612 | 639 | { |
613 | 640 | echo ' |
614 | 641 | <select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>'; |
615 | 642 | |
616 | - foreach (array('on', 'off', 'deny') as $c) |
|
617 | - echo ' |
|
643 | + foreach (array('on', 'off', 'deny') as $c) { |
|
644 | + echo ' |
|
618 | 645 | <option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
646 | + } |
|
619 | 647 | echo ' |
620 | 648 | </select>'; |
621 | 649 | } |
@@ -625,39 +653,41 @@ discard block |
||
625 | 653 | <td>'; |
626 | 654 | } |
627 | 655 | |
628 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
629 | - echo ' |
|
656 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
657 | + echo ' |
|
630 | 658 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>'; |
631 | - else |
|
659 | + } else |
|
632 | 660 | { |
633 | 661 | echo ' |
634 | 662 | <select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>'; |
635 | 663 | |
636 | - foreach (array('on', 'off', 'deny') as $c) |
|
637 | - echo ' |
|
664 | + foreach (array('on', 'off', 'deny') as $c) { |
|
665 | + echo ' |
|
638 | 666 | <option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
667 | + } |
|
639 | 668 | echo ' |
640 | 669 | </select>'; |
641 | 670 | } |
642 | - } |
|
643 | - else |
|
671 | + } else |
|
644 | 672 | { |
645 | - if ($context['group']['id'] != -1) |
|
646 | - echo ' |
|
673 | + if ($context['group']['id'] != -1) { |
|
674 | + echo ' |
|
647 | 675 | </td> |
648 | 676 | <td>'; |
677 | + } |
|
649 | 678 | |
650 | - if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) |
|
651 | - echo ' |
|
679 | + if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) { |
|
680 | + echo ' |
|
652 | 681 | <input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>'; |
653 | - else |
|
682 | + } else |
|
654 | 683 | { |
655 | 684 | echo ' |
656 | 685 | <select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>'; |
657 | 686 | |
658 | - foreach (array('on', 'off', 'deny') as $c) |
|
659 | - echo ' |
|
687 | + foreach (array('on', 'off', 'deny') as $c) { |
|
688 | + echo ' |
|
660 | 689 | <option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>'; |
690 | + } |
|
661 | 691 | echo ' |
662 | 692 | </select>'; |
663 | 693 | } |
@@ -689,11 +719,11 @@ discard block |
||
689 | 719 | <fieldset id="', $context['current_permission'], '"> |
690 | 720 | <legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>'; |
691 | 721 | |
692 | - if (empty($modSettings['permission_enable_deny'])) |
|
693 | - echo ' |
|
722 | + if (empty($modSettings['permission_enable_deny'])) { |
|
723 | + echo ' |
|
694 | 724 | <ul>'; |
695 | - else |
|
696 | - echo ' |
|
725 | + } else { |
|
726 | + echo ' |
|
697 | 727 | <div class="information">', $txt['permissions_option_desc'], '</div> |
698 | 728 | <dl class="settings"> |
699 | 729 | <dt> |
@@ -703,47 +733,52 @@ discard block |
||
703 | 733 | </dt> |
704 | 734 | <dd> |
705 | 735 | </dd>'; |
736 | + } |
|
706 | 737 | |
707 | 738 | foreach ($context['member_groups'] as $group) |
708 | 739 | { |
709 | - if (!empty($modSettings['permission_enable_deny'])) |
|
710 | - echo ' |
|
740 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
741 | + echo ' |
|
711 | 742 | <dt>'; |
712 | - else |
|
713 | - echo ' |
|
743 | + } else { |
|
744 | + echo ' |
|
714 | 745 | <li>'; |
746 | + } |
|
715 | 747 | |
716 | - if (empty($modSettings['permission_enable_deny'])) |
|
717 | - echo ' |
|
748 | + if (empty($modSettings['permission_enable_deny'])) { |
|
749 | + echo ' |
|
718 | 750 | <input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '>'; |
719 | - else |
|
720 | - echo ' |
|
751 | + } else { |
|
752 | + echo ' |
|
721 | 753 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '></span> |
722 | 754 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', '></span> |
723 | 755 | <span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', '></span>'; |
756 | + } |
|
724 | 757 | |
725 | - if (!empty($modSettings['permission_enable_deny'])) |
|
726 | - echo ' |
|
758 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
759 | + echo ' |
|
727 | 760 | </dt> |
728 | 761 | <dd> |
729 | 762 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
730 | 763 | </dd>'; |
731 | - else |
|
732 | - echo ' |
|
764 | + } else { |
|
765 | + echo ' |
|
733 | 766 | <span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span> |
734 | 767 | </li>'; |
768 | + } |
|
735 | 769 | } |
736 | 770 | |
737 | - if (empty($modSettings['permission_enable_deny'])) |
|
738 | - echo ' |
|
771 | + if (empty($modSettings['permission_enable_deny'])) { |
|
772 | + echo ' |
|
739 | 773 | <li> |
740 | 774 | <input type="checkbox" onclick="invertAll(this, this.form, \''. $context['current_permission'] . '[\');"> |
741 | 775 | <span>', $txt['check_all'], '</span> |
742 | 776 | </li> |
743 | 777 | </ul>'; |
744 | - else |
|
745 | - echo ' |
|
778 | + } else { |
|
779 | + echo ' |
|
746 | 780 | </dl>'; |
781 | + } |
|
747 | 782 | |
748 | 783 | echo ' |
749 | 784 | </fieldset> |
@@ -783,9 +818,10 @@ discard block |
||
783 | 818 | if (!empty($modSettings['postmod_active'])) |
784 | 819 | { |
785 | 820 | // Got advanced permissions - if so warn! |
786 | - if (!empty($modSettings['permission_enable_deny'])) |
|
787 | - echo ' |
|
821 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
822 | + echo ' |
|
788 | 823 | <div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>'; |
824 | + } |
|
789 | 825 | |
790 | 826 | echo ' |
791 | 827 | <div class="padding"> |
@@ -800,10 +836,11 @@ discard block |
||
800 | 836 | ', $txt['permissions_post_moderation_select'], ': |
801 | 837 | <select name="pid" onchange="document.forms.postmodForm.submit();">'; |
802 | 838 | |
803 | - foreach ($context['profiles'] as $profile) |
|
804 | - if ($profile['can_modify']) |
|
839 | + foreach ($context['profiles'] as $profile) { |
|
840 | + if ($profile['can_modify']) |
|
805 | 841 | echo ' |
806 | 842 | <option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
843 | + } |
|
807 | 844 | |
808 | 845 | echo ' |
809 | 846 | </select> |
@@ -824,11 +861,12 @@ discard block |
||
824 | 861 | ', $txt['permissions_post_moderation_replies_any'], ' |
825 | 862 | </th>'; |
826 | 863 | |
827 | - if ($modSettings['attachmentEnable'] == 1) |
|
828 | - echo ' |
|
864 | + if ($modSettings['attachmentEnable'] == 1) { |
|
865 | + echo ' |
|
829 | 866 | <th class="centercol" colspan="3"> |
830 | 867 | ', $txt['permissions_post_moderation_attachments'], ' |
831 | 868 | </th>'; |
869 | + } |
|
832 | 870 | |
833 | 871 | echo ' |
834 | 872 | </tr> |
@@ -846,11 +884,12 @@ discard block |
||
846 | 884 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
847 | 885 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
848 | 886 | |
849 | - if ($modSettings['attachmentEnable'] == 1) |
|
850 | - echo ' |
|
887 | + if ($modSettings['attachmentEnable'] == 1) { |
|
888 | + echo ' |
|
851 | 889 | <th><span class="generic_icons post_moderation_allow"></span></th> |
852 | 890 | <th><span class="generic_icons post_moderation_moderate"></span></th> |
853 | 891 | <th><span class="generic_icons post_moderation_deny"></span></th>'; |
892 | + } |
|
854 | 893 | |
855 | 894 | echo ' |
856 | 895 | </tr> |
@@ -864,10 +903,11 @@ discard block |
||
864 | 903 | <td class="half_table"> |
865 | 904 | <span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>'; |
866 | 905 | |
867 | - if (!empty($group['children'])) |
|
868 | - echo ' |
|
906 | + if (!empty($group['children'])) { |
|
907 | + echo ' |
|
869 | 908 | <br> |
870 | 909 | <span class="smalltext">', $txt['permissions_includes_inherited'], ': "', implode('", "', $group['children']), '"</span>'; |
910 | + } |
|
871 | 911 | |
872 | 912 | echo ' |
873 | 913 | </td> |
@@ -882,11 +922,11 @@ discard block |
||
882 | 922 | </td>'; |
883 | 923 | |
884 | 924 | // Guests can't have "own" permissions |
885 | - if ($group['id'] == '-1') |
|
886 | - echo ' |
|
925 | + if ($group['id'] == '-1') { |
|
926 | + echo ' |
|
887 | 927 | <td colspan="3"></td>'; |
888 | - else |
|
889 | - echo ' |
|
928 | + } else { |
|
929 | + echo ' |
|
890 | 930 | <td class="centercol"> |
891 | 931 | <input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', '> |
892 | 932 | </td> |
@@ -896,6 +936,7 @@ discard block |
||
896 | 936 | <td class="centercol"> |
897 | 937 | <input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', '> |
898 | 938 | </td>'; |
939 | + } |
|
899 | 940 | |
900 | 941 | echo ' |
901 | 942 | <td class="centercol"> |
@@ -908,8 +949,8 @@ discard block |
||
908 | 949 | <input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', '> |
909 | 950 | </td>'; |
910 | 951 | |
911 | - if ($modSettings['attachmentEnable'] == 1) |
|
912 | - echo ' |
|
952 | + if ($modSettings['attachmentEnable'] == 1) { |
|
953 | + echo ' |
|
913 | 954 | <td class="centercol"> |
914 | 955 | <input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', '> |
915 | 956 | </td> |
@@ -919,6 +960,7 @@ discard block |
||
919 | 960 | <td class="centercol"> |
920 | 961 | <input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', '> |
921 | 962 | </td>'; |
963 | + } |
|
922 | 964 | |
923 | 965 | echo ' |
924 | 966 | </tr>'; |
@@ -40,9 +40,10 @@ discard block |
||
40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
41 | 41 | |
42 | 42 | // Show a list of all the years we allow... |
43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
44 | - echo ' |
|
43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
44 | + echo ' |
|
45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
46 | + } |
|
46 | 47 | |
47 | 48 | echo ' |
48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
51 | 52 | |
52 | 53 | // There are 12 months per year - ensure that they all get listed. |
53 | - for ($month = 1; $month <= 12; $month++) |
|
54 | - echo ' |
|
54 | + for ($month = 1; $month <= 12; $month++) { |
|
55 | + echo ' |
|
55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | echo ' |
58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
61 | 63 | |
62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
64 | - echo ' |
|
65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
66 | + echo ' |
|
65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
68 | + } |
|
66 | 69 | |
67 | 70 | echo ' |
68 | 71 | </select> |
69 | 72 | </dd> |
70 | 73 | </dl>'; |
71 | 74 | |
72 | - if ($context['is_new']) |
|
73 | - echo ' |
|
75 | + if ($context['is_new']) { |
|
76 | + echo ' |
|
74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
75 | - else |
|
76 | - echo ' |
|
78 | + } else { |
|
79 | + echo ' |
|
77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
83 | + } |
|
80 | 84 | echo ' |
81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
82 | 86 | </div><!-- .windowbg2 --> |
@@ -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"> |
@@ -423,8 +435,9 @@ discard block |
||
423 | 435 | { |
424 | 436 | |
425 | 437 | // Ignore the inactive ones... |
426 | - if (empty($subscription['active'])) |
|
427 | - continue; |
|
438 | + if (empty($subscription['active'])) { |
|
439 | + continue; |
|
440 | + } |
|
428 | 441 | |
429 | 442 | echo ' |
430 | 443 | <div class="cat_bar"> |
@@ -434,9 +447,10 @@ discard block |
||
434 | 447 | <p><strong>', $subscription['name'], '</strong></p> |
435 | 448 | <p class="smalltext">', $subscription['desc'], '</p>'; |
436 | 449 | |
437 | - if (!$subscription['flexible']) |
|
438 | - echo ' |
|
450 | + if (!$subscription['flexible']) { |
|
451 | + echo ' |
|
439 | 452 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
453 | + } |
|
440 | 454 | |
441 | 455 | if ($context['user']['is_owner']) |
442 | 456 | { |
@@ -449,24 +463,25 @@ discard block |
||
449 | 463 | <select name="cur[', $subscription['id'], ']">'; |
450 | 464 | |
451 | 465 | // Print out the costs for this one. |
452 | - foreach ($subscription['costs'] as $duration => $value) |
|
453 | - echo ' |
|
466 | + foreach ($subscription['costs'] as $duration => $value) { |
|
467 | + echo ' |
|
454 | 468 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
469 | + } |
|
455 | 470 | |
456 | 471 | echo ' |
457 | 472 | </select>'; |
458 | - } |
|
459 | - else |
|
460 | - echo ' |
|
473 | + } else { |
|
474 | + echo ' |
|
461 | 475 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
476 | + } |
|
462 | 477 | |
463 | 478 | echo ' |
464 | 479 | <hr> |
465 | 480 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
466 | - } |
|
467 | - else |
|
468 | - echo ' |
|
481 | + } else { |
|
482 | + echo ' |
|
469 | 483 | <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>'; |
484 | + } |
|
470 | 485 | |
471 | 486 | echo ' |
472 | 487 | </div><!-- .windowbg -->'; |
@@ -493,19 +508,20 @@ discard block |
||
493 | 508 | </thead> |
494 | 509 | <tbody>'; |
495 | 510 | |
496 | - if (empty($context['current'])) |
|
497 | - echo ' |
|
511 | + if (empty($context['current'])) { |
|
512 | + echo ' |
|
498 | 513 | <tr class="windowbg"> |
499 | 514 | <td colspan="4"> |
500 | 515 | ', $txt['paid_none_yet'], ' |
501 | 516 | </td> |
502 | 517 | </tr>'; |
518 | + } |
|
503 | 519 | |
504 | 520 | foreach ($context['current'] as $sub) |
505 | 521 | { |
506 | 522 | |
507 | - if (!$sub['hide']) |
|
508 | - echo ' |
|
523 | + if (!$sub['hide']) { |
|
524 | + echo ' |
|
509 | 525 | <tr class="windowbg"> |
510 | 526 | <td> |
511 | 527 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -516,6 +532,7 @@ discard block |
||
516 | 532 | <td>', $sub['start'], '</td> |
517 | 533 | <td>', $sub['end'], '</td> |
518 | 534 | </tr>'; |
535 | + } |
|
519 | 536 | } |
520 | 537 | |
521 | 538 | echo ' |
@@ -567,15 +584,17 @@ discard block |
||
567 | 584 | ', $gateway['desc'], '<br> |
568 | 585 | <form action="', $gateway['form'], '" method="post">'; |
569 | 586 | |
570 | - if (!empty($gateway['javascript'])) |
|
571 | - echo ' |
|
587 | + if (!empty($gateway['javascript'])) { |
|
588 | + echo ' |
|
572 | 589 | <script> |
573 | 590 | ', $gateway['javascript'], ' |
574 | 591 | </script>'; |
592 | + } |
|
575 | 593 | |
576 | - foreach ($gateway['hidden'] as $name => $value) |
|
577 | - echo ' |
|
594 | + foreach ($gateway['hidden'] as $name => $value) { |
|
595 | + echo ' |
|
578 | 596 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
597 | + } |
|
579 | 598 | |
580 | 599 | echo ' |
581 | 600 | <br> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
74 | 76 | ); |
75 | 77 | |
76 | 78 | // Start with an empty array. |
77 | - if ($boardIndexOptions['include_categories']) |
|
78 | - $categories = array(); |
|
79 | - else |
|
80 | - $this_category = array(); |
|
79 | + if ($boardIndexOptions['include_categories']) { |
|
80 | + $categories = array(); |
|
81 | + } else { |
|
82 | + $this_category = array(); |
|
83 | + } |
|
81 | 84 | $boards = array(); |
82 | 85 | |
83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
89 | 92 | |
90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
92 | - $boards[] = $row_board['id_board']; |
|
94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
95 | + $boards[] = $row_board['id_board']; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ($boardIndexOptions['include_categories']) |
95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -161,14 +166,12 @@ discard block |
||
161 | 166 | { |
162 | 167 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
163 | 168 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
164 | - } |
|
165 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
169 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
166 | 170 | { |
167 | 171 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
168 | 172 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
169 | 173 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
170 | - } |
|
171 | - else |
|
174 | + } else |
|
172 | 175 | { |
173 | 176 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
174 | 177 | } |
@@ -219,14 +222,16 @@ discard block |
||
219 | 222 | // Child of a child... just add it on... |
220 | 223 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
221 | 224 | { |
222 | - if (!isset($parent_map)) |
|
223 | - $parent_map = array(); |
|
225 | + if (!isset($parent_map)) { |
|
226 | + $parent_map = array(); |
|
227 | + } |
|
224 | 228 | |
225 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
226 | - foreach ($this_category as $id => $board) |
|
229 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
230 | + foreach ($this_category as $id => $board) |
|
227 | 231 | { |
228 | 232 | if (!isset($board['children'][$row_board['id_parent']])) |
229 | 233 | continue; |
234 | + } |
|
230 | 235 | |
231 | 236 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
232 | 237 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -247,8 +252,9 @@ discard block |
||
247 | 252 | continue; |
248 | 253 | } |
249 | 254 | // Found a child of a child - skip. |
250 | - else |
|
251 | - continue; |
|
255 | + else { |
|
256 | + continue; |
|
257 | + } |
|
252 | 258 | |
253 | 259 | // Prepare the subject, and make sure it's not too long. |
254 | 260 | censorText($row_board['subject']); |
@@ -269,12 +275,13 @@ discard block |
||
269 | 275 | 'topic' => $row_board['id_topic'] |
270 | 276 | ); |
271 | 277 | |
272 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
273 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
278 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
279 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
274 | 280 | 'avatar' => $row_board['avatar'], |
275 | 281 | 'email' => $row_board['email_address'], |
276 | 282 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
277 | 283 | )); |
284 | + } |
|
278 | 285 | |
279 | 286 | // Provide the href and link. |
280 | 287 | if ($row_board['subject'] != '') |
@@ -286,8 +293,7 @@ discard block |
||
286 | 293 | link, href, subject, start (where they should go for the first unread post.), |
287 | 294 | and member. (which has id, name, link, href, username in it.) */ |
288 | 295 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
289 | - } |
|
290 | - else |
|
296 | + } else |
|
291 | 297 | { |
292 | 298 | $this_last_post['href'] = ''; |
293 | 299 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -295,8 +301,9 @@ discard block |
||
295 | 301 | } |
296 | 302 | |
297 | 303 | // Set the last post in the parent board. |
298 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
299 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
304 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
305 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
306 | + } |
|
300 | 307 | // Just in the child...? |
301 | 308 | if ($isChild) |
302 | 309 | { |
@@ -306,15 +313,17 @@ discard block |
||
306 | 313 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
307 | 314 | } |
308 | 315 | // No last post for this board? It's not new then, is it..? |
309 | - elseif ($row_board['poster_name'] == '') |
|
310 | - $this_category[$row_board['id_board']]['new'] = false; |
|
316 | + elseif ($row_board['poster_name'] == '') { |
|
317 | + $this_category[$row_board['id_board']]['new'] = false; |
|
318 | + } |
|
311 | 319 | |
312 | 320 | // Determine a global most recent topic. |
313 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
314 | - $latest_post = array( |
|
321 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
322 | + $latest_post = array( |
|
315 | 323 | 'timestamp' => $row_board['poster_time'], |
316 | 324 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
317 | 325 | ); |
326 | + } |
|
318 | 327 | } |
319 | 328 | $smcFunc['db_free_result']($result_boards); |
320 | 329 | |
@@ -331,8 +340,9 @@ discard block |
||
331 | 340 | if (!empty($moderators[$board['id']])) |
332 | 341 | { |
333 | 342 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
334 | - foreach ($moderators[$board['id']] as $moderator) |
|
335 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
343 | + foreach ($moderators[$board['id']] as $moderator) { |
|
344 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
345 | + } |
|
336 | 346 | } |
337 | 347 | if (!empty($groups[$board['id']])) |
338 | 348 | { |
@@ -345,16 +355,16 @@ discard block |
||
345 | 355 | } |
346 | 356 | } |
347 | 357 | } |
348 | - } |
|
349 | - else |
|
358 | + } else |
|
350 | 359 | { |
351 | 360 | foreach ($this_category as $k => $board) |
352 | 361 | { |
353 | 362 | if (!empty($moderators[$board['id']])) |
354 | 363 | { |
355 | 364 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
356 | - foreach ($moderators[$board['id']] as $moderator) |
|
357 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
365 | + foreach ($moderators[$board['id']] as $moderator) { |
|
366 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
367 | + } |
|
358 | 368 | } |
359 | 369 | if (!empty($groups[$board['id']])) |
360 | 370 | { |
@@ -368,20 +378,23 @@ discard block |
||
368 | 378 | } |
369 | 379 | } |
370 | 380 | |
371 | - if ($boardIndexOptions['include_categories']) |
|
372 | - sortCategories($categories); |
|
373 | - else |
|
374 | - sortBoards($this_category); |
|
381 | + if ($boardIndexOptions['include_categories']) { |
|
382 | + sortCategories($categories); |
|
383 | + } else { |
|
384 | + sortBoards($this_category); |
|
385 | + } |
|
375 | 386 | |
376 | 387 | // By now we should know the most recent post...if we wanna know it that is. |
377 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
378 | - $context['latest_post'] = $latest_post['ref']; |
|
388 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
389 | + $context['latest_post'] = $latest_post['ref']; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
381 | - if ($boardIndexOptions['include_categories']) |
|
382 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
383 | - else |
|
384 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
393 | + if ($boardIndexOptions['include_categories']) { |
|
394 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
395 | + } else { |
|
396 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
397 | + } |
|
385 | 398 | |
386 | 399 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
387 | 400 | } |
@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
240 | 248 | 'language' => $language_ftx |
241 | 249 | ) |
242 | 250 | ); |
243 | - } |
|
244 | - else |
|
251 | + } else |
|
245 | 252 | { |
246 | 253 | // Make sure it's gone before creating it. |
247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
259 | 266 | ) |
260 | 267 | ); |
261 | 268 | } |
262 | - } |
|
263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
264 | 270 | { |
265 | 271 | checkSession('get'); |
266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
277 | 283 | $context['fulltext_index'] = array(); |
278 | 284 | |
279 | 285 | // Go back to the default search method. |
280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
281 | - updateSettings(array( |
|
286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
287 | + updateSettings(array( |
|
282 | 288 | 'search_index' => '', |
283 | 289 | )); |
284 | - } |
|
285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
290 | + } |
|
291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
286 | 292 | { |
287 | 293 | checkSession('get'); |
288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
304 | 310 | )); |
305 | 311 | |
306 | 312 | // Go back to the default search method. |
307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
308 | - updateSettings(array( |
|
313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
314 | + updateSettings(array( |
|
309 | 315 | 'search_index' => '', |
310 | 316 | )); |
311 | - } |
|
312 | - elseif (isset($_POST['save'])) |
|
317 | + } |
|
318 | + } elseif (isset($_POST['save'])) |
|
313 | 319 | { |
314 | 320 | checkSession(); |
315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
331 | 337 | // Get some info about the messages table, to show its size and index size. |
332 | 338 | if ($db_type == 'mysql') |
333 | 339 | { |
334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
335 | - $request = $smcFunc['db_query']('', ' |
|
340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
341 | + $request = $smcFunc['db_query']('', ' |
|
336 | 342 | SHOW TABLE STATUS |
337 | 343 | FROM {string:database_name} |
338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
342 | 348 | ) |
343 | 349 | ); |
344 | - else |
|
345 | - $request = $smcFunc['db_query']('', ' |
|
350 | + } else { |
|
351 | + $request = $smcFunc['db_query']('', ' |
|
346 | 352 | SHOW TABLE STATUS |
347 | 353 | LIKE {string:table_name}', |
348 | 354 | array( |
349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
350 | 356 | ) |
351 | 357 | ); |
358 | + } |
|
352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
353 | 360 | { |
354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
360 | 367 | } |
361 | 368 | |
362 | 369 | // Now check the custom index table, if it exists at all. |
363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
364 | - $request = $smcFunc['db_query']('', ' |
|
370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
371 | + $request = $smcFunc['db_query']('', ' |
|
365 | 372 | SHOW TABLE STATUS |
366 | 373 | FROM {string:database_name} |
367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
371 | 378 | ) |
372 | 379 | ); |
373 | - else |
|
374 | - $request = $smcFunc['db_query']('', ' |
|
380 | + } else { |
|
381 | + $request = $smcFunc['db_query']('', ' |
|
375 | 382 | SHOW TABLE STATUS |
376 | 383 | LIKE {string:table_name}', |
377 | 384 | array( |
378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
379 | 386 | ) |
380 | 387 | ); |
388 | + } |
|
381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
382 | 390 | { |
383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
387 | 395 | $smcFunc['db_free_result']($request); |
388 | 396 | } |
389 | - } |
|
390 | - elseif ($db_type == 'postgresql') |
|
397 | + } elseif ($db_type == 'postgresql') |
|
391 | 398 | { |
392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
432 | - } |
|
433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
434 | 440 | { |
435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
437 | 443 | } |
438 | 444 | } |
439 | 445 | $smcFunc['db_free_result']($request); |
440 | - } |
|
441 | - else |
|
442 | - // Didn't work for some reason... |
|
446 | + } else { |
|
447 | + // Didn't work for some reason... |
|
443 | 448 | $context['table_info'] = array( |
444 | 449 | 'data_length' => $txt['not_applicable'], |
445 | 450 | 'index_length' => $txt['not_applicable'], |
446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
448 | 453 | ); |
449 | - } |
|
450 | - else |
|
451 | - $context['table_info'] = array( |
|
454 | + } |
|
455 | + } else { |
|
456 | + $context['table_info'] = array( |
|
452 | 457 | 'data_length' => $txt['not_applicable'], |
453 | 458 | 'index_length' => $txt['not_applicable'], |
454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
456 | 461 | ); |
462 | + } |
|
457 | 463 | |
458 | 464 | // Format the data and index length in kilobytes. |
459 | 465 | foreach ($context['table_info'] as $type => $size) |
460 | 466 | { |
461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
462 | - if (!is_numeric($size)) |
|
463 | - break; |
|
468 | + if (!is_numeric($size)) { |
|
469 | + break; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
489 | 496 | |
490 | 497 | // Scotty, we need more time... |
491 | 498 | @set_time_limit(600); |
492 | - if (function_exists('apache_reset_timeout')) |
|
493 | - @apache_reset_timeout(); |
|
499 | + if (function_exists('apache_reset_timeout')) { |
|
500 | + @apache_reset_timeout(); |
|
501 | + } |
|
494 | 502 | |
495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
521 | 529 | unset($context['index_settings']['resume_at']); |
522 | 530 | $context['step'] = 1; |
523 | - } |
|
524 | - else |
|
531 | + } else |
|
525 | 532 | { |
526 | 533 | $context['index_settings'] = array( |
527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
531 | 538 | |
532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
534 | - $_SESSION['admin_time'] = time(); |
|
540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
541 | + $_SESSION['admin_time'] = time(); |
|
542 | + } |
|
535 | 543 | } |
536 | 544 | |
537 | - if ($context['step'] !== 0) |
|
538 | - checkSession('request'); |
|
545 | + if ($context['step'] !== 0) { |
|
546 | + checkSession('request'); |
|
547 | + } |
|
539 | 548 | |
540 | 549 | // Step 0: let the user determine how they like their index. |
541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
565 | 574 | |
566 | 575 | // Temporarily switch back to not using a search index. |
567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
568 | - updateSettings(array('search_index' => '')); |
|
576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
577 | + updateSettings(array('search_index' => '')); |
|
578 | + } |
|
569 | 579 | |
570 | 580 | // Don't let simultanious processes be updating the search index. |
571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
572 | - updateSettings(array('search_custom_index_config' => '')); |
|
581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
582 | + updateSettings(array('search_custom_index_config' => '')); |
|
583 | + } |
|
573 | 584 | } |
574 | 585 | |
575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
585 | 596 | 'starting_id' => $context['start'], |
586 | 597 | ) |
587 | 598 | ); |
588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
601 | + } |
|
590 | 602 | |
591 | 603 | if (empty($num_messages['todo'])) |
592 | 604 | { |
593 | 605 | $context['step'] = 2; |
594 | 606 | $context['percentage'] = 80; |
595 | 607 | $context['start'] = 0; |
596 | - } |
|
597 | - else |
|
608 | + } else |
|
598 | 609 | { |
599 | 610 | // Number of seconds before the next step. |
600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
635 | 646 | |
636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
637 | 648 | |
638 | - if (!empty($inserts)) |
|
639 | - $smcFunc['db_insert']('ignore', |
|
649 | + if (!empty($inserts)) { |
|
650 | + $smcFunc['db_insert']('ignore', |
|
640 | 651 | '{db_prefix}log_search_words', |
641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
642 | 653 | $inserts, |
643 | 654 | array('id_word', 'id_msg') |
644 | 655 | ); |
656 | + } |
|
645 | 657 | if ($num_messages['todo'] === 0) |
646 | 658 | { |
647 | 659 | $context['step'] = 2; |
648 | 660 | $context['start'] = 0; |
649 | 661 | break; |
662 | + } else { |
|
663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
650 | 664 | } |
651 | - else |
|
652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
653 | 665 | } |
654 | 666 | |
655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
661 | 673 | elseif ($context['step'] === 2) |
662 | 674 | { |
663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
664 | - $context['step'] = 3; |
|
665 | - else |
|
675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
676 | + $context['step'] = 3; |
|
677 | + } else |
|
666 | 678 | { |
667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
683 | 695 | 'minimum_messages' => $max_messages, |
684 | 696 | ) |
685 | 697 | ); |
686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
687 | - $stop_words[] = $row['id_word']; |
|
698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
699 | + $stop_words[] = $row['id_word']; |
|
700 | + } |
|
688 | 701 | $smcFunc['db_free_result']($request); |
689 | 702 | |
690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
691 | 704 | |
692 | - if (!empty($stop_words)) |
|
693 | - $smcFunc['db_query']('', ' |
|
705 | + if (!empty($stop_words)) { |
|
706 | + $smcFunc['db_query']('', ' |
|
694 | 707 | DELETE FROM {db_prefix}log_search_words |
695 | 708 | WHERE id_word in ({array_int:stop_words})', |
696 | 709 | array( |
697 | 710 | 'stop_words' => $stop_words, |
698 | 711 | ) |
699 | 712 | ); |
713 | + } |
|
700 | 714 | |
701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
757 | 771 | $searchAPI = new $search_class_name(); |
758 | 772 | |
759 | 773 | // No Support? NEXT! |
760 | - if (!$searchAPI->is_supported) |
|
761 | - continue; |
|
774 | + if (!$searchAPI->is_supported) { |
|
775 | + continue; |
|
776 | + } |
|
762 | 777 | |
763 | 778 | $apis[$index_name] = array( |
764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
806 | 821 | ) |
807 | 822 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
809 | - $context['fulltext_index'][] = $row['indexname']; |
|
810 | - } |
|
811 | - else |
|
823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
824 | + $context['fulltext_index'][] = $row['indexname']; |
|
825 | + } |
|
826 | + } else |
|
812 | 827 | { |
813 | 828 | $request = $smcFunc['db_query']('', ' |
814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
819 | 834 | $context['fulltext_index'] = array(); |
820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
821 | 836 | { |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
840 | + } |
|
825 | 841 | $smcFunc['db_free_result']($request); |
826 | 842 | |
827 | - if (is_array($context['fulltext_index'])) |
|
828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
843 | + if (is_array($context['fulltext_index'])) { |
|
844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
845 | + } |
|
829 | 846 | } |
830 | 847 | |
831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
832 | - $request = $smcFunc['db_query']('', ' |
|
848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
849 | + $request = $smcFunc['db_query']('', ' |
|
833 | 850 | SHOW TABLE STATUS |
834 | 851 | FROM {string:database_name} |
835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
839 | 856 | ) |
840 | 857 | ); |
841 | - else |
|
842 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
843 | 860 | SHOW TABLE STATUS |
844 | 861 | LIKE {string:table_name}', |
845 | 862 | array( |
846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
847 | 864 | ) |
848 | 865 | ); |
866 | + } |
|
849 | 867 | |
850 | 868 | if ($request !== false) |
851 | 869 | { |
852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
854 | 872 | $context['cannot_create_fulltext'] = true; |
873 | + } |
|
855 | 874 | $smcFunc['db_free_result']($request); |
856 | 875 | } |
857 | 876 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
260 | 273 | // Bring in any changes we want to make before the query. |
261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
262 | 275 | |
263 | - foreach ($sort_methods as $key => $val) |
|
264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
276 | + foreach ($sort_methods as $key => $val) { |
|
277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | // Calculate the fastest way to get the topics. |
267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
271 | 285 | $fake_ascending = true; |
272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
288 | + } else { |
|
289 | + $fake_ascending = false; |
|
274 | 290 | } |
275 | - else |
|
276 | - $fake_ascending = false; |
|
277 | 291 | |
278 | 292 | // Setup the default topic icons... |
279 | 293 | $context['icon_sources'] = array(); |
280 | - foreach ($context['stable_icons'] as $icon) |
|
281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
294 | + foreach ($context['stable_icons'] as $icon) { |
|
295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
296 | + } |
|
282 | 297 | |
283 | 298 | $topic_ids = array(); |
284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
316 | 331 | $message_pre_index_parameters |
317 | 332 | ); |
318 | 333 | $topic_ids = array(); |
319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
320 | - $topic_ids[] = $row['id_topic']; |
|
334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
335 | + $topic_ids[] = $row['id_topic']; |
|
336 | + } |
|
321 | 337 | } |
322 | 338 | |
323 | 339 | // Grab the appropriate topic information... |
@@ -340,10 +356,11 @@ discard block |
||
340 | 356 | $message_index_wheres = array(); |
341 | 357 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
342 | 358 | |
343 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
344 | - $enableParticipation = true; |
|
345 | - else |
|
346 | - $enableParticipation = false; |
|
359 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
360 | + $enableParticipation = true; |
|
361 | + } else { |
|
362 | + $enableParticipation = false; |
|
363 | + } |
|
347 | 364 | |
348 | 365 | $result = $smcFunc['db_query']('substring', ' |
349 | 366 | SELECT |
@@ -382,11 +399,13 @@ discard block |
||
382 | 399 | // Begin 'printing' the message index for current board. |
383 | 400 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
384 | 401 | { |
385 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
386 | - continue; |
|
402 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
403 | + continue; |
|
404 | + } |
|
387 | 405 | |
388 | - if (!$pre_query) |
|
389 | - $topic_ids[] = $row['id_topic']; |
|
406 | + if (!$pre_query) { |
|
407 | + $topic_ids[] = $row['id_topic']; |
|
408 | + } |
|
390 | 409 | |
391 | 410 | // Reference the main color class. |
392 | 411 | $colorClass = 'windowbg'; |
@@ -396,8 +415,9 @@ discard block |
||
396 | 415 | { |
397 | 416 | // Limit them to $modSettings['preview_characters'] characters |
398 | 417 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
399 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
400 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
418 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
419 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
420 | + } |
|
401 | 421 | |
402 | 422 | // Censor the subject and message preview. |
403 | 423 | censorText($row['first_subject']); |
@@ -408,27 +428,27 @@ discard block |
||
408 | 428 | { |
409 | 429 | $row['last_subject'] = $row['first_subject']; |
410 | 430 | $row['last_body'] = $row['first_body']; |
411 | - } |
|
412 | - else |
|
431 | + } else |
|
413 | 432 | { |
414 | 433 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
415 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
416 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
434 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
435 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
436 | + } |
|
417 | 437 | |
418 | 438 | censorText($row['last_subject']); |
419 | 439 | censorText($row['last_body']); |
420 | 440 | } |
421 | - } |
|
422 | - else |
|
441 | + } else |
|
423 | 442 | { |
424 | 443 | $row['first_body'] = ''; |
425 | 444 | $row['last_body'] = ''; |
426 | 445 | censorText($row['first_subject']); |
427 | 446 | |
428 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
429 | - $row['last_subject'] = $row['first_subject']; |
|
430 | - else |
|
431 | - censorText($row['last_subject']); |
|
447 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
448 | + $row['last_subject'] = $row['first_subject']; |
|
449 | + } else { |
|
450 | + censorText($row['last_subject']); |
|
451 | + } |
|
432 | 452 | } |
433 | 453 | |
434 | 454 | // Decide how many pages the topic should have. |
@@ -439,42 +459,50 @@ discard block |
||
439 | 459 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
440 | 460 | |
441 | 461 | // If we can use all, show all. |
442 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
443 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
462 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
463 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
464 | + } |
|
465 | + } else { |
|
466 | + $pages = ''; |
|
444 | 467 | } |
445 | - else |
|
446 | - $pages = ''; |
|
447 | 468 | |
448 | 469 | // We need to check the topic icons exist... |
449 | 470 | if (!empty($modSettings['messageIconChecks_enable'])) |
450 | 471 | { |
451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
452 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
454 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
455 | - } |
|
456 | - else |
|
472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
473 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
474 | + } |
|
475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
476 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
477 | + } |
|
478 | + } else |
|
457 | 479 | { |
458 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
459 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
460 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
461 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
480 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
481 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
482 | + } |
|
483 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
484 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
485 | + } |
|
462 | 486 | } |
463 | 487 | |
464 | - if (!empty($board_info['recycle'])) |
|
465 | - $row['first_icon'] = 'recycled'; |
|
488 | + if (!empty($board_info['recycle'])) { |
|
489 | + $row['first_icon'] = 'recycled'; |
|
490 | + } |
|
466 | 491 | |
467 | 492 | // Is this topic pending approval, or does it have any posts pending approval? |
468 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
469 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
493 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
494 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
495 | + } |
|
470 | 496 | |
471 | 497 | // Sticky topics should get a different color, too. |
472 | - if ($row['is_sticky']) |
|
473 | - $colorClass .= ' sticky'; |
|
498 | + if ($row['is_sticky']) { |
|
499 | + $colorClass .= ' sticky'; |
|
500 | + } |
|
474 | 501 | |
475 | 502 | // Locked topics get special treatment as well. |
476 | - if ($row['locked']) |
|
477 | - $colorClass .= ' locked'; |
|
503 | + if ($row['locked']) { |
|
504 | + $colorClass .= ' locked'; |
|
505 | + } |
|
478 | 506 | |
479 | 507 | // 'Print' the topic info. |
480 | 508 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -555,8 +583,9 @@ discard block |
||
555 | 583 | $smcFunc['db_free_result']($result); |
556 | 584 | |
557 | 585 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
558 | - if ($fake_ascending) |
|
559 | - $context['topics'] = array_reverse($context['topics'], true); |
|
586 | + if ($fake_ascending) { |
|
587 | + $context['topics'] = array_reverse($context['topics'], true); |
|
588 | + } |
|
560 | 589 | } |
561 | 590 | |
562 | 591 | $context['jump_to'] = array( |
@@ -579,9 +608,9 @@ discard block |
||
579 | 608 | // Can we restore topics? |
580 | 609 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
581 | 610 | |
582 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
583 | - $context['can_move_any'] = true; |
|
584 | - else |
|
611 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
612 | + $context['can_move_any'] = true; |
|
613 | + } else |
|
585 | 614 | { |
586 | 615 | // We'll use this in a minute |
587 | 616 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -608,11 +637,13 @@ discard block |
||
608 | 637 | } |
609 | 638 | |
610 | 639 | // Can we use quick moderation checkboxes? |
611 | - if ($options['display_quick_mod'] == 1) |
|
612 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
640 | + if ($options['display_quick_mod'] == 1) { |
|
641 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
642 | + } |
|
613 | 643 | // Or the icons? |
614 | - else |
|
615 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
644 | + else { |
|
645 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
646 | + } |
|
616 | 647 | } |
617 | 648 | |
618 | 649 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -646,13 +677,15 @@ discard block |
||
646 | 677 | ); |
647 | 678 | |
648 | 679 | // We've seen all these boards now! |
649 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
650 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
680 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
681 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
651 | 682 | unset($_SESSION['topicseen_cache'][$k]); |
683 | + } |
|
652 | 684 | } |
653 | 685 | |
654 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
655 | - unset($_SESSION['topicseen_cache'][$board]); |
|
686 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
687 | + unset($_SESSION['topicseen_cache'][$board]); |
|
688 | + } |
|
656 | 689 | |
657 | 690 | $request = $smcFunc['db_query']('', ' |
658 | 691 | SELECT id_topic, id_board, sent |
@@ -673,8 +706,9 @@ discard block |
||
673 | 706 | $context['is_marked_notify'] = true; |
674 | 707 | $board_sent = $row['sent']; |
675 | 708 | } |
676 | - if (!empty($row['id_topic'])) |
|
677 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
709 | + if (!empty($row['id_topic'])) { |
|
710 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
711 | + } |
|
678 | 712 | } |
679 | 713 | $smcFunc['db_free_result']($request); |
680 | 714 | |
@@ -698,8 +732,7 @@ discard block |
||
698 | 732 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
699 | 733 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
700 | 734 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
701 | - } |
|
702 | - else |
|
735 | + } else |
|
703 | 736 | { |
704 | 737 | $context['is_marked_notify'] = false; |
705 | 738 | $context['board_notification_mode'] = 1; |
@@ -712,23 +745,27 @@ discard block |
||
712 | 745 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
713 | 746 | |
714 | 747 | // Don't want to show this forever... |
715 | - if ($context['becomesUnapproved']) |
|
716 | - unset($_SESSION['becomesUnapproved']); |
|
748 | + if ($context['becomesUnapproved']) { |
|
749 | + unset($_SESSION['becomesUnapproved']); |
|
750 | + } |
|
717 | 751 | |
718 | 752 | // Build the message index button array. |
719 | 753 | $context['normal_buttons'] = array(); |
720 | 754 | |
721 | - if ($context['can_post_new']) |
|
722 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
755 | + if ($context['can_post_new']) { |
|
756 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
757 | + } |
|
723 | 758 | |
724 | - if ($context['can_post_poll']) |
|
725 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
759 | + if ($context['can_post_poll']) { |
|
760 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
761 | + } |
|
726 | 762 | |
727 | - if (!$context['user']['is_logged']) |
|
728 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
763 | + if (!$context['user']['is_logged']) { |
|
764 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
765 | + } |
|
729 | 766 | |
730 | - if ($context['can_mark_notify']) |
|
731 | - $context['normal_buttons']['notify'] = array( |
|
767 | + if ($context['can_mark_notify']) { |
|
768 | + $context['normal_buttons']['notify'] = array( |
|
732 | 769 | 'lang' => true, |
733 | 770 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
734 | 771 | 'sub_buttons' => array( |
@@ -746,6 +783,7 @@ discard block |
||
746 | 783 | ), |
747 | 784 | ), |
748 | 785 | ); |
786 | + } |
|
749 | 787 | |
750 | 788 | // Javascript for inline editing. |
751 | 789 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -767,18 +805,21 @@ discard block |
||
767 | 805 | checkSession('request'); |
768 | 806 | |
769 | 807 | // Lets go straight to the restore area. |
770 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
771 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
808 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
809 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
810 | + } |
|
772 | 811 | |
773 | - if (isset($_SESSION['topicseen_cache'])) |
|
774 | - $_SESSION['topicseen_cache'] = array(); |
|
812 | + if (isset($_SESSION['topicseen_cache'])) { |
|
813 | + $_SESSION['topicseen_cache'] = array(); |
|
814 | + } |
|
775 | 815 | |
776 | 816 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
777 | 817 | require_once($sourcedir . '/Subs-Post.php'); |
778 | 818 | |
779 | 819 | // Remember the last board they moved things to. |
780 | - if (isset($_REQUEST['move_to'])) |
|
781 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
820 | + if (isset($_REQUEST['move_to'])) { |
|
821 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
822 | + } |
|
782 | 823 | |
783 | 824 | // Only a few possible actions. |
784 | 825 | $possibleActions = array(); |
@@ -798,8 +839,7 @@ discard block |
||
798 | 839 | ); |
799 | 840 | |
800 | 841 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
801 | - } |
|
802 | - else |
|
842 | + } else |
|
803 | 843 | { |
804 | 844 | /** |
805 | 845 | * @todo Ugly. There's no getting around this, is there? |
@@ -817,8 +857,7 @@ discard block |
||
817 | 857 | if (!empty($board)) |
818 | 858 | { |
819 | 859 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
820 | - } |
|
821 | - else |
|
860 | + } else |
|
822 | 861 | { |
823 | 862 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
824 | 863 | } |
@@ -829,55 +868,67 @@ discard block |
||
829 | 868 | } |
830 | 869 | } |
831 | 870 | |
832 | - if (!$user_info['is_guest']) |
|
833 | - $possibleActions[] = 'markread'; |
|
834 | - if (!empty($boards_can['make_sticky'])) |
|
835 | - $possibleActions[] = 'sticky'; |
|
836 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
837 | - $possibleActions[] = 'move'; |
|
838 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
839 | - $possibleActions[] = 'remove'; |
|
840 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
841 | - $possibleActions[] = 'lock'; |
|
842 | - if (!empty($boards_can['merge_any'])) |
|
843 | - $possibleActions[] = 'merge'; |
|
844 | - if (!empty($boards_can['approve_posts'])) |
|
845 | - $possibleActions[] = 'approve'; |
|
871 | + if (!$user_info['is_guest']) { |
|
872 | + $possibleActions[] = 'markread'; |
|
873 | + } |
|
874 | + if (!empty($boards_can['make_sticky'])) { |
|
875 | + $possibleActions[] = 'sticky'; |
|
876 | + } |
|
877 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
878 | + $possibleActions[] = 'move'; |
|
879 | + } |
|
880 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
881 | + $possibleActions[] = 'remove'; |
|
882 | + } |
|
883 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
884 | + $possibleActions[] = 'lock'; |
|
885 | + } |
|
886 | + if (!empty($boards_can['merge_any'])) { |
|
887 | + $possibleActions[] = 'merge'; |
|
888 | + } |
|
889 | + if (!empty($boards_can['approve_posts'])) { |
|
890 | + $possibleActions[] = 'approve'; |
|
891 | + } |
|
846 | 892 | |
847 | 893 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
848 | 894 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
849 | 895 | if (!empty($_REQUEST['topics'])) |
850 | 896 | { |
851 | 897 | // If the action isn't valid, just quit now. |
852 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
853 | - redirectexit($redirect_url); |
|
898 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
899 | + redirectexit($redirect_url); |
|
900 | + } |
|
854 | 901 | |
855 | 902 | // Merge requires all topics as one parameter and can be done at once. |
856 | 903 | if ($_REQUEST['qaction'] == 'merge') |
857 | 904 | { |
858 | 905 | // Merge requires at least two topics. |
859 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
860 | - redirectexit($redirect_url); |
|
906 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
907 | + redirectexit($redirect_url); |
|
908 | + } |
|
861 | 909 | |
862 | 910 | require_once($sourcedir . '/SplitTopics.php'); |
863 | 911 | return MergeExecute($_REQUEST['topics']); |
864 | 912 | } |
865 | 913 | |
866 | 914 | // Just convert to the other method, to make it easier. |
867 | - foreach ($_REQUEST['topics'] as $topic) |
|
868 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
915 | + foreach ($_REQUEST['topics'] as $topic) { |
|
916 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
917 | + } |
|
869 | 918 | } |
870 | 919 | |
871 | 920 | // Weird... how'd you get here? |
872 | - if (empty($_REQUEST['actions'])) |
|
873 | - redirectexit($redirect_url); |
|
921 | + if (empty($_REQUEST['actions'])) { |
|
922 | + redirectexit($redirect_url); |
|
923 | + } |
|
874 | 924 | |
875 | 925 | // Validate each action. |
876 | 926 | $temp = array(); |
877 | 927 | foreach ($_REQUEST['actions'] as $topic => $action) |
878 | 928 | { |
879 | - if (in_array($action, $possibleActions)) |
|
880 | - $temp[(int) $topic] = $action; |
|
929 | + if (in_array($action, $possibleActions)) { |
|
930 | + $temp[(int) $topic] = $action; |
|
931 | + } |
|
881 | 932 | } |
882 | 933 | $_REQUEST['actions'] = $temp; |
883 | 934 | |
@@ -898,27 +949,31 @@ discard block |
||
898 | 949 | { |
899 | 950 | if (!empty($board)) |
900 | 951 | { |
901 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
903 | - } |
|
904 | - else |
|
952 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
953 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
954 | + } |
|
955 | + } else |
|
905 | 956 | { |
906 | 957 | // Don't allow them to act on unapproved posts they can't see... |
907 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
908 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
958 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
959 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
960 | + } |
|
909 | 961 | // Goodness, this is fun. We need to validate the action. |
910 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
911 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
962 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
963 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
964 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
968 | + } |
|
916 | 969 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
917 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
918 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
970 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
971 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
972 | + } |
|
919 | 973 | // If the topic is approved then you need permission to approve the posts within. |
920 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
974 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
975 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
976 | + } |
|
922 | 977 | } |
923 | 978 | } |
924 | 979 | $smcFunc['db_free_result']($request); |
@@ -936,11 +991,11 @@ discard block |
||
936 | 991 | { |
937 | 992 | $topic = (int) $topic; |
938 | 993 | |
939 | - if ($action == 'markread') |
|
940 | - $markCache[] = $topic; |
|
941 | - elseif ($action == 'sticky') |
|
942 | - $stickyCache[] = $topic; |
|
943 | - elseif ($action == 'move') |
|
994 | + if ($action == 'markread') { |
|
995 | + $markCache[] = $topic; |
|
996 | + } elseif ($action == 'sticky') { |
|
997 | + $stickyCache[] = $topic; |
|
998 | + } elseif ($action == 'move') |
|
944 | 999 | { |
945 | 1000 | require_once($sourcedir . '/MoveTopic.php'); |
946 | 1001 | moveTopicConcurrence(); |
@@ -948,23 +1003,25 @@ discard block |
||
948 | 1003 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
949 | 1004 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
950 | 1005 | |
951 | - if (empty($moveCache[1][$topic])) |
|
952 | - continue; |
|
1006 | + if (empty($moveCache[1][$topic])) { |
|
1007 | + continue; |
|
1008 | + } |
|
953 | 1009 | |
954 | 1010 | $moveCache[0][] = $topic; |
1011 | + } elseif ($action == 'remove') { |
|
1012 | + $removeCache[] = $topic; |
|
1013 | + } elseif ($action == 'lock') { |
|
1014 | + $lockCache[] = $topic; |
|
1015 | + } elseif ($action == 'approve') { |
|
1016 | + $approveCache[] = $topic; |
|
955 | 1017 | } |
956 | - elseif ($action == 'remove') |
|
957 | - $removeCache[] = $topic; |
|
958 | - elseif ($action == 'lock') |
|
959 | - $lockCache[] = $topic; |
|
960 | - elseif ($action == 'approve') |
|
961 | - $approveCache[] = $topic; |
|
962 | 1018 | } |
963 | 1019 | |
964 | - if (empty($board)) |
|
965 | - $affectedBoards = array(); |
|
966 | - else |
|
967 | - $affectedBoards = array($board => array(0, 0)); |
|
1020 | + if (empty($board)) { |
|
1021 | + $affectedBoards = array(); |
|
1022 | + } else { |
|
1023 | + $affectedBoards = array($board => array(0, 0)); |
|
1024 | + } |
|
968 | 1025 | |
969 | 1026 | // Do all the stickies... |
970 | 1027 | if (!empty($stickyCache)) |
@@ -1024,14 +1081,16 @@ discard block |
||
1024 | 1081 | { |
1025 | 1082 | $to = $moveCache[1][$row['id_topic']]; |
1026 | 1083 | |
1027 | - if (empty($to)) |
|
1028 | - continue; |
|
1084 | + if (empty($to)) { |
|
1085 | + continue; |
|
1086 | + } |
|
1029 | 1087 | |
1030 | 1088 | // Does this topic's board count the posts or not? |
1031 | 1089 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1032 | 1090 | |
1033 | - if (!isset($moveTos[$to])) |
|
1034 | - $moveTos[$to] = array(); |
|
1091 | + if (!isset($moveTos[$to])) { |
|
1092 | + $moveTos[$to] = array(); |
|
1093 | + } |
|
1035 | 1094 | |
1036 | 1095 | $moveTos[$to][] = $row['id_topic']; |
1037 | 1096 | |
@@ -1045,8 +1104,9 @@ discard block |
||
1045 | 1104 | require_once($sourcedir . '/MoveTopic.php'); |
1046 | 1105 | |
1047 | 1106 | // Do the actual moves... |
1048 | - foreach ($moveTos as $to => $topics) |
|
1049 | - moveTopics($topics, $to); |
|
1107 | + foreach ($moveTos as $to => $topics) { |
|
1108 | + moveTopics($topics, $to); |
|
1109 | + } |
|
1050 | 1110 | |
1051 | 1111 | // Does the post counts need to be updated? |
1052 | 1112 | if (!empty($moveTos)) |
@@ -1095,20 +1155,23 @@ discard block |
||
1095 | 1155 | |
1096 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1097 | 1157 | { |
1098 | - if (!isset($members[$row['id_member']])) |
|
1099 | - $members[$row['id_member']] = 0; |
|
1158 | + if (!isset($members[$row['id_member']])) { |
|
1159 | + $members[$row['id_member']] = 0; |
|
1160 | + } |
|
1100 | 1161 | |
1101 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1102 | - $members[$row['id_member']] += 1; |
|
1103 | - else |
|
1104 | - $members[$row['id_member']] -= 1; |
|
1162 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1163 | + $members[$row['id_member']] += 1; |
|
1164 | + } else { |
|
1165 | + $members[$row['id_member']] -= 1; |
|
1166 | + } |
|
1105 | 1167 | } |
1106 | 1168 | |
1107 | 1169 | $smcFunc['db_free_result']($request); |
1108 | 1170 | |
1109 | 1171 | // And now update them member's post counts |
1110 | - foreach ($members as $id_member => $post_adj) |
|
1111 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1172 | + foreach ($members as $id_member => $post_adj) { |
|
1173 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1174 | + } |
|
1112 | 1175 | |
1113 | 1176 | } |
1114 | 1177 | } |
@@ -1188,8 +1251,9 @@ discard block |
||
1188 | 1251 | approveTopics($approveCache); |
1189 | 1252 | |
1190 | 1253 | // Time for some logging! |
1191 | - foreach ($approveCache as $topic) |
|
1192 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1254 | + foreach ($approveCache as $topic) { |
|
1255 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1256 | + } |
|
1193 | 1257 | } |
1194 | 1258 | } |
1195 | 1259 | |
@@ -1224,8 +1288,7 @@ discard block |
||
1224 | 1288 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1225 | 1289 | } |
1226 | 1290 | $smcFunc['db_free_result']($result); |
1227 | - } |
|
1228 | - else |
|
1291 | + } else |
|
1229 | 1292 | { |
1230 | 1293 | $result = $smcFunc['db_query']('', ' |
1231 | 1294 | SELECT id_topic, locked, id_board |
@@ -1275,13 +1338,15 @@ discard block |
||
1275 | 1338 | ) |
1276 | 1339 | ); |
1277 | 1340 | $logged_topics = array(); |
1278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1279 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1341 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1342 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1343 | + } |
|
1280 | 1344 | $smcFunc['db_free_result']($request); |
1281 | 1345 | |
1282 | 1346 | $markArray = array(); |
1283 | - foreach ($markCache as $topic) |
|
1284 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1347 | + foreach ($markCache as $topic) { |
|
1348 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1349 | + } |
|
1285 | 1350 | |
1286 | 1351 | $smcFunc['db_insert']('replace', |
1287 | 1352 | '{db_prefix}log_topics', |
@@ -1294,8 +1359,9 @@ discard block |
||
1294 | 1359 | foreach ($moveCache as $topic) |
1295 | 1360 | { |
1296 | 1361 | // Didn't actually move anything! |
1297 | - if (!isset($topic[0])) |
|
1298 | - break; |
|
1362 | + if (!isset($topic[0])) { |
|
1363 | + break; |
|
1364 | + } |
|
1299 | 1365 | |
1300 | 1366 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1301 | 1367 | sendNotifications($topic[0], 'move'); |
@@ -1317,8 +1383,9 @@ discard block |
||
1317 | 1383 | 'calendar_updated' => time(), |
1318 | 1384 | )); |
1319 | 1385 | |
1320 | - if (!empty($affectedBoards)) |
|
1321 | - updateLastMessages(array_keys($affectedBoards)); |
|
1386 | + if (!empty($affectedBoards)) { |
|
1387 | + updateLastMessages(array_keys($affectedBoards)); |
|
1388 | + } |
|
1322 | 1389 | |
1323 | 1390 | redirectexit($redirect_url); |
1324 | 1391 | } |
@@ -349,7 +349,7 @@ |
||
349 | 349 | SELECT |
350 | 350 | t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, |
351 | 351 | ' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from, |
352 | - ' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
352 | + ' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in, |
|
353 | 353 | ' : '') . ' |
354 | 354 | t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic, |
355 | 355 | ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon, |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
155 | 158 | 'data' => array( |
156 | 159 | 'function' => function($news) |
157 | 160 | { |
158 | - if (is_numeric($news['id'])) |
|
159 | - return ' |
|
161 | + if (is_numeric($news['id'])) { |
|
162 | + return ' |
|
160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
162 | - else |
|
163 | - return $news['unparsed']; |
|
165 | + } else { |
|
166 | + return $news['unparsed']; |
|
167 | + } |
|
164 | 168 | }, |
165 | 169 | 'class' => 'half_table', |
166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
186 | 190 | 'data' => array( |
187 | 191 | 'function' => function($news) |
188 | 192 | { |
189 | - if (is_numeric($news['id'])) |
|
190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
191 | - else |
|
192 | - return ''; |
|
193 | + if (is_numeric($news['id'])) { |
|
194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
195 | + } else { |
|
196 | + return ''; |
|
197 | + } |
|
193 | 198 | }, |
194 | 199 | 'class' => 'centercol icon', |
195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
283 | 288 | |
284 | 289 | $admin_current_news = array(); |
285 | 290 | // Ready the current news. |
286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
287 | - $admin_current_news[$id] = array( |
|
291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
292 | + $admin_current_news[$id] = array( |
|
288 | 293 | 'id' => $id, |
289 | 294 | 'unparsed' => un_preparsecode($line), |
290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
291 | 296 | ); |
297 | + } |
|
292 | 298 | |
293 | 299 | $admin_current_news['last'] = array( |
294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
355 | 361 | 'member_count' => 0, |
356 | 362 | ); |
357 | 363 | |
358 | - if ($row['min_posts'] == -1) |
|
359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
360 | - else |
|
361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
364 | + if ($row['min_posts'] == -1) { |
|
365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
366 | + } else { |
|
367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
368 | + } |
|
362 | 369 | } |
363 | 370 | $smcFunc['db_free_result']($request); |
364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
374 | 381 | 'post_group_list' => $postGroups, |
375 | 382 | ) |
376 | 383 | ); |
377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
386 | + } |
|
379 | 387 | $smcFunc['db_free_result']($query); |
380 | 388 | } |
381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
391 | 399 | 'normal_group_list' => $normalGroups, |
392 | 400 | ) |
393 | 401 | ); |
394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
404 | + } |
|
396 | 405 | $smcFunc['db_free_result']($query); |
397 | 406 | |
398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
409 | 418 | 'blank_string' => '', |
410 | 419 | ) |
411 | 420 | ); |
412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
423 | + } |
|
414 | 424 | $smcFunc['db_free_result']($query); |
415 | 425 | } |
416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
461 | 471 | { |
462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
463 | 473 | |
464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
466 | - elseif (!empty($_REQUEST['xml'])) |
|
467 | - continue; |
|
474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
477 | + continue; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | preparsecode($context[$key]); |
470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
543 | 554 | |
544 | 555 | // Start by finding any members! |
545 | 556 | $toClean = array(); |
546 | - if (!empty($_POST['members'])) |
|
547 | - $toClean[] = 'members'; |
|
548 | - if (!empty($_POST['exclude_members'])) |
|
549 | - $toClean[] = 'exclude_members'; |
|
557 | + if (!empty($_POST['members'])) { |
|
558 | + $toClean[] = 'members'; |
|
559 | + } |
|
560 | + if (!empty($_POST['exclude_members'])) { |
|
561 | + $toClean[] = 'exclude_members'; |
|
562 | + } |
|
550 | 563 | if (!empty($toClean)) |
551 | 564 | { |
552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
560 | 573 | |
561 | - foreach ($_POST[$type] as $index => $member) |
|
562 | - if (strlen(trim($member)) > 0) |
|
574 | + foreach ($_POST[$type] as $index => $member) { |
|
575 | + if (strlen(trim($member)) > 0) |
|
563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
564 | - else |
|
565 | - unset($_POST[$type][$index]); |
|
577 | + } |
|
578 | + else { |
|
579 | + unset($_POST[$type][$index]); |
|
580 | + } |
|
566 | 581 | |
567 | 582 | // Find the members |
568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
573 | 588 | { |
574 | 589 | $members = array(); |
575 | - foreach ($_POST['member_list'] as $member_id) |
|
576 | - $members[] = (int) $member_id; |
|
590 | + foreach ($_POST['member_list'] as $member_id) { |
|
591 | + $members[] = (int) $member_id; |
|
592 | + } |
|
577 | 593 | $_POST['members'] = implode(',', $members); |
578 | 594 | } |
579 | 595 | |
580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
581 | 597 | { |
582 | 598 | $members = array(); |
583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
584 | - $members[] = (int) $member_id; |
|
599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
600 | + $members[] = (int) $member_id; |
|
601 | + } |
|
585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
586 | 603 | } |
587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
605 | 622 | 'current_time' => time(), |
606 | 623 | ) |
607 | 624 | ); |
608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
627 | + } |
|
610 | 628 | $smcFunc['db_free_result']($request); |
611 | 629 | |
612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
642 | 660 | $condition_array_params |
643 | 661 | ); |
644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
664 | + } |
|
646 | 665 | $smcFunc['db_free_result']($request); |
647 | 666 | } |
648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
660 | 679 | ); |
661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
662 | 681 | { |
663 | - if (in_array(3, $context['recipients'])) |
|
664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
665 | - else |
|
666 | - $context['recipients']['members'][] = $row['identifier']; |
|
682 | + if (in_array(3, $context['recipients'])) { |
|
683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
684 | + } else { |
|
685 | + $context['recipients']['members'][] = $row['identifier']; |
|
686 | + } |
|
667 | 687 | } |
668 | 688 | $smcFunc['db_free_result']($request); |
669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
710 | 730 | $num_at_once = 1000; |
711 | 731 | |
712 | 732 | // If by PM's I suggest we half the above number. |
713 | - if (!empty($_POST['send_pm'])) |
|
714 | - $num_at_once /= 2; |
|
733 | + if (!empty($_POST['send_pm'])) { |
|
734 | + $num_at_once /= 2; |
|
735 | + } |
|
715 | 736 | |
716 | 737 | checkSession(); |
717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
734 | 755 | ); |
735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
736 | 757 | $smcFunc['db_free_result']($request); |
737 | - } |
|
738 | - else |
|
758 | + } else |
|
739 | 759 | { |
740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
753 | 773 | if (!empty($_POST['exclude_members'])) |
754 | 774 | { |
755 | 775 | $members = explode(',', $_POST['exclude_members']); |
756 | - foreach ($members as $member) |
|
757 | - if ($member >= $context['start']) |
|
776 | + foreach ($members as $member) { |
|
777 | + if ($member >= $context['start']) |
|
758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
779 | + } |
|
759 | 780 | } |
760 | 781 | |
761 | 782 | // What about members we *must* do? |
762 | 783 | if (!empty($_POST['members'])) |
763 | 784 | { |
764 | 785 | $members = explode(',', $_POST['members']); |
765 | - foreach ($members as $member) |
|
766 | - if ($member >= $context['start']) |
|
786 | + foreach ($members as $member) { |
|
787 | + if ($member >= $context['start']) |
|
767 | 788 | $context['recipients']['members'][] = (int) $member; |
789 | + } |
|
768 | 790 | } |
769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
770 | 792 | if (isset($_POST['groups'])) |
771 | 793 | { |
772 | 794 | if (is_array($_POST['groups'])) |
773 | 795 | { |
774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
775 | - $context['recipients']['groups'][] = (int) $group; |
|
776 | - } |
|
777 | - else |
|
796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
797 | + $context['recipients']['groups'][] = (int) $group; |
|
798 | + } |
|
799 | + } else |
|
778 | 800 | { |
779 | 801 | $groups = explode(',', $_POST['groups']); |
780 | - foreach ($groups as $group) |
|
781 | - $context['recipients']['groups'][] = (int) $group; |
|
802 | + foreach ($groups as $group) { |
|
803 | + $context['recipients']['groups'][] = (int) $group; |
|
804 | + } |
|
782 | 805 | } |
783 | 806 | } |
784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
786 | 809 | { |
787 | 810 | if (is_array($_POST['exclude_groups'])) |
788 | 811 | { |
789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
814 | + } |
|
791 | 815 | } |
792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
793 | 817 | elseif ($_POST['exclude_groups'] != '') |
794 | 818 | { |
795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
796 | - foreach ($groups as $group) |
|
797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
820 | + foreach ($groups as $group) { |
|
821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
822 | + } |
|
798 | 823 | } |
799 | 824 | } |
800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
804 | 829 | foreach ($addressed as $curmem) |
805 | 830 | { |
806 | 831 | $curmem = trim($curmem); |
807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
834 | + } |
|
809 | 835 | } |
810 | 836 | } |
811 | 837 | |
812 | 838 | // If we're only cleaning drop out here. |
813 | - if ($clean_only) |
|
814 | - return; |
|
839 | + if ($clean_only) { |
|
840 | + return; |
|
841 | + } |
|
815 | 842 | |
816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
828 | 855 | { |
829 | 856 | // Prepare the message for HTML. |
830 | - if (!empty($_POST['parse_html'])) |
|
831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
857 | + if (!empty($_POST['parse_html'])) { |
|
858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
859 | + } |
|
832 | 860 | |
833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
835 | 863 | { |
836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
838 | - else |
|
839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
866 | + } else { |
|
867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
868 | + } |
|
840 | 869 | } |
841 | 870 | } |
842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
891 | 920 | { |
892 | 921 | // Done as many as we can? |
893 | - if ($i >= $num_at_once) |
|
894 | - break; |
|
922 | + if ($i >= $num_at_once) { |
|
923 | + break; |
|
924 | + } |
|
895 | 925 | |
896 | 926 | // Don't sent it twice! |
897 | 927 | unset($context['recipients']['emails'][$k]); |
898 | 928 | |
899 | 929 | // Dammit - can't PM emails! |
900 | - if ($context['send_pm']) |
|
901 | - continue; |
|
930 | + if ($context['send_pm']) { |
|
931 | + continue; |
|
932 | + } |
|
902 | 933 | |
903 | 934 | $to_member = array( |
904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
933 | 964 | } |
934 | 965 | } |
935 | - if (!empty($queryBuild)) |
|
936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
966 | + if (!empty($queryBuild)) { |
|
967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
968 | + } |
|
937 | 969 | } |
938 | 970 | if (!empty($context['recipients']['members'])) |
939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
952 | 984 | } |
953 | 985 | |
954 | 986 | // Anything to exclude? |
955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
989 | + } |
|
957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
958 | 991 | { |
959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
989 | 1022 | foreach ($rows as $row) |
990 | 1023 | { |
991 | 1024 | // Force them to have it? |
992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
993 | - continue; |
|
1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1026 | + continue; |
|
1027 | + } |
|
994 | 1028 | |
995 | 1029 | // What groups are we looking at here? |
996 | - if (empty($row['additional_groups'])) |
|
997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
998 | - else |
|
999 | - $groups = array_merge( |
|
1030 | + if (empty($row['additional_groups'])) { |
|
1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1032 | + } else { |
|
1033 | + $groups = array_merge( |
|
1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
1001 | 1035 | explode(',', $row['additional_groups']) |
1002 | 1036 | ); |
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // Excluded groups? |
1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1006 | - continue; |
|
1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1041 | + continue; |
|
1042 | + } |
|
1007 | 1043 | |
1008 | 1044 | // We might need this |
1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
1026 | 1062 | ), $_POST['subject']); |
1027 | 1063 | |
1028 | 1064 | // Send the actual email - or a PM! |
1029 | - if (!$context['send_pm']) |
|
1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1031 | - else |
|
1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1065 | + if (!$context['send_pm']) { |
|
1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1067 | + } else { |
|
1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1069 | + } |
|
1033 | 1070 | } |
1034 | 1071 | } |
1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
1079 | 1116 | |
1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1081 | 1118 | |
1082 | - if ($return_config) |
|
1083 | - return $config_vars; |
|
1119 | + if ($return_config) { |
|
1120 | + return $config_vars; |
|
1121 | + } |
|
1084 | 1122 | |
1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -5495,7 +5495,6 @@ discard block |
||
5495 | 5495 | |
5496 | 5496 | /** |
5497 | 5497 | * Tries different modes to make file/dirs writable. Wrapper function for chmod() |
5498 | - |
|
5499 | 5498 | * @param string $file The file/dir full path. |
5500 | 5499 | * @param int $value Not needed, added for legacy reasons. |
5501 | 5500 | * @return boolean true if the file/dir is already writable or the function was able to make it writable, false if the function couldn't make the file/dir writable. |
@@ -5535,7 +5534,6 @@ discard block |
||
5535 | 5534 | |
5536 | 5535 | /** |
5537 | 5536 | * Wrapper function for json_decode() with error handling. |
5538 | - |
|
5539 | 5537 | * @param string $json The string to decode. |
5540 | 5538 | * @param bool $returnAsArray To return the decoded string as an array or an object, SMF only uses Arrays but to keep on compatibility with json_decode its set to false as default. |
5541 | 5539 | * @param bool $logIt To specify if the error will be logged if theres any. |
@@ -6029,7 +6027,7 @@ discard block |
||
6029 | 6027 | $params = stream_context_get_params($stream); |
6030 | 6028 | $result = isset($params["options"]["ssl"]["peer_certificate"]) ? true : false; |
6031 | 6029 | } |
6032 | - return $result; |
|
6030 | + return $result; |
|
6033 | 6031 | } |
6034 | 6032 | |
6035 | 6033 | /** |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * - caches the formatting data from the setting for optimization. |
694 | 694 | * |
695 | 695 | * @param float $number A number |
696 | - * @param bool|int $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
696 | + * @param integer $override_decimal_count If set, will use the specified number of decimal places. Otherwise it's automatically determined |
|
697 | 697 | * @return string A formatted number |
698 | 698 | */ |
699 | 699 | function comma_format($number, $override_decimal_count = false) |
@@ -5646,7 +5646,7 @@ discard block |
||
5646 | 5646 | * It assumes the data is already a string. |
5647 | 5647 | * @param string $data The data to print |
5648 | 5648 | * @param string $type The content type. Defaults to Json. |
5649 | - * @return void |
|
5649 | + * @return false|null |
|
5650 | 5650 | */ |
5651 | 5651 | function smf_serverResponse($data = '', $type = 'content-type: application/json') |
5652 | 5652 | { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | { |
387 | 387 | $val = 'CASE '; |
388 | 388 | foreach ($members as $k => $v) |
389 | - $val .= 'WHEN id_member = ' . $v . ' THEN '. count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
389 | + $val .= 'WHEN id_member = ' . $v . ' THEN ' . count(fetch_alerts($v, false, 0, array(), false)) . ' '; |
|
390 | 390 | $val = $val . ' END'; |
391 | 391 | $type = 'raw'; |
392 | 392 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | $unsupportedFormats = (array) cache_get_data('unsupportedtimeformats', 86400); |
818 | 818 | if (empty($unsupportedFormats)) |
819 | 819 | { |
820 | - foreach($strftimeFormatSubstitutions as $format => $substitution) |
|
820 | + foreach ($strftimeFormatSubstitutions as $format => $substitution) |
|
821 | 821 | { |
822 | 822 | $value = @strftime('%' . $format); |
823 | 823 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | 'height' => array('optional' => true, 'match' => '(\d+)'), |
1183 | 1183 | ), |
1184 | 1184 | 'content' => '$1', |
1185 | - 'validate' => function (&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1185 | + 'validate' => function(&$tag, &$data, $disabled, $params) use ($modSettings, $context, $sourcedir, $txt) |
|
1186 | 1186 | { |
1187 | 1187 | $returnContext = ''; |
1188 | 1188 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | } |
1218 | 1218 | |
1219 | 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>'; |
|
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 | 1221 | else |
1222 | 1222 | $returnContext .= '<img src="' . $currentAttachment['href'] . ';image"' . $alt . $title . $width . $height . ' class="bbc_img"/>'; |
1223 | 1223 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | 'type' => 'unparsed_content', |
1247 | 1247 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1248 | 1248 | // @todo Maybe this can be simplified? |
1249 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1249 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1250 | 1250 | { |
1251 | 1251 | if (!isset($disabled['code'])) |
1252 | 1252 | { |
@@ -1283,7 +1283,7 @@ discard block |
||
1283 | 1283 | 'type' => 'unparsed_equals_content', |
1284 | 1284 | 'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> ($2) <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a></div><code class="bbc_code">$1</code>', |
1285 | 1285 | // @todo Maybe this can be simplified? |
1286 | - 'validate' => isset($disabled['code']) ? null : function (&$tag, &$data, $disabled) use ($context) |
|
1286 | + 'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($context) |
|
1287 | 1287 | { |
1288 | 1288 | if (!isset($disabled['code'])) |
1289 | 1289 | { |
@@ -1327,7 +1327,7 @@ discard block |
||
1327 | 1327 | 'type' => 'unparsed_content', |
1328 | 1328 | 'content' => '<a href="mailto:$1" class="bbc_email">$1</a>', |
1329 | 1329 | // @todo Should this respect guest_hideContacts? |
1330 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1330 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1331 | 1331 | { |
1332 | 1332 | $data = strtr($data, array('<br>' => '')); |
1333 | 1333 | }, |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | 'type' => 'unparsed_commas_content', |
1347 | 1347 | 'test' => '\d+,\d+\]', |
1348 | 1348 | 'content' => '<embed type="application/x-shockwave-flash" src="$1" width="$2" height="$3" play="true" loop="true" quality="high" AllowScriptAccess="never">', |
1349 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1349 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1350 | 1350 | { |
1351 | 1351 | if (isset($disabled['url'])) |
1352 | 1352 | $tag['content'] = '$1'; |
@@ -1362,7 +1362,7 @@ discard block |
||
1362 | 1362 | 'test' => '(left|right)(\s+max=\d+(?:%|px|em|rem|ex|pt|pc|ch|vw|vh|vmin|vmax|cm|mm|in)?)?\]', |
1363 | 1363 | 'before' => '<div $1>', |
1364 | 1364 | 'after' => '</div>', |
1365 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1365 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1366 | 1366 | { |
1367 | 1367 | $class = 'class="bbc_float float' . (strpos($data, 'left') === 0 ? 'left' : 'right') . '"'; |
1368 | 1368 | |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | 'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'), |
1412 | 1412 | ), |
1413 | 1413 | 'content' => '<img src="$1" alt="{alt}" title="{title}"{width}{height} class="bbc_img resized">', |
1414 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1414 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1415 | 1415 | { |
1416 | 1416 | global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info; |
1417 | 1417 | |
@@ -1437,7 +1437,7 @@ discard block |
||
1437 | 1437 | 'tag' => 'img', |
1438 | 1438 | 'type' => 'unparsed_content', |
1439 | 1439 | 'content' => '<img src="$1" alt="" class="bbc_img">', |
1440 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1440 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1441 | 1441 | { |
1442 | 1442 | global $image_proxy_enabled, $image_proxy_secret, $boardurl, $user_info; |
1443 | 1443 | |
@@ -1463,7 +1463,7 @@ discard block |
||
1463 | 1463 | 'tag' => 'iurl', |
1464 | 1464 | 'type' => 'unparsed_content', |
1465 | 1465 | 'content' => '<a href="$1" class="bbc_link">$1</a>', |
1466 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1466 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1467 | 1467 | { |
1468 | 1468 | $data = strtr($data, array('<br>' => '')); |
1469 | 1469 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | 'quoted' => 'optional', |
1478 | 1478 | 'before' => '<a href="$1" class="bbc_link">', |
1479 | 1479 | 'after' => '</a>', |
1480 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1480 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1481 | 1481 | { |
1482 | 1482 | if (substr($data, 0, 1) == '#') |
1483 | 1483 | $data = '#post_' . substr($data, 1); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | 'tag' => 'php', |
1558 | 1558 | 'type' => 'unparsed_content', |
1559 | 1559 | 'content' => '<span class="phpcode">$1</span>', |
1560 | - 'validate' => isset($disabled['php']) ? null : function (&$tag, &$data, $disabled) |
|
1560 | + 'validate' => isset($disabled['php']) ? null : function(&$tag, &$data, $disabled) |
|
1561 | 1561 | { |
1562 | 1562 | if (!isset($disabled['php'])) |
1563 | 1563 | { |
@@ -1655,7 +1655,7 @@ discard block |
||
1655 | 1655 | 'test' => '[1-7]\]', |
1656 | 1656 | 'before' => '<span style="font-size: $1;" class="bbc_size">', |
1657 | 1657 | 'after' => '</span>', |
1658 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1658 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1659 | 1659 | { |
1660 | 1660 | $sizes = array(1 => 0.7, 2 => 1.0, 3 => 1.35, 4 => 1.45, 5 => 2.0, 6 => 2.65, 7 => 3.95); |
1661 | 1661 | $data = $sizes[$data] . 'em'; |
@@ -1693,7 +1693,7 @@ discard block |
||
1693 | 1693 | 'tag' => 'time', |
1694 | 1694 | 'type' => 'unparsed_content', |
1695 | 1695 | 'content' => '$1', |
1696 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1696 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1697 | 1697 | { |
1698 | 1698 | if (is_numeric($data)) |
1699 | 1699 | $data = timeformat($data); |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | 'tag' => 'url', |
1722 | 1722 | 'type' => 'unparsed_content', |
1723 | 1723 | 'content' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">$1</a>', |
1724 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1724 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1725 | 1725 | { |
1726 | 1726 | $data = strtr($data, array('<br>' => '')); |
1727 | 1727 | $scheme = parse_url($data, PHP_URL_SCHEME); |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | 'quoted' => 'optional', |
1736 | 1736 | 'before' => '<a href="$1" class="bbc_link" target="_blank" rel="noopener">', |
1737 | 1737 | 'after' => '</a>', |
1738 | - 'validate' => function (&$tag, &$data, $disabled) |
|
1738 | + 'validate' => function(&$tag, &$data, $disabled) |
|
1739 | 1739 | { |
1740 | 1740 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | 1741 | if (empty($scheme)) |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | { |
1762 | 1762 | if (isset($temp_bbc)) |
1763 | 1763 | $bbc_codes = $temp_bbc; |
1764 | - usort($codes, function ($a, $b) { |
|
1764 | + usort($codes, function($a, $b) { |
|
1765 | 1765 | return strcmp($a['tag'], $b['tag']); |
1766 | 1766 | }); |
1767 | 1767 | return $codes; |
@@ -1998,7 +1998,7 @@ discard block |
||
1998 | 1998 | # a run of Unicode domain name characters and a dot |
1999 | 1999 | [\p{L}\p{M}\p{N}\-.:@]+\. |
2000 | 2000 | # and then a TLD valid in the DNS or the reserved "local" TLD |
2001 | - (?:'. $modSettings['tld_regex'] .'|local) |
|
2001 | + (?:'. $modSettings['tld_regex'] . '|local) |
|
2002 | 2002 | ) |
2003 | 2003 | # followed by a non-domain character or end of line |
2004 | 2004 | (?=[^\p{L}\p{N}\-.]|$) |
@@ -2066,7 +2066,7 @@ discard block |
||
2066 | 2066 | )? |
2067 | 2067 | '; |
2068 | 2068 | |
2069 | - $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function ($matches) { |
|
2069 | + $data = preg_replace_callback('~' . $url_regex . '~xi' . ($context['utf8'] ? 'u' : ''), function($matches) { |
|
2070 | 2070 | $url = array_shift($matches); |
2071 | 2071 | |
2072 | 2072 | $scheme = parse_url($url, PHP_URL_SCHEME); |
@@ -2147,7 +2147,7 @@ discard block |
||
2147 | 2147 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2148 | 2148 | |
2149 | 2149 | // A closing tag that doesn't match any open tags? Skip it. |
2150 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2150 | + if (!in_array($look_for, array_map(function($code) {return $code['tag']; }, $open_tags))) |
|
2151 | 2151 | continue; |
2152 | 2152 | |
2153 | 2153 | $to_close = array(); |
@@ -2814,7 +2814,7 @@ discard block |
||
2814 | 2814 | for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) |
2815 | 2815 | { |
2816 | 2816 | $specialChars = $smcFunc['htmlspecialchars']($smileysfrom[$i], ENT_QUOTES); |
2817 | - $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')). '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2817 | + $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" title="' . strtr($smcFunc['htmlspecialchars']($smileysdescs[$i]), array(':' => ':', '(' => '(', ')' => ')', '$' => '$', '[' => '[')) . '" class="smiley">'; |
|
2818 | 2818 | |
2819 | 2819 | $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode; |
2820 | 2820 | |
@@ -2831,7 +2831,7 @@ discard block |
||
2831 | 2831 | |
2832 | 2832 | // Replace away! |
2833 | 2833 | $message = preg_replace_callback($smileyPregSearch, |
2834 | - function ($matches) use ($smileyPregReplacements) |
|
2834 | + function($matches) use ($smileyPregReplacements) |
|
2835 | 2835 | { |
2836 | 2836 | return $smileyPregReplacements[$matches[1]]; |
2837 | 2837 | }, $message); |
@@ -2897,13 +2897,13 @@ discard block |
||
2897 | 2897 | { |
2898 | 2898 | if (defined('SID') && SID != '') |
2899 | 2899 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
2900 | - function ($m) use ($scripturl) |
|
2900 | + function($m) use ($scripturl) |
|
2901 | 2901 | { |
2902 | - return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
|
2902 | + return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID . (isset($m[2]) ? "$m[2]" : ""); |
|
2903 | 2903 | }, $setLocation); |
2904 | 2904 | else |
2905 | 2905 | $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
2906 | - function ($m) use ($scripturl) |
|
2906 | + function($m) use ($scripturl) |
|
2907 | 2907 | { |
2908 | 2908 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
2909 | 2909 | }, $setLocation); |
@@ -3226,7 +3226,7 @@ discard block |
||
3226 | 3226 | |
3227 | 3227 | // Add a generic "Are you sure?" confirmation message. |
3228 | 3228 | addInlineJavaScript(' |
3229 | - var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
|
3229 | + var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) . ';'); |
|
3230 | 3230 | |
3231 | 3231 | // Now add the capping code for avatars. |
3232 | 3232 | 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') |
@@ -3675,7 +3675,7 @@ discard block |
||
3675 | 3675 | if (!empty($normal)) |
3676 | 3676 | foreach ($normal as $nf) |
3677 | 3677 | echo ' |
3678 | - <link rel="stylesheet" href="', $nf ,'">'; |
|
3678 | + <link rel="stylesheet" href="', $nf, '">'; |
|
3679 | 3679 | |
3680 | 3680 | if ($db_show_debug === true) |
3681 | 3681 | { |
@@ -3691,7 +3691,7 @@ discard block |
||
3691 | 3691 | <style>'; |
3692 | 3692 | |
3693 | 3693 | foreach ($context['css_header'] as $css) |
3694 | - echo $css .' |
|
3694 | + echo $css . ' |
|
3695 | 3695 | '; |
3696 | 3696 | |
3697 | 3697 | echo' |
@@ -3730,7 +3730,7 @@ discard block |
||
3730 | 3730 | return true; |
3731 | 3731 | |
3732 | 3732 | // No namespaces, sorry! |
3733 | - $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
|
3733 | + $classType = 'MatthiasMullie\\Minify\\' . strtoupper($type); |
|
3734 | 3734 | |
3735 | 3735 | // Temp path. |
3736 | 3736 | $cTempPath = $settings['theme_dir'] . '/' . ($type == 'css' ? 'css' : 'scripts') . '/'; |
@@ -3856,7 +3856,7 @@ discard block |
||
3856 | 3856 | else |
3857 | 3857 | $path = $modSettings['attachmentUploadDir']; |
3858 | 3858 | |
3859 | - return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
|
3859 | + return $path . '/' . $attachment_id . '_' . $file_hash . '.dat'; |
|
3860 | 3860 | } |
3861 | 3861 | |
3862 | 3862 | /** |
@@ -3900,10 +3900,10 @@ discard block |
||
3900 | 3900 | $valid_low = isValidIP($ip_parts[0]); |
3901 | 3901 | $valid_high = isValidIP($ip_parts[1]); |
3902 | 3902 | $count = 0; |
3903 | - $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
|
3903 | + $mode = (preg_match('/:/', $ip_parts[0]) > 0 ? ':' : '.'); |
|
3904 | 3904 | $max = ($mode == ':' ? 'ffff' : '255'); |
3905 | 3905 | $min = 0; |
3906 | - if(!$valid_low) |
|
3906 | + if (!$valid_low) |
|
3907 | 3907 | { |
3908 | 3908 | $ip_parts[0] = preg_replace('/\*/', '0', $ip_parts[0]); |
3909 | 3909 | $valid_low = isValidIP($ip_parts[0]); |
@@ -3917,7 +3917,7 @@ discard block |
||
3917 | 3917 | } |
3918 | 3918 | |
3919 | 3919 | $count = 0; |
3920 | - if(!$valid_high) |
|
3920 | + if (!$valid_high) |
|
3921 | 3921 | { |
3922 | 3922 | $ip_parts[1] = preg_replace('/\*/', $max, $ip_parts[1]); |
3923 | 3923 | $valid_high = isValidIP($ip_parts[1]); |
@@ -3930,7 +3930,7 @@ discard block |
||
3930 | 3930 | } |
3931 | 3931 | } |
3932 | 3932 | |
3933 | - if($valid_high && $valid_low) |
|
3933 | + if ($valid_high && $valid_low) |
|
3934 | 3934 | { |
3935 | 3935 | $ip_array['low'] = $ip_parts[0]; |
3936 | 3936 | $ip_array['high'] = $ip_parts[1]; |
@@ -4112,7 +4112,7 @@ discard block |
||
4112 | 4112 | addInlineJavaScript(' |
4113 | 4113 | var user_menus = new smc_PopupMenu(); |
4114 | 4114 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4115 | - user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
|
4115 | + user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u=' . $context['user']['id'] . '");', true); |
|
4116 | 4116 | if ($context['allow_pm']) |
4117 | 4117 | addInlineJavaScript(' |
4118 | 4118 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
@@ -4748,7 +4748,7 @@ discard block |
||
4748 | 4748 | // No? try a fallback to $sourcedir |
4749 | 4749 | else |
4750 | 4750 | { |
4751 | - $absPath = $sourcedir .'/'. $file; |
|
4751 | + $absPath = $sourcedir . '/' . $file; |
|
4752 | 4752 | |
4753 | 4753 | if (file_exists($absPath)) |
4754 | 4754 | require_once($absPath); |
@@ -4829,15 +4829,15 @@ discard block |
||
4829 | 4829 | |
4830 | 4830 | // UTF-8 occurences of MS special characters |
4831 | 4831 | $findchars_utf8 = array( |
4832 | - "\xe2\x80\x9a", // single low-9 quotation mark |
|
4833 | - "\xe2\x80\x9e", // double low-9 quotation mark |
|
4834 | - "\xe2\x80\xa6", // horizontal ellipsis |
|
4835 | - "\xe2\x80\x98", // left single curly quote |
|
4836 | - "\xe2\x80\x99", // right single curly quote |
|
4837 | - "\xe2\x80\x9c", // left double curly quote |
|
4838 | - "\xe2\x80\x9d", // right double curly quote |
|
4839 | - "\xe2\x80\x93", // en dash |
|
4840 | - "\xe2\x80\x94", // em dash |
|
4832 | + "\xe2\x80\x9a", // single low-9 quotation mark |
|
4833 | + "\xe2\x80\x9e", // double low-9 quotation mark |
|
4834 | + "\xe2\x80\xa6", // horizontal ellipsis |
|
4835 | + "\xe2\x80\x98", // left single curly quote |
|
4836 | + "\xe2\x80\x99", // right single curly quote |
|
4837 | + "\xe2\x80\x9c", // left double curly quote |
|
4838 | + "\xe2\x80\x9d", // right double curly quote |
|
4839 | + "\xe2\x80\x93", // en dash |
|
4840 | + "\xe2\x80\x94", // em dash |
|
4841 | 4841 | ); |
4842 | 4842 | |
4843 | 4843 | // windows 1252 / iso equivalents |
@@ -4855,15 +4855,15 @@ discard block |
||
4855 | 4855 | |
4856 | 4856 | // safe replacements |
4857 | 4857 | $replacechars = array( |
4858 | - ',', // ‚ |
|
4859 | - ',,', // „ |
|
4860 | - '...', // … |
|
4861 | - "'", // ‘ |
|
4862 | - "'", // ’ |
|
4863 | - '"', // “ |
|
4864 | - '"', // ” |
|
4865 | - '-', // – |
|
4866 | - '--', // — |
|
4858 | + ',', // ‚ |
|
4859 | + ',,', // „ |
|
4860 | + '...', // … |
|
4861 | + "'", // ‘ |
|
4862 | + "'", // ’ |
|
4863 | + '"', // “ |
|
4864 | + '"', // ” |
|
4865 | + '-', // – |
|
4866 | + '--', // — |
|
4867 | 4867 | ); |
4868 | 4868 | |
4869 | 4869 | if ($context['utf8']) |
@@ -5281,7 +5281,7 @@ discard block |
||
5281 | 5281 | */ |
5282 | 5282 | function inet_dtop($bin) |
5283 | 5283 | { |
5284 | - if(empty($bin)) |
|
5284 | + if (empty($bin)) |
|
5285 | 5285 | return ''; |
5286 | 5286 | |
5287 | 5287 | global $db_type; |
@@ -5312,28 +5312,28 @@ discard block |
||
5312 | 5312 | */ |
5313 | 5313 | function _safe_serialize($value) |
5314 | 5314 | { |
5315 | - if(is_null($value)) |
|
5315 | + if (is_null($value)) |
|
5316 | 5316 | return 'N;'; |
5317 | 5317 | |
5318 | - if(is_bool($value)) |
|
5319 | - return 'b:'. (int) $value .';'; |
|
5318 | + if (is_bool($value)) |
|
5319 | + return 'b:' . (int) $value . ';'; |
|
5320 | 5320 | |
5321 | - if(is_int($value)) |
|
5322 | - return 'i:'. $value .';'; |
|
5321 | + if (is_int($value)) |
|
5322 | + return 'i:' . $value . ';'; |
|
5323 | 5323 | |
5324 | - if(is_float($value)) |
|
5325 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5324 | + if (is_float($value)) |
|
5325 | + return 'd:' . str_replace(',', '.', $value) . ';'; |
|
5326 | 5326 | |
5327 | - if(is_string($value)) |
|
5328 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5327 | + if (is_string($value)) |
|
5328 | + return 's:' . strlen($value) . ':"' . $value . '";'; |
|
5329 | 5329 | |
5330 | - if(is_array($value)) |
|
5330 | + if (is_array($value)) |
|
5331 | 5331 | { |
5332 | 5332 | $out = ''; |
5333 | - foreach($value as $k => $v) |
|
5333 | + foreach ($value as $k => $v) |
|
5334 | 5334 | $out .= _safe_serialize($k) . _safe_serialize($v); |
5335 | 5335 | |
5336 | - return 'a:'. count($value) .':{'. $out .'}'; |
|
5336 | + return 'a:' . count($value) . ':{' . $out . '}'; |
|
5337 | 5337 | } |
5338 | 5338 | |
5339 | 5339 | // safe_serialize cannot serialize resources or objects. |
@@ -5375,7 +5375,7 @@ discard block |
||
5375 | 5375 | function _safe_unserialize($str) |
5376 | 5376 | { |
5377 | 5377 | // Input is not a string. |
5378 | - if(empty($str) || !is_string($str)) |
|
5378 | + if (empty($str) || !is_string($str)) |
|
5379 | 5379 | return false; |
5380 | 5380 | |
5381 | 5381 | $stack = array(); |
@@ -5389,40 +5389,40 @@ discard block |
||
5389 | 5389 | * 3 - in array, expecting value or another array |
5390 | 5390 | */ |
5391 | 5391 | $state = 0; |
5392 | - while($state != 1) |
|
5392 | + while ($state != 1) |
|
5393 | 5393 | { |
5394 | 5394 | $type = isset($str[0]) ? $str[0] : ''; |
5395 | - if($type == '}') |
|
5395 | + if ($type == '}') |
|
5396 | 5396 | $str = substr($str, 1); |
5397 | 5397 | |
5398 | - else if($type == 'N' && $str[1] == ';') |
|
5398 | + else if ($type == 'N' && $str[1] == ';') |
|
5399 | 5399 | { |
5400 | 5400 | $value = null; |
5401 | 5401 | $str = substr($str, 2); |
5402 | 5402 | } |
5403 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5403 | + else if ($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5404 | 5404 | { |
5405 | 5405 | $value = $matches[1] == '1' ? true : false; |
5406 | 5406 | $str = substr($str, 4); |
5407 | 5407 | } |
5408 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5408 | + else if ($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5409 | 5409 | { |
5410 | - $value = (int)$matches[1]; |
|
5410 | + $value = (int) $matches[1]; |
|
5411 | 5411 | $str = $matches[2]; |
5412 | 5412 | } |
5413 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5413 | + else if ($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5414 | 5414 | { |
5415 | - $value = (float)$matches[1]; |
|
5415 | + $value = (float) $matches[1]; |
|
5416 | 5416 | $str = $matches[3]; |
5417 | 5417 | } |
5418 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5418 | + else if ($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int) $matches[1], 2) == '";') |
|
5419 | 5419 | { |
5420 | - $value = substr($matches[2], 0, (int)$matches[1]); |
|
5421 | - $str = substr($matches[2], (int)$matches[1] + 2); |
|
5420 | + $value = substr($matches[2], 0, (int) $matches[1]); |
|
5421 | + $str = substr($matches[2], (int) $matches[1] + 2); |
|
5422 | 5422 | } |
5423 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5423 | + else if ($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5424 | 5424 | { |
5425 | - $expectedLength = (int)$matches[1]; |
|
5425 | + $expectedLength = (int) $matches[1]; |
|
5426 | 5426 | $str = $matches[2]; |
5427 | 5427 | } |
5428 | 5428 | |
@@ -5430,10 +5430,10 @@ discard block |
||
5430 | 5430 | else |
5431 | 5431 | return false; |
5432 | 5432 | |
5433 | - switch($state) |
|
5433 | + switch ($state) |
|
5434 | 5434 | { |
5435 | 5435 | case 3: // In array, expecting value or another array. |
5436 | - if($type == 'a') |
|
5436 | + if ($type == 'a') |
|
5437 | 5437 | { |
5438 | 5438 | $stack[] = &$list; |
5439 | 5439 | $list[$key] = array(); |
@@ -5442,7 +5442,7 @@ discard block |
||
5442 | 5442 | $state = 2; |
5443 | 5443 | break; |
5444 | 5444 | } |
5445 | - if($type != '}') |
|
5445 | + if ($type != '}') |
|
5446 | 5446 | { |
5447 | 5447 | $list[$key] = $value; |
5448 | 5448 | $state = 2; |
@@ -5453,29 +5453,29 @@ discard block |
||
5453 | 5453 | return false; |
5454 | 5454 | |
5455 | 5455 | case 2: // in array, expecting end of array or a key |
5456 | - if($type == '}') |
|
5456 | + if ($type == '}') |
|
5457 | 5457 | { |
5458 | 5458 | // Array size is less than expected. |
5459 | - if(count($list) < end($expected)) |
|
5459 | + if (count($list) < end($expected)) |
|
5460 | 5460 | return false; |
5461 | 5461 | |
5462 | 5462 | unset($list); |
5463 | - $list = &$stack[count($stack)-1]; |
|
5463 | + $list = &$stack[count($stack) - 1]; |
|
5464 | 5464 | array_pop($stack); |
5465 | 5465 | |
5466 | 5466 | // Go to terminal state if we're at the end of the root array. |
5467 | 5467 | array_pop($expected); |
5468 | 5468 | |
5469 | - if(count($expected) == 0) |
|
5469 | + if (count($expected) == 0) |
|
5470 | 5470 | $state = 1; |
5471 | 5471 | |
5472 | 5472 | break; |
5473 | 5473 | } |
5474 | 5474 | |
5475 | - if($type == 'i' || $type == 's') |
|
5475 | + if ($type == 'i' || $type == 's') |
|
5476 | 5476 | { |
5477 | 5477 | // Array size exceeds expected length. |
5478 | - if(count($list) >= end($expected)) |
|
5478 | + if (count($list) >= end($expected)) |
|
5479 | 5479 | return false; |
5480 | 5480 | |
5481 | 5481 | $key = $value; |
@@ -5488,7 +5488,7 @@ discard block |
||
5488 | 5488 | |
5489 | 5489 | // Expecting array or value. |
5490 | 5490 | case 0: |
5491 | - if($type == 'a') |
|
5491 | + if ($type == 'a') |
|
5492 | 5492 | { |
5493 | 5493 | $data = array(); |
5494 | 5494 | $list = &$data; |
@@ -5497,7 +5497,7 @@ discard block |
||
5497 | 5497 | break; |
5498 | 5498 | } |
5499 | 5499 | |
5500 | - if($type != '}') |
|
5500 | + if ($type != '}') |
|
5501 | 5501 | { |
5502 | 5502 | $data = $value; |
5503 | 5503 | $state = 1; |
@@ -5510,7 +5510,7 @@ discard block |
||
5510 | 5510 | } |
5511 | 5511 | |
5512 | 5512 | // Trailing data in input. |
5513 | - if(!empty($str)) |
|
5513 | + if (!empty($str)) |
|
5514 | 5514 | return false; |
5515 | 5515 | |
5516 | 5516 | return $data; |
@@ -5564,7 +5564,7 @@ discard block |
||
5564 | 5564 | // Set different modes. |
5565 | 5565 | $chmodValues = $isDir ? array(0750, 0755, 0775, 0777) : array(0644, 0664, 0666); |
5566 | 5566 | |
5567 | - foreach($chmodValues as $val) |
|
5567 | + foreach ($chmodValues as $val) |
|
5568 | 5568 | { |
5569 | 5569 | // If it's writable, break out of the loop. |
5570 | 5570 | if (is_writable($file)) |
@@ -5599,13 +5599,13 @@ discard block |
||
5599 | 5599 | $returnArray = @json_decode($json, $returnAsArray); |
5600 | 5600 | |
5601 | 5601 | // PHP 5.3 so no json_last_error_msg() |
5602 | - switch(json_last_error()) |
|
5602 | + switch (json_last_error()) |
|
5603 | 5603 | { |
5604 | 5604 | case JSON_ERROR_NONE: |
5605 | 5605 | $jsonError = false; |
5606 | 5606 | break; |
5607 | 5607 | case JSON_ERROR_DEPTH: |
5608 | - $jsonError = 'JSON_ERROR_DEPTH'; |
|
5608 | + $jsonError = 'JSON_ERROR_DEPTH'; |
|
5609 | 5609 | break; |
5610 | 5610 | case JSON_ERROR_STATE_MISMATCH: |
5611 | 5611 | $jsonError = 'JSON_ERROR_STATE_MISMATCH'; |
@@ -5633,10 +5633,10 @@ discard block |
||
5633 | 5633 | loadLanguage('Errors'); |
5634 | 5634 | |
5635 | 5635 | if (!empty($jsonDebug)) |
5636 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5636 | + log_error($txt['json_' . $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5637 | 5637 | |
5638 | 5638 | else |
5639 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5639 | + log_error($txt['json_' . $jsonError], 'critical'); |
|
5640 | 5640 | |
5641 | 5641 | // Everyone expects an array. |
5642 | 5642 | return array(); |
@@ -5748,7 +5748,7 @@ discard block |
||
5748 | 5748 | }); |
5749 | 5749 | |
5750 | 5750 | // Convert Punycode to Unicode |
5751 | - $tlds = array_map(function ($input) { |
|
5751 | + $tlds = array_map(function($input) { |
|
5752 | 5752 | $prefix = 'xn--'; |
5753 | 5753 | $safe_char = 0xFFFC; |
5754 | 5754 | $base = 36; |
@@ -5764,7 +5764,7 @@ discard block |
||
5764 | 5764 | |
5765 | 5765 | foreach ($enco_parts as $encoded) |
5766 | 5766 | { |
5767 | - if (strpos($encoded,$prefix) !== 0 || strlen(trim(str_replace($prefix,'',$encoded))) == 0) |
|
5767 | + if (strpos($encoded, $prefix) !== 0 || strlen(trim(str_replace($prefix, '', $encoded))) == 0) |
|
5768 | 5768 | { |
5769 | 5769 | $output_parts[] = $encoded; |
5770 | 5770 | continue; |
@@ -5775,7 +5775,7 @@ discard block |
||
5775 | 5775 | $idx = 0; |
5776 | 5776 | $char = 0x80; |
5777 | 5777 | $decoded = array(); |
5778 | - $output=''; |
|
5778 | + $output = ''; |
|
5779 | 5779 | $delim_pos = strrpos($encoded, '-'); |
5780 | 5780 | |
5781 | 5781 | if ($delim_pos > strlen($prefix)) |
@@ -5791,7 +5791,7 @@ discard block |
||
5791 | 5791 | |
5792 | 5792 | for ($enco_idx = $delim_pos ? ($delim_pos + 1) : 0; $enco_idx < $enco_len; ++$deco_len) |
5793 | 5793 | { |
5794 | - for ($old_idx = $idx, $w = 1, $k = $base; 1 ; $k += $base) |
|
5794 | + for ($old_idx = $idx, $w = 1, $k = $base; 1; $k += $base) |
|
5795 | 5795 | { |
5796 | 5796 | $cp = ord($encoded{$enco_idx++}); |
5797 | 5797 | $digit = ($cp - 48 < 10) ? $cp - 22 : (($cp - 65 < 26) ? $cp - 65 : (($cp - 97 < 26) ? $cp - 97 : $base)); |
@@ -5832,15 +5832,15 @@ discard block |
||
5832 | 5832 | |
5833 | 5833 | // 2 bytes |
5834 | 5834 | elseif ($v < (1 << 11)) |
5835 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
5835 | + $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63)); |
|
5836 | 5836 | |
5837 | 5837 | // 3 bytes |
5838 | 5838 | elseif ($v < (1 << 16)) |
5839 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5839 | + $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5840 | 5840 | |
5841 | 5841 | // 4 bytes |
5842 | 5842 | elseif ($v < (1 << 21)) |
5843 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
5843 | + $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63)); |
|
5844 | 5844 | |
5845 | 5845 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5846 | 5846 | else |
@@ -5945,7 +5945,7 @@ discard block |
||
5945 | 5945 | } |
5946 | 5946 | |
5947 | 5947 | // This recursive function creates the index array from the strings |
5948 | - $add_string_to_index = function ($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5948 | + $add_string_to_index = function($string, $index) use (&$strlen, &$substr, &$add_string_to_index) |
|
5949 | 5949 | { |
5950 | 5950 | static $depth = 0; |
5951 | 5951 | $depth++; |
@@ -5972,7 +5972,7 @@ discard block |
||
5972 | 5972 | }; |
5973 | 5973 | |
5974 | 5974 | // This recursive function turns the index array into a regular expression |
5975 | - $index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5975 | + $index_to_regex = function(&$index, $delim) use (&$strlen, &$index_to_regex) |
|
5976 | 5976 | { |
5977 | 5977 | static $depth = 0; |
5978 | 5978 | $depth++; |
@@ -5996,11 +5996,11 @@ discard block |
||
5996 | 5996 | |
5997 | 5997 | if (count(array_keys($value)) == 1) |
5998 | 5998 | { |
5999 | - $new_key_array = explode('(?'.'>', $sub_regex); |
|
5999 | + $new_key_array = explode('(?' . '>', $sub_regex); |
|
6000 | 6000 | $new_key .= $new_key_array[0]; |
6001 | 6001 | } |
6002 | 6002 | else |
6003 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
6003 | + $sub_regex = '(?' . '>' . $sub_regex . ')'; |
|
6004 | 6004 | } |
6005 | 6005 | |
6006 | 6006 | if ($depth > 1) |
@@ -6043,10 +6043,10 @@ discard block |
||
6043 | 6043 | { |
6044 | 6044 | $regex = array(); |
6045 | 6045 | while (!empty($index)) |
6046 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6046 | + $regex[] = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6047 | 6047 | } |
6048 | 6048 | else |
6049 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6049 | + $regex = '(?' . '>' . $index_to_regex($index, $delim) . ')'; |
|
6050 | 6050 | |
6051 | 6051 | // Restore PHP's internal character encoding to whatever it was originally |
6052 | 6052 | if (!empty($current_encoding)) |
@@ -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 = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1500 | + if ($scheme != 'https') { |
|
1501 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
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 = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
1529 | + if ($scheme != 'https') { |
|
1530 | + $data = $boardurl . '/proxy.php?request=' . urlencode($data) . '&hash=' . md5($data . $image_proxy_secret); |
|
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'), |
@@ -1563,8 +1641,9 @@ discard block |
||
1563 | 1641 | { |
1564 | 1642 | $add_begin = substr(trim($data), 0, 5) != '<?'; |
1565 | 1643 | $data = highlight_php_code($add_begin ? '<?php ' . $data . '?>' : $data); |
1566 | - if ($add_begin) |
|
1567 | - $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1644 | + if ($add_begin) { |
|
1645 | + $data = preg_replace(array('~^(.+?)<\?.{0,40}?php(?: |\s)~', '~\?>((?:</(font|span)>)*)$~'), '$1', $data, 2); |
|
1646 | + } |
|
1568 | 1647 | } |
1569 | 1648 | }, |
1570 | 1649 | 'block_level' => false, |
@@ -1695,10 +1774,11 @@ discard block |
||
1695 | 1774 | 'content' => '$1', |
1696 | 1775 | 'validate' => function (&$tag, &$data, $disabled) |
1697 | 1776 | { |
1698 | - if (is_numeric($data)) |
|
1699 | - $data = timeformat($data); |
|
1700 | - else |
|
1701 | - $tag['content'] = '[time]$1[/time]'; |
|
1777 | + if (is_numeric($data)) { |
|
1778 | + $data = timeformat($data); |
|
1779 | + } else { |
|
1780 | + $tag['content'] = '[time]$1[/time]'; |
|
1781 | + } |
|
1702 | 1782 | }, |
1703 | 1783 | ), |
1704 | 1784 | array( |
@@ -1725,8 +1805,9 @@ discard block |
||
1725 | 1805 | { |
1726 | 1806 | $data = strtr($data, array('<br>' => '')); |
1727 | 1807 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1728 | - if (empty($scheme)) |
|
1729 | - $data = '//' . ltrim($data, ':/'); |
|
1808 | + if (empty($scheme)) { |
|
1809 | + $data = '//' . ltrim($data, ':/'); |
|
1810 | + } |
|
1730 | 1811 | }, |
1731 | 1812 | ), |
1732 | 1813 | array( |
@@ -1738,8 +1819,9 @@ discard block |
||
1738 | 1819 | 'validate' => function (&$tag, &$data, $disabled) |
1739 | 1820 | { |
1740 | 1821 | $scheme = parse_url($data, PHP_URL_SCHEME); |
1741 | - if (empty($scheme)) |
|
1742 | - $data = '//' . ltrim($data, ':/'); |
|
1822 | + if (empty($scheme)) { |
|
1823 | + $data = '//' . ltrim($data, ':/'); |
|
1824 | + } |
|
1743 | 1825 | }, |
1744 | 1826 | 'disallow_children' => array('email', 'ftp', 'url', 'iurl'), |
1745 | 1827 | 'disabled_after' => ' ($1)', |
@@ -1759,8 +1841,9 @@ discard block |
||
1759 | 1841 | // This is mainly for the bbc manager, so it's easy to add tags above. Custom BBC should be added above this line. |
1760 | 1842 | if ($message === false) |
1761 | 1843 | { |
1762 | - if (isset($temp_bbc)) |
|
1763 | - $bbc_codes = $temp_bbc; |
|
1844 | + if (isset($temp_bbc)) { |
|
1845 | + $bbc_codes = $temp_bbc; |
|
1846 | + } |
|
1764 | 1847 | usort($codes, function ($a, $b) { |
1765 | 1848 | return strcmp($a['tag'], $b['tag']); |
1766 | 1849 | }); |
@@ -1780,8 +1863,9 @@ discard block |
||
1780 | 1863 | ); |
1781 | 1864 | if (!isset($disabled['li']) && !isset($disabled['list'])) |
1782 | 1865 | { |
1783 | - foreach ($itemcodes as $c => $dummy) |
|
1784 | - $bbc_codes[$c] = array(); |
|
1866 | + foreach ($itemcodes as $c => $dummy) { |
|
1867 | + $bbc_codes[$c] = array(); |
|
1868 | + } |
|
1785 | 1869 | } |
1786 | 1870 | |
1787 | 1871 | // Shhhh! |
@@ -1802,12 +1886,14 @@ discard block |
||
1802 | 1886 | foreach ($codes as $code) |
1803 | 1887 | { |
1804 | 1888 | // Make it easier to process parameters later |
1805 | - if (!empty($code['parameters'])) |
|
1806 | - ksort($code['parameters'], SORT_STRING); |
|
1889 | + if (!empty($code['parameters'])) { |
|
1890 | + ksort($code['parameters'], SORT_STRING); |
|
1891 | + } |
|
1807 | 1892 | |
1808 | 1893 | // If we are not doing every tag only do ones we are interested in. |
1809 | - if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) |
|
1810 | - $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1894 | + if (empty($parse_tags) || in_array($code['tag'], $parse_tags)) { |
|
1895 | + $bbc_codes[substr($code['tag'], 0, 1)][] = $code; |
|
1896 | + } |
|
1811 | 1897 | } |
1812 | 1898 | $codes = null; |
1813 | 1899 | } |
@@ -1818,8 +1904,9 @@ discard block |
||
1818 | 1904 | // It's likely this will change if the message is modified. |
1819 | 1905 | $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']); |
1820 | 1906 | |
1821 | - if (($temp = cache_get_data($cache_key, 240)) != null) |
|
1822 | - return $temp; |
|
1907 | + if (($temp = cache_get_data($cache_key, 240)) != null) { |
|
1908 | + return $temp; |
|
1909 | + } |
|
1823 | 1910 | |
1824 | 1911 | $cache_t = microtime(); |
1825 | 1912 | } |
@@ -1851,8 +1938,9 @@ discard block |
||
1851 | 1938 | $disabled['flash'] = true; |
1852 | 1939 | |
1853 | 1940 | // @todo Change maybe? |
1854 | - if (!isset($_GET['images'])) |
|
1855 | - $disabled['img'] = true; |
|
1941 | + if (!isset($_GET['images'])) { |
|
1942 | + $disabled['img'] = true; |
|
1943 | + } |
|
1856 | 1944 | |
1857 | 1945 | // @todo Interface/setting to add more? |
1858 | 1946 | } |
@@ -1876,8 +1964,9 @@ discard block |
||
1876 | 1964 | $pos = isset($matches[0][1]) ? $matches[0][1] : false; |
1877 | 1965 | |
1878 | 1966 | // Failsafe. |
1879 | - if ($pos === false || $last_pos > $pos) |
|
1880 | - $pos = strlen($message) + 1; |
|
1967 | + if ($pos === false || $last_pos > $pos) { |
|
1968 | + $pos = strlen($message) + 1; |
|
1969 | + } |
|
1881 | 1970 | |
1882 | 1971 | // Can't have a one letter smiley, URL, or email! (sorry.) |
1883 | 1972 | if ($last_pos < $pos - 1) |
@@ -1895,8 +1984,9 @@ discard block |
||
1895 | 1984 | |
1896 | 1985 | // <br> should be empty. |
1897 | 1986 | $empty_tags = array('br', 'hr'); |
1898 | - foreach ($empty_tags as $tag) |
|
1899 | - $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1987 | + foreach ($empty_tags as $tag) { |
|
1988 | + $data = str_replace(array('<' . $tag . '>', '<' . $tag . '/>', '<' . $tag . ' />'), '<' . $tag . '>', $data); |
|
1989 | + } |
|
1900 | 1990 | |
1901 | 1991 | // b, u, i, s, pre... basic tags. |
1902 | 1992 | $closable_tags = array('b', 'u', 'i', 's', 'em', 'ins', 'del', 'pre', 'blockquote', 'strong'); |
@@ -1905,8 +1995,9 @@ discard block |
||
1905 | 1995 | $diff = substr_count($data, '<' . $tag . '>') - substr_count($data, '</' . $tag . '>'); |
1906 | 1996 | $data = strtr($data, array('<' . $tag . '>' => '<' . $tag . '>', '</' . $tag . '>' => '</' . $tag . '>')); |
1907 | 1997 | |
1908 | - if ($diff > 0) |
|
1909 | - $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
1998 | + if ($diff > 0) { |
|
1999 | + $data = substr($data, 0, -1) . str_repeat('</' . $tag . '>', $diff) . substr($data, -1); |
|
2000 | + } |
|
1910 | 2001 | } |
1911 | 2002 | |
1912 | 2003 | // Do <img ...> - with security... action= -> action-. |
@@ -1919,8 +2010,9 @@ discard block |
||
1919 | 2010 | $alt = empty($matches[3][$match]) ? '' : ' alt=' . preg_replace('~^"|"$~', '', $matches[3][$match]); |
1920 | 2011 | |
1921 | 2012 | // Remove action= from the URL - no funny business, now. |
1922 | - if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) |
|
1923 | - $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2013 | + if (preg_match('~action(=|%3d)(?!dlattach)~i', $imgtag) != 0) { |
|
2014 | + $imgtag = preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $imgtag); |
|
2015 | + } |
|
1924 | 2016 | |
1925 | 2017 | // Check if the image is larger than allowed. |
1926 | 2018 | if (!empty($modSettings['max_image_width']) && !empty($modSettings['max_image_height'])) |
@@ -1941,9 +2033,9 @@ discard block |
||
1941 | 2033 | |
1942 | 2034 | // Set the new image tag. |
1943 | 2035 | $replaces[$matches[0][$match]] = '[img width=' . $width . ' height=' . $height . $alt . ']' . $imgtag . '[/img]'; |
2036 | + } else { |
|
2037 | + $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1944 | 2038 | } |
1945 | - else |
|
1946 | - $replaces[$matches[0][$match]] = '[img' . $alt . ']' . $imgtag . '[/img]'; |
|
1947 | 2039 | } |
1948 | 2040 | |
1949 | 2041 | $data = strtr($data, $replaces); |
@@ -1956,16 +2048,18 @@ discard block |
||
1956 | 2048 | $no_autolink_area = false; |
1957 | 2049 | if (!empty($open_tags)) |
1958 | 2050 | { |
1959 | - foreach ($open_tags as $open_tag) |
|
1960 | - if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
2051 | + foreach ($open_tags as $open_tag) { |
|
2052 | + if (in_array($open_tag['tag'], $no_autolink_tags)) |
|
1961 | 2053 | $no_autolink_area = true; |
2054 | + } |
|
1962 | 2055 | } |
1963 | 2056 | |
1964 | 2057 | // Don't go backwards. |
1965 | 2058 | // @todo Don't think is the real solution.... |
1966 | 2059 | $lastAutoPos = isset($lastAutoPos) ? $lastAutoPos : 0; |
1967 | - if ($pos < $lastAutoPos) |
|
1968 | - $no_autolink_area = true; |
|
2060 | + if ($pos < $lastAutoPos) { |
|
2061 | + $no_autolink_area = true; |
|
2062 | + } |
|
1969 | 2063 | $lastAutoPos = $pos; |
1970 | 2064 | |
1971 | 2065 | if (!$no_autolink_area) |
@@ -2074,17 +2168,19 @@ discard block |
||
2074 | 2168 | if ($scheme == 'mailto') |
2075 | 2169 | { |
2076 | 2170 | $email_address = str_replace('mailto:', '', $url); |
2077 | - if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) |
|
2078 | - return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2079 | - else |
|
2080 | - return $url; |
|
2171 | + if (!isset($disabled['email']) && filter_var($email_address, FILTER_VALIDATE_EMAIL) !== false) { |
|
2172 | + return '[email=' . $email_address . ']' . $url . '[/email]'; |
|
2173 | + } else { |
|
2174 | + return $url; |
|
2175 | + } |
|
2081 | 2176 | } |
2082 | 2177 | |
2083 | 2178 | // Are we linking a schemeless URL or naked domain name (e.g. "example.com")? |
2084 | - if (empty($scheme)) |
|
2085 | - $fullUrl = '//' . ltrim($url, ':/'); |
|
2086 | - else |
|
2087 | - $fullUrl = $url; |
|
2179 | + if (empty($scheme)) { |
|
2180 | + $fullUrl = '//' . ltrim($url, ':/'); |
|
2181 | + } else { |
|
2182 | + $fullUrl = $url; |
|
2183 | + } |
|
2088 | 2184 | |
2089 | 2185 | return '[url="' . str_replace(array('[', ']'), array('[', ']'), $fullUrl) . '"]' . $url . '[/url]'; |
2090 | 2186 | }, $data); |
@@ -2133,22 +2229,25 @@ discard block |
||
2133 | 2229 | } |
2134 | 2230 | |
2135 | 2231 | // Are we there yet? Are we there yet? |
2136 | - if ($pos >= strlen($message) - 1) |
|
2137 | - break; |
|
2232 | + if ($pos >= strlen($message) - 1) { |
|
2233 | + break; |
|
2234 | + } |
|
2138 | 2235 | |
2139 | 2236 | $tags = strtolower($message[$pos + 1]); |
2140 | 2237 | |
2141 | 2238 | if ($tags == '/' && !empty($open_tags)) |
2142 | 2239 | { |
2143 | 2240 | $pos2 = strpos($message, ']', $pos + 1); |
2144 | - if ($pos2 == $pos + 2) |
|
2145 | - continue; |
|
2241 | + if ($pos2 == $pos + 2) { |
|
2242 | + continue; |
|
2243 | + } |
|
2146 | 2244 | |
2147 | 2245 | $look_for = strtolower(substr($message, $pos + 2, $pos2 - $pos - 2)); |
2148 | 2246 | |
2149 | 2247 | // A closing tag that doesn't match any open tags? Skip it. |
2150 | - if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) |
|
2151 | - continue; |
|
2248 | + if (!in_array($look_for, array_map(function($code){return $code['tag'];}, $open_tags))) { |
|
2249 | + continue; |
|
2250 | + } |
|
2152 | 2251 | |
2153 | 2252 | $to_close = array(); |
2154 | 2253 | $block_level = null; |
@@ -2156,8 +2255,9 @@ discard block |
||
2156 | 2255 | do |
2157 | 2256 | { |
2158 | 2257 | $tag = array_pop($open_tags); |
2159 | - if (!$tag) |
|
2160 | - break; |
|
2258 | + if (!$tag) { |
|
2259 | + break; |
|
2260 | + } |
|
2161 | 2261 | |
2162 | 2262 | if (!empty($tag['block_level'])) |
2163 | 2263 | { |
@@ -2171,10 +2271,11 @@ discard block |
||
2171 | 2271 | // The idea is, if we are LOOKING for a block level tag, we can close them on the way. |
2172 | 2272 | if (strlen($look_for) > 0 && isset($bbc_codes[$look_for[0]])) |
2173 | 2273 | { |
2174 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2175 | - if ($temp['tag'] == $look_for) |
|
2274 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2275 | + if ($temp['tag'] == $look_for) |
|
2176 | 2276 | { |
2177 | 2277 | $block_level = !empty($temp['block_level']); |
2278 | + } |
|
2178 | 2279 | break; |
2179 | 2280 | } |
2180 | 2281 | } |
@@ -2196,15 +2297,15 @@ discard block |
||
2196 | 2297 | { |
2197 | 2298 | $open_tags = $to_close; |
2198 | 2299 | continue; |
2199 | - } |
|
2200 | - elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2300 | + } elseif (!empty($to_close) && $tag['tag'] != $look_for) |
|
2201 | 2301 | { |
2202 | 2302 | if ($block_level === null && isset($look_for[0], $bbc_codes[$look_for[0]])) |
2203 | 2303 | { |
2204 | - foreach ($bbc_codes[$look_for[0]] as $temp) |
|
2205 | - if ($temp['tag'] == $look_for) |
|
2304 | + foreach ($bbc_codes[$look_for[0]] as $temp) { |
|
2305 | + if ($temp['tag'] == $look_for) |
|
2206 | 2306 | { |
2207 | 2307 | $block_level = !empty($temp['block_level']); |
2308 | + } |
|
2208 | 2309 | break; |
2209 | 2310 | } |
2210 | 2311 | } |
@@ -2212,8 +2313,9 @@ discard block |
||
2212 | 2313 | // We're not looking for a block level tag (or maybe even a tag that exists...) |
2213 | 2314 | if (!$block_level) |
2214 | 2315 | { |
2215 | - foreach ($to_close as $tag) |
|
2216 | - array_push($open_tags, $tag); |
|
2316 | + foreach ($to_close as $tag) { |
|
2317 | + array_push($open_tags, $tag); |
|
2318 | + } |
|
2217 | 2319 | continue; |
2218 | 2320 | } |
2219 | 2321 | } |
@@ -2226,14 +2328,17 @@ discard block |
||
2226 | 2328 | |
2227 | 2329 | // See the comment at the end of the big loop - just eating whitespace ;). |
2228 | 2330 | $whitespace_regex = ''; |
2229 | - if (!empty($tag['block_level'])) |
|
2230 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2331 | + if (!empty($tag['block_level'])) { |
|
2332 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2333 | + } |
|
2231 | 2334 | // Trim one line of whitespace after unnested tags, but all of it after nested ones |
2232 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2233 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2335 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2336 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2337 | + } |
|
2234 | 2338 | |
2235 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2236 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2339 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2340 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2341 | + } |
|
2237 | 2342 | } |
2238 | 2343 | |
2239 | 2344 | if (!empty($to_close)) |
@@ -2246,8 +2351,9 @@ discard block |
||
2246 | 2351 | } |
2247 | 2352 | |
2248 | 2353 | // No tags for this character, so just keep going (fastest possible course.) |
2249 | - if (!isset($bbc_codes[$tags])) |
|
2250 | - continue; |
|
2354 | + if (!isset($bbc_codes[$tags])) { |
|
2355 | + continue; |
|
2356 | + } |
|
2251 | 2357 | |
2252 | 2358 | $inside = empty($open_tags) ? null : $open_tags[count($open_tags) - 1]; |
2253 | 2359 | $tag = null; |
@@ -2256,48 +2362,57 @@ discard block |
||
2256 | 2362 | $pt_strlen = strlen($possible['tag']); |
2257 | 2363 | |
2258 | 2364 | // Not a match? |
2259 | - if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) |
|
2260 | - continue; |
|
2365 | + if (strtolower(substr($message, $pos + 1, $pt_strlen)) != $possible['tag']) { |
|
2366 | + continue; |
|
2367 | + } |
|
2261 | 2368 | |
2262 | 2369 | $next_c = isset($message[$pos + 1 + $pt_strlen]) ? $message[$pos + 1 + $pt_strlen] : ''; |
2263 | 2370 | |
2264 | 2371 | // A tag is the last char maybe |
2265 | - if ($next_c == '') |
|
2266 | - break; |
|
2372 | + if ($next_c == '') { |
|
2373 | + break; |
|
2374 | + } |
|
2267 | 2375 | |
2268 | 2376 | // A test validation? |
2269 | - if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) |
|
2270 | - continue; |
|
2377 | + if (isset($possible['test']) && preg_match('~^' . $possible['test'] . '~', substr($message, $pos + 1 + $pt_strlen + 1)) === 0) { |
|
2378 | + continue; |
|
2379 | + } |
|
2271 | 2380 | // Do we want parameters? |
2272 | 2381 | elseif (!empty($possible['parameters'])) |
2273 | 2382 | { |
2274 | - if ($next_c != ' ') |
|
2275 | - continue; |
|
2276 | - } |
|
2277 | - elseif (isset($possible['type'])) |
|
2383 | + if ($next_c != ' ') { |
|
2384 | + continue; |
|
2385 | + } |
|
2386 | + } elseif (isset($possible['type'])) |
|
2278 | 2387 | { |
2279 | 2388 | // Do we need an equal sign? |
2280 | - if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') |
|
2281 | - continue; |
|
2389 | + if (in_array($possible['type'], array('unparsed_equals', 'unparsed_commas', 'unparsed_commas_content', 'unparsed_equals_content', 'parsed_equals')) && $next_c != '=') { |
|
2390 | + continue; |
|
2391 | + } |
|
2282 | 2392 | // Maybe we just want a /... |
2283 | - if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') |
|
2284 | - continue; |
|
2393 | + if ($possible['type'] == 'closed' && $next_c != ']' && substr($message, $pos + 1 + $pt_strlen, 2) != '/]' && substr($message, $pos + 1 + $pt_strlen, 3) != ' /]') { |
|
2394 | + continue; |
|
2395 | + } |
|
2285 | 2396 | // An immediate ]? |
2286 | - if ($possible['type'] == 'unparsed_content' && $next_c != ']') |
|
2287 | - continue; |
|
2397 | + if ($possible['type'] == 'unparsed_content' && $next_c != ']') { |
|
2398 | + continue; |
|
2399 | + } |
|
2288 | 2400 | } |
2289 | 2401 | // No type means 'parsed_content', which demands an immediate ] without parameters! |
2290 | - elseif ($next_c != ']') |
|
2291 | - continue; |
|
2402 | + elseif ($next_c != ']') { |
|
2403 | + continue; |
|
2404 | + } |
|
2292 | 2405 | |
2293 | 2406 | // Check allowed tree? |
2294 | - if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) |
|
2295 | - continue; |
|
2296 | - elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) |
|
2297 | - continue; |
|
2407 | + if (isset($possible['require_parents']) && ($inside === null || !in_array($inside['tag'], $possible['require_parents']))) { |
|
2408 | + continue; |
|
2409 | + } elseif (isset($inside['require_children']) && !in_array($possible['tag'], $inside['require_children'])) { |
|
2410 | + continue; |
|
2411 | + } |
|
2298 | 2412 | // If this is in the list of disallowed child tags, don't parse it. |
2299 | - elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) |
|
2300 | - continue; |
|
2413 | + elseif (isset($inside['disallow_children']) && in_array($possible['tag'], $inside['disallow_children'])) { |
|
2414 | + continue; |
|
2415 | + } |
|
2301 | 2416 | |
2302 | 2417 | $pos1 = $pos + 1 + $pt_strlen + 1; |
2303 | 2418 | |
@@ -2309,8 +2424,9 @@ discard block |
||
2309 | 2424 | foreach ($open_tags as $open_quote) |
2310 | 2425 | { |
2311 | 2426 | // Every parent quote this quote has flips the styling |
2312 | - if ($open_quote['tag'] == 'quote') |
|
2313 | - $quote_alt = !$quote_alt; |
|
2427 | + if ($open_quote['tag'] == 'quote') { |
|
2428 | + $quote_alt = !$quote_alt; |
|
2429 | + } |
|
2314 | 2430 | } |
2315 | 2431 | // Add a class to the quote to style alternating blockquotes |
2316 | 2432 | $possible['before'] = strtr($possible['before'], array('<blockquote>' => '<blockquote class="bbc_' . ($quote_alt ? 'alternate' : 'standard') . '_quote">')); |
@@ -2321,8 +2437,9 @@ discard block |
||
2321 | 2437 | { |
2322 | 2438 | // Build a regular expression for each parameter for the current tag. |
2323 | 2439 | $preg = array(); |
2324 | - foreach ($possible['parameters'] as $p => $info) |
|
2325 | - $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2440 | + foreach ($possible['parameters'] as $p => $info) { |
|
2441 | + $preg[] = '(\s+' . $p . '=' . (empty($info['quoted']) ? '' : '"') . (isset($info['match']) ? $info['match'] : '(.+?)') . (empty($info['quoted']) ? '' : '"') . '\s*)' . (empty($info['optional']) ? '' : '?'); |
|
2442 | + } |
|
2326 | 2443 | |
2327 | 2444 | // Extract the string that potentially holds our parameters. |
2328 | 2445 | $blob = preg_split('~\[/?(?:' . $alltags_regex . ')~i', substr($message, $pos)); |
@@ -2342,24 +2459,27 @@ discard block |
||
2342 | 2459 | |
2343 | 2460 | $match = preg_match('~^' . implode('', $preg) . '$~i', implode(' ', $given_params), $matches) !== 0; |
2344 | 2461 | |
2345 | - if ($match) |
|
2346 | - $blob_counter = count($blobs) + 1; |
|
2462 | + if ($match) { |
|
2463 | + $blob_counter = count($blobs) + 1; |
|
2464 | + } |
|
2347 | 2465 | } |
2348 | 2466 | |
2349 | 2467 | // Didn't match our parameter list, try the next possible. |
2350 | - if (!$match) |
|
2351 | - continue; |
|
2468 | + if (!$match) { |
|
2469 | + continue; |
|
2470 | + } |
|
2352 | 2471 | |
2353 | 2472 | $params = array(); |
2354 | 2473 | for ($i = 1, $n = count($matches); $i < $n; $i += 2) |
2355 | 2474 | { |
2356 | 2475 | $key = strtok(ltrim($matches[$i]), '='); |
2357 | - if (isset($possible['parameters'][$key]['value'])) |
|
2358 | - $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2359 | - elseif (isset($possible['parameters'][$key]['validate'])) |
|
2360 | - $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2361 | - else |
|
2362 | - $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2476 | + if (isset($possible['parameters'][$key]['value'])) { |
|
2477 | + $params['{' . $key . '}'] = strtr($possible['parameters'][$key]['value'], array('$1' => $matches[$i + 1])); |
|
2478 | + } elseif (isset($possible['parameters'][$key]['validate'])) { |
|
2479 | + $params['{' . $key . '}'] = $possible['parameters'][$key]['validate']($matches[$i + 1]); |
|
2480 | + } else { |
|
2481 | + $params['{' . $key . '}'] = $matches[$i + 1]; |
|
2482 | + } |
|
2363 | 2483 | |
2364 | 2484 | // Just to make sure: replace any $ or { so they can't interpolate wrongly. |
2365 | 2485 | $params['{' . $key . '}'] = strtr($params['{' . $key . '}'], array('$' => '$', '{' => '{')); |
@@ -2367,23 +2487,26 @@ discard block |
||
2367 | 2487 | |
2368 | 2488 | foreach ($possible['parameters'] as $p => $info) |
2369 | 2489 | { |
2370 | - if (!isset($params['{' . $p . '}'])) |
|
2371 | - $params['{' . $p . '}'] = ''; |
|
2490 | + if (!isset($params['{' . $p . '}'])) { |
|
2491 | + $params['{' . $p . '}'] = ''; |
|
2492 | + } |
|
2372 | 2493 | } |
2373 | 2494 | |
2374 | 2495 | $tag = $possible; |
2375 | 2496 | |
2376 | 2497 | // Put the parameters into the string. |
2377 | - if (isset($tag['before'])) |
|
2378 | - $tag['before'] = strtr($tag['before'], $params); |
|
2379 | - if (isset($tag['after'])) |
|
2380 | - $tag['after'] = strtr($tag['after'], $params); |
|
2381 | - if (isset($tag['content'])) |
|
2382 | - $tag['content'] = strtr($tag['content'], $params); |
|
2498 | + if (isset($tag['before'])) { |
|
2499 | + $tag['before'] = strtr($tag['before'], $params); |
|
2500 | + } |
|
2501 | + if (isset($tag['after'])) { |
|
2502 | + $tag['after'] = strtr($tag['after'], $params); |
|
2503 | + } |
|
2504 | + if (isset($tag['content'])) { |
|
2505 | + $tag['content'] = strtr($tag['content'], $params); |
|
2506 | + } |
|
2383 | 2507 | |
2384 | 2508 | $pos1 += strlen($given_param_string); |
2385 | - } |
|
2386 | - else |
|
2509 | + } else |
|
2387 | 2510 | { |
2388 | 2511 | $tag = $possible; |
2389 | 2512 | $params = array(); |
@@ -2394,8 +2517,9 @@ discard block |
||
2394 | 2517 | // Item codes are complicated buggers... they are implicit [li]s and can make [list]s! |
2395 | 2518 | if ($smileys !== false && $tag === null && isset($itemcodes[$message[$pos + 1]]) && $message[$pos + 2] == ']' && !isset($disabled['list']) && !isset($disabled['li'])) |
2396 | 2519 | { |
2397 | - if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) |
|
2398 | - continue; |
|
2520 | + if ($message[$pos + 1] == '0' && !in_array($message[$pos - 1], array(';', ' ', "\t", "\n", '>'))) { |
|
2521 | + continue; |
|
2522 | + } |
|
2399 | 2523 | |
2400 | 2524 | $tag = $itemcodes[$message[$pos + 1]]; |
2401 | 2525 | |
@@ -2416,9 +2540,9 @@ discard block |
||
2416 | 2540 | { |
2417 | 2541 | array_pop($open_tags); |
2418 | 2542 | $code = '</li>'; |
2543 | + } else { |
|
2544 | + $code = ''; |
|
2419 | 2545 | } |
2420 | - else |
|
2421 | - $code = ''; |
|
2422 | 2546 | |
2423 | 2547 | // Now we open a new tag. |
2424 | 2548 | $open_tags[] = array( |
@@ -2465,12 +2589,14 @@ discard block |
||
2465 | 2589 | } |
2466 | 2590 | |
2467 | 2591 | // No tag? Keep looking, then. Silly people using brackets without actual tags. |
2468 | - if ($tag === null) |
|
2469 | - continue; |
|
2592 | + if ($tag === null) { |
|
2593 | + continue; |
|
2594 | + } |
|
2470 | 2595 | |
2471 | 2596 | // Propagate the list to the child (so wrapping the disallowed tag won't work either.) |
2472 | - if (isset($inside['disallow_children'])) |
|
2473 | - $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2597 | + if (isset($inside['disallow_children'])) { |
|
2598 | + $tag['disallow_children'] = isset($tag['disallow_children']) ? array_unique(array_merge($tag['disallow_children'], $inside['disallow_children'])) : $inside['disallow_children']; |
|
2599 | + } |
|
2474 | 2600 | |
2475 | 2601 | // Is this tag disabled? |
2476 | 2602 | if (isset($disabled[$tag['tag']])) |
@@ -2480,14 +2606,13 @@ discard block |
||
2480 | 2606 | $tag['before'] = !empty($tag['block_level']) ? '<div>' : ''; |
2481 | 2607 | $tag['after'] = !empty($tag['block_level']) ? '</div>' : ''; |
2482 | 2608 | $tag['content'] = isset($tag['type']) && $tag['type'] == 'closed' ? '' : (!empty($tag['block_level']) ? '<div>$1</div>' : '$1'); |
2483 | - } |
|
2484 | - elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2609 | + } elseif (isset($tag['disabled_before']) || isset($tag['disabled_after'])) |
|
2485 | 2610 | { |
2486 | 2611 | $tag['before'] = isset($tag['disabled_before']) ? $tag['disabled_before'] : (!empty($tag['block_level']) ? '<div>' : ''); |
2487 | 2612 | $tag['after'] = isset($tag['disabled_after']) ? $tag['disabled_after'] : (!empty($tag['block_level']) ? '</div>' : ''); |
2613 | + } else { |
|
2614 | + $tag['content'] = $tag['disabled_content']; |
|
2488 | 2615 | } |
2489 | - else |
|
2490 | - $tag['content'] = $tag['disabled_content']; |
|
2491 | 2616 | } |
2492 | 2617 | |
2493 | 2618 | // we use this a lot |
@@ -2497,8 +2622,9 @@ discard block |
||
2497 | 2622 | if (!empty($tag['block_level']) && $tag['tag'] != 'html' && empty($inside['block_level'])) |
2498 | 2623 | { |
2499 | 2624 | $n = count($open_tags) - 1; |
2500 | - while (empty($open_tags[$n]['block_level']) && $n >= 0) |
|
2501 | - $n--; |
|
2625 | + while (empty($open_tags[$n]['block_level']) && $n >= 0) { |
|
2626 | + $n--; |
|
2627 | + } |
|
2502 | 2628 | |
2503 | 2629 | // Close all the non block level tags so this tag isn't surrounded by them. |
2504 | 2630 | for ($i = count($open_tags) - 1; $i > $n; $i--) |
@@ -2510,12 +2636,15 @@ discard block |
||
2510 | 2636 | |
2511 | 2637 | // Trim or eat trailing stuff... see comment at the end of the big loop. |
2512 | 2638 | $whitespace_regex = ''; |
2513 | - if (!empty($tag['block_level'])) |
|
2514 | - $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2515 | - if (!empty($tag['trim']) && $tag['trim'] != 'inside') |
|
2516 | - $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2517 | - if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) |
|
2518 | - $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2639 | + if (!empty($tag['block_level'])) { |
|
2640 | + $whitespace_regex .= '( |\s)*(<br>)?'; |
|
2641 | + } |
|
2642 | + if (!empty($tag['trim']) && $tag['trim'] != 'inside') { |
|
2643 | + $whitespace_regex .= empty($tag['require_parents']) ? '( |\s)*' : '(<br>| |\s)*'; |
|
2644 | + } |
|
2645 | + if (!empty($whitespace_regex) && preg_match('~' . $whitespace_regex . '~', substr($message, $pos), $matches) != 0) { |
|
2646 | + $message = substr($message, 0, $pos) . substr($message, $pos + strlen($matches[0])); |
|
2647 | + } |
|
2519 | 2648 | |
2520 | 2649 | array_pop($open_tags); |
2521 | 2650 | } |
@@ -2536,16 +2665,19 @@ discard block |
||
2536 | 2665 | elseif ($tag['type'] == 'unparsed_content') |
2537 | 2666 | { |
2538 | 2667 | $pos2 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos1); |
2539 | - if ($pos2 === false) |
|
2540 | - continue; |
|
2668 | + if ($pos2 === false) { |
|
2669 | + continue; |
|
2670 | + } |
|
2541 | 2671 | |
2542 | 2672 | $data = substr($message, $pos1, $pos2 - $pos1); |
2543 | 2673 | |
2544 | - if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') |
|
2545 | - $data = substr($data, 4); |
|
2674 | + if (!empty($tag['block_level']) && substr($data, 0, 4) == '<br>') { |
|
2675 | + $data = substr($data, 4); |
|
2676 | + } |
|
2546 | 2677 | |
2547 | - if (isset($tag['validate'])) |
|
2548 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2678 | + if (isset($tag['validate'])) { |
|
2679 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2680 | + } |
|
2549 | 2681 | |
2550 | 2682 | $code = strtr($tag['content'], array('$1' => $data)); |
2551 | 2683 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 3 + $tag_strlen); |
@@ -2561,34 +2693,40 @@ discard block |
||
2561 | 2693 | if (isset($tag['quoted'])) |
2562 | 2694 | { |
2563 | 2695 | $quoted = substr($message, $pos1, 6) == '"'; |
2564 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2565 | - continue; |
|
2696 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2697 | + continue; |
|
2698 | + } |
|
2566 | 2699 | |
2567 | - if ($quoted) |
|
2568 | - $pos1 += 6; |
|
2700 | + if ($quoted) { |
|
2701 | + $pos1 += 6; |
|
2702 | + } |
|
2703 | + } else { |
|
2704 | + $quoted = false; |
|
2569 | 2705 | } |
2570 | - else |
|
2571 | - $quoted = false; |
|
2572 | 2706 | |
2573 | 2707 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2574 | - if ($pos2 === false) |
|
2575 | - continue; |
|
2708 | + if ($pos2 === false) { |
|
2709 | + continue; |
|
2710 | + } |
|
2576 | 2711 | |
2577 | 2712 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2578 | - if ($pos3 === false) |
|
2579 | - continue; |
|
2713 | + if ($pos3 === false) { |
|
2714 | + continue; |
|
2715 | + } |
|
2580 | 2716 | |
2581 | 2717 | $data = array( |
2582 | 2718 | substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), |
2583 | 2719 | substr($message, $pos1, $pos2 - $pos1) |
2584 | 2720 | ); |
2585 | 2721 | |
2586 | - if (!empty($tag['block_level']) && substr($data[0], 0, 4) == '<br>') |
|
2587 | - $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 | + } |
|
2588 | 2725 | |
2589 | 2726 | // Validation for my parking, please! |
2590 | - if (isset($tag['validate'])) |
|
2591 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2727 | + if (isset($tag['validate'])) { |
|
2728 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2729 | + } |
|
2592 | 2730 | |
2593 | 2731 | $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1])); |
2594 | 2732 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
@@ -2605,23 +2743,27 @@ discard block |
||
2605 | 2743 | elseif ($tag['type'] == 'unparsed_commas_content') |
2606 | 2744 | { |
2607 | 2745 | $pos2 = strpos($message, ']', $pos1); |
2608 | - if ($pos2 === false) |
|
2609 | - continue; |
|
2746 | + if ($pos2 === false) { |
|
2747 | + continue; |
|
2748 | + } |
|
2610 | 2749 | |
2611 | 2750 | $pos3 = stripos($message, '[/' . substr($message, $pos + 1, $tag_strlen) . ']', $pos2); |
2612 | - if ($pos3 === false) |
|
2613 | - continue; |
|
2751 | + if ($pos3 === false) { |
|
2752 | + continue; |
|
2753 | + } |
|
2614 | 2754 | |
2615 | 2755 | // We want $1 to be the content, and the rest to be csv. |
2616 | 2756 | $data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1)); |
2617 | 2757 | $data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1); |
2618 | 2758 | |
2619 | - if (isset($tag['validate'])) |
|
2620 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2759 | + if (isset($tag['validate'])) { |
|
2760 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2761 | + } |
|
2621 | 2762 | |
2622 | 2763 | $code = $tag['content']; |
2623 | - foreach ($data as $k => $d) |
|
2624 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2764 | + foreach ($data as $k => $d) { |
|
2765 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2766 | + } |
|
2625 | 2767 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + $tag_strlen); |
2626 | 2768 | $pos += strlen($code) - 1 + 2; |
2627 | 2769 | } |
@@ -2629,24 +2771,28 @@ discard block |
||
2629 | 2771 | elseif ($tag['type'] == 'unparsed_commas') |
2630 | 2772 | { |
2631 | 2773 | $pos2 = strpos($message, ']', $pos1); |
2632 | - if ($pos2 === false) |
|
2633 | - continue; |
|
2774 | + if ($pos2 === false) { |
|
2775 | + continue; |
|
2776 | + } |
|
2634 | 2777 | |
2635 | 2778 | $data = explode(',', substr($message, $pos1, $pos2 - $pos1)); |
2636 | 2779 | |
2637 | - if (isset($tag['validate'])) |
|
2638 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2780 | + if (isset($tag['validate'])) { |
|
2781 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2782 | + } |
|
2639 | 2783 | |
2640 | 2784 | // Fix after, for disabled code mainly. |
2641 | - foreach ($data as $k => $d) |
|
2642 | - $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 | + } |
|
2643 | 2788 | |
2644 | 2789 | $open_tags[] = $tag; |
2645 | 2790 | |
2646 | 2791 | // Replace them out, $1, $2, $3, $4, etc. |
2647 | 2792 | $code = $tag['before']; |
2648 | - foreach ($data as $k => $d) |
|
2649 | - $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2793 | + foreach ($data as $k => $d) { |
|
2794 | + $code = strtr($code, array('$' . ($k + 1) => trim($d))); |
|
2795 | + } |
|
2650 | 2796 | $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1); |
2651 | 2797 | $pos += strlen($code) - 1 + 2; |
2652 | 2798 | } |
@@ -2657,28 +2803,33 @@ discard block |
||
2657 | 2803 | if (isset($tag['quoted'])) |
2658 | 2804 | { |
2659 | 2805 | $quoted = substr($message, $pos1, 6) == '"'; |
2660 | - if ($tag['quoted'] != 'optional' && !$quoted) |
|
2661 | - continue; |
|
2806 | + if ($tag['quoted'] != 'optional' && !$quoted) { |
|
2807 | + continue; |
|
2808 | + } |
|
2662 | 2809 | |
2663 | - if ($quoted) |
|
2664 | - $pos1 += 6; |
|
2810 | + if ($quoted) { |
|
2811 | + $pos1 += 6; |
|
2812 | + } |
|
2813 | + } else { |
|
2814 | + $quoted = false; |
|
2665 | 2815 | } |
2666 | - else |
|
2667 | - $quoted = false; |
|
2668 | 2816 | |
2669 | 2817 | $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); |
2670 | - if ($pos2 === false) |
|
2671 | - continue; |
|
2818 | + if ($pos2 === false) { |
|
2819 | + continue; |
|
2820 | + } |
|
2672 | 2821 | |
2673 | 2822 | $data = substr($message, $pos1, $pos2 - $pos1); |
2674 | 2823 | |
2675 | 2824 | // Validation for my parking, please! |
2676 | - if (isset($tag['validate'])) |
|
2677 | - $tag['validate']($tag, $data, $disabled, $params); |
|
2825 | + if (isset($tag['validate'])) { |
|
2826 | + $tag['validate']($tag, $data, $disabled, $params); |
|
2827 | + } |
|
2678 | 2828 | |
2679 | 2829 | // For parsed content, we must recurse to avoid security problems. |
2680 | - if ($tag['type'] != 'unparsed_equals') |
|
2681 | - $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 | + } |
|
2682 | 2833 | |
2683 | 2834 | $tag['after'] = strtr($tag['after'], array('$1' => $data)); |
2684 | 2835 | |
@@ -2690,34 +2841,40 @@ discard block |
||
2690 | 2841 | } |
2691 | 2842 | |
2692 | 2843 | // If this is block level, eat any breaks after it. |
2693 | - if (!empty($tag['block_level']) && substr($message, $pos + 1, 4) == '<br>') |
|
2694 | - $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 | + } |
|
2695 | 2847 | |
2696 | 2848 | // Are we trimming outside this tag? |
2697 | - if (!empty($tag['trim']) && $tag['trim'] != 'outside' && preg_match('~(<br>| |\s)*~', substr($message, $pos + 1), $matches) != 0) |
|
2698 | - $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 | + } |
|
2699 | 2852 | } |
2700 | 2853 | |
2701 | 2854 | // Close any remaining tags. |
2702 | - while ($tag = array_pop($open_tags)) |
|
2703 | - $message .= "\n" . $tag['after'] . "\n"; |
|
2855 | + while ($tag = array_pop($open_tags)) { |
|
2856 | + $message .= "\n" . $tag['after'] . "\n"; |
|
2857 | + } |
|
2704 | 2858 | |
2705 | 2859 | // Parse the smileys within the parts where it can be done safely. |
2706 | 2860 | if ($smileys === true) |
2707 | 2861 | { |
2708 | 2862 | $message_parts = explode("\n", $message); |
2709 | - for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) |
|
2710 | - parsesmileys($message_parts[$i]); |
|
2863 | + for ($i = 0, $n = count($message_parts); $i < $n; $i += 2) { |
|
2864 | + parsesmileys($message_parts[$i]); |
|
2865 | + } |
|
2711 | 2866 | |
2712 | 2867 | $message = implode('', $message_parts); |
2713 | 2868 | } |
2714 | 2869 | |
2715 | 2870 | // No smileys, just get rid of the markers. |
2716 | - else |
|
2717 | - $message = strtr($message, array("\n" => '')); |
|
2871 | + else { |
|
2872 | + $message = strtr($message, array("\n" => '')); |
|
2873 | + } |
|
2718 | 2874 | |
2719 | - if ($message !== '' && $message[0] === ' ') |
|
2720 | - $message = ' ' . substr($message, 1); |
|
2875 | + if ($message !== '' && $message[0] === ' ') { |
|
2876 | + $message = ' ' . substr($message, 1); |
|
2877 | + } |
|
2721 | 2878 | |
2722 | 2879 | // Cleanup whitespace. |
2723 | 2880 | $message = strtr($message, array(' ' => ' ', "\r" => '', "\n" => '<br>', '<br> ' => '<br> ', ' ' => "\n")); |
@@ -2726,15 +2883,16 @@ discard block |
||
2726 | 2883 | call_integration_hook('integrate_post_parsebbc', array(&$message, &$smileys, &$cache_id, &$parse_tags)); |
2727 | 2884 | |
2728 | 2885 | // Cache the output if it took some time... |
2729 | - if (isset($cache_key, $cache_t) && array_sum(explode(' ', microtime())) - array_sum(explode(' ', $cache_t)) > 0.05) |
|
2730 | - 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 | + } |
|
2731 | 2889 | |
2732 | 2890 | // If this was a force parse revert if needed. |
2733 | 2891 | if (!empty($parse_tags)) |
2734 | 2892 | { |
2735 | - if (empty($temp_bbc)) |
|
2736 | - $bbc_codes = array(); |
|
2737 | - else |
|
2893 | + if (empty($temp_bbc)) { |
|
2894 | + $bbc_codes = array(); |
|
2895 | + } else |
|
2738 | 2896 | { |
2739 | 2897 | $bbc_codes = $temp_bbc; |
2740 | 2898 | unset($temp_bbc); |
@@ -2761,8 +2919,9 @@ discard block |
||
2761 | 2919 | static $smileyPregSearch = null, $smileyPregReplacements = array(); |
2762 | 2920 | |
2763 | 2921 | // No smiley set at all?! |
2764 | - if ($user_info['smiley_set'] == 'none' || trim($message) == '') |
|
2765 | - return; |
|
2922 | + if ($user_info['smiley_set'] == 'none' || trim($message) == '') { |
|
2923 | + return; |
|
2924 | + } |
|
2766 | 2925 | |
2767 | 2926 | // If smileyPregSearch hasn't been set, do it now. |
2768 | 2927 | if (empty($smileyPregSearch)) |
@@ -2773,8 +2932,7 @@ discard block |
||
2773 | 2932 | $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)'); |
2774 | 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'); |
2775 | 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'], '', '', '', ''); |
2776 | - } |
|
2777 | - else |
|
2935 | + } else |
|
2778 | 2936 | { |
2779 | 2937 | // Load the smileys in reverse order by length so they don't get parsed wrong. |
2780 | 2938 | if (($temp = cache_get_data('parsing_smileys', 480)) == null) |
@@ -2798,9 +2956,9 @@ discard block |
||
2798 | 2956 | $smcFunc['db_free_result']($result); |
2799 | 2957 | |
2800 | 2958 | cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480); |
2959 | + } else { |
|
2960 | + list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2801 | 2961 | } |
2802 | - else |
|
2803 | - list ($smileysfrom, $smileysto, $smileysdescs) = $temp; |
|
2804 | 2962 | } |
2805 | 2963 | |
2806 | 2964 | // The non-breaking-space is a complex thing... |
@@ -2877,35 +3035,41 @@ discard block |
||
2877 | 3035 | global $scripturl, $context, $modSettings, $db_show_debug, $db_cache; |
2878 | 3036 | |
2879 | 3037 | // In case we have mail to send, better do that - as obExit doesn't always quite make it... |
2880 | - if (!empty($context['flush_mail'])) |
|
2881 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3038 | + if (!empty($context['flush_mail'])) { |
|
3039 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2882 | 3040 | AddMailQueue(true); |
3041 | + } |
|
2883 | 3042 | |
2884 | 3043 | $add = preg_match('~^(ftp|http)[s]?://~', $setLocation) == 0 && substr($setLocation, 0, 6) != 'about:'; |
2885 | 3044 | |
2886 | - if ($add) |
|
2887 | - $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3045 | + if ($add) { |
|
3046 | + $setLocation = $scripturl . ($setLocation != '' ? '?' . $setLocation : ''); |
|
3047 | + } |
|
2888 | 3048 | |
2889 | 3049 | // Put the session ID in. |
2890 | - if (defined('SID') && SID != '') |
|
2891 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3050 | + if (defined('SID') && SID != '') { |
|
3051 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '(?!\?' . preg_quote(SID, '/') . ')\\??/', $scripturl . '?' . SID . ';', $setLocation); |
|
3052 | + } |
|
2892 | 3053 | // Keep that debug in their for template debugging! |
2893 | - elseif (isset($_GET['debug'])) |
|
2894 | - $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3054 | + elseif (isset($_GET['debug'])) { |
|
3055 | + $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\\??/', $scripturl . '?debug;', $setLocation); |
|
3056 | + } |
|
2895 | 3057 | |
2896 | 3058 | 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']))) |
2897 | 3059 | { |
2898 | - if (defined('SID') && SID != '') |
|
2899 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
3060 | + if (defined('SID') && SID != '') { |
|
3061 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&))((?:board|topic)=[^#]+?)(#[^"]*?)?$~', |
|
2900 | 3062 | function ($m) use ($scripturl) |
2901 | 3063 | { |
2902 | 3064 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html?' . SID. (isset($m[2]) ? "$m[2]" : ""); |
3065 | + } |
|
2903 | 3066 | }, $setLocation); |
2904 | - else |
|
2905 | - $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
3067 | + else { |
|
3068 | + $setLocation = preg_replace_callback('~^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$~', |
|
2906 | 3069 | function ($m) use ($scripturl) |
2907 | 3070 | { |
2908 | 3071 | return $scripturl . '/' . strtr("$m[1]", '&;=', '//,') . '.html' . (isset($m[2]) ? "$m[2]" : ""); |
3072 | + } |
|
2909 | 3073 | }, $setLocation); |
2910 | 3074 | } |
2911 | 3075 | |
@@ -2916,8 +3080,9 @@ discard block |
||
2916 | 3080 | header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); |
2917 | 3081 | |
2918 | 3082 | // Debugging. |
2919 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
2920 | - $_SESSION['debug_redirect'] = $db_cache; |
|
3083 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3084 | + $_SESSION['debug_redirect'] = $db_cache; |
|
3085 | + } |
|
2921 | 3086 | |
2922 | 3087 | obExit(false); |
2923 | 3088 | } |
@@ -2936,51 +3101,60 @@ discard block |
||
2936 | 3101 | |
2937 | 3102 | // Attempt to prevent a recursive loop. |
2938 | 3103 | ++$level; |
2939 | - if ($level > 1 && !$from_fatal_error && !$has_fatal_error) |
|
2940 | - exit; |
|
2941 | - if ($from_fatal_error) |
|
2942 | - $has_fatal_error = true; |
|
3104 | + if ($level > 1 && !$from_fatal_error && !$has_fatal_error) { |
|
3105 | + exit; |
|
3106 | + } |
|
3107 | + if ($from_fatal_error) { |
|
3108 | + $has_fatal_error = true; |
|
3109 | + } |
|
2943 | 3110 | |
2944 | 3111 | // Clear out the stat cache. |
2945 | 3112 | trackStats(); |
2946 | 3113 | |
2947 | 3114 | // If we have mail to send, send it. |
2948 | - if (!empty($context['flush_mail'])) |
|
2949 | - // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
3115 | + if (!empty($context['flush_mail'])) { |
|
3116 | + // @todo this relies on 'flush_mail' being only set in AddMailQueue itself... :\ |
|
2950 | 3117 | AddMailQueue(true); |
3118 | + } |
|
2951 | 3119 | |
2952 | 3120 | $do_header = $header === null ? !$header_done : $header; |
2953 | - if ($do_footer === null) |
|
2954 | - $do_footer = $do_header; |
|
3121 | + if ($do_footer === null) { |
|
3122 | + $do_footer = $do_header; |
|
3123 | + } |
|
2955 | 3124 | |
2956 | 3125 | // Has the template/header been done yet? |
2957 | 3126 | if ($do_header) |
2958 | 3127 | { |
2959 | 3128 | // Was the page title set last minute? Also update the HTML safe one. |
2960 | - if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) |
|
2961 | - $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3129 | + if (!empty($context['page_title']) && empty($context['page_title_html_safe'])) { |
|
3130 | + $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
|
3131 | + } |
|
2962 | 3132 | |
2963 | 3133 | // Start up the session URL fixer. |
2964 | 3134 | ob_start('ob_sessrewrite'); |
2965 | 3135 | |
2966 | - if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) |
|
2967 | - $buffers = explode(',', $settings['output_buffers']); |
|
2968 | - elseif (!empty($settings['output_buffers'])) |
|
2969 | - $buffers = $settings['output_buffers']; |
|
2970 | - else |
|
2971 | - $buffers = array(); |
|
3136 | + if (!empty($settings['output_buffers']) && is_string($settings['output_buffers'])) { |
|
3137 | + $buffers = explode(',', $settings['output_buffers']); |
|
3138 | + } elseif (!empty($settings['output_buffers'])) { |
|
3139 | + $buffers = $settings['output_buffers']; |
|
3140 | + } else { |
|
3141 | + $buffers = array(); |
|
3142 | + } |
|
2972 | 3143 | |
2973 | - if (isset($modSettings['integrate_buffer'])) |
|
2974 | - $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3144 | + if (isset($modSettings['integrate_buffer'])) { |
|
3145 | + $buffers = array_merge(explode(',', $modSettings['integrate_buffer']), $buffers); |
|
3146 | + } |
|
2975 | 3147 | |
2976 | - if (!empty($buffers)) |
|
2977 | - foreach ($buffers as $function) |
|
3148 | + if (!empty($buffers)) { |
|
3149 | + foreach ($buffers as $function) |
|
2978 | 3150 | { |
2979 | 3151 | $call = call_helper($function, true); |
3152 | + } |
|
2980 | 3153 | |
2981 | 3154 | // Is it valid? |
2982 | - if (!empty($call)) |
|
2983 | - ob_start($call); |
|
3155 | + if (!empty($call)) { |
|
3156 | + ob_start($call); |
|
3157 | + } |
|
2984 | 3158 | } |
2985 | 3159 | |
2986 | 3160 | // Display the screen in the logical order. |
@@ -2992,8 +3166,9 @@ discard block |
||
2992 | 3166 | loadSubTemplate(isset($context['sub_template']) ? $context['sub_template'] : 'main'); |
2993 | 3167 | |
2994 | 3168 | // Anything special to put out? |
2995 | - if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) |
|
2996 | - echo $context['insert_after_template']; |
|
3169 | + if (!empty($context['insert_after_template']) && !isset($_REQUEST['xml'])) { |
|
3170 | + echo $context['insert_after_template']; |
|
3171 | + } |
|
2997 | 3172 | |
2998 | 3173 | // Just so we don't get caught in an endless loop of errors from the footer... |
2999 | 3174 | if (!$footer_done) |
@@ -3002,14 +3177,16 @@ discard block |
||
3002 | 3177 | template_footer(); |
3003 | 3178 | |
3004 | 3179 | // (since this is just debugging... it's okay that it's after </html>.) |
3005 | - if (!isset($_REQUEST['xml'])) |
|
3006 | - displayDebug(); |
|
3180 | + if (!isset($_REQUEST['xml'])) { |
|
3181 | + displayDebug(); |
|
3182 | + } |
|
3007 | 3183 | } |
3008 | 3184 | } |
3009 | 3185 | |
3010 | 3186 | // Remember this URL in case someone doesn't like sending HTTP_REFERER. |
3011 | - if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) |
|
3012 | - $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3187 | + if (strpos($_SERVER['REQUEST_URL'], 'action=dlattach') === false && strpos($_SERVER['REQUEST_URL'], 'action=viewsmfile') === false) { |
|
3188 | + $_SESSION['old_url'] = $_SERVER['REQUEST_URL']; |
|
3189 | + } |
|
3013 | 3190 | |
3014 | 3191 | // For session check verification.... don't switch browsers... |
3015 | 3192 | $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; |
@@ -3018,9 +3195,10 @@ discard block |
||
3018 | 3195 | call_integration_hook('integrate_exit', array($do_footer)); |
3019 | 3196 | |
3020 | 3197 | // Don't exit if we're coming from index.php; that will pass through normally. |
3021 | - if (!$from_index) |
|
3022 | - exit; |
|
3023 | -} |
|
3198 | + if (!$from_index) { |
|
3199 | + exit; |
|
3200 | + } |
|
3201 | + } |
|
3024 | 3202 | |
3025 | 3203 | /** |
3026 | 3204 | * Get the size of a specified image with better error handling. |
@@ -3039,8 +3217,9 @@ discard block |
||
3039 | 3217 | $url = str_replace(' ', '%20', $url); |
3040 | 3218 | |
3041 | 3219 | // Can we pull this from the cache... please please? |
3042 | - if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) |
|
3043 | - return $temp; |
|
3220 | + if (($temp = cache_get_data('url_image_size-' . md5($url), 240)) !== null) { |
|
3221 | + return $temp; |
|
3222 | + } |
|
3044 | 3223 | $t = microtime(); |
3045 | 3224 | |
3046 | 3225 | // Get the host to pester... |
@@ -3050,12 +3229,10 @@ discard block |
||
3050 | 3229 | if ($url == '' || $url == 'http://' || $url == 'https://') |
3051 | 3230 | { |
3052 | 3231 | return false; |
3053 | - } |
|
3054 | - elseif (!isset($match[1])) |
|
3232 | + } elseif (!isset($match[1])) |
|
3055 | 3233 | { |
3056 | 3234 | $size = @getimagesize($url); |
3057 | - } |
|
3058 | - else |
|
3235 | + } else |
|
3059 | 3236 | { |
3060 | 3237 | // Try to connect to the server... give it half a second. |
3061 | 3238 | $temp = 0; |
@@ -3094,12 +3271,14 @@ discard block |
||
3094 | 3271 | } |
3095 | 3272 | |
3096 | 3273 | // If we didn't get it, we failed. |
3097 | - if (!isset($size)) |
|
3098 | - $size = false; |
|
3274 | + if (!isset($size)) { |
|
3275 | + $size = false; |
|
3276 | + } |
|
3099 | 3277 | |
3100 | 3278 | // If this took a long time, we may never have to do it again, but then again we might... |
3101 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) |
|
3102 | - cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3279 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.8) { |
|
3280 | + cache_put_data('url_image_size-' . md5($url), $size, 240); |
|
3281 | + } |
|
3103 | 3282 | |
3104 | 3283 | // Didn't work. |
3105 | 3284 | return $size; |
@@ -3117,8 +3296,9 @@ discard block |
||
3117 | 3296 | |
3118 | 3297 | // Under SSI this function can be called more then once. That can cause some problems. |
3119 | 3298 | // So only run the function once unless we are forced to run it again. |
3120 | - if ($loaded && !$forceload) |
|
3121 | - return; |
|
3299 | + if ($loaded && !$forceload) { |
|
3300 | + return; |
|
3301 | + } |
|
3122 | 3302 | |
3123 | 3303 | $loaded = true; |
3124 | 3304 | |
@@ -3130,14 +3310,16 @@ discard block |
||
3130 | 3310 | $context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news']))))); |
3131 | 3311 | for ($i = 0, $n = count($context['news_lines']); $i < $n; $i++) |
3132 | 3312 | { |
3133 | - if (trim($context['news_lines'][$i]) == '') |
|
3134 | - continue; |
|
3313 | + if (trim($context['news_lines'][$i]) == '') { |
|
3314 | + continue; |
|
3315 | + } |
|
3135 | 3316 | |
3136 | 3317 | // Clean it up for presentation ;). |
3137 | 3318 | $context['news_lines'][$i] = parse_bbc(stripslashes(trim($context['news_lines'][$i])), true, 'news' . $i); |
3138 | 3319 | } |
3139 | - if (!empty($context['news_lines'])) |
|
3140 | - $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3320 | + if (!empty($context['news_lines'])) { |
|
3321 | + $context['random_news_line'] = $context['news_lines'][mt_rand(0, count($context['news_lines']) - 1)]; |
|
3322 | + } |
|
3141 | 3323 | |
3142 | 3324 | if (!$user_info['is_guest']) |
3143 | 3325 | { |
@@ -3146,40 +3328,48 @@ discard block |
||
3146 | 3328 | $context['user']['alerts'] = &$user_info['alerts']; |
3147 | 3329 | |
3148 | 3330 | // Personal message popup... |
3149 | - if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) |
|
3150 | - $context['user']['popup_messages'] = true; |
|
3151 | - else |
|
3152 | - $context['user']['popup_messages'] = false; |
|
3331 | + if ($user_info['unread_messages'] > (isset($_SESSION['unread_messages']) ? $_SESSION['unread_messages'] : 0)) { |
|
3332 | + $context['user']['popup_messages'] = true; |
|
3333 | + } else { |
|
3334 | + $context['user']['popup_messages'] = false; |
|
3335 | + } |
|
3153 | 3336 | $_SESSION['unread_messages'] = $user_info['unread_messages']; |
3154 | 3337 | |
3155 | - if (allowedTo('moderate_forum')) |
|
3156 | - $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3338 | + if (allowedTo('moderate_forum')) { |
|
3339 | + $context['unapproved_members'] = (!empty($modSettings['registration_method']) && ($modSettings['registration_method'] == 2 || (!empty($modSettings['coppaType']) && $modSettings['coppaType'] == 2))) || !empty($modSettings['approveAccountDeletion']) ? $modSettings['unapprovedMembers'] : 0; |
|
3340 | + } |
|
3157 | 3341 | |
3158 | 3342 | $context['user']['avatar'] = array(); |
3159 | 3343 | |
3160 | 3344 | // Check for gravatar first since we might be forcing them... |
3161 | 3345 | if (($modSettings['gravatarEnabled'] && substr($user_info['avatar']['url'], 0, 11) == 'gravatar://') || !empty($modSettings['gravatarOverride'])) |
3162 | 3346 | { |
3163 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) |
|
3164 | - $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3165 | - else |
|
3166 | - $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3347 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($user_info['avatar']['url'], 'gravatar://') && strlen($user_info['avatar']['url']) > 11) { |
|
3348 | + $context['user']['avatar']['href'] = get_gravatar_url($smcFunc['substr']($user_info['avatar']['url'], 11)); |
|
3349 | + } else { |
|
3350 | + $context['user']['avatar']['href'] = get_gravatar_url($user_info['email']); |
|
3351 | + } |
|
3167 | 3352 | } |
3168 | 3353 | // Uploaded? |
3169 | - elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) |
|
3170 | - $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'; |
|
3354 | + elseif ($user_info['avatar']['url'] == '' && !empty($user_info['avatar']['id_attach'])) { |
|
3355 | + $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'; |
|
3356 | + } |
|
3171 | 3357 | // Full URL? |
3172 | - elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) |
|
3173 | - $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3358 | + elseif (strpos($user_info['avatar']['url'], 'http://') === 0 || strpos($user_info['avatar']['url'], 'https://') === 0) { |
|
3359 | + $context['user']['avatar']['href'] = $user_info['avatar']['url']; |
|
3360 | + } |
|
3174 | 3361 | // Otherwise we assume it's server stored. |
3175 | - elseif ($user_info['avatar']['url'] != '') |
|
3176 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3362 | + elseif ($user_info['avatar']['url'] != '') { |
|
3363 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($user_info['avatar']['url']); |
|
3364 | + } |
|
3177 | 3365 | // No avatar at all? Fine, we have a big fat default avatar ;) |
3178 | - else |
|
3179 | - $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3366 | + else { |
|
3367 | + $context['user']['avatar']['href'] = $modSettings['avatar_url'] . '/default.png'; |
|
3368 | + } |
|
3180 | 3369 | |
3181 | - if (!empty($context['user']['avatar'])) |
|
3182 | - $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3370 | + if (!empty($context['user']['avatar'])) { |
|
3371 | + $context['user']['avatar']['image'] = '<img src="' . $context['user']['avatar']['href'] . '" alt="" class="avatar">'; |
|
3372 | + } |
|
3183 | 3373 | |
3184 | 3374 | // Figure out how long they've been logged in. |
3185 | 3375 | $context['user']['total_time_logged_in'] = array( |
@@ -3187,8 +3377,7 @@ discard block |
||
3187 | 3377 | 'hours' => floor(($user_info['total_time_logged_in'] % 86400) / 3600), |
3188 | 3378 | 'minutes' => floor(($user_info['total_time_logged_in'] % 3600) / 60) |
3189 | 3379 | ); |
3190 | - } |
|
3191 | - else |
|
3380 | + } else |
|
3192 | 3381 | { |
3193 | 3382 | $context['user']['messages'] = 0; |
3194 | 3383 | $context['user']['unread_messages'] = 0; |
@@ -3196,12 +3385,14 @@ discard block |
||
3196 | 3385 | $context['user']['total_time_logged_in'] = array('days' => 0, 'hours' => 0, 'minutes' => 0); |
3197 | 3386 | $context['user']['popup_messages'] = false; |
3198 | 3387 | |
3199 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) |
|
3200 | - $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3388 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1) { |
|
3389 | + $txt['welcome_guest'] .= $txt['welcome_guest_activate']; |
|
3390 | + } |
|
3201 | 3391 | |
3202 | 3392 | // If we've upgraded recently, go easy on the passwords. |
3203 | - if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) |
|
3204 | - $context['disable_login_hashing'] = true; |
|
3393 | + if (!empty($modSettings['disableHashTime']) && ($modSettings['disableHashTime'] == 1 || time() < $modSettings['disableHashTime'])) { |
|
3394 | + $context['disable_login_hashing'] = true; |
|
3395 | + } |
|
3205 | 3396 | } |
3206 | 3397 | |
3207 | 3398 | // Setup the main menu items. |
@@ -3214,8 +3405,8 @@ discard block |
||
3214 | 3405 | $context['show_pm_popup'] = $context['user']['popup_messages'] && !empty($options['popup_messages']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'pm'); |
3215 | 3406 | |
3216 | 3407 | // 2.1+: Add the PM popup here instead. Theme authors can still override it simply by editing/removing the 'fPmPopup' in the array. |
3217 | - if ($context['show_pm_popup']) |
|
3218 | - addInlineJavaScript(' |
|
3408 | + if ($context['show_pm_popup']) { |
|
3409 | + addInlineJavaScript(' |
|
3219 | 3410 | jQuery(document).ready(function($) { |
3220 | 3411 | new smc_Popup({ |
3221 | 3412 | heading: ' . JavaScriptEscape($txt['show_personal_messages_heading']) . ', |
@@ -3223,15 +3414,17 @@ discard block |
||
3223 | 3414 | icon_class: \'generic_icons mail_new\' |
3224 | 3415 | }); |
3225 | 3416 | });'); |
3417 | + } |
|
3226 | 3418 | |
3227 | 3419 | // Add a generic "Are you sure?" confirmation message. |
3228 | 3420 | addInlineJavaScript(' |
3229 | 3421 | var smf_you_sure =' . JavaScriptEscape($txt['quickmod_confirm']) .';'); |
3230 | 3422 | |
3231 | 3423 | // Now add the capping code for avatars. |
3232 | - 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') |
|
3233 | - addInlineCss(' |
|
3424 | + 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') { |
|
3425 | + addInlineCss(' |
|
3234 | 3426 | img.avatar { max-width: ' . $modSettings['avatar_max_width_external'] . 'px; max-height: ' . $modSettings['avatar_max_height_external'] . 'px; }'); |
3427 | + } |
|
3235 | 3428 | |
3236 | 3429 | // This looks weird, but it's because BoardIndex.php references the variable. |
3237 | 3430 | $context['common_stats']['latest_member'] = array( |
@@ -3248,11 +3441,13 @@ discard block |
||
3248 | 3441 | ); |
3249 | 3442 | $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']); |
3250 | 3443 | |
3251 | - if (empty($settings['theme_version'])) |
|
3252 | - addJavaScriptVar('smf_scripturl', $scripturl); |
|
3444 | + if (empty($settings['theme_version'])) { |
|
3445 | + addJavaScriptVar('smf_scripturl', $scripturl); |
|
3446 | + } |
|
3253 | 3447 | |
3254 | - if (!isset($context['page_title'])) |
|
3255 | - $context['page_title'] = ''; |
|
3448 | + if (!isset($context['page_title'])) { |
|
3449 | + $context['page_title'] = ''; |
|
3450 | + } |
|
3256 | 3451 | |
3257 | 3452 | // Set some specific vars. |
3258 | 3453 | $context['page_title_html_safe'] = $smcFunc['htmlspecialchars'](un_htmlspecialchars($context['page_title'])) . (!empty($context['current_page']) ? ' - ' . $txt['page'] . ' ' . ($context['current_page'] + 1) : ''); |
@@ -3262,21 +3457,23 @@ discard block |
||
3262 | 3457 | $context['meta_tags'][] = array('property' => 'og:site_name', 'content' => $context['forum_name']); |
3263 | 3458 | $context['meta_tags'][] = array('property' => 'og:title', 'content' => $context['page_title_html_safe']); |
3264 | 3459 | |
3265 | - if (!empty($context['meta_keywords'])) |
|
3266 | - $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3460 | + if (!empty($context['meta_keywords'])) { |
|
3461 | + $context['meta_tags'][] = array('name' => 'keywords', 'content' => $context['meta_keywords']); |
|
3462 | + } |
|
3267 | 3463 | |
3268 | - if (!empty($context['canonical_url'])) |
|
3269 | - $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3464 | + if (!empty($context['canonical_url'])) { |
|
3465 | + $context['meta_tags'][] = array('property' => 'og:url', 'content' => $context['canonical_url']); |
|
3466 | + } |
|
3270 | 3467 | |
3271 | - if (!empty($settings['og_image'])) |
|
3272 | - $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3468 | + if (!empty($settings['og_image'])) { |
|
3469 | + $context['meta_tags'][] = array('property' => 'og:image', 'content' => $settings['og_image']); |
|
3470 | + } |
|
3273 | 3471 | |
3274 | 3472 | if (!empty($context['meta_description'])) |
3275 | 3473 | { |
3276 | 3474 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['meta_description']); |
3277 | 3475 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['meta_description']); |
3278 | - } |
|
3279 | - else |
|
3476 | + } else |
|
3280 | 3477 | { |
3281 | 3478 | $context['meta_tags'][] = array('property' => 'og:description', 'content' => $context['page_title_html_safe']); |
3282 | 3479 | $context['meta_tags'][] = array('name' => 'description', 'content' => $context['page_title_html_safe']); |
@@ -3301,8 +3498,9 @@ discard block |
||
3301 | 3498 | $memory_needed = memoryReturnBytes($needed); |
3302 | 3499 | |
3303 | 3500 | // should we account for how much is currently being used? |
3304 | - if ($in_use) |
|
3305 | - $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3501 | + if ($in_use) { |
|
3502 | + $memory_needed += function_exists('memory_get_usage') ? memory_get_usage() : (2 * 1048576); |
|
3503 | + } |
|
3306 | 3504 | |
3307 | 3505 | // if more is needed, request it |
3308 | 3506 | if ($memory_current < $memory_needed) |
@@ -3325,8 +3523,9 @@ discard block |
||
3325 | 3523 | */ |
3326 | 3524 | function memoryReturnBytes($val) |
3327 | 3525 | { |
3328 | - if (is_integer($val)) |
|
3329 | - return $val; |
|
3526 | + if (is_integer($val)) { |
|
3527 | + return $val; |
|
3528 | + } |
|
3330 | 3529 | |
3331 | 3530 | // Separate the number from the designator |
3332 | 3531 | $val = trim($val); |
@@ -3362,10 +3561,11 @@ discard block |
||
3362 | 3561 | header('last-modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
3363 | 3562 | |
3364 | 3563 | // Are we debugging the template/html content? |
3365 | - if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) |
|
3366 | - header('content-type: application/xhtml+xml'); |
|
3367 | - elseif (!isset($_REQUEST['xml'])) |
|
3368 | - header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3564 | + if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !isBrowser('ie')) { |
|
3565 | + header('content-type: application/xhtml+xml'); |
|
3566 | + } elseif (!isset($_REQUEST['xml'])) { |
|
3567 | + header('content-type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3568 | + } |
|
3369 | 3569 | } |
3370 | 3570 | |
3371 | 3571 | header('content-type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
@@ -3374,8 +3574,9 @@ discard block |
||
3374 | 3574 | if ($context['in_maintenance'] && $context['user']['is_admin']) |
3375 | 3575 | { |
3376 | 3576 | $position = array_search('body', $context['template_layers']); |
3377 | - if ($position === false) |
|
3378 | - $position = array_search('main', $context['template_layers']); |
|
3577 | + if ($position === false) { |
|
3578 | + $position = array_search('main', $context['template_layers']); |
|
3579 | + } |
|
3379 | 3580 | |
3380 | 3581 | if ($position !== false) |
3381 | 3582 | { |
@@ -3403,23 +3604,25 @@ discard block |
||
3403 | 3604 | |
3404 | 3605 | foreach ($securityFiles as $i => $securityFile) |
3405 | 3606 | { |
3406 | - if (!file_exists($boarddir . '/' . $securityFile)) |
|
3407 | - unset($securityFiles[$i]); |
|
3607 | + if (!file_exists($boarddir . '/' . $securityFile)) { |
|
3608 | + unset($securityFiles[$i]); |
|
3609 | + } |
|
3408 | 3610 | } |
3409 | 3611 | |
3410 | 3612 | // We are already checking so many files...just few more doesn't make any difference! :P |
3411 | - if (!empty($modSettings['currentAttachmentUploadDir'])) |
|
3412 | - $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3413 | - |
|
3414 | - else |
|
3415 | - $path = $modSettings['attachmentUploadDir']; |
|
3613 | + if (!empty($modSettings['currentAttachmentUploadDir'])) { |
|
3614 | + $path = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']]; |
|
3615 | + } else { |
|
3616 | + $path = $modSettings['attachmentUploadDir']; |
|
3617 | + } |
|
3416 | 3618 | |
3417 | 3619 | secureDirectory($path, true); |
3418 | 3620 | secureDirectory($cachedir); |
3419 | 3621 | |
3420 | 3622 | // If agreement is enabled, at least the english version shall exists |
3421 | - if ($modSettings['requireAgreement']) |
|
3422 | - $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3623 | + if ($modSettings['requireAgreement']) { |
|
3624 | + $agreement = !file_exists($boarddir . '/agreement.txt'); |
|
3625 | + } |
|
3423 | 3626 | |
3424 | 3627 | if (!empty($securityFiles) || (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) || !empty($agreement)) |
3425 | 3628 | { |
@@ -3434,18 +3637,21 @@ discard block |
||
3434 | 3637 | echo ' |
3435 | 3638 | ', $txt['not_removed'], '<strong>', $securityFile, '</strong>!<br>'; |
3436 | 3639 | |
3437 | - if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') |
|
3438 | - echo ' |
|
3640 | + if ($securityFile == 'Settings.php~' || $securityFile == 'Settings_bak.php~') { |
|
3641 | + echo ' |
|
3439 | 3642 | ', sprintf($txt['not_removed_extra'], $securityFile, substr($securityFile, 0, -1)), '<br>'; |
3643 | + } |
|
3440 | 3644 | } |
3441 | 3645 | |
3442 | - if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) |
|
3443 | - echo ' |
|
3646 | + if (!empty($modSettings['cache_enable']) && !is_writable($cachedir)) { |
|
3647 | + echo ' |
|
3444 | 3648 | <strong>', $txt['cache_writable'], '</strong><br>'; |
3649 | + } |
|
3445 | 3650 | |
3446 | - if (!empty($agreement)) |
|
3447 | - echo ' |
|
3651 | + if (!empty($agreement)) { |
|
3652 | + echo ' |
|
3448 | 3653 | <strong>', $txt['agreement_missing'], '</strong><br>'; |
3654 | + } |
|
3449 | 3655 | |
3450 | 3656 | echo ' |
3451 | 3657 | </p> |
@@ -3460,16 +3666,18 @@ discard block |
||
3460 | 3666 | <div class="windowbg alert" style="margin: 2ex; padding: 2ex; border: 2px dashed red;"> |
3461 | 3667 | ', sprintf($txt['you_are_post_banned'], $user_info['is_guest'] ? $txt['guest_title'] : $user_info['name']); |
3462 | 3668 | |
3463 | - if (!empty($_SESSION['ban']['cannot_post']['reason'])) |
|
3464 | - echo ' |
|
3669 | + if (!empty($_SESSION['ban']['cannot_post']['reason'])) { |
|
3670 | + echo ' |
|
3465 | 3671 | <div style="padding-left: 4ex; padding-top: 1ex;">', $_SESSION['ban']['cannot_post']['reason'], '</div>'; |
3672 | + } |
|
3466 | 3673 | |
3467 | - if (!empty($_SESSION['ban']['expire_time'])) |
|
3468 | - echo ' |
|
3674 | + if (!empty($_SESSION['ban']['expire_time'])) { |
|
3675 | + echo ' |
|
3469 | 3676 | <div>', sprintf($txt['your_ban_expires'], timeformat($_SESSION['ban']['expire_time'], false)), '</div>'; |
3470 | - else |
|
3471 | - echo ' |
|
3677 | + } else { |
|
3678 | + echo ' |
|
3472 | 3679 | <div>', $txt['your_ban_expires_never'], '</div>'; |
3680 | + } |
|
3473 | 3681 | |
3474 | 3682 | echo ' |
3475 | 3683 | </div>'; |
@@ -3485,8 +3693,9 @@ discard block |
||
3485 | 3693 | global $forum_copyright, $software_year, $forum_version; |
3486 | 3694 | |
3487 | 3695 | // Don't display copyright for things like SSI. |
3488 | - if (!isset($forum_version) || !isset($software_year)) |
|
3489 | - return; |
|
3696 | + if (!isset($forum_version) || !isset($software_year)) { |
|
3697 | + return; |
|
3698 | + } |
|
3490 | 3699 | |
3491 | 3700 | // Put in the version... |
3492 | 3701 | printf($forum_copyright, $forum_version, $software_year); |
@@ -3504,9 +3713,10 @@ discard block |
||
3504 | 3713 | $context['load_time'] = round(microtime(true) - $time_start, 3); |
3505 | 3714 | $context['load_queries'] = $db_count; |
3506 | 3715 | |
3507 | - foreach (array_reverse($context['template_layers']) as $layer) |
|
3508 | - loadSubTemplate($layer . '_below', true); |
|
3509 | -} |
|
3716 | + foreach (array_reverse($context['template_layers']) as $layer) { |
|
3717 | + loadSubTemplate($layer . '_below', true); |
|
3718 | + } |
|
3719 | + } |
|
3510 | 3720 | |
3511 | 3721 | /** |
3512 | 3722 | * Output the Javascript files |
@@ -3537,8 +3747,7 @@ discard block |
||
3537 | 3747 | { |
3538 | 3748 | echo ' |
3539 | 3749 | var ', $key, ';'; |
3540 | - } |
|
3541 | - else |
|
3750 | + } else |
|
3542 | 3751 | { |
3543 | 3752 | echo ' |
3544 | 3753 | var ', $key, ' = ', $value, ';'; |
@@ -3553,26 +3762,27 @@ discard block |
||
3553 | 3762 | foreach ($context['javascript_files'] as $id => $js_file) |
3554 | 3763 | { |
3555 | 3764 | // Last minute call! allow theme authors to disable single files. |
3556 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3557 | - continue; |
|
3765 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3766 | + continue; |
|
3767 | + } |
|
3558 | 3768 | |
3559 | 3769 | // By default all files don't get minimized unless the file explicitly says so! |
3560 | 3770 | if (!empty($js_file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3561 | 3771 | { |
3562 | - if ($do_deferred && !empty($js_file['options']['defer'])) |
|
3563 | - $toMinifyDefer[] = $js_file; |
|
3564 | - |
|
3565 | - elseif (!$do_deferred && empty($js_file['options']['defer'])) |
|
3566 | - $toMinify[] = $js_file; |
|
3772 | + if ($do_deferred && !empty($js_file['options']['defer'])) { |
|
3773 | + $toMinifyDefer[] = $js_file; |
|
3774 | + } elseif (!$do_deferred && empty($js_file['options']['defer'])) { |
|
3775 | + $toMinify[] = $js_file; |
|
3776 | + } |
|
3567 | 3777 | |
3568 | 3778 | // Grab a random seed. |
3569 | - if (!isset($minSeed) && isset($js_file['options']['seed'])) |
|
3570 | - $minSeed = $js_file['options']['seed']; |
|
3571 | - } |
|
3572 | - |
|
3573 | - elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) |
|
3574 | - echo ' |
|
3779 | + if (!isset($minSeed) && isset($js_file['options']['seed'])) { |
|
3780 | + $minSeed = $js_file['options']['seed']; |
|
3781 | + } |
|
3782 | + } elseif ((!$do_deferred && empty($js_file['options']['defer'])) || ($do_deferred && !empty($js_file['options']['defer']))) { |
|
3783 | + echo ' |
|
3575 | 3784 | <script src="', $js_file['fileUrl'], '"', !empty($js_file['options']['async']) ? ' async="async"' : '', '></script>'; |
3785 | + } |
|
3576 | 3786 | } |
3577 | 3787 | |
3578 | 3788 | if ((!$do_deferred && !empty($toMinify)) || ($do_deferred && !empty($toMinifyDefer))) |
@@ -3581,9 +3791,10 @@ discard block |
||
3581 | 3791 | |
3582 | 3792 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3583 | 3793 | |
3584 | - foreach ($result as $minFile) |
|
3585 | - echo ' |
|
3794 | + foreach ($result as $minFile) { |
|
3795 | + echo ' |
|
3586 | 3796 | <script src="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '"', !empty($minFile['options']['async']) ? ' async="async"' : '', '></script>'; |
3797 | + } |
|
3587 | 3798 | |
3588 | 3799 | } |
3589 | 3800 | |
@@ -3595,8 +3806,9 @@ discard block |
||
3595 | 3806 | echo ' |
3596 | 3807 | <script>'; |
3597 | 3808 | |
3598 | - foreach ($context['javascript_inline']['defer'] as $js_code) |
|
3599 | - echo $js_code; |
|
3809 | + foreach ($context['javascript_inline']['defer'] as $js_code) { |
|
3810 | + echo $js_code; |
|
3811 | + } |
|
3600 | 3812 | |
3601 | 3813 | echo ' |
3602 | 3814 | </script>'; |
@@ -3607,8 +3819,9 @@ discard block |
||
3607 | 3819 | echo ' |
3608 | 3820 | <script>'; |
3609 | 3821 | |
3610 | - foreach ($context['javascript_inline']['standard'] as $js_code) |
|
3611 | - echo $js_code; |
|
3822 | + foreach ($context['javascript_inline']['standard'] as $js_code) { |
|
3823 | + echo $js_code; |
|
3824 | + } |
|
3612 | 3825 | |
3613 | 3826 | echo ' |
3614 | 3827 | </script>'; |
@@ -3636,23 +3849,26 @@ discard block |
||
3636 | 3849 | foreach ($context['css_files'] as $id => $file) |
3637 | 3850 | { |
3638 | 3851 | // Last minute call! allow theme authors to disable single files. |
3639 | - if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) |
|
3640 | - continue; |
|
3852 | + if (!empty($settings['disable_files']) && in_array($id, $settings['disable_files'])) { |
|
3853 | + continue; |
|
3854 | + } |
|
3641 | 3855 | |
3642 | 3856 | // Files are minimized unless they explicitly opt out. |
3643 | - if (!isset($file['options']['minimize'])) |
|
3644 | - $file['options']['minimize'] = true; |
|
3857 | + if (!isset($file['options']['minimize'])) { |
|
3858 | + $file['options']['minimize'] = true; |
|
3859 | + } |
|
3645 | 3860 | |
3646 | 3861 | if (!empty($file['options']['minimize']) && !empty($modSettings['minimize_files'])) |
3647 | 3862 | { |
3648 | 3863 | $toMinify[] = $file; |
3649 | 3864 | |
3650 | 3865 | // Grab a random seed. |
3651 | - if (!isset($minSeed) && isset($file['options']['seed'])) |
|
3652 | - $minSeed = $file['options']['seed']; |
|
3866 | + if (!isset($minSeed) && isset($file['options']['seed'])) { |
|
3867 | + $minSeed = $file['options']['seed']; |
|
3868 | + } |
|
3869 | + } else { |
|
3870 | + $normal[] = $file['fileUrl']; |
|
3653 | 3871 | } |
3654 | - else |
|
3655 | - $normal[] = $file['fileUrl']; |
|
3656 | 3872 | } |
3657 | 3873 | |
3658 | 3874 | if (!empty($toMinify)) |
@@ -3661,23 +3877,26 @@ discard block |
||
3661 | 3877 | |
3662 | 3878 | $minSuccessful = array_keys($result) === array('smf_minified'); |
3663 | 3879 | |
3664 | - foreach ($result as $minFile) |
|
3665 | - echo ' |
|
3880 | + foreach ($result as $minFile) { |
|
3881 | + echo ' |
|
3666 | 3882 | <link rel="stylesheet" href="', $minFile['fileUrl'], $minSuccessful && isset($minSeed) ? $minSeed : '', '">'; |
3883 | + } |
|
3667 | 3884 | } |
3668 | 3885 | |
3669 | 3886 | // Print the rest after the minified files. |
3670 | - if (!empty($normal)) |
|
3671 | - foreach ($normal as $nf) |
|
3887 | + if (!empty($normal)) { |
|
3888 | + foreach ($normal as $nf) |
|
3672 | 3889 | echo ' |
3673 | 3890 | <link rel="stylesheet" href="', $nf ,'">'; |
3891 | + } |
|
3674 | 3892 | |
3675 | 3893 | if ($db_show_debug === true) |
3676 | 3894 | { |
3677 | 3895 | // Try to keep only what's useful. |
3678 | 3896 | $repl = array($boardurl . '/Themes/' => '', $boardurl . '/' => ''); |
3679 | - foreach ($context['css_files'] as $file) |
|
3680 | - $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3897 | + foreach ($context['css_files'] as $file) { |
|
3898 | + $context['debug']['sheets'][] = strtr($file['fileName'], $repl); |
|
3899 | + } |
|
3681 | 3900 | } |
3682 | 3901 | |
3683 | 3902 | if (!empty($context['css_header'])) |
@@ -3685,9 +3904,10 @@ discard block |
||
3685 | 3904 | echo ' |
3686 | 3905 | <style>'; |
3687 | 3906 | |
3688 | - foreach ($context['css_header'] as $css) |
|
3689 | - echo $css .' |
|
3907 | + foreach ($context['css_header'] as $css) { |
|
3908 | + echo $css .' |
|
3690 | 3909 | '; |
3910 | + } |
|
3691 | 3911 | |
3692 | 3912 | echo' |
3693 | 3913 | </style>'; |
@@ -3711,8 +3931,9 @@ discard block |
||
3711 | 3931 | $type = !empty($type) && in_array($type, $types) ? $type : false; |
3712 | 3932 | $data = !empty($data) ? $data : false; |
3713 | 3933 | |
3714 | - if (empty($type) || empty($data)) |
|
3715 | - return false; |
|
3934 | + if (empty($type) || empty($data)) { |
|
3935 | + return false; |
|
3936 | + } |
|
3716 | 3937 | |
3717 | 3938 | // Different pages include different files, so we use a hash to label the different combinations |
3718 | 3939 | $hash = md5(implode(' ', array_keys($data))); |
@@ -3721,8 +3942,9 @@ discard block |
||
3721 | 3942 | $toCache = cache_get_data('minimized_' . $settings['theme_id'] . '_' . $type . '_' . $hash, 86400); |
3722 | 3943 | |
3723 | 3944 | // Already done? |
3724 | - if (!empty($toCache)) |
|
3725 | - return true; |
|
3945 | + if (!empty($toCache)) { |
|
3946 | + return true; |
|
3947 | + } |
|
3726 | 3948 | |
3727 | 3949 | // No namespaces, sorry! |
3728 | 3950 | $classType = 'MatthiasMullie\\Minify\\'. strtoupper($type); |
@@ -3754,8 +3976,9 @@ discard block |
||
3754 | 3976 | $toAdd = file_exists($tempFile) ? $tempFile : false; |
3755 | 3977 | |
3756 | 3978 | // A minified script should only be loaded asynchronously if all its components wanted to be. |
3757 | - if (empty($file['options']['async'])) |
|
3758 | - $async = false; |
|
3979 | + if (empty($file['options']['async'])) { |
|
3980 | + $async = false; |
|
3981 | + } |
|
3759 | 3982 | |
3760 | 3983 | // The file couldn't be located so it won't be added. Log this error. |
3761 | 3984 | if (empty($toAdd)) |
@@ -3815,8 +4038,9 @@ discard block |
||
3815 | 4038 | global $modSettings, $smcFunc; |
3816 | 4039 | |
3817 | 4040 | // Just make up a nice hash... |
3818 | - if ($new) |
|
3819 | - return sha1(md5($filename . time()) . mt_rand()); |
|
4041 | + if ($new) { |
|
4042 | + return sha1(md5($filename . time()) . mt_rand()); |
|
4043 | + } |
|
3820 | 4044 | |
3821 | 4045 | // Just make sure that attachment id is only a int |
3822 | 4046 | $attachment_id = (int) $attachment_id; |
@@ -3833,23 +4057,25 @@ discard block |
||
3833 | 4057 | 'id_attach' => $attachment_id, |
3834 | 4058 | )); |
3835 | 4059 | |
3836 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
3837 | - return false; |
|
4060 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
4061 | + return false; |
|
4062 | + } |
|
3838 | 4063 | |
3839 | 4064 | list ($file_hash) = $smcFunc['db_fetch_row']($request); |
3840 | 4065 | $smcFunc['db_free_result']($request); |
3841 | 4066 | } |
3842 | 4067 | |
3843 | 4068 | // Still no hash? mmm... |
3844 | - if (empty($file_hash)) |
|
3845 | - $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4069 | + if (empty($file_hash)) { |
|
4070 | + $file_hash = sha1(md5($filename . time()) . mt_rand()); |
|
4071 | + } |
|
3846 | 4072 | |
3847 | 4073 | // Are we using multiple directories? |
3848 | - if (is_array($modSettings['attachmentUploadDir'])) |
|
3849 | - $path = $modSettings['attachmentUploadDir'][$dir]; |
|
3850 | - |
|
3851 | - else |
|
3852 | - $path = $modSettings['attachmentUploadDir']; |
|
4074 | + if (is_array($modSettings['attachmentUploadDir'])) { |
|
4075 | + $path = $modSettings['attachmentUploadDir'][$dir]; |
|
4076 | + } else { |
|
4077 | + $path = $modSettings['attachmentUploadDir']; |
|
4078 | + } |
|
3853 | 4079 | |
3854 | 4080 | return $path . '/' . $attachment_id . '_' . $file_hash .'.dat'; |
3855 | 4081 | } |
@@ -3864,8 +4090,9 @@ discard block |
||
3864 | 4090 | function ip2range($fullip) |
3865 | 4091 | { |
3866 | 4092 | // Pretend that 'unknown' is 255.255.255.255. (since that can't be an IP anyway.) |
3867 | - if ($fullip == 'unknown') |
|
3868 | - $fullip = '255.255.255.255'; |
|
4093 | + if ($fullip == 'unknown') { |
|
4094 | + $fullip = '255.255.255.255'; |
|
4095 | + } |
|
3869 | 4096 | |
3870 | 4097 | $ip_parts = explode('-', $fullip); |
3871 | 4098 | $ip_array = array(); |
@@ -3889,10 +4116,11 @@ discard block |
||
3889 | 4116 | $ip_array['low'] = $ip_parts[0]; |
3890 | 4117 | $ip_array['high'] = $ip_parts[1]; |
3891 | 4118 | return $ip_array; |
3892 | - } |
|
3893 | - elseif (count($ip_parts) == 2) // if ip 22.22.*-22.22.* |
|
4119 | + } elseif (count($ip_parts) == 2) { |
|
4120 | + // if ip 22.22.*-22.22.* |
|
3894 | 4121 | { |
3895 | 4122 | $valid_low = isValidIP($ip_parts[0]); |
4123 | + } |
|
3896 | 4124 | $valid_high = isValidIP($ip_parts[1]); |
3897 | 4125 | $count = 0; |
3898 | 4126 | $mode = (preg_match('/:/',$ip_parts[0]) > 0 ? ':' : '.'); |
@@ -3907,7 +4135,9 @@ discard block |
||
3907 | 4135 | $ip_parts[0] .= $mode . $min; |
3908 | 4136 | $valid_low = isValidIP($ip_parts[0]); |
3909 | 4137 | $count++; |
3910 | - if ($count > 9) break; |
|
4138 | + if ($count > 9) { |
|
4139 | + break; |
|
4140 | + } |
|
3911 | 4141 | } |
3912 | 4142 | } |
3913 | 4143 | |
@@ -3921,7 +4151,9 @@ discard block |
||
3921 | 4151 | $ip_parts[1] .= $mode . $max; |
3922 | 4152 | $valid_high = isValidIP($ip_parts[1]); |
3923 | 4153 | $count++; |
3924 | - if ($count > 9) break; |
|
4154 | + if ($count > 9) { |
|
4155 | + break; |
|
4156 | + } |
|
3925 | 4157 | } |
3926 | 4158 | } |
3927 | 4159 | |
@@ -3946,46 +4178,54 @@ discard block |
||
3946 | 4178 | { |
3947 | 4179 | global $modSettings; |
3948 | 4180 | |
3949 | - if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) |
|
3950 | - return $host; |
|
4181 | + if (($host = cache_get_data('hostlookup-' . $ip, 600)) !== null) { |
|
4182 | + return $host; |
|
4183 | + } |
|
3951 | 4184 | $t = microtime(); |
3952 | 4185 | |
3953 | 4186 | // Try the Linux host command, perhaps? |
3954 | 4187 | if (!isset($host) && (strpos(strtolower(PHP_OS), 'win') === false || strpos(strtolower(PHP_OS), 'darwin') !== false) && mt_rand(0, 1) == 1) |
3955 | 4188 | { |
3956 | - if (!isset($modSettings['host_to_dis'])) |
|
3957 | - $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
3958 | - else |
|
3959 | - $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4189 | + if (!isset($modSettings['host_to_dis'])) { |
|
4190 | + $test = @shell_exec('host -W 1 ' . @escapeshellarg($ip)); |
|
4191 | + } else { |
|
4192 | + $test = @shell_exec('host ' . @escapeshellarg($ip)); |
|
4193 | + } |
|
3960 | 4194 | |
3961 | 4195 | // Did host say it didn't find anything? |
3962 | - if (strpos($test, 'not found') !== false) |
|
3963 | - $host = ''; |
|
4196 | + if (strpos($test, 'not found') !== false) { |
|
4197 | + $host = ''; |
|
4198 | + } |
|
3964 | 4199 | // Invalid server option? |
3965 | - elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) |
|
3966 | - updateSettings(array('host_to_dis' => 1)); |
|
4200 | + elseif ((strpos($test, 'invalid option') || strpos($test, 'Invalid query name 1')) && !isset($modSettings['host_to_dis'])) { |
|
4201 | + updateSettings(array('host_to_dis' => 1)); |
|
4202 | + } |
|
3967 | 4203 | // Maybe it found something, after all? |
3968 | - elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) |
|
3969 | - $host = $match[1]; |
|
4204 | + elseif (preg_match('~\s([^\s]+?)\.\s~', $test, $match) == 1) { |
|
4205 | + $host = $match[1]; |
|
4206 | + } |
|
3970 | 4207 | } |
3971 | 4208 | |
3972 | 4209 | // This is nslookup; usually only Windows, but possibly some Unix? |
3973 | 4210 | if (!isset($host) && stripos(PHP_OS, 'win') !== false && strpos(strtolower(PHP_OS), 'darwin') === false && mt_rand(0, 1) == 1) |
3974 | 4211 | { |
3975 | 4212 | $test = @shell_exec('nslookup -timeout=1 ' . @escapeshellarg($ip)); |
3976 | - if (strpos($test, 'Non-existent domain') !== false) |
|
3977 | - $host = ''; |
|
3978 | - elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) |
|
3979 | - $host = $match[1]; |
|
4213 | + if (strpos($test, 'Non-existent domain') !== false) { |
|
4214 | + $host = ''; |
|
4215 | + } elseif (preg_match('~Name:\s+([^\s]+)~', $test, $match) == 1) { |
|
4216 | + $host = $match[1]; |
|
4217 | + } |
|
3980 | 4218 | } |
3981 | 4219 | |
3982 | 4220 | // This is the last try :/. |
3983 | - if (!isset($host) || $host === false) |
|
3984 | - $host = @gethostbyaddr($ip); |
|
4221 | + if (!isset($host) || $host === false) { |
|
4222 | + $host = @gethostbyaddr($ip); |
|
4223 | + } |
|
3985 | 4224 | |
3986 | 4225 | // It took a long time, so let's cache it! |
3987 | - if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) |
|
3988 | - cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4226 | + if (array_sum(explode(' ', microtime())) - array_sum(explode(' ', $t)) > 0.5) { |
|
4227 | + cache_put_data('hostlookup-' . $ip, $host, 600); |
|
4228 | + } |
|
3989 | 4229 | |
3990 | 4230 | return $host; |
3991 | 4231 | } |
@@ -4021,20 +4261,21 @@ discard block |
||
4021 | 4261 | { |
4022 | 4262 | $encrypted = substr(crypt($word, 'uk'), 2, $max_chars); |
4023 | 4263 | $total = 0; |
4024 | - for ($i = 0; $i < $max_chars; $i++) |
|
4025 | - $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4264 | + for ($i = 0; $i < $max_chars; $i++) { |
|
4265 | + $total += $possible_chars[ord($encrypted{$i})] * pow(63, $i); |
|
4266 | + } |
|
4026 | 4267 | $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total; |
4027 | 4268 | } |
4028 | 4269 | } |
4029 | 4270 | return array_unique($returned_ints); |
4030 | - } |
|
4031 | - else |
|
4271 | + } else |
|
4032 | 4272 | { |
4033 | 4273 | // Trim characters before and after and add slashes for database insertion. |
4034 | 4274 | $returned_words = array(); |
4035 | - foreach ($words as $word) |
|
4036 | - if (($word = trim($word, '-_\'')) !== '') |
|
4275 | + foreach ($words as $word) { |
|
4276 | + if (($word = trim($word, '-_\'')) !== '') |
|
4037 | 4277 | $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars); |
4278 | + } |
|
4038 | 4279 | |
4039 | 4280 | // Filter out all words that occur more than once. |
4040 | 4281 | return array_unique($returned_words); |
@@ -4056,16 +4297,18 @@ discard block |
||
4056 | 4297 | global $settings, $txt; |
4057 | 4298 | |
4058 | 4299 | // Does the current loaded theme have this and we are not forcing the usage of this function? |
4059 | - if (function_exists('template_create_button') && !$force_use) |
|
4060 | - return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4300 | + if (function_exists('template_create_button') && !$force_use) { |
|
4301 | + return template_create_button($name, $alt, $label = '', $custom = ''); |
|
4302 | + } |
|
4061 | 4303 | |
4062 | - if (!$settings['use_image_buttons']) |
|
4063 | - return $txt[$alt]; |
|
4064 | - elseif (!empty($settings['use_buttons'])) |
|
4065 | - return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4066 | - else |
|
4067 | - return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4068 | -} |
|
4304 | + if (!$settings['use_image_buttons']) { |
|
4305 | + return $txt[$alt]; |
|
4306 | + } elseif (!empty($settings['use_buttons'])) { |
|
4307 | + return '<span class="generic_icons ' . $name . '" alt="' . $txt[$alt] . '"></span>' . ($label != '' ? ' <strong>' . $txt[$label] . '</strong>' : ''); |
|
4308 | + } else { |
|
4309 | + return '<img src="' . $settings['lang_images_url'] . '/' . $name . '" alt="' . $txt[$alt] . '" ' . $custom . '>'; |
|
4310 | + } |
|
4311 | + } |
|
4069 | 4312 | |
4070 | 4313 | /** |
4071 | 4314 | * Sets up all of the top menu buttons |
@@ -4108,9 +4351,10 @@ discard block |
||
4108 | 4351 | var user_menus = new smc_PopupMenu(); |
4109 | 4352 | user_menus.add("profile", "' . $scripturl . '?action=profile;area=popup"); |
4110 | 4353 | user_menus.add("alerts", "' . $scripturl . '?action=profile;area=alerts_popup;u='. $context['user']['id'] .'");', true); |
4111 | - if ($context['allow_pm']) |
|
4112 | - addInlineJavaScript(' |
|
4354 | + if ($context['allow_pm']) { |
|
4355 | + addInlineJavaScript(' |
|
4113 | 4356 | user_menus.add("pm", "' . $scripturl . '?action=pm;sa=popup");', true); |
4357 | + } |
|
4114 | 4358 | |
4115 | 4359 | if (!empty($modSettings['enable_ajax_alerts'])) |
4116 | 4360 | { |
@@ -4270,88 +4514,96 @@ discard block |
||
4270 | 4514 | |
4271 | 4515 | // Now we put the buttons in the context so the theme can use them. |
4272 | 4516 | $menu_buttons = array(); |
4273 | - foreach ($buttons as $act => $button) |
|
4274 | - if (!empty($button['show'])) |
|
4517 | + foreach ($buttons as $act => $button) { |
|
4518 | + if (!empty($button['show'])) |
|
4275 | 4519 | { |
4276 | 4520 | $button['active_button'] = false; |
4521 | + } |
|
4277 | 4522 | |
4278 | 4523 | // This button needs some action. |
4279 | - if (isset($button['action_hook'])) |
|
4280 | - $needs_action_hook = true; |
|
4524 | + if (isset($button['action_hook'])) { |
|
4525 | + $needs_action_hook = true; |
|
4526 | + } |
|
4281 | 4527 | |
4282 | 4528 | // Make sure the last button truly is the last button. |
4283 | 4529 | if (!empty($button['is_last'])) |
4284 | 4530 | { |
4285 | - if (isset($last_button)) |
|
4286 | - unset($menu_buttons[$last_button]['is_last']); |
|
4531 | + if (isset($last_button)) { |
|
4532 | + unset($menu_buttons[$last_button]['is_last']); |
|
4533 | + } |
|
4287 | 4534 | $last_button = $act; |
4288 | 4535 | } |
4289 | 4536 | |
4290 | 4537 | // Go through the sub buttons if there are any. |
4291 | - if (!empty($button['sub_buttons'])) |
|
4292 | - foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4538 | + if (!empty($button['sub_buttons'])) { |
|
4539 | + foreach ($button['sub_buttons'] as $key => $subbutton) |
|
4293 | 4540 | { |
4294 | 4541 | if (empty($subbutton['show'])) |
4295 | 4542 | unset($button['sub_buttons'][$key]); |
4543 | + } |
|
4296 | 4544 | |
4297 | 4545 | // 2nd level sub buttons next... |
4298 | 4546 | if (!empty($subbutton['sub_buttons'])) |
4299 | 4547 | { |
4300 | 4548 | foreach ($subbutton['sub_buttons'] as $key2 => $sub_button2) |
4301 | 4549 | { |
4302 | - if (empty($sub_button2['show'])) |
|
4303 | - unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4550 | + if (empty($sub_button2['show'])) { |
|
4551 | + unset($button['sub_buttons'][$key]['sub_buttons'][$key2]); |
|
4552 | + } |
|
4304 | 4553 | } |
4305 | 4554 | } |
4306 | 4555 | } |
4307 | 4556 | |
4308 | 4557 | // Does this button have its own icon? |
4309 | - if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) |
|
4310 | - $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4311 | - elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) |
|
4312 | - $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4313 | - elseif (isset($button['icon'])) |
|
4314 | - $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4315 | - else |
|
4316 | - $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4558 | + if (isset($button['icon']) && file_exists($settings['theme_dir'] . '/images/' . $button['icon'])) { |
|
4559 | + $button['icon'] = '<img src="' . $settings['images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4560 | + } elseif (isset($button['icon']) && file_exists($settings['default_theme_dir'] . '/images/' . $button['icon'])) { |
|
4561 | + $button['icon'] = '<img src="' . $settings['default_images_url'] . '/' . $button['icon'] . '" alt="">'; |
|
4562 | + } elseif (isset($button['icon'])) { |
|
4563 | + $button['icon'] = '<span class="generic_icons ' . $button['icon'] . '"></span>'; |
|
4564 | + } else { |
|
4565 | + $button['icon'] = '<span class="generic_icons ' . $act . '"></span>'; |
|
4566 | + } |
|
4317 | 4567 | |
4318 | 4568 | $menu_buttons[$act] = $button; |
4319 | 4569 | } |
4320 | 4570 | |
4321 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
4322 | - cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4571 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
4572 | + cache_put_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $menu_buttons, $cacheTime); |
|
4573 | + } |
|
4323 | 4574 | } |
4324 | 4575 | |
4325 | 4576 | $context['menu_buttons'] = $menu_buttons; |
4326 | 4577 | |
4327 | 4578 | // Logging out requires the session id in the url. |
4328 | - if (isset($context['menu_buttons']['logout'])) |
|
4329 | - $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4579 | + if (isset($context['menu_buttons']['logout'])) { |
|
4580 | + $context['menu_buttons']['logout']['href'] = sprintf($context['menu_buttons']['logout']['href'], $context['session_var'], $context['session_id']); |
|
4581 | + } |
|
4330 | 4582 | |
4331 | 4583 | // Figure out which action we are doing so we can set the active tab. |
4332 | 4584 | // Default to home. |
4333 | 4585 | $current_action = 'home'; |
4334 | 4586 | |
4335 | - if (isset($context['menu_buttons'][$context['current_action']])) |
|
4336 | - $current_action = $context['current_action']; |
|
4337 | - elseif ($context['current_action'] == 'search2') |
|
4338 | - $current_action = 'search'; |
|
4339 | - elseif ($context['current_action'] == 'theme') |
|
4340 | - $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4341 | - elseif ($context['current_action'] == 'register2') |
|
4342 | - $current_action = 'register'; |
|
4343 | - elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) |
|
4344 | - $current_action = 'login'; |
|
4345 | - elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) |
|
4346 | - $current_action = 'moderate'; |
|
4587 | + if (isset($context['menu_buttons'][$context['current_action']])) { |
|
4588 | + $current_action = $context['current_action']; |
|
4589 | + } elseif ($context['current_action'] == 'search2') { |
|
4590 | + $current_action = 'search'; |
|
4591 | + } elseif ($context['current_action'] == 'theme') { |
|
4592 | + $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin'; |
|
4593 | + } elseif ($context['current_action'] == 'register2') { |
|
4594 | + $current_action = 'register'; |
|
4595 | + } elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder')) { |
|
4596 | + $current_action = 'login'; |
|
4597 | + } elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center']) { |
|
4598 | + $current_action = 'moderate'; |
|
4599 | + } |
|
4347 | 4600 | |
4348 | 4601 | // There are certain exceptions to the above where we don't want anything on the menu highlighted. |
4349 | 4602 | if ($context['current_action'] == 'profile' && !empty($context['user']['is_owner'])) |
4350 | 4603 | { |
4351 | 4604 | $current_action = !empty($_GET['area']) && $_GET['area'] == 'showalerts' ? 'self_alerts' : 'self_profile'; |
4352 | 4605 | $context[$current_action] = true; |
4353 | - } |
|
4354 | - elseif ($context['current_action'] == 'pm') |
|
4606 | + } elseif ($context['current_action'] == 'pm') |
|
4355 | 4607 | { |
4356 | 4608 | $current_action = 'self_pm'; |
4357 | 4609 | $context['self_pm'] = true; |
@@ -4408,12 +4660,14 @@ discard block |
||
4408 | 4660 | } |
4409 | 4661 | |
4410 | 4662 | // Not all actions are simple. |
4411 | - if (!empty($needs_action_hook)) |
|
4412 | - call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4663 | + if (!empty($needs_action_hook)) { |
|
4664 | + call_integration_hook('integrate_current_action', array(&$current_action)); |
|
4665 | + } |
|
4413 | 4666 | |
4414 | - if (isset($context['menu_buttons'][$current_action])) |
|
4415 | - $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4416 | -} |
|
4667 | + if (isset($context['menu_buttons'][$current_action])) { |
|
4668 | + $context['menu_buttons'][$current_action]['active_button'] = true; |
|
4669 | + } |
|
4670 | + } |
|
4417 | 4671 | |
4418 | 4672 | /** |
4419 | 4673 | * Generate a random seed and ensure it's stored in settings. |
@@ -4437,30 +4691,35 @@ discard block |
||
4437 | 4691 | global $modSettings, $settings, $boarddir, $sourcedir, $db_show_debug; |
4438 | 4692 | global $context, $txt; |
4439 | 4693 | |
4440 | - if ($db_show_debug === true) |
|
4441 | - $context['debug']['hooks'][] = $hook; |
|
4694 | + if ($db_show_debug === true) { |
|
4695 | + $context['debug']['hooks'][] = $hook; |
|
4696 | + } |
|
4442 | 4697 | |
4443 | 4698 | // Need to have some control. |
4444 | - if (!isset($context['instances'])) |
|
4445 | - $context['instances'] = array(); |
|
4699 | + if (!isset($context['instances'])) { |
|
4700 | + $context['instances'] = array(); |
|
4701 | + } |
|
4446 | 4702 | |
4447 | 4703 | $results = array(); |
4448 | - if (empty($modSettings[$hook])) |
|
4449 | - return $results; |
|
4704 | + if (empty($modSettings[$hook])) { |
|
4705 | + return $results; |
|
4706 | + } |
|
4450 | 4707 | |
4451 | 4708 | $functions = explode(',', $modSettings[$hook]); |
4452 | 4709 | // Loop through each function. |
4453 | 4710 | foreach ($functions as $function) |
4454 | 4711 | { |
4455 | 4712 | // Hook has been marked as "disabled". Skip it! |
4456 | - if (strpos($function, '!') !== false) |
|
4457 | - continue; |
|
4713 | + if (strpos($function, '!') !== false) { |
|
4714 | + continue; |
|
4715 | + } |
|
4458 | 4716 | |
4459 | 4717 | $call = call_helper($function, true); |
4460 | 4718 | |
4461 | 4719 | // Is it valid? |
4462 | - if (!empty($call)) |
|
4463 | - $results[$function] = call_user_func_array($call, $parameters); |
|
4720 | + if (!empty($call)) { |
|
4721 | + $results[$function] = call_user_func_array($call, $parameters); |
|
4722 | + } |
|
4464 | 4723 | |
4465 | 4724 | // Whatever it was suppose to call, it failed :( |
4466 | 4725 | elseif (!empty($function)) |
@@ -4476,8 +4735,9 @@ discard block |
||
4476 | 4735 | } |
4477 | 4736 | |
4478 | 4737 | // "Assume" the file resides on $boarddir somewhere... |
4479 | - else |
|
4480 | - log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4738 | + else { |
|
4739 | + log_error(sprintf($txt['hook_fail_call_to'], $function, $boarddir), 'general'); |
|
4740 | + } |
|
4481 | 4741 | } |
4482 | 4742 | } |
4483 | 4743 | |
@@ -4499,12 +4759,14 @@ discard block |
||
4499 | 4759 | global $smcFunc, $modSettings; |
4500 | 4760 | |
4501 | 4761 | // Any objects? |
4502 | - if ($object) |
|
4503 | - $function = $function . '#'; |
|
4762 | + if ($object) { |
|
4763 | + $function = $function . '#'; |
|
4764 | + } |
|
4504 | 4765 | |
4505 | 4766 | // Any files to load? |
4506 | - if (!empty($file) && is_string($file)) |
|
4507 | - $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4767 | + if (!empty($file) && is_string($file)) { |
|
4768 | + $function = $file . (!empty($function) ? '|' . $function : ''); |
|
4769 | + } |
|
4508 | 4770 | |
4509 | 4771 | // Get the correct string. |
4510 | 4772 | $integration_call = $function; |
@@ -4526,13 +4788,14 @@ discard block |
||
4526 | 4788 | if (!empty($current_functions)) |
4527 | 4789 | { |
4528 | 4790 | $current_functions = explode(',', $current_functions); |
4529 | - if (in_array($integration_call, $current_functions)) |
|
4530 | - return; |
|
4791 | + if (in_array($integration_call, $current_functions)) { |
|
4792 | + return; |
|
4793 | + } |
|
4531 | 4794 | |
4532 | 4795 | $permanent_functions = array_merge($current_functions, array($integration_call)); |
4796 | + } else { |
|
4797 | + $permanent_functions = array($integration_call); |
|
4533 | 4798 | } |
4534 | - else |
|
4535 | - $permanent_functions = array($integration_call); |
|
4536 | 4799 | |
4537 | 4800 | updateSettings(array($hook => implode(',', $permanent_functions))); |
4538 | 4801 | } |
@@ -4541,8 +4804,9 @@ discard block |
||
4541 | 4804 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4542 | 4805 | |
4543 | 4806 | // Do nothing, if it's already there. |
4544 | - if (in_array($integration_call, $functions)) |
|
4545 | - return; |
|
4807 | + if (in_array($integration_call, $functions)) { |
|
4808 | + return; |
|
4809 | + } |
|
4546 | 4810 | |
4547 | 4811 | $functions[] = $integration_call; |
4548 | 4812 | $modSettings[$hook] = implode(',', $functions); |
@@ -4565,12 +4829,14 @@ discard block |
||
4565 | 4829 | global $smcFunc, $modSettings; |
4566 | 4830 | |
4567 | 4831 | // Any objects? |
4568 | - if ($object) |
|
4569 | - $function = $function . '#'; |
|
4832 | + if ($object) { |
|
4833 | + $function = $function . '#'; |
|
4834 | + } |
|
4570 | 4835 | |
4571 | 4836 | // Any files to load? |
4572 | - if (!empty($file) && is_string($file)) |
|
4573 | - $function = $file . '|' . $function; |
|
4837 | + if (!empty($file) && is_string($file)) { |
|
4838 | + $function = $file . '|' . $function; |
|
4839 | + } |
|
4574 | 4840 | |
4575 | 4841 | // Get the correct string. |
4576 | 4842 | $integration_call = $function; |
@@ -4591,16 +4857,18 @@ discard block |
||
4591 | 4857 | { |
4592 | 4858 | $current_functions = explode(',', $current_functions); |
4593 | 4859 | |
4594 | - if (in_array($integration_call, $current_functions)) |
|
4595 | - updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4860 | + if (in_array($integration_call, $current_functions)) { |
|
4861 | + updateSettings(array($hook => implode(',', array_diff($current_functions, array($integration_call))))); |
|
4862 | + } |
|
4596 | 4863 | } |
4597 | 4864 | |
4598 | 4865 | // Turn the function list into something usable. |
4599 | 4866 | $functions = empty($modSettings[$hook]) ? array() : explode(',', $modSettings[$hook]); |
4600 | 4867 | |
4601 | 4868 | // You can only remove it if it's available. |
4602 | - if (!in_array($integration_call, $functions)) |
|
4603 | - return; |
|
4869 | + if (!in_array($integration_call, $functions)) { |
|
4870 | + return; |
|
4871 | + } |
|
4604 | 4872 | |
4605 | 4873 | $functions = array_diff($functions, array($integration_call)); |
4606 | 4874 | $modSettings[$hook] = implode(',', $functions); |
@@ -4621,17 +4889,20 @@ discard block |
||
4621 | 4889 | global $context, $smcFunc, $txt, $db_show_debug; |
4622 | 4890 | |
4623 | 4891 | // Really? |
4624 | - if (empty($string)) |
|
4625 | - return false; |
|
4892 | + if (empty($string)) { |
|
4893 | + return false; |
|
4894 | + } |
|
4626 | 4895 | |
4627 | 4896 | // An array? should be a "callable" array IE array(object/class, valid_callable). |
4628 | 4897 | // A closure? should be a callable one. |
4629 | - if (is_array($string) || $string instanceof Closure) |
|
4630 | - return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4898 | + if (is_array($string) || $string instanceof Closure) { |
|
4899 | + return $return ? $string : (is_callable($string) ? call_user_func($string) : false); |
|
4900 | + } |
|
4631 | 4901 | |
4632 | 4902 | // No full objects, sorry! pass a method or a property instead! |
4633 | - if (is_object($string)) |
|
4634 | - return false; |
|
4903 | + if (is_object($string)) { |
|
4904 | + return false; |
|
4905 | + } |
|
4635 | 4906 | |
4636 | 4907 | // Stay vitaminized my friends... |
4637 | 4908 | $string = $smcFunc['htmlspecialchars']($smcFunc['htmltrim']($string)); |
@@ -4640,8 +4911,9 @@ discard block |
||
4640 | 4911 | $string = load_file($string); |
4641 | 4912 | |
4642 | 4913 | // Loaded file failed |
4643 | - if (empty($string)) |
|
4644 | - return false; |
|
4914 | + if (empty($string)) { |
|
4915 | + return false; |
|
4916 | + } |
|
4645 | 4917 | |
4646 | 4918 | // Found a method. |
4647 | 4919 | if (strpos($string, '::') !== false) |
@@ -4662,8 +4934,9 @@ discard block |
||
4662 | 4934 | // Add another one to the list. |
4663 | 4935 | if ($db_show_debug === true) |
4664 | 4936 | { |
4665 | - if (!isset($context['debug']['instances'])) |
|
4666 | - $context['debug']['instances'] = array(); |
|
4937 | + if (!isset($context['debug']['instances'])) { |
|
4938 | + $context['debug']['instances'] = array(); |
|
4939 | + } |
|
4667 | 4940 | |
4668 | 4941 | $context['debug']['instances'][$class] = $class; |
4669 | 4942 | } |
@@ -4673,13 +4946,15 @@ discard block |
||
4673 | 4946 | } |
4674 | 4947 | |
4675 | 4948 | // Right then. This is a call to a static method. |
4676 | - else |
|
4677 | - $func = array($class, $method); |
|
4949 | + else { |
|
4950 | + $func = array($class, $method); |
|
4951 | + } |
|
4678 | 4952 | } |
4679 | 4953 | |
4680 | 4954 | // Nope! just a plain regular function. |
4681 | - else |
|
4682 | - $func = $string; |
|
4955 | + else { |
|
4956 | + $func = $string; |
|
4957 | + } |
|
4683 | 4958 | |
4684 | 4959 | // Right, we got what we need, time to do some checks. |
4685 | 4960 | if (!is_callable($func, false, $callable_name)) |
@@ -4695,17 +4970,18 @@ discard block |
||
4695 | 4970 | else |
4696 | 4971 | { |
4697 | 4972 | // What are we gonna do about it? |
4698 | - if ($return) |
|
4699 | - return $func; |
|
4973 | + if ($return) { |
|
4974 | + return $func; |
|
4975 | + } |
|
4700 | 4976 | |
4701 | 4977 | // If this is a plain function, avoid the heat of calling call_user_func(). |
4702 | 4978 | else |
4703 | 4979 | { |
4704 | - if (is_array($func)) |
|
4705 | - call_user_func($func); |
|
4706 | - |
|
4707 | - else |
|
4708 | - $func(); |
|
4980 | + if (is_array($func)) { |
|
4981 | + call_user_func($func); |
|
4982 | + } else { |
|
4983 | + $func(); |
|
4984 | + } |
|
4709 | 4985 | } |
4710 | 4986 | } |
4711 | 4987 | } |
@@ -4722,31 +4998,34 @@ discard block |
||
4722 | 4998 | { |
4723 | 4999 | global $sourcedir, $txt, $boarddir, $settings; |
4724 | 5000 | |
4725 | - if (empty($string)) |
|
4726 | - return false; |
|
5001 | + if (empty($string)) { |
|
5002 | + return false; |
|
5003 | + } |
|
4727 | 5004 | |
4728 | 5005 | if (strpos($string, '|') !== false) |
4729 | 5006 | { |
4730 | 5007 | list ($file, $string) = explode('|', $string); |
4731 | 5008 | |
4732 | 5009 | // Match the wildcards to their regular vars. |
4733 | - if (empty($settings['theme_dir'])) |
|
4734 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
4735 | - |
|
4736 | - else |
|
4737 | - $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5010 | + if (empty($settings['theme_dir'])) { |
|
5011 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
|
5012 | + } else { |
|
5013 | + $absPath = strtr(trim($file), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
|
5014 | + } |
|
4738 | 5015 | |
4739 | 5016 | // Load the file if it can be loaded. |
4740 | - if (file_exists($absPath)) |
|
4741 | - require_once($absPath); |
|
5017 | + if (file_exists($absPath)) { |
|
5018 | + require_once($absPath); |
|
5019 | + } |
|
4742 | 5020 | |
4743 | 5021 | // No? try a fallback to $sourcedir |
4744 | 5022 | else |
4745 | 5023 | { |
4746 | 5024 | $absPath = $sourcedir .'/'. $file; |
4747 | 5025 | |
4748 | - if (file_exists($absPath)) |
|
4749 | - require_once($absPath); |
|
5026 | + if (file_exists($absPath)) { |
|
5027 | + require_once($absPath); |
|
5028 | + } |
|
4750 | 5029 | |
4751 | 5030 | // Sorry, can't do much for you at this point. |
4752 | 5031 | else |
@@ -4773,8 +5052,9 @@ discard block |
||
4773 | 5052 | global $user_info, $smcFunc; |
4774 | 5053 | |
4775 | 5054 | // Make sure we have something to work with. |
4776 | - if (empty($topic)) |
|
4777 | - return array(); |
|
5055 | + if (empty($topic)) { |
|
5056 | + return array(); |
|
5057 | + } |
|
4778 | 5058 | |
4779 | 5059 | |
4780 | 5060 | // We already know the number of likes per message, we just want to know whether the current user liked it or not. |
@@ -4797,8 +5077,9 @@ discard block |
||
4797 | 5077 | 'topic' => $topic, |
4798 | 5078 | ) |
4799 | 5079 | ); |
4800 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
4801 | - $temp[] = (int) $row['content_id']; |
|
5080 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
5081 | + $temp[] = (int) $row['content_id']; |
|
5082 | + } |
|
4802 | 5083 | |
4803 | 5084 | cache_put_data($cache_key, $temp, $ttl); |
4804 | 5085 | } |
@@ -4819,8 +5100,9 @@ discard block |
||
4819 | 5100 | { |
4820 | 5101 | global $context; |
4821 | 5102 | |
4822 | - if (empty($string)) |
|
4823 | - return $string; |
|
5103 | + if (empty($string)) { |
|
5104 | + return $string; |
|
5105 | + } |
|
4824 | 5106 | |
4825 | 5107 | // UTF-8 occurences of MS special characters |
4826 | 5108 | $findchars_utf8 = array( |
@@ -4861,10 +5143,11 @@ discard block |
||
4861 | 5143 | '--', // — |
4862 | 5144 | ); |
4863 | 5145 | |
4864 | - if ($context['utf8']) |
|
4865 | - $string = str_replace($findchars_utf8, $replacechars, $string); |
|
4866 | - else |
|
4867 | - $string = str_replace($findchars_iso, $replacechars, $string); |
|
5146 | + if ($context['utf8']) { |
|
5147 | + $string = str_replace($findchars_utf8, $replacechars, $string); |
|
5148 | + } else { |
|
5149 | + $string = str_replace($findchars_iso, $replacechars, $string); |
|
5150 | + } |
|
4868 | 5151 | |
4869 | 5152 | return $string; |
4870 | 5153 | } |
@@ -4883,49 +5166,59 @@ discard block |
||
4883 | 5166 | { |
4884 | 5167 | global $context; |
4885 | 5168 | |
4886 | - if (!isset($matches[2])) |
|
4887 | - return ''; |
|
5169 | + if (!isset($matches[2])) { |
|
5170 | + return ''; |
|
5171 | + } |
|
4888 | 5172 | |
4889 | 5173 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4890 | 5174 | |
4891 | 5175 | // remove left to right / right to left overrides |
4892 | - if ($num === 0x202D || $num === 0x202E) |
|
4893 | - return ''; |
|
5176 | + if ($num === 0x202D || $num === 0x202E) { |
|
5177 | + return ''; |
|
5178 | + } |
|
4894 | 5179 | |
4895 | 5180 | // Quote, Ampersand, Apostrophe, Less/Greater Than get html replaced |
4896 | - if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) |
|
4897 | - return '&#' . $num . ';'; |
|
5181 | + if (in_array($num, array(0x22, 0x26, 0x27, 0x3C, 0x3E))) { |
|
5182 | + return '&#' . $num . ';'; |
|
5183 | + } |
|
4898 | 5184 | |
4899 | 5185 | if (empty($context['utf8'])) |
4900 | 5186 | { |
4901 | 5187 | // no control characters |
4902 | - if ($num < 0x20) |
|
4903 | - return ''; |
|
5188 | + if ($num < 0x20) { |
|
5189 | + return ''; |
|
5190 | + } |
|
4904 | 5191 | // text is text |
4905 | - elseif ($num < 0x80) |
|
4906 | - return chr($num); |
|
5192 | + elseif ($num < 0x80) { |
|
5193 | + return chr($num); |
|
5194 | + } |
|
4907 | 5195 | // all others get html-ised |
4908 | - else |
|
4909 | - return '&#' . $matches[2] . ';'; |
|
4910 | - } |
|
4911 | - else |
|
5196 | + else { |
|
5197 | + return '&#' . $matches[2] . ';'; |
|
5198 | + } |
|
5199 | + } else |
|
4912 | 5200 | { |
4913 | 5201 | // <0x20 are control characters, 0x20 is a space, > 0x10FFFF is past the end of the utf8 character set |
4914 | 5202 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text) |
4915 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) |
|
4916 | - return ''; |
|
5203 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF)) { |
|
5204 | + return ''; |
|
5205 | + } |
|
4917 | 5206 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4918 | - elseif ($num < 0x80) |
|
4919 | - return chr($num); |
|
5207 | + elseif ($num < 0x80) { |
|
5208 | + return chr($num); |
|
5209 | + } |
|
4920 | 5210 | // <0x800 (2048) |
4921 | - elseif ($num < 0x800) |
|
4922 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5211 | + elseif ($num < 0x800) { |
|
5212 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5213 | + } |
|
4923 | 5214 | // < 0x10000 (65536) |
4924 | - elseif ($num < 0x10000) |
|
4925 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5215 | + elseif ($num < 0x10000) { |
|
5216 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5217 | + } |
|
4926 | 5218 | // <= 0x10FFFF (1114111) |
4927 | - else |
|
4928 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5219 | + else { |
|
5220 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5221 | + } |
|
4929 | 5222 | } |
4930 | 5223 | } |
4931 | 5224 | |
@@ -4941,28 +5234,34 @@ discard block |
||
4941 | 5234 | */ |
4942 | 5235 | function fixchar__callback($matches) |
4943 | 5236 | { |
4944 | - if (!isset($matches[1])) |
|
4945 | - return ''; |
|
5237 | + if (!isset($matches[1])) { |
|
5238 | + return ''; |
|
5239 | + } |
|
4946 | 5240 | |
4947 | 5241 | $num = $matches[1][0] === 'x' ? hexdec(substr($matches[1], 1)) : (int) $matches[1]; |
4948 | 5242 | |
4949 | 5243 | // <0x20 are control characters, > 0x10FFFF is past the end of the utf8 character set |
4950 | 5244 | // 0xD800 >= $num <= 0xDFFF are surrogate markers (not valid for utf8 text), 0x202D-E are left to right overrides |
4951 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) |
|
4952 | - return ''; |
|
5245 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202D || $num === 0x202E) { |
|
5246 | + return ''; |
|
5247 | + } |
|
4953 | 5248 | // <0x80 (or less than 128) are standard ascii characters a-z A-Z 0-9 and punctuation |
4954 | - elseif ($num < 0x80) |
|
4955 | - return chr($num); |
|
5249 | + elseif ($num < 0x80) { |
|
5250 | + return chr($num); |
|
5251 | + } |
|
4956 | 5252 | // <0x800 (2048) |
4957 | - elseif ($num < 0x800) |
|
4958 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5253 | + elseif ($num < 0x800) { |
|
5254 | + return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
5255 | + } |
|
4959 | 5256 | // < 0x10000 (65536) |
4960 | - elseif ($num < 0x10000) |
|
4961 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5257 | + elseif ($num < 0x10000) { |
|
5258 | + return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5259 | + } |
|
4962 | 5260 | // <= 0x10FFFF (1114111) |
4963 | - else |
|
4964 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
4965 | -} |
|
5261 | + else { |
|
5262 | + return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
5263 | + } |
|
5264 | + } |
|
4966 | 5265 | |
4967 | 5266 | /** |
4968 | 5267 | * Strips out invalid html entities, replaces others with html style { codes |
@@ -4975,17 +5274,19 @@ discard block |
||
4975 | 5274 | */ |
4976 | 5275 | function entity_fix__callback($matches) |
4977 | 5276 | { |
4978 | - if (!isset($matches[2])) |
|
4979 | - return ''; |
|
5277 | + if (!isset($matches[2])) { |
|
5278 | + return ''; |
|
5279 | + } |
|
4980 | 5280 | |
4981 | 5281 | $num = $matches[2][0] === 'x' ? hexdec(substr($matches[2], 1)) : (int) $matches[2]; |
4982 | 5282 | |
4983 | 5283 | // we don't allow control characters, characters out of range, byte markers, etc |
4984 | - if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) |
|
4985 | - return ''; |
|
4986 | - else |
|
4987 | - return '&#' . $num . ';'; |
|
4988 | -} |
|
5284 | + if ($num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num == 0x202D || $num == 0x202E) { |
|
5285 | + return ''; |
|
5286 | + } else { |
|
5287 | + return '&#' . $num . ';'; |
|
5288 | + } |
|
5289 | + } |
|
4989 | 5290 | |
4990 | 5291 | /** |
4991 | 5292 | * Return a Gravatar URL based on |
@@ -5009,18 +5310,23 @@ discard block |
||
5009 | 5310 | $ratings = array('G', 'PG', 'R', 'X'); |
5010 | 5311 | $defaults = array('mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'); |
5011 | 5312 | $url_params = array(); |
5012 | - if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) |
|
5013 | - $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5014 | - if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) |
|
5015 | - $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5016 | - if (!empty($modSettings['avatar_max_width_external'])) |
|
5017 | - $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5018 | - if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) |
|
5019 | - if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5313 | + if (!empty($modSettings['gravatarMaxRating']) && in_array($modSettings['gravatarMaxRating'], $ratings)) { |
|
5314 | + $url_params[] = 'rating=' . $modSettings['gravatarMaxRating']; |
|
5315 | + } |
|
5316 | + if (!empty($modSettings['gravatarDefault']) && in_array($modSettings['gravatarDefault'], $defaults)) { |
|
5317 | + $url_params[] = 'default=' . $modSettings['gravatarDefault']; |
|
5318 | + } |
|
5319 | + if (!empty($modSettings['avatar_max_width_external'])) { |
|
5320 | + $size_string = (int) $modSettings['avatar_max_width_external']; |
|
5321 | + } |
|
5322 | + if (!empty($modSettings['avatar_max_height_external']) && !empty($size_string)) { |
|
5323 | + if ((int) $modSettings['avatar_max_height_external'] < $size_string) |
|
5020 | 5324 | $size_string = $modSettings['avatar_max_height_external']; |
5325 | + } |
|
5021 | 5326 | |
5022 | - if (!empty($size_string)) |
|
5023 | - $url_params[] = 's=' . $size_string; |
|
5327 | + if (!empty($size_string)) { |
|
5328 | + $url_params[] = 's=' . $size_string; |
|
5329 | + } |
|
5024 | 5330 | } |
5025 | 5331 | $http_method = !empty($modSettings['force_ssl']) ? 'https://secure' : 'http://www'; |
5026 | 5332 | |
@@ -5039,22 +5345,26 @@ discard block |
||
5039 | 5345 | static $timezones = null, $lastwhen = null; |
5040 | 5346 | |
5041 | 5347 | // No point doing this over if we already did it once |
5042 | - if (!empty($timezones) && $when == $lastwhen) |
|
5043 | - return $timezones; |
|
5044 | - else |
|
5045 | - $lastwhen = $when; |
|
5348 | + if (!empty($timezones) && $when == $lastwhen) { |
|
5349 | + return $timezones; |
|
5350 | + } else { |
|
5351 | + $lastwhen = $when; |
|
5352 | + } |
|
5046 | 5353 | |
5047 | 5354 | // Parseable datetime string? |
5048 | - if (is_int($timestamp = strtotime($when))) |
|
5049 | - $when = $timestamp; |
|
5355 | + if (is_int($timestamp = strtotime($when))) { |
|
5356 | + $when = $timestamp; |
|
5357 | + } |
|
5050 | 5358 | |
5051 | 5359 | // A Unix timestamp? |
5052 | - elseif (is_numeric($when)) |
|
5053 | - $when = intval($when); |
|
5360 | + elseif (is_numeric($when)) { |
|
5361 | + $when = intval($when); |
|
5362 | + } |
|
5054 | 5363 | |
5055 | 5364 | // Invalid value? Just get current Unix timestamp. |
5056 | - else |
|
5057 | - $when = time(); |
|
5365 | + else { |
|
5366 | + $when = time(); |
|
5367 | + } |
|
5058 | 5368 | |
5059 | 5369 | // We'll need these too |
5060 | 5370 | $date_when = date_create('@' . $when); |
@@ -5118,8 +5428,9 @@ discard block |
||
5118 | 5428 | foreach ($priority_countries as $country) |
5119 | 5429 | { |
5120 | 5430 | $country_tzids = @timezone_identifiers_list(DateTimeZone::PER_COUNTRY, strtoupper(trim($country))); |
5121 | - if (!empty($country_tzids)) |
|
5122 | - $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5431 | + if (!empty($country_tzids)) { |
|
5432 | + $priority_tzids = array_merge($priority_tzids, $country_tzids); |
|
5433 | + } |
|
5123 | 5434 | } |
5124 | 5435 | |
5125 | 5436 | // Process the preferred timezones first, then the rest. |
@@ -5129,8 +5440,9 @@ discard block |
||
5129 | 5440 | foreach ($tzids as $tzid) |
5130 | 5441 | { |
5131 | 5442 | // We don't want UTC right now |
5132 | - if ($tzid == 'UTC') |
|
5133 | - continue; |
|
5443 | + if ($tzid == 'UTC') { |
|
5444 | + continue; |
|
5445 | + } |
|
5134 | 5446 | |
5135 | 5447 | $tz = timezone_open($tzid); |
5136 | 5448 | |
@@ -5151,8 +5463,9 @@ discard block |
||
5151 | 5463 | } |
5152 | 5464 | |
5153 | 5465 | // A time zone from a prioritized country? |
5154 | - if (in_array($tzid, $priority_tzids)) |
|
5155 | - $priority_zones[$tzkey] = true; |
|
5466 | + if (in_array($tzid, $priority_tzids)) { |
|
5467 | + $priority_zones[$tzkey] = true; |
|
5468 | + } |
|
5156 | 5469 | |
5157 | 5470 | // Keep track of the location and offset for this tzid |
5158 | 5471 | $tzid_parts = explode('/', $tzid); |
@@ -5171,15 +5484,17 @@ discard block |
||
5171 | 5484 | { |
5172 | 5485 | date_timezone_set($date_when, timezone_open($tzvalue['tzid'])); |
5173 | 5486 | |
5174 | - if (!empty($timezone_descriptions[$tzvalue['tzid']])) |
|
5175 | - $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5176 | - else |
|
5177 | - $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5487 | + if (!empty($timezone_descriptions[$tzvalue['tzid']])) { |
|
5488 | + $desc = $timezone_descriptions[$tzvalue['tzid']]; |
|
5489 | + } else { |
|
5490 | + $desc = implode(', ', array_unique($tzvalue['locations'])); |
|
5491 | + } |
|
5178 | 5492 | |
5179 | - if (isset($priority_zones[$tzkey])) |
|
5180 | - $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5181 | - else |
|
5182 | - $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5493 | + if (isset($priority_zones[$tzkey])) { |
|
5494 | + $priority_timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5495 | + } else { |
|
5496 | + $timezones[$tzvalue['tzid']] = $tzvalue['abbr'] . ' - ' . $desc . ' [UTC' . date_format($date_when, 'P') . ']'; |
|
5497 | + } |
|
5183 | 5498 | } |
5184 | 5499 | |
5185 | 5500 | $timezones = array_merge( |
@@ -5233,9 +5548,9 @@ discard block |
||
5233 | 5548 | 'Indian/Kerguelen' => 'TFT', |
5234 | 5549 | ); |
5235 | 5550 | |
5236 | - if (!empty($missing_tz_abbrs[$tzid])) |
|
5237 | - $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5238 | - else |
|
5551 | + if (!empty($missing_tz_abbrs[$tzid])) { |
|
5552 | + $tz_abbrev = $missing_tz_abbrs[$tzid]; |
|
5553 | + } else |
|
5239 | 5554 | { |
5240 | 5555 | // Russia likes to experiment with time zones often, and names them as offsets from Moscow |
5241 | 5556 | $tz_location = timezone_location_get(timezone_open($tzid)); |
@@ -5263,8 +5578,9 @@ discard block |
||
5263 | 5578 | */ |
5264 | 5579 | function inet_ptod($ip_address) |
5265 | 5580 | { |
5266 | - if (!isValidIP($ip_address)) |
|
5267 | - return $ip_address; |
|
5581 | + if (!isValidIP($ip_address)) { |
|
5582 | + return $ip_address; |
|
5583 | + } |
|
5268 | 5584 | |
5269 | 5585 | $bin = inet_pton($ip_address); |
5270 | 5586 | return $bin; |
@@ -5276,13 +5592,15 @@ discard block |
||
5276 | 5592 | */ |
5277 | 5593 | function inet_dtop($bin) |
5278 | 5594 | { |
5279 | - if(empty($bin)) |
|
5280 | - return ''; |
|
5595 | + if(empty($bin)) { |
|
5596 | + return ''; |
|
5597 | + } |
|
5281 | 5598 | |
5282 | 5599 | global $db_type; |
5283 | 5600 | |
5284 | - if ($db_type == 'postgresql') |
|
5285 | - return $bin; |
|
5601 | + if ($db_type == 'postgresql') { |
|
5602 | + return $bin; |
|
5603 | + } |
|
5286 | 5604 | |
5287 | 5605 | $ip_address = inet_ntop($bin); |
5288 | 5606 | |
@@ -5307,26 +5625,32 @@ discard block |
||
5307 | 5625 | */ |
5308 | 5626 | function _safe_serialize($value) |
5309 | 5627 | { |
5310 | - if(is_null($value)) |
|
5311 | - return 'N;'; |
|
5628 | + if(is_null($value)) { |
|
5629 | + return 'N;'; |
|
5630 | + } |
|
5312 | 5631 | |
5313 | - if(is_bool($value)) |
|
5314 | - return 'b:'. (int) $value .';'; |
|
5632 | + if(is_bool($value)) { |
|
5633 | + return 'b:'. (int) $value .';'; |
|
5634 | + } |
|
5315 | 5635 | |
5316 | - if(is_int($value)) |
|
5317 | - return 'i:'. $value .';'; |
|
5636 | + if(is_int($value)) { |
|
5637 | + return 'i:'. $value .';'; |
|
5638 | + } |
|
5318 | 5639 | |
5319 | - if(is_float($value)) |
|
5320 | - return 'd:'. str_replace(',', '.', $value) .';'; |
|
5640 | + if(is_float($value)) { |
|
5641 | + return 'd:'. str_replace(',', '.', $value) .';'; |
|
5642 | + } |
|
5321 | 5643 | |
5322 | - if(is_string($value)) |
|
5323 | - return 's:'. strlen($value) .':"'. $value .'";'; |
|
5644 | + if(is_string($value)) { |
|
5645 | + return 's:'. strlen($value) .':"'. $value .'";'; |
|
5646 | + } |
|
5324 | 5647 | |
5325 | 5648 | if(is_array($value)) |
5326 | 5649 | { |
5327 | 5650 | $out = ''; |
5328 | - foreach($value as $k => $v) |
|
5329 | - $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5651 | + foreach($value as $k => $v) { |
|
5652 | + $out .= _safe_serialize($k) . _safe_serialize($v); |
|
5653 | + } |
|
5330 | 5654 | |
5331 | 5655 | return 'a:'. count($value) .':{'. $out .'}'; |
5332 | 5656 | } |
@@ -5352,8 +5676,9 @@ discard block |
||
5352 | 5676 | |
5353 | 5677 | $out = _safe_serialize($value); |
5354 | 5678 | |
5355 | - if (isset($mbIntEnc)) |
|
5356 | - mb_internal_encoding($mbIntEnc); |
|
5679 | + if (isset($mbIntEnc)) { |
|
5680 | + mb_internal_encoding($mbIntEnc); |
|
5681 | + } |
|
5357 | 5682 | |
5358 | 5683 | return $out; |
5359 | 5684 | } |
@@ -5370,8 +5695,9 @@ discard block |
||
5370 | 5695 | function _safe_unserialize($str) |
5371 | 5696 | { |
5372 | 5697 | // Input is not a string. |
5373 | - if(empty($str) || !is_string($str)) |
|
5374 | - return false; |
|
5698 | + if(empty($str) || !is_string($str)) { |
|
5699 | + return false; |
|
5700 | + } |
|
5375 | 5701 | |
5376 | 5702 | $stack = array(); |
5377 | 5703 | $expected = array(); |
@@ -5387,43 +5713,38 @@ discard block |
||
5387 | 5713 | while($state != 1) |
5388 | 5714 | { |
5389 | 5715 | $type = isset($str[0]) ? $str[0] : ''; |
5390 | - if($type == '}') |
|
5391 | - $str = substr($str, 1); |
|
5392 | - |
|
5393 | - else if($type == 'N' && $str[1] == ';') |
|
5716 | + if($type == '}') { |
|
5717 | + $str = substr($str, 1); |
|
5718 | + } else if($type == 'N' && $str[1] == ';') |
|
5394 | 5719 | { |
5395 | 5720 | $value = null; |
5396 | 5721 | $str = substr($str, 2); |
5397 | - } |
|
5398 | - else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5722 | + } else if($type == 'b' && preg_match('/^b:([01]);/', $str, $matches)) |
|
5399 | 5723 | { |
5400 | 5724 | $value = $matches[1] == '1' ? true : false; |
5401 | 5725 | $str = substr($str, 4); |
5402 | - } |
|
5403 | - else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5726 | + } else if($type == 'i' && preg_match('/^i:(-?[0-9]+);(.*)/s', $str, $matches)) |
|
5404 | 5727 | { |
5405 | 5728 | $value = (int)$matches[1]; |
5406 | 5729 | $str = $matches[2]; |
5407 | - } |
|
5408 | - else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5730 | + } else if($type == 'd' && preg_match('/^d:(-?[0-9]+\.?[0-9]*(E[+-][0-9]+)?);(.*)/s', $str, $matches)) |
|
5409 | 5731 | { |
5410 | 5732 | $value = (float)$matches[1]; |
5411 | 5733 | $str = $matches[3]; |
5412 | - } |
|
5413 | - else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5734 | + } else if($type == 's' && preg_match('/^s:([0-9]+):"(.*)/s', $str, $matches) && substr($matches[2], (int)$matches[1], 2) == '";') |
|
5414 | 5735 | { |
5415 | 5736 | $value = substr($matches[2], 0, (int)$matches[1]); |
5416 | 5737 | $str = substr($matches[2], (int)$matches[1] + 2); |
5417 | - } |
|
5418 | - else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5738 | + } else if($type == 'a' && preg_match('/^a:([0-9]+):{(.*)/s', $str, $matches)) |
|
5419 | 5739 | { |
5420 | 5740 | $expectedLength = (int)$matches[1]; |
5421 | 5741 | $str = $matches[2]; |
5422 | 5742 | } |
5423 | 5743 | |
5424 | 5744 | // Object or unknown/malformed type. |
5425 | - else |
|
5426 | - return false; |
|
5745 | + else { |
|
5746 | + return false; |
|
5747 | + } |
|
5427 | 5748 | |
5428 | 5749 | switch($state) |
5429 | 5750 | { |
@@ -5451,8 +5772,9 @@ discard block |
||
5451 | 5772 | if($type == '}') |
5452 | 5773 | { |
5453 | 5774 | // Array size is less than expected. |
5454 | - if(count($list) < end($expected)) |
|
5455 | - return false; |
|
5775 | + if(count($list) < end($expected)) { |
|
5776 | + return false; |
|
5777 | + } |
|
5456 | 5778 | |
5457 | 5779 | unset($list); |
5458 | 5780 | $list = &$stack[count($stack)-1]; |
@@ -5461,8 +5783,9 @@ discard block |
||
5461 | 5783 | // Go to terminal state if we're at the end of the root array. |
5462 | 5784 | array_pop($expected); |
5463 | 5785 | |
5464 | - if(count($expected) == 0) |
|
5465 | - $state = 1; |
|
5786 | + if(count($expected) == 0) { |
|
5787 | + $state = 1; |
|
5788 | + } |
|
5466 | 5789 | |
5467 | 5790 | break; |
5468 | 5791 | } |
@@ -5470,8 +5793,9 @@ discard block |
||
5470 | 5793 | if($type == 'i' || $type == 's') |
5471 | 5794 | { |
5472 | 5795 | // Array size exceeds expected length. |
5473 | - if(count($list) >= end($expected)) |
|
5474 | - return false; |
|
5796 | + if(count($list) >= end($expected)) { |
|
5797 | + return false; |
|
5798 | + } |
|
5475 | 5799 | |
5476 | 5800 | $key = $value; |
5477 | 5801 | $state = 3; |
@@ -5505,8 +5829,9 @@ discard block |
||
5505 | 5829 | } |
5506 | 5830 | |
5507 | 5831 | // Trailing data in input. |
5508 | - if(!empty($str)) |
|
5509 | - return false; |
|
5832 | + if(!empty($str)) { |
|
5833 | + return false; |
|
5834 | + } |
|
5510 | 5835 | |
5511 | 5836 | return $data; |
5512 | 5837 | } |
@@ -5529,8 +5854,9 @@ discard block |
||
5529 | 5854 | |
5530 | 5855 | $out = _safe_unserialize($str); |
5531 | 5856 | |
5532 | - if (isset($mbIntEnc)) |
|
5533 | - mb_internal_encoding($mbIntEnc); |
|
5857 | + if (isset($mbIntEnc)) { |
|
5858 | + mb_internal_encoding($mbIntEnc); |
|
5859 | + } |
|
5534 | 5860 | |
5535 | 5861 | return $out; |
5536 | 5862 | } |
@@ -5545,12 +5871,14 @@ discard block |
||
5545 | 5871 | function smf_chmod($file, $value = 0) |
5546 | 5872 | { |
5547 | 5873 | // No file? no checks! |
5548 | - if (empty($file)) |
|
5549 | - return false; |
|
5874 | + if (empty($file)) { |
|
5875 | + return false; |
|
5876 | + } |
|
5550 | 5877 | |
5551 | 5878 | // Already writable? |
5552 | - if (is_writable($file)) |
|
5553 | - return true; |
|
5879 | + if (is_writable($file)) { |
|
5880 | + return true; |
|
5881 | + } |
|
5554 | 5882 | |
5555 | 5883 | // Do we have a file or a dir? |
5556 | 5884 | $isDir = is_dir($file); |
@@ -5566,10 +5894,9 @@ discard block |
||
5566 | 5894 | { |
5567 | 5895 | $isWritable = true; |
5568 | 5896 | break; |
5897 | + } else { |
|
5898 | + @chmod($file, $val); |
|
5569 | 5899 | } |
5570 | - |
|
5571 | - else |
|
5572 | - @chmod($file, $val); |
|
5573 | 5900 | } |
5574 | 5901 | |
5575 | 5902 | return $isWritable; |
@@ -5588,8 +5915,9 @@ discard block |
||
5588 | 5915 | global $txt; |
5589 | 5916 | |
5590 | 5917 | // Come on... |
5591 | - if (empty($json) || !is_string($json)) |
|
5592 | - return array(); |
|
5918 | + if (empty($json) || !is_string($json)) { |
|
5919 | + return array(); |
|
5920 | + } |
|
5593 | 5921 | |
5594 | 5922 | $returnArray = @json_decode($json, $returnAsArray); |
5595 | 5923 | |
@@ -5627,11 +5955,11 @@ discard block |
||
5627 | 5955 | $jsonDebug = $jsonDebug[0]; |
5628 | 5956 | loadLanguage('Errors'); |
5629 | 5957 | |
5630 | - if (!empty($jsonDebug)) |
|
5631 | - log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5632 | - |
|
5633 | - else |
|
5634 | - log_error($txt['json_'. $jsonError], 'critical'); |
|
5958 | + if (!empty($jsonDebug)) { |
|
5959 | + log_error($txt['json_'. $jsonError], 'critical', $jsonDebug['file'], $jsonDebug['line']); |
|
5960 | + } else { |
|
5961 | + log_error($txt['json_'. $jsonError], 'critical'); |
|
5962 | + } |
|
5635 | 5963 | |
5636 | 5964 | // Everyone expects an array. |
5637 | 5965 | return array(); |
@@ -5665,8 +5993,9 @@ discard block |
||
5665 | 5993 | global $db_show_debug, $modSettings; |
5666 | 5994 | |
5667 | 5995 | // Defensive programming anyone? |
5668 | - if (empty($data)) |
|
5669 | - return false; |
|
5996 | + if (empty($data)) { |
|
5997 | + return false; |
|
5998 | + } |
|
5670 | 5999 | |
5671 | 6000 | // Don't need extra stuff... |
5672 | 6001 | $db_show_debug = false; |
@@ -5674,11 +6003,11 @@ discard block |
||
5674 | 6003 | // Kill anything else. |
5675 | 6004 | ob_end_clean(); |
5676 | 6005 | |
5677 | - if (!empty($modSettings['CompressedOutput'])) |
|
5678 | - @ob_start('ob_gzhandler'); |
|
5679 | - |
|
5680 | - else |
|
5681 | - ob_start(); |
|
6006 | + if (!empty($modSettings['CompressedOutput'])) { |
|
6007 | + @ob_start('ob_gzhandler'); |
|
6008 | + } else { |
|
6009 | + ob_start(); |
|
6010 | + } |
|
5682 | 6011 | |
5683 | 6012 | // Set the header. |
5684 | 6013 | header($type); |
@@ -5710,8 +6039,9 @@ discard block |
||
5710 | 6039 | static $done = false; |
5711 | 6040 | |
5712 | 6041 | // If we don't need to do anything, don't |
5713 | - if (!$update && $done) |
|
5714 | - return; |
|
6042 | + if (!$update && $done) { |
|
6043 | + return; |
|
6044 | + } |
|
5715 | 6045 | |
5716 | 6046 | // Should we get a new copy of the official list of TLDs? |
5717 | 6047 | if ($update) |
@@ -5720,8 +6050,9 @@ discard block |
||
5720 | 6050 | $tlds = fetch_web_data('https://data.iana.org/TLD/tlds-alpha-by-domain.txt'); |
5721 | 6051 | |
5722 | 6052 | // If the Internet Assigned Numbers Authority can't be reached, the Internet is gone. We're probably running on a server hidden in a bunker deep underground to protect it from marauding bandits roaming on the surface. We don't want to waste precious electricity on pointlessly repeating background tasks, so we'll wait until the next regularly scheduled update to see if civilization has been restored. |
5723 | - if ($tlds === false) |
|
5724 | - $postapocalypticNightmare = true; |
|
6053 | + if ($tlds === false) { |
|
6054 | + $postapocalypticNightmare = true; |
|
6055 | + } |
|
5725 | 6056 | } |
5726 | 6057 | // If we aren't updating and the regex is valid, we're done |
5727 | 6058 | elseif (!empty($modSettings['tld_regex']) && @preg_match('~' . $modSettings['tld_regex'] . '~', null) !== false) |
@@ -5736,10 +6067,11 @@ discard block |
||
5736 | 6067 | // Clean $tlds and convert it to an array |
5737 | 6068 | $tlds = array_filter(explode("\n", strtolower($tlds)), function($line) { |
5738 | 6069 | $line = trim($line); |
5739 | - if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) |
|
5740 | - return false; |
|
5741 | - else |
|
5742 | - return true; |
|
6070 | + if (empty($line) || strpos($line, '#') !== false || strpos($line, ' ') !== false) { |
|
6071 | + return false; |
|
6072 | + } else { |
|
6073 | + return true; |
|
6074 | + } |
|
5743 | 6075 | }); |
5744 | 6076 | |
5745 | 6077 | // Convert Punycode to Unicode |
@@ -5793,8 +6125,9 @@ discard block |
||
5793 | 6125 | $idx += $digit * $w; |
5794 | 6126 | $t = ($k <= $bias) ? $tmin : (($k >= $bias + $tmax) ? $tmax : ($k - $bias)); |
5795 | 6127 | |
5796 | - if ($digit < $t) |
|
5797 | - break; |
|
6128 | + if ($digit < $t) { |
|
6129 | + break; |
|
6130 | + } |
|
5798 | 6131 | |
5799 | 6132 | $w = (int) ($w * ($base - $t)); |
5800 | 6133 | } |
@@ -5803,8 +6136,9 @@ discard block |
||
5803 | 6136 | $delta = intval($is_first ? ($delta / $damp) : ($delta / 2)); |
5804 | 6137 | $delta += intval($delta / ($deco_len + 1)); |
5805 | 6138 | |
5806 | - for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) |
|
5807 | - $delta = intval($delta / ($base - $tmin)); |
|
6139 | + for ($k = 0; $delta > (($base - $tmin) * $tmax) / 2; $k += $base) { |
|
6140 | + $delta = intval($delta / ($base - $tmin)); |
|
6141 | + } |
|
5808 | 6142 | |
5809 | 6143 | $bias = intval($k + ($base - $tmin + 1) * $delta / ($delta + $skew)); |
5810 | 6144 | $is_first = false; |
@@ -5813,8 +6147,9 @@ discard block |
||
5813 | 6147 | |
5814 | 6148 | if ($deco_len > 0) |
5815 | 6149 | { |
5816 | - for ($i = $deco_len; $i > $idx; $i--) |
|
5817 | - $decoded[$i] = $decoded[($i - 1)]; |
|
6150 | + for ($i = $deco_len; $i > $idx; $i--) { |
|
6151 | + $decoded[$i] = $decoded[($i - 1)]; |
|
6152 | + } |
|
5818 | 6153 | } |
5819 | 6154 | $decoded[$idx++] = $char; |
5820 | 6155 | } |
@@ -5822,24 +6157,29 @@ discard block |
||
5822 | 6157 | foreach ($decoded as $k => $v) |
5823 | 6158 | { |
5824 | 6159 | // 7bit are transferred literally |
5825 | - if ($v < 128) |
|
5826 | - $output .= chr($v); |
|
6160 | + if ($v < 128) { |
|
6161 | + $output .= chr($v); |
|
6162 | + } |
|
5827 | 6163 | |
5828 | 6164 | // 2 bytes |
5829 | - elseif ($v < (1 << 11)) |
|
5830 | - $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6165 | + elseif ($v < (1 << 11)) { |
|
6166 | + $output .= chr(192+($v >> 6)) . chr(128+($v & 63)); |
|
6167 | + } |
|
5831 | 6168 | |
5832 | 6169 | // 3 bytes |
5833 | - elseif ($v < (1 << 16)) |
|
5834 | - $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6170 | + elseif ($v < (1 << 16)) { |
|
6171 | + $output .= chr(224+($v >> 12)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6172 | + } |
|
5835 | 6173 | |
5836 | 6174 | // 4 bytes |
5837 | - elseif ($v < (1 << 21)) |
|
5838 | - $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6175 | + elseif ($v < (1 << 21)) { |
|
6176 | + $output .= chr(240+($v >> 18)) . chr(128+(($v >> 12) & 63)) . chr(128+(($v >> 6) & 63)) . chr(128+($v & 63)); |
|
6177 | + } |
|
5839 | 6178 | |
5840 | 6179 | // 'Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k |
5841 | - else |
|
5842 | - $output .= $safe_char; |
|
6180 | + else { |
|
6181 | + $output .= $safe_char; |
|
6182 | + } |
|
5843 | 6183 | } |
5844 | 6184 | |
5845 | 6185 | $output_parts[] = $output; |
@@ -5932,8 +6272,7 @@ discard block |
||
5932 | 6272 | |
5933 | 6273 | $strlen = 'mb_strlen'; |
5934 | 6274 | $substr = 'mb_substr'; |
5935 | - } |
|
5936 | - else |
|
6275 | + } else |
|
5937 | 6276 | { |
5938 | 6277 | $strlen = $smcFunc['strlen']; |
5939 | 6278 | $substr = $smcFunc['substr']; |
@@ -5947,20 +6286,21 @@ discard block |
||
5947 | 6286 | |
5948 | 6287 | $first = $substr($string, 0, 1); |
5949 | 6288 | |
5950 | - if (empty($index[$first])) |
|
5951 | - $index[$first] = array(); |
|
6289 | + if (empty($index[$first])) { |
|
6290 | + $index[$first] = array(); |
|
6291 | + } |
|
5952 | 6292 | |
5953 | 6293 | if ($strlen($string) > 1) |
5954 | 6294 | { |
5955 | 6295 | // Sanity check on recursion |
5956 | - if ($depth > 99) |
|
5957 | - $index[$first][$substr($string, 1)] = ''; |
|
5958 | - |
|
5959 | - else |
|
5960 | - $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6296 | + if ($depth > 99) { |
|
6297 | + $index[$first][$substr($string, 1)] = ''; |
|
6298 | + } else { |
|
6299 | + $index[$first] = $add_string_to_index($substr($string, 1), $index[$first]); |
|
6300 | + } |
|
6301 | + } else { |
|
6302 | + $index[$first][''] = ''; |
|
5961 | 6303 | } |
5962 | - else |
|
5963 | - $index[$first][''] = ''; |
|
5964 | 6304 | |
5965 | 6305 | $depth--; |
5966 | 6306 | return $index; |
@@ -5983,9 +6323,9 @@ discard block |
||
5983 | 6323 | $key_regex = preg_quote($key, $delim); |
5984 | 6324 | $new_key = $key; |
5985 | 6325 | |
5986 | - if (empty($value)) |
|
5987 | - $sub_regex = ''; |
|
5988 | - else |
|
6326 | + if (empty($value)) { |
|
6327 | + $sub_regex = ''; |
|
6328 | + } else |
|
5989 | 6329 | { |
5990 | 6330 | $sub_regex = $index_to_regex($value, $delim); |
5991 | 6331 | |
@@ -5993,22 +6333,22 @@ discard block |
||
5993 | 6333 | { |
5994 | 6334 | $new_key_array = explode('(?'.'>', $sub_regex); |
5995 | 6335 | $new_key .= $new_key_array[0]; |
6336 | + } else { |
|
6337 | + $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5996 | 6338 | } |
5997 | - else |
|
5998 | - $sub_regex = '(?'.'>' . $sub_regex . ')'; |
|
5999 | 6339 | } |
6000 | 6340 | |
6001 | - if ($depth > 1) |
|
6002 | - $regex[$new_key] = $key_regex . $sub_regex; |
|
6003 | - else |
|
6341 | + if ($depth > 1) { |
|
6342 | + $regex[$new_key] = $key_regex . $sub_regex; |
|
6343 | + } else |
|
6004 | 6344 | { |
6005 | 6345 | if (($length += strlen($key_regex) + 1) < $max_length || empty($regex)) |
6006 | 6346 | { |
6007 | 6347 | $regex[$new_key] = $key_regex . $sub_regex; |
6008 | 6348 | unset($index[$key]); |
6349 | + } else { |
|
6350 | + break; |
|
6009 | 6351 | } |
6010 | - else |
|
6011 | - break; |
|
6012 | 6352 | } |
6013 | 6353 | } |
6014 | 6354 | |
@@ -6017,10 +6357,11 @@ discard block |
||
6017 | 6357 | $l1 = $strlen($k1); |
6018 | 6358 | $l2 = $strlen($k2); |
6019 | 6359 | |
6020 | - if ($l1 == $l2) |
|
6021 | - return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6022 | - else |
|
6023 | - return $l1 > $l2 ? -1 : 1; |
|
6360 | + if ($l1 == $l2) { |
|
6361 | + return strcmp($k1, $k2) > 0 ? 1 : -1; |
|
6362 | + } else { |
|
6363 | + return $l1 > $l2 ? -1 : 1; |
|
6364 | + } |
|
6024 | 6365 | }); |
6025 | 6366 | |
6026 | 6367 | $depth--; |
@@ -6031,21 +6372,24 @@ discard block |
||
6031 | 6372 | $index = array(); |
6032 | 6373 | $regex = ''; |
6033 | 6374 | |
6034 | - foreach ($strings as $string) |
|
6035 | - $index = $add_string_to_index($string, $index); |
|
6375 | + foreach ($strings as $string) { |
|
6376 | + $index = $add_string_to_index($string, $index); |
|
6377 | + } |
|
6036 | 6378 | |
6037 | 6379 | if ($returnArray === true) |
6038 | 6380 | { |
6039 | 6381 | $regex = array(); |
6040 | - while (!empty($index)) |
|
6041 | - $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6382 | + while (!empty($index)) { |
|
6383 | + $regex[] = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6384 | + } |
|
6385 | + } else { |
|
6386 | + $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6042 | 6387 | } |
6043 | - else |
|
6044 | - $regex = '(?'.'>' . $index_to_regex($index, $delim) . ')'; |
|
6045 | 6388 | |
6046 | 6389 | // Restore PHP's internal character encoding to whatever it was originally |
6047 | - if (!empty($current_encoding)) |
|
6048 | - mb_internal_encoding($current_encoding); |
|
6390 | + if (!empty($current_encoding)) { |
|
6391 | + mb_internal_encoding($current_encoding); |
|
6392 | + } |
|
6049 | 6393 | |
6050 | 6394 | return $regex; |
6051 | 6395 | } |
@@ -6088,13 +6432,15 @@ discard block |
||
6088 | 6432 | // Need to add the trailing slash, or it puts it there & thinks there's a redirect when there isn't... |
6089 | 6433 | $url = str_ireplace('https://', 'http://', $url) . '/'; |
6090 | 6434 | $headers = @get_headers($url); |
6091 | - if ($headers === false) |
|
6092 | - return false; |
|
6435 | + if ($headers === false) { |
|
6436 | + return false; |
|
6437 | + } |
|
6093 | 6438 | |
6094 | 6439 | // Now to see if it came back https... |
6095 | 6440 | // First check for a redirect status code in first row (301, 302, 307) |
6096 | - if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) |
|
6097 | - return false; |
|
6441 | + if (strstr($headers[0], '301') === false && strstr($headers[0], '302') === false && strstr($headers[0], '307') === false) { |
|
6442 | + return false; |
|
6443 | + } |
|
6098 | 6444 | |
6099 | 6445 | // Search for the location entry to confirm https |
6100 | 6446 | $result = false; |
@@ -6130,8 +6476,7 @@ discard block |
||
6130 | 6476 | $is_admin = $user_info['is_admin']; |
6131 | 6477 | $mod_cache = !empty($user_info['mod_cache']) ? $user_info['mod_cache'] : null; |
6132 | 6478 | $ignoreboards = !empty($user_info['ignoreboards']) ? $user_info['ignoreboards'] : null; |
6133 | - } |
|
6134 | - else |
|
6479 | + } else |
|
6135 | 6480 | { |
6136 | 6481 | $request = $smcFunc['db_query']('', ' |
6137 | 6482 | SELECT mem.ignore_boards, mem.id_group, mem.additional_groups, mem.id_post_group |
@@ -6145,17 +6490,19 @@ discard block |
||
6145 | 6490 | |
6146 | 6491 | $row = $smcFunc['db_fetch_assoc']($request); |
6147 | 6492 | |
6148 | - if (empty($row['additional_groups'])) |
|
6149 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
6150 | - else |
|
6151 | - $groups = array_merge( |
|
6493 | + if (empty($row['additional_groups'])) { |
|
6494 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
6495 | + } else { |
|
6496 | + $groups = array_merge( |
|
6152 | 6497 | array($row['id_group'], $row['id_post_group']), |
6153 | 6498 | explode(',', $row['additional_groups']) |
6154 | 6499 | ); |
6500 | + } |
|
6155 | 6501 | |
6156 | 6502 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
6157 | - foreach ($groups as $k => $v) |
|
6158 | - $groups[$k] = (int) $v; |
|
6503 | + foreach ($groups as $k => $v) { |
|
6504 | + $groups[$k] = (int) $v; |
|
6505 | + } |
|
6159 | 6506 | |
6160 | 6507 | $is_admin = in_array(1, $groups); |
6161 | 6508 | |
@@ -6172,8 +6519,9 @@ discard block |
||
6172 | 6519 | 'current_member' => $userid, |
6173 | 6520 | ) |
6174 | 6521 | ); |
6175 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6176 | - $boards_mod[] = $row['id_board']; |
|
6522 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6523 | + $boards_mod[] = $row['id_board']; |
|
6524 | + } |
|
6177 | 6525 | $smcFunc['db_free_result']($request); |
6178 | 6526 | |
6179 | 6527 | // Can any of the groups they're in moderate any of the boards? |
@@ -6185,8 +6533,9 @@ discard block |
||
6185 | 6533 | 'groups' => $groups, |
6186 | 6534 | ) |
6187 | 6535 | ); |
6188 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
6189 | - $boards_mod[] = $row['id_board']; |
|
6536 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
6537 | + $boards_mod[] = $row['id_board']; |
|
6538 | + } |
|
6190 | 6539 | $smcFunc['db_free_result']($request); |
6191 | 6540 | |
6192 | 6541 | // Just in case we've got duplicates here... |
@@ -6196,21 +6545,25 @@ discard block |
||
6196 | 6545 | } |
6197 | 6546 | |
6198 | 6547 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
6199 | - if ($is_admin) |
|
6200 | - $query_part['query_see_board'] = '1=1'; |
|
6548 | + if ($is_admin) { |
|
6549 | + $query_part['query_see_board'] = '1=1'; |
|
6550 | + } |
|
6201 | 6551 | // Otherwise just the groups in $user_info['groups']. |
6202 | - else |
|
6203 | - $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'] : '') . ')'; |
|
6552 | + else { |
|
6553 | + $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'] : '') . ')'; |
|
6554 | + } |
|
6204 | 6555 | |
6205 | 6556 | // Build the list of boards they WANT to see. |
6206 | 6557 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
6207 | 6558 | |
6208 | 6559 | // If they aren't ignoring any boards then they want to see all the boards they can see |
6209 | - if (empty($ignoreboards)) |
|
6210 | - $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6560 | + if (empty($ignoreboards)) { |
|
6561 | + $query_part['query_wanna_see_board'] = $query_part['query_see_board']; |
|
6562 | + } |
|
6211 | 6563 | // Ok I guess they don't want to see all the boards |
6212 | - else |
|
6213 | - $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6564 | + else { |
|
6565 | + $query_part['query_wanna_see_board'] = '(' . $query_part['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $ignoreboards) . '))'; |
|
6566 | + } |
|
6214 | 6567 | |
6215 | 6568 | return $query_part; |
6216 | 6569 | } |
@@ -6224,10 +6577,11 @@ discard block |
||
6224 | 6577 | { |
6225 | 6578 | $secure = false; |
6226 | 6579 | |
6227 | - if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') |
|
6228 | - $secure = true; |
|
6229 | - 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') |
|
6230 | - $secure = true; |
|
6580 | + if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { |
|
6581 | + $secure = true; |
|
6582 | + } 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') { |
|
6583 | + $secure = true; |
|
6584 | + } |
|
6231 | 6585 | |
6232 | 6586 | return $secure; |
6233 | 6587 | } |