@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
31 | 32 | global $smcFunc, $modSettings, $txt; |
32 | 33 | |
33 | 34 | // Make sure it's an array. |
34 | - if (!is_array($groups)) |
|
35 | - $groups = array((int) $groups); |
|
36 | - else |
|
35 | + if (!is_array($groups)) { |
|
36 | + $groups = array((int) $groups); |
|
37 | + } else |
|
37 | 38 | { |
38 | 39 | $groups = array_unique($groups); |
39 | 40 | |
40 | 41 | // Make sure all groups are integer. |
41 | - foreach ($groups as $key => $value) |
|
42 | - $groups[$key] = (int) $value; |
|
42 | + foreach ($groups as $key => $value) { |
|
43 | + $groups[$key] = (int) $value; |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
56 | 58 | 'is_protected' => 1, |
57 | 59 | ) |
58 | 60 | ); |
59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
60 | - $protected_groups[] = $row['id_group']; |
|
61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
62 | + $protected_groups[] = $row['id_group']; |
|
63 | + } |
|
61 | 64 | $smcFunc['db_free_result']($request); |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Make sure they don't delete protected groups! |
65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
66 | - if (empty($groups)) |
|
67 | - return 'no_group_found'; |
|
69 | + if (empty($groups)) { |
|
70 | + return 'no_group_found'; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | ORDER BY name'); |
75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
76 | 80 | { |
77 | - if (in_array($row['id_group'], $groups)) |
|
78 | - $subscriptions[] = $row['name']; |
|
79 | - else |
|
81 | + if (in_array($row['id_group'], $groups)) { |
|
82 | + $subscriptions[] = $row['name']; |
|
83 | + } else |
|
80 | 84 | { |
81 | 85 | $add_groups = explode(',', $row['add_groups']); |
82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
83 | - $subscriptions[] = $row['name']; |
|
86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
87 | + $subscriptions[] = $row['name']; |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
101 | 106 | 'group_list' => $groups, |
102 | 107 | ) |
103 | 108 | ); |
104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
111 | + } |
|
106 | 112 | $smcFunc['db_free_result']($request); |
107 | 113 | |
108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
187 | 193 | ) |
188 | 194 | ); |
189 | 195 | $updates = array(); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
198 | + } |
|
192 | 199 | $smcFunc['db_free_result']($request); |
193 | 200 | |
194 | - foreach ($updates as $additional_groups => $memberArray) |
|
195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // No boards can provide access to these membergroups anymore. |
198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
204 | 212 | ) |
205 | 213 | ); |
206 | 214 | $updates = array(); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
217 | + } |
|
209 | 218 | $smcFunc['db_free_result']($request); |
210 | 219 | |
211 | - foreach ($updates as $member_groups => $boardArray) |
|
212 | - $smcFunc['db_query']('', ' |
|
220 | + foreach ($updates as $member_groups => $boardArray) { |
|
221 | + $smcFunc['db_query']('', ' |
|
213 | 222 | UPDATE {db_prefix}boards |
214 | 223 | SET member_groups = {string:member_groups} |
215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
219 | 228 | ) |
220 | 229 | ); |
230 | + } |
|
221 | 231 | |
222 | 232 | // Recalculate the post groups, as they likely changed. |
223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
225 | 235 | // Make a note of the fact that the cache may be wrong. |
226 | 236 | $settings_update = array('settings_updated' => time()); |
227 | 237 | // Have we deleted the spider group? |
228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
229 | - $settings_update['spider_group'] = 0; |
|
238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
239 | + $settings_update['spider_group'] = 0; |
|
240 | + } |
|
230 | 241 | |
231 | 242 | updateSettings($settings_update); |
232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
251 | 262 | |
252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
253 | - if (!$permissionCheckDone) |
|
254 | - isAllowedTo('manage_membergroups'); |
|
264 | + if (!$permissionCheckDone) { |
|
265 | + isAllowedTo('manage_membergroups'); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Assume something will happen. |
257 | 269 | updateSettings(array('settings_updated' => time())); |
258 | 270 | |
259 | 271 | // Cleaning the input. |
260 | - if (!is_array($members)) |
|
261 | - $members = array((int) $members); |
|
262 | - else |
|
272 | + if (!is_array($members)) { |
|
273 | + $members = array((int) $members); |
|
274 | + } else |
|
263 | 275 | { |
264 | 276 | $members = array_unique($members); |
265 | 277 | |
266 | 278 | // Cast the members to integer. |
267 | - foreach ($members as $key => $value) |
|
268 | - $members[$key] = (int) $value; |
|
279 | + foreach ($members as $key => $value) { |
|
280 | + $members[$key] = (int) $value; |
|
281 | + } |
|
269 | 282 | } |
270 | 283 | |
271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
277 | 290 | // Remove any admins if there are too many. |
278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
279 | 292 | |
280 | - if (empty($non_changing_admins)) |
|
281 | - $members = array_diff($members, array_keys($admins)); |
|
293 | + if (empty($non_changing_admins)) { |
|
294 | + $members = array_diff($members, array_keys($admins)); |
|
295 | + } |
|
282 | 296 | } |
283 | 297 | |
284 | 298 | // Just in case. |
285 | - if (empty($members)) |
|
286 | - return false; |
|
287 | - elseif ($groups === null) |
|
299 | + if (empty($members)) { |
|
300 | + return false; |
|
301 | + } elseif ($groups === null) |
|
288 | 302 | { |
289 | 303 | // Wanna remove all groups from these members? That's easy. |
290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
306 | 320 | updateStats('postgroups', $members); |
307 | 321 | |
308 | 322 | // Log what just happened. |
309 | - foreach ($members as $member) |
|
310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
323 | + foreach ($members as $member) { |
|
324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
325 | + } |
|
311 | 326 | |
312 | 327 | return true; |
313 | - } |
|
314 | - elseif (!is_array($groups)) |
|
315 | - $groups = array((int) $groups); |
|
316 | - else |
|
328 | + } elseif (!is_array($groups)) { |
|
329 | + $groups = array((int) $groups); |
|
330 | + } else |
|
317 | 331 | { |
318 | 332 | $groups = array_unique($groups); |
319 | 333 | |
320 | 334 | // Make sure all groups are integer. |
321 | - foreach ($groups as $key => $value) |
|
322 | - $groups[$key] = (int) $value; |
|
335 | + foreach ($groups as $key => $value) { |
|
336 | + $groups[$key] = (int) $value; |
|
337 | + } |
|
323 | 338 | } |
324 | 339 | |
325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
335 | 350 | $group_names = array(); |
336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
337 | 352 | { |
338 | - if ($row['min_posts'] != -1) |
|
339 | - $implicitGroups[] = $row['id_group']; |
|
340 | - else |
|
341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
353 | + if ($row['min_posts'] != -1) { |
|
354 | + $implicitGroups[] = $row['id_group']; |
|
355 | + } else { |
|
356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | $smcFunc['db_free_result']($request); |
344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
357 | 373 | ) |
358 | 374 | ); |
359 | 375 | $protected_groups = array(1); |
360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
361 | - $protected_groups[] = $row['id_group']; |
|
376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
377 | + $protected_groups[] = $row['id_group']; |
|
378 | + } |
|
362 | 379 | $smcFunc['db_free_result']($request); |
363 | 380 | |
364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
366 | 383 | } |
367 | 384 | |
368 | 385 | // Only continue if there are still groups and members left. |
369 | - if (empty($groups) || empty($members)) |
|
370 | - return false; |
|
386 | + if (empty($groups) || empty($members)) { |
|
387 | + return false; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
381 | 399 | 'member_list' => $members, |
382 | 400 | ) |
383 | 401 | ); |
384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
404 | + } |
|
386 | 405 | $smcFunc['db_free_result']($request); |
387 | 406 | |
388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
415 | 434 | { |
416 | 435 | // What log entries must we make for this one, eh? |
417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
418 | - if (in_array($group, $groups)) |
|
436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
437 | + if (in_array($group, $groups)) |
|
419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
439 | + } |
|
420 | 440 | |
421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
422 | 442 | } |
423 | 443 | $smcFunc['db_free_result']($request); |
424 | 444 | |
425 | - foreach ($updates as $additional_groups => $memberArray) |
|
426 | - $smcFunc['db_query']('', ' |
|
445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
446 | + $smcFunc['db_query']('', ' |
|
427 | 447 | UPDATE {db_prefix}members |
428 | 448 | SET additional_groups = {string:additional_groups} |
429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
433 | 453 | ) |
434 | 454 | ); |
455 | + } |
|
435 | 456 | |
436 | 457 | // Their post groups may have changed now... |
437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
441 | 462 | { |
442 | 463 | require_once($sourcedir . '/Logging.php'); |
443 | - foreach ($log_inserts as $extra) |
|
444 | - logAction('removed_from_group', $extra, 'admin'); |
|
464 | + foreach ($log_inserts as $extra) { |
|
465 | + logAction('removed_from_group', $extra, 'admin'); |
|
466 | + } |
|
445 | 467 | } |
446 | 468 | |
447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
477 | 499 | global $smcFunc, $sourcedir; |
478 | 500 | |
479 | 501 | // Show your licence, but only if it hasn't been done yet. |
480 | - if (!$permissionCheckDone) |
|
481 | - isAllowedTo('manage_membergroups'); |
|
502 | + if (!$permissionCheckDone) { |
|
503 | + isAllowedTo('manage_membergroups'); |
|
504 | + } |
|
482 | 505 | |
483 | 506 | // Make sure we don't keep old stuff cached. |
484 | 507 | updateSettings(array('settings_updated' => time())); |
485 | 508 | |
486 | - if (!is_array($members)) |
|
487 | - $members = array((int) $members); |
|
488 | - else |
|
509 | + if (!is_array($members)) { |
|
510 | + $members = array((int) $members); |
|
511 | + } else |
|
489 | 512 | { |
490 | 513 | $members = array_unique($members); |
491 | 514 | |
492 | 515 | // Make sure all members are integer. |
493 | - foreach ($members as $key => $value) |
|
494 | - $members[$key] = (int) $value; |
|
516 | + foreach ($members as $key => $value) { |
|
517 | + $members[$key] = (int) $value; |
|
518 | + } |
|
495 | 519 | } |
496 | 520 | $group = (int) $group; |
497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
508 | 532 | $group_names = array(); |
509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
510 | 534 | { |
511 | - if ($row['min_posts'] != -1) |
|
512 | - $implicitGroups[] = $row['id_group']; |
|
513 | - else |
|
514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
535 | + if ($row['min_posts'] != -1) { |
|
536 | + $implicitGroups[] = $row['id_group']; |
|
537 | + } else { |
|
538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
539 | + } |
|
515 | 540 | } |
516 | 541 | $smcFunc['db_free_result']($request); |
517 | 542 | |
518 | 543 | // Sorry, you can't join an implicit group. |
519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
520 | - return false; |
|
544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
545 | + return false; |
|
546 | + } |
|
521 | 547 | |
522 | 548 | // Only admins can add admins... |
523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
524 | - return false; |
|
549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
550 | + return false; |
|
551 | + } |
|
525 | 552 | // ... and assign protected groups! |
526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
539 | 566 | $smcFunc['db_free_result']($request); |
540 | 567 | |
541 | 568 | // Is it protected? |
542 | - if ($is_protected == 1) |
|
543 | - return false; |
|
569 | + if ($is_protected == 1) { |
|
570 | + return false; |
|
571 | + } |
|
544 | 572 | } |
545 | 573 | |
546 | 574 | // Do the actual updates. |
547 | - if ($type == 'only_additional') |
|
548 | - $smcFunc['db_query']('', ' |
|
575 | + if ($type == 'only_additional') { |
|
576 | + $smcFunc['db_query']('', ' |
|
549 | 577 | UPDATE {db_prefix}members |
550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
559 | 587 | 'blank_string' => '', |
560 | 588 | ) |
561 | 589 | ); |
562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
563 | - $smcFunc['db_query']('', ' |
|
590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
591 | + $smcFunc['db_query']('', ' |
|
564 | 592 | UPDATE {db_prefix}members |
565 | 593 | SET id_group = {int:id_group} |
566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
572 | 600 | 'regular_group' => 0, |
573 | 601 | ) |
574 | 602 | ); |
575 | - elseif ($type == 'auto') |
|
576 | - $smcFunc['db_query']('', ' |
|
603 | + } elseif ($type == 'auto') { |
|
604 | + $smcFunc['db_query']('', ' |
|
577 | 605 | UPDATE {db_prefix}members |
578 | 606 | SET |
579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
592 | 620 | 'id_group_string_extend' => ',' . $group, |
593 | 621 | ) |
594 | 622 | ); |
623 | + } |
|
595 | 624 | // Ack!!? What happened? |
596 | - else |
|
597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
625 | + else { |
|
626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
627 | + } |
|
598 | 628 | |
599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
603 | 633 | |
604 | 634 | // Log the data. |
605 | 635 | require_once($sourcedir . '/Logging.php'); |
606 | - foreach ($members as $member) |
|
607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
636 | + foreach ($members as $member) { |
|
637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member' => $member), 'admin'); |
|
638 | + } |
|
608 | 639 | |
609 | 640 | return true; |
610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
632 | 663 | ) |
633 | 664 | ); |
634 | 665 | $members = array(); |
635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
668 | + } |
|
637 | 669 | $smcFunc['db_free_result']($request); |
638 | 670 | |
639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
641 | 673 | { |
642 | 674 | array_pop($members); |
643 | 675 | return true; |
676 | + } else { |
|
677 | + return false; |
|
678 | + } |
|
644 | 679 | } |
645 | - else |
|
646 | - return false; |
|
647 | -} |
|
648 | 680 | |
649 | 681 | /** |
650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
669 | 701 | ) |
670 | 702 | ); |
671 | 703 | $groupCache = array(); |
672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
706 | + } |
|
674 | 707 | $smcFunc['db_free_result']($request); |
675 | 708 | |
676 | 709 | return array( |
@@ -718,8 +751,9 @@ discard block |
||
718 | 751 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
719 | 752 | { |
720 | 753 | // We only list the groups they can see. |
721 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
722 | - continue; |
|
754 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
755 | + continue; |
|
756 | + } |
|
723 | 757 | |
724 | 758 | $row['icons'] = explode('#', $row['icons']); |
725 | 759 | |
@@ -754,12 +788,11 @@ discard block |
||
754 | 788 | 'group_list' => $group_ids, |
755 | 789 | ) |
756 | 790 | ); |
757 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
758 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
791 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
792 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
793 | + } |
|
759 | 794 | $smcFunc['db_free_result']($query); |
760 | - } |
|
761 | - |
|
762 | - else |
|
795 | + } else |
|
763 | 796 | { |
764 | 797 | $query = $smcFunc['db_query']('', ' |
765 | 798 | SELECT id_group, COUNT(*) AS num_members |
@@ -770,8 +803,9 @@ discard block |
||
770 | 803 | 'group_list' => $group_ids, |
771 | 804 | ) |
772 | 805 | ); |
773 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
774 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
806 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
807 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
808 | + } |
|
775 | 809 | $smcFunc['db_free_result']($query); |
776 | 810 | |
777 | 811 | // Only do additional groups if we can moderate... |
@@ -790,8 +824,9 @@ discard block |
||
790 | 824 | 'blank_string' => '', |
791 | 825 | ) |
792 | 826 | ); |
793 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
794 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
827 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
828 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
829 | + } |
|
795 | 830 | $smcFunc['db_free_result']($query); |
796 | 831 | } |
797 | 832 | } |
@@ -805,8 +840,9 @@ discard block |
||
805 | 840 | 'group_list' => $group_ids, |
806 | 841 | ) |
807 | 842 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
809 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
843 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
844 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
845 | + } |
|
810 | 846 | $smcFunc['db_free_result']($query); |
811 | 847 | } |
812 | 848 | |
@@ -815,8 +851,9 @@ discard block |
||
815 | 851 | { |
816 | 852 | $sort_ascending = strpos($sort, 'DESC') === false; |
817 | 853 | |
818 | - foreach ($groups as $group) |
|
819 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
854 | + foreach ($groups as $group) { |
|
855 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
856 | + } |
|
820 | 857 | |
821 | 858 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
822 | 859 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Redirect to the user help ;). |
@@ -95,12 +96,13 @@ discard block |
||
95 | 96 | ); |
96 | 97 | |
97 | 98 | // Have we got a localized one? |
98 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
99 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
100 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
101 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
102 | - else |
|
103 | - $context['agreement'] = ''; |
|
99 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
100 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
101 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
102 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
103 | + } else { |
|
104 | + $context['agreement'] = ''; |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Nothing to show, so let's get out of here |
106 | 108 | if (empty($context['agreement'])) |
@@ -128,18 +130,21 @@ discard block |
||
128 | 130 | { |
129 | 131 | global $txt, $helptxt, $context, $scripturl; |
130 | 132 | |
131 | - if (!isset($_GET['help']) || !is_string($_GET['help'])) |
|
132 | - fatal_lang_error('no_access', false); |
|
133 | + if (!isset($_GET['help']) || !is_string($_GET['help'])) { |
|
134 | + fatal_lang_error('no_access', false); |
|
135 | + } |
|
133 | 136 | |
134 | - if (!isset($helptxt)) |
|
135 | - $helptxt = array(); |
|
137 | + if (!isset($helptxt)) { |
|
138 | + $helptxt = array(); |
|
139 | + } |
|
136 | 140 | |
137 | 141 | // Load the admin help language file and template. |
138 | 142 | loadLanguage('Help'); |
139 | 143 | |
140 | 144 | // Permission specific help? |
141 | - if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') |
|
142 | - loadLanguage('ManagePermissions'); |
|
145 | + if (isset($_GET['help']) && substr($_GET['help'], 0, 14) == 'permissionhelp') { |
|
146 | + loadLanguage('ManagePermissions'); |
|
147 | + } |
|
143 | 148 | |
144 | 149 | loadTemplate('Help'); |
145 | 150 | |
@@ -154,16 +159,18 @@ discard block |
||
154 | 159 | $context['sub_template'] = 'popup'; |
155 | 160 | |
156 | 161 | // What help string should be used? |
157 | - if (isset($helptxt[$_GET['help']])) |
|
158 | - $context['help_text'] = $helptxt[$_GET['help']]; |
|
159 | - elseif (isset($txt[$_GET['help']])) |
|
160 | - $context['help_text'] = $txt[$_GET['help']]; |
|
161 | - else |
|
162 | - $context['help_text'] = $_GET['help']; |
|
162 | + if (isset($helptxt[$_GET['help']])) { |
|
163 | + $context['help_text'] = $helptxt[$_GET['help']]; |
|
164 | + } elseif (isset($txt[$_GET['help']])) { |
|
165 | + $context['help_text'] = $txt[$_GET['help']]; |
|
166 | + } else { |
|
167 | + $context['help_text'] = $_GET['help']; |
|
168 | + } |
|
163 | 169 | |
164 | 170 | // Does this text contain a link that we should fill in? |
165 | - if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) |
|
166 | - $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
167 | -} |
|
171 | + if (preg_match('~%([0-9]+\$)?s\?~', $context['help_text'], $match)) { |
|
172 | + $context['help_text'] = sprintf($context['help_text'], $scripturl, $context['session_id'], $context['session_var']); |
|
173 | + } |
|
174 | + } |
|
168 | 175 | |
169 | 176 | ?> |
170 | 177 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,41 +116,45 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
117 | 124 | // We'll need the ID as well... |
118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
119 | 126 | // Does it have a custom URL? |
120 | - if (isset($area['custom_url'])) |
|
121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
127 | + if (isset($area['custom_url'])) { |
|
128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
129 | + } |
|
122 | 130 | |
123 | 131 | // Does this area have its own icon? |
124 | - if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
|
125 | - $menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9')); |
|
126 | - elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
|
127 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
128 | - elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
129 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
130 | - elseif (isset($area['icon'])) |
|
131 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
132 | - else |
|
133 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
134 | - |
|
135 | - if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
|
136 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
137 | - elseif (isset($area['icon'])) |
|
132 | + if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') { |
|
133 | + $menu_context['sections'][$section_id]['areas'][$area_id] = safe_unserialize(base64_decode('YTozOntzOjU6ImxhYmVsIjtzOjEyOiJPb21wYSBMb29tcGEiO3M6MzoidXJsIjtzOjQzOiJodHRwOi8vZW4ud2lraXBlZGlhLm9yZy93aWtpL09vbXBhX0xvb21wYXM/IjtzOjQ6Imljb24iO3M6ODY6IjxpbWcgc3JjPSJodHRwOi8vd3d3LnNpbXBsZW1hY2hpbmVzLm9yZy9pbWFnZXMvb29tcGEuZ2lmIiBhbHQ9IkknbSBhbiBPb21wYSBMb29tcGEiIC8+Ijt9')); |
|
134 | + } elseif (isset($area['icon']) && file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
135 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
136 | + } elseif (isset($area['icon']) && file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) { |
|
137 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
|
138 | + } elseif (isset($area['icon'])) { |
|
139 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
140 | + } else { |
|
141 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
142 | + } |
|
143 | + |
|
144 | + if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) { |
|
145 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
|
146 | + } elseif (isset($area['icon'])) |
|
138 | 147 | { |
139 | - if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
140 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
141 | - elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
148 | + if ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
149 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
|
150 | + } elseif ((substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') && file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) { |
|
151 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
|
152 | + } |
|
143 | 153 | |
144 | 154 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
155 | + } else { |
|
156 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
145 | 157 | } |
146 | - else |
|
147 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
148 | 158 | |
149 | 159 | // Some areas may be listed but not active, which we show as greyed out. |
150 | 160 | $menu_context['sections'][$section_id]['areas'][$area_id]['inactive'] = !empty($area['inactive']); |
@@ -158,35 +168,41 @@ discard block |
||
158 | 168 | { |
159 | 169 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
160 | 170 | { |
161 | - if ($first_sa == null) |
|
162 | - $first_sa = $sa; |
|
171 | + if ($first_sa == null) { |
|
172 | + $first_sa = $sa; |
|
173 | + } |
|
163 | 174 | |
164 | 175 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
165 | 176 | // Custom URL? |
166 | - if (isset($sub['url'])) |
|
167 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
177 | + if (isset($sub['url'])) { |
|
178 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
179 | + } |
|
168 | 180 | |
169 | 181 | // A bit complicated - but is this set? |
170 | 182 | if ($menu_context['current_area'] == $area_id) |
171 | 183 | { |
172 | 184 | // Save which is the first... |
173 | - if (empty($first_sa)) |
|
174 | - $first_sa = $sa; |
|
185 | + if (empty($first_sa)) { |
|
186 | + $first_sa = $sa; |
|
187 | + } |
|
175 | 188 | |
176 | 189 | // Is this the current subsection? |
177 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
178 | - $menu_context['current_subsection'] = $sa; |
|
190 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
191 | + $menu_context['current_subsection'] = $sa; |
|
192 | + } |
|
179 | 193 | // Otherwise is it the default? |
180 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
181 | - $menu_context['current_subsection'] = $sa; |
|
194 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
195 | + $menu_context['current_subsection'] = $sa; |
|
196 | + } |
|
182 | 197 | } |
183 | 198 | |
184 | 199 | // Let's assume this is the last, for now. |
185 | 200 | $last_sa = $sa; |
186 | 201 | } |
187 | 202 | // Mark it as disabled... |
188 | - else |
|
189 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
203 | + else { |
|
204 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
205 | + } |
|
190 | 206 | } |
191 | 207 | |
192 | 208 | // Set which one is first, last and selected in the group. |
@@ -195,8 +211,9 @@ discard block |
||
195 | 211 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
196 | 212 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
197 | 213 | |
198 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
199 | - $menu_context['current_subsection'] = $first_sa; |
|
214 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
215 | + $menu_context['current_subsection'] = $first_sa; |
|
216 | + } |
|
200 | 217 | } |
201 | 218 | } |
202 | 219 | } |
@@ -230,23 +247,26 @@ discard block |
||
230 | 247 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
231 | 248 | |
232 | 249 | // If we didn't find the area we were looking for go to a default one. |
233 | - if (isset($backup_area) && empty($found_section)) |
|
234 | - $menu_context['current_area'] = $backup_area; |
|
250 | + if (isset($backup_area) && empty($found_section)) { |
|
251 | + $menu_context['current_area'] = $backup_area; |
|
252 | + } |
|
235 | 253 | |
236 | 254 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
237 | 255 | if (!empty($menu_context['current_section'])) |
238 | 256 | { |
239 | 257 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
240 | 258 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
241 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
242 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
259 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
260 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
261 | + } |
|
243 | 262 | |
244 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
245 | - foreach ($section['areas'] as $area_id => $area) |
|
263 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
264 | + foreach ($section['areas'] as $area_id => $area) |
|
246 | 265 | { |
247 | 266 | if (!isset($menu_context['sections'][$section_id]['url'])) |
248 | 267 | { |
249 | 268 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
269 | + } |
|
250 | 270 | break; |
251 | 271 | } |
252 | 272 | } |
@@ -257,8 +277,9 @@ discard block |
||
257 | 277 | { |
258 | 278 | // Never happened! |
259 | 279 | $context['max_menu_id']--; |
260 | - if ($context['max_menu_id'] == 0) |
|
261 | - unset($context['max_menu_id']); |
|
280 | + if ($context['max_menu_id'] == 0) { |
|
281 | + unset($context['max_menu_id']); |
|
282 | + } |
|
262 | 283 | |
263 | 284 | return false; |
264 | 285 | } |
@@ -269,8 +290,9 @@ discard block |
||
269 | 290 | $context['template_layers'][] = $menu_context['layer_name']; |
270 | 291 | |
271 | 292 | // Check we had something - for sanity sake. |
272 | - if (empty($include_data)) |
|
273 | - return false; |
|
293 | + if (empty($include_data)) { |
|
294 | + return false; |
|
295 | + } |
|
274 | 296 | |
275 | 297 | // Finally - return information on the selected item. |
276 | 298 | $include_data += array( |
@@ -293,12 +315,14 @@ discard block |
||
293 | 315 | global $context; |
294 | 316 | |
295 | 317 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
296 | - if (!isset($context[$menu_name])) |
|
297 | - return false; |
|
318 | + if (!isset($context[$menu_name])) { |
|
319 | + return false; |
|
320 | + } |
|
298 | 321 | |
299 | 322 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
300 | - if ($layer_index !== false) |
|
301 | - unset($context['template_layers'][$layer_index]); |
|
323 | + if ($layer_index !== false) { |
|
324 | + unset($context['template_layers'][$layer_index]); |
|
325 | + } |
|
302 | 326 | |
303 | 327 | unset($context[$menu_name]); |
304 | 328 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main entrance point for the Manage Members screen. |
@@ -62,16 +63,18 @@ discard block |
||
62 | 63 | $context['activation_numbers'] = array(); |
63 | 64 | $context['awaiting_activation'] = 0; |
64 | 65 | $context['awaiting_approval'] = 0; |
65 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
66 | - $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
66 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
67 | + $context['activation_numbers'][$row['is_activated']] = $row['total_members']; |
|
68 | + } |
|
67 | 69 | $smcFunc['db_free_result']($request); |
68 | 70 | |
69 | 71 | foreach ($context['activation_numbers'] as $activation_type => $total_members) |
70 | 72 | { |
71 | - if (in_array($activation_type, array(0, 2))) |
|
72 | - $context['awaiting_activation'] += $total_members; |
|
73 | - elseif (in_array($activation_type, array(3, 4, 5))) |
|
74 | - $context['awaiting_approval'] += $total_members; |
|
73 | + if (in_array($activation_type, array(0, 2))) { |
|
74 | + $context['awaiting_activation'] += $total_members; |
|
75 | + } elseif (in_array($activation_type, array(3, 4, 5))) { |
|
76 | + $context['awaiting_approval'] += $total_members; |
|
77 | + } |
|
75 | 78 | } |
76 | 79 | |
77 | 80 | // For the page header... do we show activation? |
@@ -124,8 +127,9 @@ discard block |
||
124 | 127 | } |
125 | 128 | if (!$context['show_approve'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'approve')) |
126 | 129 | { |
127 | - if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) |
|
128 | - $context['tabs']['search']['is_last'] = true; |
|
130 | + if (!$context['show_activate'] && ($_REQUEST['sa'] != 'browse' || $_REQUEST['type'] != 'activate')) { |
|
131 | + $context['tabs']['search']['is_last'] = true; |
|
132 | + } |
|
129 | 133 | unset($context['tabs']['approve']); |
130 | 134 | } |
131 | 135 | |
@@ -157,8 +161,9 @@ discard block |
||
157 | 161 | foreach ($_POST['delete'] as $key => $value) |
158 | 162 | { |
159 | 163 | // Don't delete yourself, idiot. |
160 | - if ($value != $user_info['id']) |
|
161 | - $delete[$key] = (int) $value; |
|
164 | + if ($value != $user_info['id']) { |
|
165 | + $delete[$key] = (int) $value; |
|
166 | + } |
|
162 | 167 | } |
163 | 168 | |
164 | 169 | if (!empty($delete)) |
@@ -194,17 +199,18 @@ discard block |
||
194 | 199 | ); |
195 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
196 | 201 | { |
197 | - if ($row['min_posts'] == -1) |
|
198 | - $context['membergroups'][] = array( |
|
202 | + if ($row['min_posts'] == -1) { |
|
203 | + $context['membergroups'][] = array( |
|
199 | 204 | 'id' => $row['id_group'], |
200 | 205 | 'name' => $row['group_name'], |
201 | 206 | 'can_be_additional' => true |
202 | 207 | ); |
203 | - else |
|
204 | - $context['postgroups'][] = array( |
|
208 | + } else { |
|
209 | + $context['postgroups'][] = array( |
|
205 | 210 | 'id' => $row['id_group'], |
206 | 211 | 'name' => $row['group_name'] |
207 | 212 | ); |
213 | + } |
|
208 | 214 | } |
209 | 215 | $smcFunc['db_free_result']($request); |
210 | 216 | |
@@ -268,14 +274,15 @@ discard block |
||
268 | 274 | call_integration_hook('integrate_view_members_params', array(&$params)); |
269 | 275 | |
270 | 276 | $search_params = array(); |
271 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
272 | - $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
273 | - elseif (!empty($_POST)) |
|
277 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
278 | + $search_params = smf_json_decode(base64_decode($_REQUEST['params']), true); |
|
279 | + } elseif (!empty($_POST)) |
|
274 | 280 | { |
275 | 281 | $search_params['types'] = $_POST['types']; |
276 | - foreach ($params as $param_name => $param_info) |
|
277 | - if (isset($_POST[$param_name])) |
|
282 | + foreach ($params as $param_name => $param_info) { |
|
283 | + if (isset($_POST[$param_name])) |
|
278 | 284 | $search_params[$param_name] = $_POST[$param_name]; |
285 | + } |
|
279 | 286 | } |
280 | 287 | |
281 | 288 | $search_url_params = isset($search_params) ? base64_encode(json_encode($search_params)) : null; |
@@ -288,18 +295,21 @@ discard block |
||
288 | 295 | foreach ($params as $param_name => $param_info) |
289 | 296 | { |
290 | 297 | // Not filled in? |
291 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
292 | - continue; |
|
298 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
299 | + continue; |
|
300 | + } |
|
293 | 301 | |
294 | 302 | // Make sure numeric values are really numeric. |
295 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
296 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
303 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
304 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
305 | + } |
|
297 | 306 | // Date values have to match the specified format. |
298 | 307 | elseif ($param_info['type'] == 'date') |
299 | 308 | { |
300 | 309 | // Check if this date format is valid. |
301 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
302 | - continue; |
|
310 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
311 | + continue; |
|
312 | + } |
|
303 | 313 | |
304 | 314 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
305 | 315 | } |
@@ -308,8 +318,9 @@ discard block |
||
308 | 318 | if (!empty($param_info['range'])) |
309 | 319 | { |
310 | 320 | // Default to '=', just in case... |
311 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
312 | - $search_params['types'][$param_name] = '='; |
|
321 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
322 | + $search_params['types'][$param_name] = '='; |
|
323 | + } |
|
313 | 324 | |
314 | 325 | // Handle special case 'age'. |
315 | 326 | if ($param_info['type'] == 'age') |
@@ -337,29 +348,30 @@ discard block |
||
337 | 348 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
338 | 349 | { |
339 | 350 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
351 | + } else { |
|
352 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
340 | 353 | } |
341 | - else |
|
342 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
343 | 354 | } |
344 | 355 | // Checkboxes. |
345 | 356 | elseif ($param_info['type'] == 'checkbox') |
346 | 357 | { |
347 | 358 | // Each checkbox or no checkbox at all is checked -> ignore. |
348 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
349 | - continue; |
|
359 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
360 | + continue; |
|
361 | + } |
|
350 | 362 | |
351 | 363 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
352 | 364 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
353 | - } |
|
354 | - else |
|
365 | + } else |
|
355 | 366 | { |
356 | 367 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
357 | 368 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
358 | 369 | |
359 | - if ($smcFunc['db_case_sensitive']) |
|
360 | - $query_parts[] = '(LOWER(' . implode( ') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
361 | - else |
|
362 | - $query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
370 | + if ($smcFunc['db_case_sensitive']) { |
|
371 | + $query_parts[] = '(LOWER(' . implode( ') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
372 | + } else { |
|
373 | + $query_parts[] = '(' . implode( ' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
374 | + } |
|
363 | 375 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
364 | 376 | } |
365 | 377 | } |
@@ -375,16 +387,18 @@ discard block |
||
375 | 387 | } |
376 | 388 | |
377 | 389 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
378 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
379 | - foreach ($search_params['membergroups'][2] as $mg) |
|
390 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
391 | + foreach ($search_params['membergroups'][2] as $mg) |
|
380 | 392 | { |
381 | 393 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
394 | + } |
|
382 | 395 | $where_params['add_group_' . $mg] = $mg; |
383 | 396 | } |
384 | 397 | |
385 | 398 | // Combine the one or two membergroup parts into one query part linked with an OR. |
386 | - if (!empty($mg_query_parts)) |
|
387 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
399 | + if (!empty($mg_query_parts)) { |
|
400 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
401 | + } |
|
388 | 402 | |
389 | 403 | // Get all selected post count related membergroups. |
390 | 404 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -396,9 +410,9 @@ discard block |
||
396 | 410 | // Construct the where part of the query. |
397 | 411 | $where = empty($query_parts) ? '1=1' : implode(' |
398 | 412 | AND ', $query_parts); |
413 | + } else { |
|
414 | + $search_url_params = null; |
|
399 | 415 | } |
400 | - else |
|
401 | - $search_url_params = null; |
|
402 | 416 | |
403 | 417 | // Construct the additional URL part with the query info in it. |
404 | 418 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -521,28 +535,32 @@ discard block |
||
521 | 535 | 'function' => function ($rowData) use ($txt) |
522 | 536 | { |
523 | 537 | // Calculate number of days since last online. |
524 | - if (empty($rowData['last_login'])) |
|
525 | - $difference = $txt['never']; |
|
526 | - else |
|
538 | + if (empty($rowData['last_login'])) { |
|
539 | + $difference = $txt['never']; |
|
540 | + } else |
|
527 | 541 | { |
528 | 542 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
529 | 543 | |
530 | 544 | // Today. |
531 | - if (empty($num_days_difference)) |
|
532 | - $difference = $txt['viewmembers_today']; |
|
545 | + if (empty($num_days_difference)) { |
|
546 | + $difference = $txt['viewmembers_today']; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | // Yesterday. |
535 | - elseif ($num_days_difference == 1) |
|
536 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
550 | + elseif ($num_days_difference == 1) { |
|
551 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
552 | + } |
|
537 | 553 | |
538 | 554 | // X days ago. |
539 | - else |
|
540 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
555 | + else { |
|
556 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
557 | + } |
|
541 | 558 | } |
542 | 559 | |
543 | 560 | // Show it in italics if they're not activated... |
544 | - if ($rowData['is_activated'] % 10 != 1) |
|
545 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
561 | + if ($rowData['is_activated'] % 10 != 1) { |
|
562 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
563 | + } |
|
546 | 564 | |
547 | 565 | return $difference; |
548 | 566 | }, |
@@ -594,8 +612,9 @@ discard block |
||
594 | 612 | ); |
595 | 613 | |
596 | 614 | // Without enough permissions, don't show 'delete members' checkboxes. |
597 | - if (!allowedTo('profile_remove_any')) |
|
598 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
615 | + if (!allowedTo('profile_remove_any')) { |
|
616 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
617 | + } |
|
599 | 618 | |
600 | 619 | require_once($sourcedir . '/Subs-List.php'); |
601 | 620 | createList($listOptions); |
@@ -638,17 +657,18 @@ discard block |
||
638 | 657 | ); |
639 | 658 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
640 | 659 | { |
641 | - if ($row['min_posts'] == -1) |
|
642 | - $context['membergroups'][] = array( |
|
660 | + if ($row['min_posts'] == -1) { |
|
661 | + $context['membergroups'][] = array( |
|
643 | 662 | 'id' => $row['id_group'], |
644 | 663 | 'name' => $row['group_name'], |
645 | 664 | 'can_be_additional' => true |
646 | 665 | ); |
647 | - else |
|
648 | - $context['postgroups'][] = array( |
|
666 | + } else { |
|
667 | + $context['postgroups'][] = array( |
|
649 | 668 | 'id' => $row['id_group'], |
650 | 669 | 'name' => $row['group_name'] |
651 | 670 | ); |
671 | + } |
|
652 | 672 | } |
653 | 673 | $smcFunc['db_free_result']($request); |
654 | 674 | |
@@ -675,8 +695,9 @@ discard block |
||
675 | 695 | $context['page_title'] = $txt['admin_members']; |
676 | 696 | $context['sub_template'] = 'admin_browse'; |
677 | 697 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
678 | - if (isset($context['tabs'][$context['browse_type']])) |
|
679 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
698 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
699 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
700 | + } |
|
680 | 701 | |
681 | 702 | // Allowed filters are those we can have, in theory. |
682 | 703 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -687,18 +708,20 @@ discard block |
||
687 | 708 | foreach ($context['activation_numbers'] as $type => $amount) |
688 | 709 | { |
689 | 710 | // We have some of these... |
690 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
691 | - $context['available_filters'][] = array( |
|
711 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
712 | + $context['available_filters'][] = array( |
|
692 | 713 | 'type' => $type, |
693 | 714 | 'amount' => $amount, |
694 | 715 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
695 | 716 | 'selected' => $type == $context['current_filter'] |
696 | 717 | ); |
718 | + } |
|
697 | 719 | } |
698 | 720 | |
699 | 721 | // If the filter was not sent, set it to whatever has people in it! |
700 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
701 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
722 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
723 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
724 | + } |
|
702 | 725 | |
703 | 726 | // This little variable is used to determine if we should flag where we are looking. |
704 | 727 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -713,44 +736,47 @@ discard block |
||
713 | 736 | ); |
714 | 737 | |
715 | 738 | // Are we showing duplicate information? |
716 | - if (isset($_GET['showdupes'])) |
|
717 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
739 | + if (isset($_GET['showdupes'])) { |
|
740 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
741 | + } |
|
718 | 742 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
719 | 743 | |
720 | 744 | // Determine which actions we should allow on this page. |
721 | 745 | if ($context['browse_type'] == 'approve') |
722 | 746 | { |
723 | 747 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
724 | - if ($context['current_filter'] == 4) |
|
725 | - $context['allowed_actions'] = array( |
|
748 | + if ($context['current_filter'] == 4) { |
|
749 | + $context['allowed_actions'] = array( |
|
726 | 750 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
727 | 751 | 'ok' => $txt['admin_browse_w_reject'], |
728 | 752 | ); |
729 | - else |
|
730 | - $context['allowed_actions'] = array( |
|
753 | + } else { |
|
754 | + $context['allowed_actions'] = array( |
|
731 | 755 | 'ok' => $txt['admin_browse_w_approve'], |
732 | 756 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
733 | 757 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
734 | 758 | 'reject' => $txt['admin_browse_w_reject'], |
735 | 759 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
736 | 760 | ); |
737 | - } |
|
738 | - elseif ($context['browse_type'] == 'activate') |
|
739 | - $context['allowed_actions'] = array( |
|
761 | + } |
|
762 | + } elseif ($context['browse_type'] == 'activate') { |
|
763 | + $context['allowed_actions'] = array( |
|
740 | 764 | 'ok' => $txt['admin_browse_w_activate'], |
741 | 765 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
742 | 766 | 'delete' => $txt['admin_browse_w_delete'], |
743 | 767 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
744 | 768 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
745 | 769 | ); |
770 | + } |
|
746 | 771 | |
747 | 772 | // Create an option list for actions allowed to be done with selected members. |
748 | 773 | $allowed_actions = ' |
749 | 774 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
750 | 775 | <option value="" disabled>-----------------------------</option>'; |
751 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
752 | - $allowed_actions .= ' |
|
776 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
777 | + $allowed_actions .= ' |
|
753 | 778 | <option value="' . $key . '">' . $desc . '</option>'; |
779 | + } |
|
754 | 780 | |
755 | 781 | // Setup the Javascript function for selecting an action for the list. |
756 | 782 | $javascript = ' |
@@ -762,15 +788,16 @@ discard block |
||
762 | 788 | var message = "";'; |
763 | 789 | |
764 | 790 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
765 | - if ($context['current_filter'] == 4) |
|
766 | - $javascript .= ' |
|
791 | + if ($context['current_filter'] == 4) { |
|
792 | + $javascript .= ' |
|
767 | 793 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
768 | 794 | message = "' . $txt['admin_browse_w_delete'] . '"; |
769 | 795 | else |
770 | 796 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
797 | + } |
|
771 | 798 | // Otherwise a nice standard message. |
772 | - else |
|
773 | - $javascript .= ' |
|
799 | + else { |
|
800 | + $javascript .= ' |
|
774 | 801 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
775 | 802 | message = "' . $txt['admin_browse_w_delete'] . '"; |
776 | 803 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -779,6 +806,7 @@ discard block |
||
779 | 806 | message = "' . $txt['admin_browse_w_remind'] . '"; |
780 | 807 | else |
781 | 808 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
809 | + } |
|
782 | 810 | $javascript .= ' |
783 | 811 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
784 | 812 | document.forms.postForm.submit(); |
@@ -911,10 +939,11 @@ discard block |
||
911 | 939 | $member_links = array(); |
912 | 940 | foreach ($rowData['duplicate_members'] as $member) |
913 | 941 | { |
914 | - if ($member['id']) |
|
915 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
916 | - else |
|
917 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
942 | + if ($member['id']) { |
|
943 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
944 | + } else { |
|
945 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
946 | + } |
|
918 | 947 | } |
919 | 948 | return implode (', ', $member_links); |
920 | 949 | }, |
@@ -963,14 +992,16 @@ discard block |
||
963 | 992 | ); |
964 | 993 | |
965 | 994 | // Pick what column to actually include if we're showing duplicates. |
966 | - if ($context['show_duplicates']) |
|
967 | - unset($listOptions['columns']['email']); |
|
968 | - else |
|
969 | - unset($listOptions['columns']['duplicates']); |
|
995 | + if ($context['show_duplicates']) { |
|
996 | + unset($listOptions['columns']['email']); |
|
997 | + } else { |
|
998 | + unset($listOptions['columns']['duplicates']); |
|
999 | + } |
|
970 | 1000 | |
971 | 1001 | // Only show hostname on duplicates as it takes a lot of time. |
972 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
973 | - unset($listOptions['columns']['hostname']); |
|
1002 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1003 | + unset($listOptions['columns']['hostname']); |
|
1004 | + } |
|
974 | 1005 | |
975 | 1006 | // Is there any need to show filters? |
976 | 1007 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -978,9 +1009,10 @@ discard block |
||
978 | 1009 | $filterOptions = ' |
979 | 1010 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
980 | 1011 | <select name="filter" onchange="this.form.submit();">'; |
981 | - foreach ($context['available_filters'] as $filter) |
|
982 | - $filterOptions .= ' |
|
1012 | + foreach ($context['available_filters'] as $filter) { |
|
1013 | + $filterOptions .= ' |
|
983 | 1014 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1015 | + } |
|
984 | 1016 | $filterOptions .= ' |
985 | 1017 | </select> |
986 | 1018 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button_submit"></noscript>'; |
@@ -992,12 +1024,13 @@ discard block |
||
992 | 1024 | } |
993 | 1025 | |
994 | 1026 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
995 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
996 | - $listOptions['additional_rows'][] = array( |
|
1027 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1028 | + $listOptions['additional_rows'][] = array( |
|
997 | 1029 | 'position' => 'above_column_headers', |
998 | 1030 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
999 | 1031 | 'class' => 'smalltext floatright', |
1000 | 1032 | ); |
1033 | + } |
|
1001 | 1034 | |
1002 | 1035 | // Now that we have all the options, create the list. |
1003 | 1036 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1028,12 +1061,14 @@ discard block |
||
1028 | 1061 | $current_filter = (int) $_REQUEST['orig_filter']; |
1029 | 1062 | |
1030 | 1063 | // If we are applying a filter do just that - then redirect. |
1031 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1032 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1064 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1065 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1066 | + } |
|
1033 | 1067 | |
1034 | 1068 | // Nothing to do? |
1035 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1036 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1069 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1070 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1071 | + } |
|
1037 | 1072 | |
1038 | 1073 | // Are we dealing with members who have been waiting for > set amount of time? |
1039 | 1074 | if (isset($_POST['time_passed'])) |
@@ -1046,8 +1081,9 @@ discard block |
||
1046 | 1081 | else |
1047 | 1082 | { |
1048 | 1083 | $members = array(); |
1049 | - foreach ($_POST['todoAction'] as $id) |
|
1050 | - $members[] = (int) $id; |
|
1084 | + foreach ($_POST['todoAction'] as $id) { |
|
1085 | + $members[] = (int) $id; |
|
1086 | + } |
|
1051 | 1087 | $condition = ' |
1052 | 1088 | AND id_member IN ({array_int:members})'; |
1053 | 1089 | } |
@@ -1068,8 +1104,9 @@ discard block |
||
1068 | 1104 | $member_count = $smcFunc['db_num_rows']($request); |
1069 | 1105 | |
1070 | 1106 | // If no results then just return! |
1071 | - if ($member_count == 0) |
|
1072 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1107 | + if ($member_count == 0) { |
|
1108 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1109 | + } |
|
1073 | 1110 | |
1074 | 1111 | $member_info = array(); |
1075 | 1112 | $members = array(); |
@@ -1108,8 +1145,9 @@ discard block |
||
1108 | 1145 | // Do we have to let the integration code know about the activations? |
1109 | 1146 | if (!empty($modSettings['integrate_activate'])) |
1110 | 1147 | { |
1111 | - foreach ($member_info as $member) |
|
1112 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1148 | + foreach ($member_info as $member) { |
|
1149 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1150 | + } |
|
1113 | 1151 | } |
1114 | 1152 | |
1115 | 1153 | // Check for email. |
@@ -1240,20 +1278,23 @@ discard block |
||
1240 | 1278 | $log_inserts = array(); |
1241 | 1279 | |
1242 | 1280 | require_once($sourcedir . '/Logging.php'); |
1243 | - foreach ($member_info as $member) |
|
1244 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1281 | + foreach ($member_info as $member) { |
|
1282 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1283 | + } |
|
1245 | 1284 | } |
1246 | 1285 | |
1247 | 1286 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1248 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1249 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1287 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1288 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1289 | + } |
|
1250 | 1290 | |
1251 | 1291 | // Update the member's stats. (but, we know the member didn't change their name.) |
1252 | 1292 | updateStats('member', false); |
1253 | 1293 | |
1254 | 1294 | // If they haven't been deleted, update the post group statistics on them... |
1255 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1256 | - updateStats('postgroups', $members); |
|
1295 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1296 | + updateStats('postgroups', $members); |
|
1297 | + } |
|
1257 | 1298 | |
1258 | 1299 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1259 | 1300 | } |
@@ -1278,10 +1319,11 @@ discard block |
||
1278 | 1319 | $dis = time() - $old; |
1279 | 1320 | |
1280 | 1321 | // Before midnight? |
1281 | - if ($dis < $sinceMidnight) |
|
1282 | - return 0; |
|
1283 | - else |
|
1284 | - $dis -= $sinceMidnight; |
|
1322 | + if ($dis < $sinceMidnight) { |
|
1323 | + return 0; |
|
1324 | + } else { |
|
1325 | + $dis -= $sinceMidnight; |
|
1326 | + } |
|
1285 | 1327 | |
1286 | 1328 | // Divide out the seconds in a day to get the number of days. |
1287 | 1329 | return ceil($dis / (24 * 60 * 60)); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function shows the board index. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | $context['canonical_url'] = $scripturl; |
35 | 36 | |
36 | 37 | // Do not let search engines index anything if there is a random thing in $_GET. |
37 | - if (!empty($_GET)) |
|
38 | - $context['robot_no_index'] = true; |
|
38 | + if (!empty($_GET)) { |
|
39 | + $context['robot_no_index'] = true; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Retrieve the categories and boards. |
41 | 43 | require_once($sourcedir . '/Subs-BoardIndex.php'); |
@@ -62,11 +64,12 @@ discard block |
||
62 | 64 | $context['latest_posts'] = cache_quick_get('boardindex-latest_posts:' . md5($user_info['query_wanna_see_board'] . $user_info['language']), 'Subs-Recent.php', 'cache_getLastPosts', array($latestPostOptions)); |
63 | 65 | } |
64 | 66 | |
65 | - if (!empty($context['latest_posts']) || !empty($context['latest_post'])) |
|
66 | - $context['info_center'][] = array( |
|
67 | + if (!empty($context['latest_posts']) || !empty($context['latest_post'])) { |
|
68 | + $context['info_center'][] = array( |
|
67 | 69 | 'tpl' => 'recent', |
68 | 70 | 'txt' => 'recent_posts', |
69 | 71 | ); |
72 | + } |
|
70 | 73 | } |
71 | 74 | |
72 | 75 | // Load the calendar? |
@@ -87,20 +90,22 @@ discard block |
||
87 | 90 | // This is used to show the "how-do-I-edit" help. |
88 | 91 | $context['calendar_can_edit'] = allowedTo('calendar_edit_any'); |
89 | 92 | |
90 | - if ($context['show_calendar']) |
|
91 | - $context['info_center'][] = array( |
|
93 | + if ($context['show_calendar']) { |
|
94 | + $context['info_center'][] = array( |
|
92 | 95 | 'tpl' => 'calendar', |
93 | 96 | 'txt' => $context['calendar_only_today'] ? 'calendar_today' : 'calendar_upcoming', |
94 | 97 | ); |
98 | + } |
|
95 | 99 | } |
96 | 100 | |
97 | 101 | // And stats. |
98 | 102 | $context['show_stats'] = allowedTo('view_stats') && !empty($modSettings['trackStats']); |
99 | - if ($settings['show_stats_index']) |
|
100 | - $context['info_center'][] = array( |
|
103 | + if ($settings['show_stats_index']) { |
|
104 | + $context['info_center'][] = array( |
|
101 | 105 | 'tpl' => 'stats', |
102 | 106 | 'txt' => 'forum_stats', |
103 | 107 | ); |
108 | + } |
|
104 | 109 | |
105 | 110 | // Now the online stuff |
106 | 111 | require_once($sourcedir . '/Subs-MembersOnline.php'); |
@@ -118,12 +123,14 @@ discard block |
||
118 | 123 | ); |
119 | 124 | |
120 | 125 | // Track most online statistics? (Subs-MembersOnline.php) |
121 | - if (!empty($modSettings['trackStats'])) |
|
122 | - trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
126 | + if (!empty($modSettings['trackStats'])) { |
|
127 | + trackStatsUsersOnline($context['num_guests'] + $context['num_spiders'] + $context['num_users_online']); |
|
128 | + } |
|
123 | 129 | |
124 | 130 | // Are we showing all membergroups on the board index? |
125 | - if (!empty($settings['show_group_key'])) |
|
126 | - $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
131 | + if (!empty($settings['show_group_key'])) { |
|
132 | + $context['membergroups'] = cache_quick_get('membergroup_list', 'Subs-Membergroups.php', 'cache_getMembergroupList', array()); |
|
133 | + } |
|
127 | 134 | |
128 | 135 | // And back to normality. |
129 | 136 | $context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
45 | 46 | $temp2 = $temp->getVersion(); |
46 | 47 | $im_version = $temp2['versionString']; |
47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
48 | - } |
|
49 | - else |
|
49 | + } else |
|
50 | 50 | { |
51 | 51 | $im_version = MagickGetVersionString(); |
52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | if (in_array('db_server', $checkFor)) |
62 | 62 | { |
63 | 63 | db_extend(); |
64 | - if (!isset($db_connection) || $db_connection === false) |
|
65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | - else |
|
64 | + if (!isset($db_connection) || $db_connection === false) { |
|
65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | + } else |
|
67 | 67 | { |
68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_engine'](); |
@@ -74,24 +74,31 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | // If we're using memcache we need the server info. |
77 | - if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') |
|
78 | - get_memcached_server(); |
|
77 | + if (empty($memcached) && function_exists('memcache_get') && isset($modSettings['cache_memcached']) && trim($modSettings['cache_memcached']) != '') { |
|
78 | + get_memcached_server(); |
|
79 | + } |
|
79 | 80 | |
80 | 81 | // Check to see if we have any accelerators installed... |
81 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
82 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
83 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
84 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
85 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
86 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
87 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
88 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
82 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
83 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
84 | + } |
|
85 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
86 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
87 | + } |
|
88 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
89 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => empty($memcached) ? '???' : memcache_get_version($memcached)); |
|
90 | + } |
|
91 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
92 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
93 | + } |
|
89 | 94 | |
90 | - if (in_array('php', $checkFor)) |
|
91 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
95 | + if (in_array('php', $checkFor)) { |
|
96 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
97 | + } |
|
92 | 98 | |
93 | - if (in_array('server', $checkFor)) |
|
94 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
99 | + if (in_array('server', $checkFor)) { |
|
100 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | return $versions; |
97 | 104 | } |
@@ -131,11 +138,13 @@ discard block |
||
131 | 138 | fclose($fp); |
132 | 139 | |
133 | 140 | // The comment looks rougly like... that. |
134 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
135 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
141 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
142 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
143 | + } |
|
136 | 144 | // Not found! This is bad. |
137 | - else |
|
138 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
145 | + else { |
|
146 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
147 | + } |
|
139 | 148 | } |
140 | 149 | |
141 | 150 | // Do the paid subscriptions handler? |
@@ -146,11 +155,13 @@ discard block |
||
146 | 155 | fclose($fp); |
147 | 156 | |
148 | 157 | // Found it? |
149 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
150 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
158 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
159 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
160 | + } |
|
151 | 161 | // If we haven't how do we all get paid? |
152 | - else |
|
153 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
162 | + else { |
|
163 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
164 | + } |
|
154 | 165 | } |
155 | 166 | |
156 | 167 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -165,11 +176,13 @@ discard block |
||
165 | 176 | fclose($fp); |
166 | 177 | |
167 | 178 | // Look for the version comment in the file header. |
168 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
169 | - $version_info['file_versions'][$entry] = $match[1]; |
|
179 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
180 | + $version_info['file_versions'][$entry] = $match[1]; |
|
181 | + } |
|
170 | 182 | // It wasn't found, but the file was... show a '??'. |
171 | - else |
|
172 | - $version_info['file_versions'][$entry] = '??'; |
|
183 | + else { |
|
184 | + $version_info['file_versions'][$entry] = '??'; |
|
185 | + } |
|
173 | 186 | } |
174 | 187 | } |
175 | 188 | $sources_dir->close(); |
@@ -188,11 +201,13 @@ discard block |
||
188 | 201 | fclose($fp); |
189 | 202 | |
190 | 203 | // Look for the version comment in the file header. |
191 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
192 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
204 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
205 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
206 | + } |
|
193 | 207 | // It wasn't found, but the file was... show a '??'. |
194 | - else |
|
195 | - $version_info['tasks_versions'][$entry] = '??'; |
|
208 | + else { |
|
209 | + $version_info['tasks_versions'][$entry] = '??'; |
|
210 | + } |
|
196 | 211 | } |
197 | 212 | } |
198 | 213 | $tasks_dir->close(); |
@@ -200,8 +215,9 @@ discard block |
||
200 | 215 | |
201 | 216 | // Load all the files in the default template directory - and the current theme if applicable. |
202 | 217 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
203 | - if ($settings['theme_id'] != 1) |
|
204 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
218 | + if ($settings['theme_id'] != 1) { |
|
219 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
220 | + } |
|
205 | 221 | |
206 | 222 | foreach ($directories as $type => $dirname) |
207 | 223 | { |
@@ -216,11 +232,13 @@ discard block |
||
216 | 232 | fclose($fp); |
217 | 233 | |
218 | 234 | // Look for the version comment in the file header. |
219 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
220 | - $version_info[$type][$entry] = $match[1]; |
|
235 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
236 | + $version_info[$type][$entry] = $match[1]; |
|
237 | + } |
|
221 | 238 | // It wasn't found, but the file was... show a '??'. |
222 | - else |
|
223 | - $version_info[$type][$entry] = '??'; |
|
239 | + else { |
|
240 | + $version_info[$type][$entry] = '??'; |
|
241 | + } |
|
224 | 242 | } |
225 | 243 | } |
226 | 244 | $this_dir->close(); |
@@ -241,11 +259,13 @@ discard block |
||
241 | 259 | list ($name, $language) = explode('.', $entry); |
242 | 260 | |
243 | 261 | // Look for the version comment in the file header. |
244 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
245 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
262 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
263 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
264 | + } |
|
246 | 265 | // It wasn't found, but the file was... show a '??'. |
247 | - else |
|
248 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
266 | + else { |
|
267 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
268 | + } |
|
249 | 269 | } |
250 | 270 | } |
251 | 271 | $this_dir->close(); |
@@ -260,8 +280,9 @@ discard block |
||
260 | 280 | ksort($version_info['tasks_versions']); |
261 | 281 | |
262 | 282 | // For languages sort each language too. |
263 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
264 | - ksort($version_info['default_language_versions'][$language]); |
|
283 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
284 | + ksort($version_info['default_language_versions'][$language]); |
|
285 | + } |
|
265 | 286 | } |
266 | 287 | return $version_info; |
267 | 288 | } |
@@ -303,27 +324,31 @@ discard block |
||
303 | 324 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
304 | 325 | |
305 | 326 | // Break it up based on \r or \n, and then clean out extra characters. |
306 | - if (strpos($settingsArray, "\n") !== false) |
|
307 | - $settingsArray = explode("\n", $settingsArray); |
|
308 | - elseif (strpos($settingsArray, "\r") !== false) |
|
309 | - $settingsArray = explode("\r", $settingsArray); |
|
310 | - else |
|
311 | - return; |
|
327 | + if (strpos($settingsArray, "\n") !== false) { |
|
328 | + $settingsArray = explode("\n", $settingsArray); |
|
329 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
330 | + $settingsArray = explode("\r", $settingsArray); |
|
331 | + } else { |
|
332 | + return; |
|
333 | + } |
|
312 | 334 | |
313 | 335 | // Presumably, the file has to have stuff in it for this function to be called :P. |
314 | - if (count($settingsArray) < 10) |
|
315 | - return; |
|
336 | + if (count($settingsArray) < 10) { |
|
337 | + return; |
|
338 | + } |
|
316 | 339 | |
317 | 340 | // remove any /r's that made there way in here |
318 | - foreach ($settingsArray as $k => $dummy) |
|
319 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
341 | + foreach ($settingsArray as $k => $dummy) { |
|
342 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
343 | + } |
|
320 | 344 | |
321 | 345 | // go line by line and see whats changing |
322 | 346 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
323 | 347 | { |
324 | 348 | // Don't trim or bother with it if it's not a variable. |
325 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
326 | - continue; |
|
349 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
350 | + continue; |
|
351 | + } |
|
327 | 352 | |
328 | 353 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
329 | 354 | |
@@ -335,8 +360,7 @@ discard block |
||
335 | 360 | { |
336 | 361 | updateDbLastError($val); |
337 | 362 | unset($config_vars[$var]); |
338 | - } |
|
339 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
363 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
340 | 364 | { |
341 | 365 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
342 | 366 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -347,34 +371,39 @@ discard block |
||
347 | 371 | } |
348 | 372 | |
349 | 373 | // End of the file ... maybe |
350 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
351 | - $end = $i; |
|
374 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
375 | + $end = $i; |
|
376 | + } |
|
352 | 377 | } |
353 | 378 | |
354 | 379 | // This should never happen, but apparently it is happening. |
355 | - if (empty($end) || $end < 10) |
|
356 | - $end = count($settingsArray) - 1; |
|
380 | + if (empty($end) || $end < 10) { |
|
381 | + $end = count($settingsArray) - 1; |
|
382 | + } |
|
357 | 383 | |
358 | 384 | // Still more variables to go? Then lets add them at the end. |
359 | 385 | if (!empty($config_vars)) |
360 | 386 | { |
361 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
362 | - $settingsArray[$end++] = ''; |
|
363 | - else |
|
364 | - $end++; |
|
387 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
388 | + $settingsArray[$end++] = ''; |
|
389 | + } else { |
|
390 | + $end++; |
|
391 | + } |
|
365 | 392 | |
366 | 393 | // Add in any newly defined vars that were passed |
367 | - foreach ($config_vars as $var => $val) |
|
368 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
394 | + foreach ($config_vars as $var => $val) { |
|
395 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
396 | + } |
|
369 | 397 | |
370 | 398 | $settingsArray[$end] = '?' . '>'; |
399 | + } else { |
|
400 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
371 | 401 | } |
372 | - else |
|
373 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
374 | 402 | |
375 | 403 | // Sanity error checking: the file needs to be at least 12 lines. |
376 | - if (count($settingsArray) < 12) |
|
377 | - return; |
|
404 | + if (count($settingsArray) < 12) { |
|
405 | + return; |
|
406 | + } |
|
378 | 407 | |
379 | 408 | // Try to avoid a few pitfalls: |
380 | 409 | // - like a possible race condition, |
@@ -382,8 +411,9 @@ discard block |
||
382 | 411 | // |
383 | 412 | // Check before you act: if cache is enabled, we can do a simple write test |
384 | 413 | // to validate that we even write things on this filesystem. |
385 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
386 | - $cachedir = $boarddir . '/cache'; |
|
414 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
415 | + $cachedir = $boarddir . '/cache'; |
|
416 | + } |
|
387 | 417 | |
388 | 418 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
389 | 419 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
419 | 449 | // Well this is not good at all, lets see if we can save this |
420 | 450 | $context['settings_message'] = 'settings_error'; |
421 | 451 | |
422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
454 | + } |
|
424 | 455 | } |
425 | 456 | } |
426 | 457 | |
427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
429 | - if (function_exists('opcache_invalidate')) |
|
430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
431 | -} |
|
460 | + if (function_exists('opcache_invalidate')) { |
|
461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
462 | + } |
|
463 | + } |
|
432 | 464 | |
433 | 465 | /** |
434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
455 | 487 | |
456 | 488 | // This must exist! |
457 | - if (!isset($context['admin_preferences'])) |
|
458 | - return false; |
|
489 | + if (!isset($context['admin_preferences'])) { |
|
490 | + return false; |
|
491 | + } |
|
459 | 492 | |
460 | 493 | // This is what we'll be saving. |
461 | 494 | $options['admin_preferences'] = json_encode($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
519 | 552 | $emails_sent = array(); |
520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
521 | 554 | { |
522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
523 | - continue; |
|
555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
556 | + continue; |
|
557 | + } |
|
524 | 558 | |
525 | 559 | // Stick their particulars in the replacement data. |
526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
539 | 573 | $smcFunc['db_free_result']($request); |
540 | 574 | |
541 | 575 | // Any additional users we must email this to? |
542 | - if (!empty($additional_recipients)) |
|
543 | - foreach ($additional_recipients as $recipient) |
|
576 | + if (!empty($additional_recipients)) { |
|
577 | + foreach ($additional_recipients as $recipient) |
|
544 | 578 | { |
545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
546 | 580 | continue; |
581 | + } |
|
547 | 582 | |
548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
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 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
31 | 32 | |
32 | 33 | // We should have debug mode enabled, as well as something to display! |
33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
34 | - fatal_lang_error('no_access', false); |
|
34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
35 | + fatal_lang_error('no_access', false); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Don't allow except for administrators. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
41 | 43 | { |
42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
43 | 45 | |
44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
45 | - redirectexit(); |
|
46 | - else |
|
47 | - redirectexit($_SESSION['old_url']); |
|
46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
47 | + redirectexit(); |
|
48 | + } else { |
|
49 | + redirectexit($_SESSION['old_url']); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
83 | 86 | foreach ($query as $line) |
84 | 87 | { |
85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
87 | - $min_indent = strlen($temp[0]); |
|
89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
90 | + $min_indent = strlen($temp[0]); |
|
91 | + } |
|
92 | + } |
|
93 | + foreach ($query as $l => $dummy) { |
|
94 | + $query[$l] = substr($dummy, $min_indent); |
|
88 | 95 | } |
89 | - foreach ($query as $l => $dummy) |
|
90 | - $query[$l] = substr($dummy, $min_indent); |
|
91 | 96 | $query_data['q'] = implode("\n", $query); |
92 | 97 | |
93 | 98 | // Make the filenames look a bit better. |
94 | - if (isset($query_data['f'])) |
|
95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
99 | + if (isset($query_data['f'])) { |
|
100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
98 | - if ($is_select_query) |
|
99 | - $select = $query_data['q']; |
|
100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
104 | + if ($is_select_query) { |
|
105 | + $select = $query_data['q']; |
|
106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
101 | 107 | { |
102 | 108 | $is_select_query = true; |
103 | 109 | $select = $matches[1]; |
104 | - } |
|
105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
106 | 111 | { |
107 | 112 | $is_select_query = true; |
108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
110 | 115 | // Temporary tables created in earlier queries are not explainable. |
111 | 116 | if ($is_select_query) |
112 | 117 | { |
113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
114 | - if (strpos($select, $tmp) !== false) |
|
118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
119 | + if (strpos($select, $tmp) !== false) |
|
115 | 120 | { |
116 | 121 | $is_select_query = false; |
122 | + } |
|
117 | 123 | break; |
118 | 124 | } |
119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
125 | 131 | </a><br>'; |
126 | 132 | |
127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
135 | + } |
|
129 | 136 | |
130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
132 | - else |
|
133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
139 | + } else { |
|
140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
141 | + } |
|
134 | 142 | |
135 | 143 | echo ' |
136 | 144 | </div>'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
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 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $context, $txt; |
32 | 33 | |
33 | 34 | // Old templates might still request this. |
34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $subActions = array( |
38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | checkSession(); |
100 | 102 | validateToken('admin-regc'); |
101 | 103 | |
102 | - foreach ($_POST as $key => $value) |
|
103 | - if (!is_array($_POST[$key])) |
|
104 | + foreach ($_POST as $key => $value) { |
|
105 | + if (!is_array($_POST[$key])) |
|
104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
107 | + } |
|
105 | 108 | |
106 | 109 | $regOptions = array( |
107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
161 | 164 | ) |
162 | 165 | ); |
163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
169 | + } |
|
166 | 170 | $smcFunc['db_free_result']($request); |
171 | + } else { |
|
172 | + $context['member_groups'] = array(); |
|
167 | 173 | } |
168 | - else |
|
169 | - $context['member_groups'] = array(); |
|
170 | 174 | |
171 | 175 | // Basic stuff. |
172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | { |
208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
209 | 213 | // Are we editing this? |
210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | } |
214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
223 | 228 | |
224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
225 | 230 | |
226 | - if ($bytes == strlen($to_write)) |
|
227 | - $context['saved_successful'] = true; |
|
228 | - else |
|
229 | - $context['could_not_save'] = true; |
|
231 | + if ($bytes == strlen($to_write)) { |
|
232 | + $context['saved_successful'] = true; |
|
233 | + } else { |
|
234 | + $context['could_not_save'] = true; |
|
235 | + } |
|
230 | 236 | } |
231 | 237 | |
232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
310 | 316 | |
311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
312 | 318 | |
313 | - if ($return_config) |
|
314 | - return $config_vars; |
|
319 | + if ($return_config) { |
|
320 | + return $config_vars; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // Setup the template |
317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
322 | 329 | checkSession(); |
323 | 330 | |
324 | 331 | // Are there some contacts missing? |
325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
334 | + } |
|
327 | 335 | |
328 | 336 | // Post needs to take into account line breaks. |
329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | * @version 2.1 Beta 3 |
19 | 19 | */ |
20 | 20 | |
21 | -if (!defined('SMF')) |
|
21 | +if (!defined('SMF')) { |
|
22 | 22 | die('No direct access...'); |
23 | +} |
|
23 | 24 | |
24 | 25 | /** |
25 | 26 | * downloads a file from a url and stores it locally for avatar use by id_member. |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $destName = 'avatar_' . $memID . '_' . time() . '.' . $ext; |
45 | 46 | |
46 | 47 | // Just making sure there is a non-zero member. |
47 | - if (empty($memID)) |
|
48 | - return false; |
|
48 | + if (empty($memID)) { |
|
49 | + return false; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | require_once($sourcedir . '/ManageAttachments.php'); |
51 | 53 | removeAttachments(array('id_member' => $memID)); |
@@ -76,10 +78,11 @@ discard block |
||
76 | 78 | $destName = $modSettings['custom_avatar_dir'] . '/' . $destName . '.tmp'; |
77 | 79 | |
78 | 80 | // Resize it. |
79 | - if (!empty($modSettings['avatar_download_png'])) |
|
80 | - $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
81 | - else |
|
82 | - $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
81 | + if (!empty($modSettings['avatar_download_png'])) { |
|
82 | + $success = resizeImageFile($url, $destName, $max_width, $max_height, 3); |
|
83 | + } else { |
|
84 | + $success = resizeImageFile($url, $destName, $max_width, $max_height); |
|
85 | + } |
|
83 | 86 | |
84 | 87 | // Remove the .tmp extension. |
85 | 88 | $destName = substr($destName, 0, -4); |
@@ -108,11 +111,10 @@ discard block |
||
108 | 111 | ) |
109 | 112 | ); |
110 | 113 | return true; |
114 | + } else { |
|
115 | + return false; |
|
111 | 116 | } |
112 | - else |
|
113 | - return false; |
|
114 | - } |
|
115 | - else |
|
117 | + } else |
|
116 | 118 | { |
117 | 119 | $smcFunc['db_query']('', ' |
118 | 120 | DELETE FROM {db_prefix}attachments |
@@ -144,17 +146,18 @@ discard block |
||
144 | 146 | $destName = $source . '_thumb.tmp'; |
145 | 147 | |
146 | 148 | // Do the actual resize. |
147 | - if (!empty($modSettings['attachment_thumb_png'])) |
|
148 | - $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
149 | - else |
|
150 | - $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
149 | + if (!empty($modSettings['attachment_thumb_png'])) { |
|
150 | + $success = resizeImageFile($source, $destName, $max_width, $max_height, 3); |
|
151 | + } else { |
|
152 | + $success = resizeImageFile($source, $destName, $max_width, $max_height); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | // Okay, we're done with the temporary stuff. |
153 | 156 | $destName = substr($destName, 0, -4); |
154 | 157 | |
155 | - if ($success && @rename($destName . '.tmp', $destName)) |
|
156 | - return true; |
|
157 | - else |
|
158 | + if ($success && @rename($destName . '.tmp', $destName)) { |
|
159 | + return true; |
|
160 | + } else |
|
158 | 161 | { |
159 | 162 | @unlink($destName . '.tmp'); |
160 | 163 | @touch($destName); |
@@ -176,18 +179,21 @@ discard block |
||
176 | 179 | { |
177 | 180 | if (!resizeImageFile($fileName, $fileName . '.tmp', null, null, $preferred_format)) |
178 | 181 | { |
179 | - if (file_exists($fileName . '.tmp')) |
|
180 | - unlink($fileName . '.tmp'); |
|
182 | + if (file_exists($fileName . '.tmp')) { |
|
183 | + unlink($fileName . '.tmp'); |
|
184 | + } |
|
181 | 185 | |
182 | 186 | return false; |
183 | 187 | } |
184 | 188 | |
185 | - if (!unlink($fileName)) |
|
186 | - return false; |
|
189 | + if (!unlink($fileName)) { |
|
190 | + return false; |
|
191 | + } |
|
187 | 192 | |
188 | - if (!rename($fileName . '.tmp', $fileName)) |
|
189 | - return false; |
|
190 | -} |
|
193 | + if (!rename($fileName . '.tmp', $fileName)) { |
|
194 | + return false; |
|
195 | + } |
|
196 | + } |
|
191 | 197 | |
192 | 198 | /** |
193 | 199 | * Searches through the file to see if there's potentially harmful non-binary content. |
@@ -200,8 +206,9 @@ discard block |
||
200 | 206 | function checkImageContents($fileName, $extensiveCheck = false) |
201 | 207 | { |
202 | 208 | $fp = fopen($fileName, 'rb'); |
203 | - if (!$fp) |
|
204 | - fatal_lang_error('attach_timeout'); |
|
209 | + if (!$fp) { |
|
210 | + fatal_lang_error('attach_timeout'); |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $prev_chunk = ''; |
207 | 214 | while (!feof($fp)) |
@@ -217,8 +224,7 @@ discard block |
||
217 | 224 | fclose($fp); |
218 | 225 | return false; |
219 | 226 | } |
220 | - } |
|
221 | - else |
|
227 | + } else |
|
222 | 228 | { |
223 | 229 | // Check for potential infection |
224 | 230 | if (preg_match('~(iframe|(?<!cellTextIs)html|eval|body|script\W|[CF]WS[\x01-\x0C])~i', $prev_chunk . $cur_chunk) === 1) |
@@ -245,8 +251,9 @@ discard block |
||
245 | 251 | global $gd2; |
246 | 252 | |
247 | 253 | // Check to see if GD is installed and what version. |
248 | - if (($extensionFunctions = get_extension_funcs('gd')) === false) |
|
249 | - return false; |
|
254 | + if (($extensionFunctions = get_extension_funcs('gd')) === false) { |
|
255 | + return false; |
|
256 | + } |
|
250 | 257 | |
251 | 258 | // Also determine if GD2 is installed and store it in a global. |
252 | 259 | $gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor'); |
@@ -318,8 +325,9 @@ discard block |
||
318 | 325 | global $sourcedir; |
319 | 326 | |
320 | 327 | // Nothing to do without GD or IM/MW |
321 | - if (!checkGD() && !checkImagick() && !checkMagickWand()) |
|
322 | - return false; |
|
328 | + if (!checkGD() && !checkImagick() && !checkMagickWand()) { |
|
329 | + return false; |
|
330 | + } |
|
323 | 331 | |
324 | 332 | static $default_formats = array( |
325 | 333 | '1' => 'gif', |
@@ -341,38 +349,39 @@ discard block |
||
341 | 349 | fclose($fp_destination); |
342 | 350 | |
343 | 351 | $sizes = @getimagesize($destination); |
344 | - } |
|
345 | - elseif ($fp_destination) |
|
352 | + } elseif ($fp_destination) |
|
346 | 353 | { |
347 | 354 | $sizes = @getimagesize($source); |
348 | 355 | |
349 | 356 | $fp_source = fopen($source, 'rb'); |
350 | 357 | if ($fp_source !== false) |
351 | 358 | { |
352 | - while (!feof($fp_source)) |
|
353 | - fwrite($fp_destination, fread($fp_source, 8192)); |
|
359 | + while (!feof($fp_source)) { |
|
360 | + fwrite($fp_destination, fread($fp_source, 8192)); |
|
361 | + } |
|
354 | 362 | fclose($fp_source); |
363 | + } else { |
|
364 | + $sizes = array(-1, -1, -1); |
|
355 | 365 | } |
356 | - else |
|
357 | - $sizes = array(-1, -1, -1); |
|
358 | 366 | fclose($fp_destination); |
359 | 367 | } |
360 | 368 | // We can't get to the file. |
361 | - else |
|
362 | - $sizes = array(-1, -1, -1); |
|
369 | + else { |
|
370 | + $sizes = array(-1, -1, -1); |
|
371 | + } |
|
363 | 372 | |
364 | 373 | // See if we have -or- can get the needed memory for this operation |
365 | 374 | // ImageMagick isn't subject to PHP's memory limits :) |
366 | - if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) |
|
367 | - return false; |
|
375 | + if (!(checkIMagick() || checkMagickWand()) && checkGD() && !imageMemoryCheck($sizes)) { |
|
376 | + return false; |
|
377 | + } |
|
368 | 378 | |
369 | 379 | // A known and supported format? |
370 | 380 | // @todo test PSD and gif. |
371 | 381 | if ((checkImagick() || checkMagickWand()) && isset($default_formats[$sizes[2]])) |
372 | 382 | { |
373 | 383 | return resizeImage(null, $destination, null, null, $max_width, $max_height, true, $preferred_format); |
374 | - } |
|
375 | - elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
384 | + } elseif (checkGD() && isset($default_formats[$sizes[2]]) && function_exists('imagecreatefrom' . $default_formats[$sizes[2]])) |
|
376 | 385 | { |
377 | 386 | $imagecreatefrom = 'imagecreatefrom' . $default_formats[$sizes[2]]; |
378 | 387 | if ($src_img = @$imagecreatefrom($destination)) |
@@ -425,14 +434,14 @@ discard block |
||
425 | 434 | $dest_width = empty($max_width) ? $src_width : $max_width; |
426 | 435 | $dest_height = empty($max_height) ? $src_height : $max_height; |
427 | 436 | |
428 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
429 | - $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
437 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
438 | + $imagick->setCompressionQuality(!empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
439 | + } |
|
430 | 440 | |
431 | 441 | $imagick->setImageFormat($default_formats[$preferred_format]); |
432 | 442 | $imagick->resizeImage($dest_width, $dest_height, Imagick::FILTER_LANCZOS, 1, true); |
433 | 443 | $success = $imagick->writeImage($destName); |
434 | - } |
|
435 | - else |
|
444 | + } else |
|
436 | 445 | { |
437 | 446 | $magick_wand = newMagickWand(); |
438 | 447 | MagickReadImage($magick_wand, $destName); |
@@ -441,8 +450,9 @@ discard block |
||
441 | 450 | $dest_width = empty($max_width) ? $src_width : $max_width; |
442 | 451 | $dest_height = empty($max_height) ? $src_height : $max_height; |
443 | 452 | |
444 | - if ($default_formats[$preferred_format] == 'jpeg') |
|
445 | - MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
453 | + if ($default_formats[$preferred_format] == 'jpeg') { |
|
454 | + MagickSetCompressionQuality($magick_wand, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
455 | + } |
|
446 | 456 | |
447 | 457 | MagickSetImageFormat($magick_wand, $default_formats[$preferred_format]); |
448 | 458 | MagickResizeImage($magick_wand, $dest_width, $dest_height, MW_LanczosFilter, 1, true); |
@@ -450,8 +460,7 @@ discard block |
||
450 | 460 | } |
451 | 461 | |
452 | 462 | return !empty($success); |
453 | - } |
|
454 | - elseif (checkGD()) |
|
463 | + } elseif (checkGD()) |
|
455 | 464 | { |
456 | 465 | $success = false; |
457 | 466 | |
@@ -462,8 +471,7 @@ discard block |
||
462 | 471 | { |
463 | 472 | $dst_width = $max_width; |
464 | 473 | $dst_height = round($src_height * $max_width / $src_width); |
465 | - } |
|
466 | - elseif (!empty($max_height)) |
|
474 | + } elseif (!empty($max_height)) |
|
467 | 475 | { |
468 | 476 | $dst_width = round($src_width * $max_height / $src_height); |
469 | 477 | $dst_height = $max_height; |
@@ -481,44 +489,48 @@ discard block |
||
481 | 489 | if ((!empty($preferred_format)) && ($preferred_format == 3)) |
482 | 490 | { |
483 | 491 | imagealphablending($dst_img, false); |
484 | - if (function_exists('imagesavealpha')) |
|
485 | - imagesavealpha($dst_img, true); |
|
492 | + if (function_exists('imagesavealpha')) { |
|
493 | + imagesavealpha($dst_img, true); |
|
494 | + } |
|
486 | 495 | } |
496 | + } else { |
|
497 | + $dst_img = imagecreate($dst_width, $dst_height); |
|
487 | 498 | } |
488 | - else |
|
489 | - $dst_img = imagecreate($dst_width, $dst_height); |
|
490 | 499 | |
491 | 500 | // Resize it! |
492 | - if ($gd2) |
|
493 | - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
494 | - else |
|
495 | - imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
501 | + if ($gd2) { |
|
502 | + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
503 | + } else { |
|
504 | + imagecopyresamplebicubic($dst_img, $src_img, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height); |
|
505 | + } |
|
506 | + } else { |
|
507 | + $dst_img = $src_img; |
|
496 | 508 | } |
497 | - else |
|
498 | - $dst_img = $src_img; |
|
509 | + } else { |
|
510 | + $dst_img = $src_img; |
|
499 | 511 | } |
500 | - else |
|
501 | - $dst_img = $src_img; |
|
502 | 512 | |
503 | 513 | // Save the image as ... |
504 | - if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) |
|
505 | - $success = imagepng($dst_img, $destName); |
|
506 | - elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) |
|
507 | - $success = imagegif($dst_img, $destName); |
|
508 | - elseif (function_exists('imagejpeg')) |
|
509 | - $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
514 | + if (!empty($preferred_format) && ($preferred_format == 3) && function_exists('imagepng')) { |
|
515 | + $success = imagepng($dst_img, $destName); |
|
516 | + } elseif (!empty($preferred_format) && ($preferred_format == 1) && function_exists('imagegif')) { |
|
517 | + $success = imagegif($dst_img, $destName); |
|
518 | + } elseif (function_exists('imagejpeg')) { |
|
519 | + $success = imagejpeg($dst_img, $destName, !empty($modSettings['avatar_jpeg_quality']) ? $modSettings['avatar_jpeg_quality'] : 82); |
|
520 | + } |
|
510 | 521 | |
511 | 522 | // Free the memory. |
512 | 523 | imagedestroy($src_img); |
513 | - if ($dst_img != $src_img) |
|
514 | - imagedestroy($dst_img); |
|
524 | + if ($dst_img != $src_img) { |
|
525 | + imagedestroy($dst_img); |
|
526 | + } |
|
515 | 527 | |
516 | 528 | return $success; |
517 | - } |
|
518 | - else |
|
519 | - // Without GD, no image resizing at all. |
|
529 | + } else { |
|
530 | + // Without GD, no image resizing at all. |
|
520 | 531 | return false; |
521 | -} |
|
532 | + } |
|
533 | + } |
|
522 | 534 | |
523 | 535 | /** |
524 | 536 | * Copy image. |
@@ -572,8 +584,9 @@ discard block |
||
572 | 584 | $color = imagecolorresolve($dst_img, $red, $green, $blue); |
573 | 585 | if ($color == -1) |
574 | 586 | { |
575 | - if ($palsize++ < 256) |
|
576 | - imagecolorallocate($dst_img, $red, $green, $blue); |
|
587 | + if ($palsize++ < 256) { |
|
588 | + imagecolorallocate($dst_img, $red, $green, $blue); |
|
589 | + } |
|
577 | 590 | $color = imagecolorclosest($dst_img, $red, $green, $blue); |
578 | 591 | } |
579 | 592 | |
@@ -603,13 +616,15 @@ discard block |
||
603 | 616 | $header = unpack('vtype/Vsize/Vreserved/Voffset', fread($fp, 14)); |
604 | 617 | $info = unpack('Vsize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vncolor/Vcolorimportant', fread($fp, 40)); |
605 | 618 | |
606 | - if ($header['type'] != 0x4D42) |
|
607 | - return false; |
|
619 | + if ($header['type'] != 0x4D42) { |
|
620 | + return false; |
|
621 | + } |
|
608 | 622 | |
609 | - if ($gd2) |
|
610 | - $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
611 | - else |
|
612 | - $dst_img = imagecreate($info['width'], $info['height']); |
|
623 | + if ($gd2) { |
|
624 | + $dst_img = imagecreatetruecolor($info['width'], $info['height']); |
|
625 | + } else { |
|
626 | + $dst_img = imagecreate($info['width'], $info['height']); |
|
627 | + } |
|
613 | 628 | |
614 | 629 | $palette_size = $header['offset'] - 54; |
615 | 630 | $info['ncolor'] = $palette_size / 4; |
@@ -635,8 +650,9 @@ discard block |
||
635 | 650 | fseek($fp, $header['offset'] + ($scan_line_size + $scan_line_align) * $l); |
636 | 651 | $scan_line = fread($fp, $scan_line_size); |
637 | 652 | |
638 | - if (strlen($scan_line) < $scan_line_size) |
|
639 | - continue; |
|
653 | + if (strlen($scan_line) < $scan_line_size) { |
|
654 | + continue; |
|
655 | + } |
|
640 | 656 | |
641 | 657 | if ($info['bits'] == 32) |
642 | 658 | { |
@@ -654,14 +670,14 @@ discard block |
||
654 | 670 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
655 | 671 | |
656 | 672 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
657 | - if ($color == -1) |
|
658 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
673 | + if ($color == -1) { |
|
674 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
675 | + } |
|
659 | 676 | } |
660 | 677 | |
661 | 678 | imagesetpixel($dst_img, $x, $y, $color); |
662 | 679 | } |
663 | - } |
|
664 | - elseif ($info['bits'] == 24) |
|
680 | + } elseif ($info['bits'] == 24) |
|
665 | 681 | { |
666 | 682 | $x = 0; |
667 | 683 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -676,14 +692,14 @@ discard block |
||
676 | 692 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
677 | 693 | |
678 | 694 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
679 | - if ($color == -1) |
|
680 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
695 | + if ($color == -1) { |
|
696 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
697 | + } |
|
681 | 698 | } |
682 | 699 | |
683 | 700 | imagesetpixel($dst_img, $x, $y, $color); |
684 | 701 | } |
685 | - } |
|
686 | - elseif ($info['bits'] == 16) |
|
702 | + } elseif ($info['bits'] == 16) |
|
687 | 703 | { |
688 | 704 | $x = 0; |
689 | 705 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -704,20 +720,20 @@ discard block |
||
704 | 720 | $color = imagecolorallocate($dst_img, $r, $g, $b); |
705 | 721 | |
706 | 722 | // Gah! Out of colors? Stupid GD 1... try anyhow. |
707 | - if ($color == -1) |
|
708 | - $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
723 | + if ($color == -1) { |
|
724 | + $color = imagecolorclosest($dst_img, $r, $g, $b); |
|
725 | + } |
|
709 | 726 | } |
710 | 727 | |
711 | 728 | imagesetpixel($dst_img, $x, $y, $color); |
712 | 729 | } |
713 | - } |
|
714 | - elseif ($info['bits'] == 8) |
|
730 | + } elseif ($info['bits'] == 8) |
|
715 | 731 | { |
716 | 732 | $x = 0; |
717 | - for ($j = 0; $j < $scan_line_size; $x++) |
|
718 | - imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
719 | - } |
|
720 | - elseif ($info['bits'] == 4) |
|
733 | + for ($j = 0; $j < $scan_line_size; $x++) { |
|
734 | + imagesetpixel($dst_img, $x, $y, $palette[ord($scan_line{$j++})]); |
|
735 | + } |
|
736 | + } elseif ($info['bits'] == 4) |
|
721 | 737 | { |
722 | 738 | $x = 0; |
723 | 739 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -725,11 +741,11 @@ discard block |
||
725 | 741 | $byte = ord($scan_line{$j++}); |
726 | 742 | |
727 | 743 | imagesetpixel($dst_img, $x, $y, $palette[(int) ($byte / 16)]); |
728 | - if (++$x < $info['width']) |
|
729 | - imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
744 | + if (++$x < $info['width']) { |
|
745 | + imagesetpixel($dst_img, $x, $y, $palette[$byte & 15]); |
|
746 | + } |
|
730 | 747 | } |
731 | - } |
|
732 | - elseif ($info['bits'] == 1) |
|
748 | + } elseif ($info['bits'] == 1) |
|
733 | 749 | { |
734 | 750 | $x = 0; |
735 | 751 | for ($j = 0; $j < $scan_line_size; $x++) |
@@ -738,7 +754,9 @@ discard block |
||
738 | 754 | |
739 | 755 | imagesetpixel($dst_img, $x, $y, $palette[(($byte) & 128) != 0]); |
740 | 756 | for ($shift = 1; $shift < 8; $shift++) { |
741 | - if (++$x < $info['width']) imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
757 | + if (++$x < $info['width']) { |
|
758 | + imagesetpixel($dst_img, $x, $y, $palette[(($byte << $shift) & 128) != 0]); |
|
759 | + } |
|
742 | 760 | } |
743 | 761 | } |
744 | 762 | } |
@@ -762,15 +780,18 @@ discard block |
||
762 | 780 | */ |
763 | 781 | function gif_outputAsPng($gif, $lpszFileName, $background_color = -1) |
764 | 782 | { |
765 | - if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') |
|
766 | - return false; |
|
783 | + if (!isset($gif) || @get_class($gif) != 'cgif' || !$gif->loaded || $lpszFileName == '') { |
|
784 | + return false; |
|
785 | + } |
|
767 | 786 | |
768 | 787 | $fd = $gif->get_png_data($background_color); |
769 | - if (strlen($fd) <= 0) |
|
770 | - return false; |
|
788 | + if (strlen($fd) <= 0) { |
|
789 | + return false; |
|
790 | + } |
|
771 | 791 | |
772 | - if (!($fh = @fopen($lpszFileName, 'wb'))) |
|
773 | - return false; |
|
792 | + if (!($fh = @fopen($lpszFileName, 'wb'))) { |
|
793 | + return false; |
|
794 | + } |
|
774 | 795 | |
775 | 796 | @fwrite($fh, $fd, strlen($fd)); |
776 | 797 | @fflush($fh); |
@@ -797,8 +818,9 @@ discard block |
||
797 | 818 | // What type are we going to be doing? |
798 | 819 | $imageType = $modSettings['visual_verification_type']; |
799 | 820 | // Special case to allow the admin center to show samples. |
800 | - if ($user_info['is_admin'] && isset($_GET['type'])) |
|
801 | - $imageType = (int) $_GET['type']; |
|
821 | + if ($user_info['is_admin'] && isset($_GET['type'])) { |
|
822 | + $imageType = (int) $_GET['type']; |
|
823 | + } |
|
802 | 824 | |
803 | 825 | // Some quick references for what we do. |
804 | 826 | // Do we show no, low or high noise? |
@@ -832,25 +854,28 @@ discard block |
||
832 | 854 | $character_spacing = 1; |
833 | 855 | |
834 | 856 | // What color is the background - generally white unless we're on "hard". |
835 | - if ($simpleBGColor) |
|
836 | - $background_color = array(255, 255, 255); |
|
837 | - else |
|
838 | - $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
857 | + if ($simpleBGColor) { |
|
858 | + $background_color = array(255, 255, 255); |
|
859 | + } else { |
|
860 | + $background_color = isset($settings['verification_background']) ? $settings['verification_background'] : array(236, 237, 243); |
|
861 | + } |
|
839 | 862 | |
840 | 863 | // The color of the characters shown (red, green, blue). |
841 | - if ($simpleFGColor) |
|
842 | - $foreground_color = array(0, 0, 0); |
|
843 | - else |
|
864 | + if ($simpleFGColor) { |
|
865 | + $foreground_color = array(0, 0, 0); |
|
866 | + } else |
|
844 | 867 | { |
845 | 868 | $foreground_color = array(64, 101, 136); |
846 | 869 | |
847 | 870 | // Has the theme author requested a custom color? |
848 | - if (isset($settings['verification_foreground'])) |
|
849 | - $foreground_color = $settings['verification_foreground']; |
|
871 | + if (isset($settings['verification_foreground'])) { |
|
872 | + $foreground_color = $settings['verification_foreground']; |
|
873 | + } |
|
850 | 874 | } |
851 | 875 | |
852 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
853 | - return false; |
|
876 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
877 | + return false; |
|
878 | + } |
|
854 | 879 | |
855 | 880 | // Get a list of the available fonts. |
856 | 881 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
@@ -861,25 +886,28 @@ discard block |
||
861 | 886 | { |
862 | 887 | if (preg_match('~^(.+)\.gdf$~', $entry, $matches) === 1) |
863 | 888 | { |
864 | - if ($endian ^ (strpos($entry, '_end.gdf') === false)) |
|
865 | - $font_list[] = $entry; |
|
889 | + if ($endian ^ (strpos($entry, '_end.gdf') === false)) { |
|
890 | + $font_list[] = $entry; |
|
891 | + } |
|
892 | + } elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) { |
|
893 | + $ttfont_list[] = $entry; |
|
866 | 894 | } |
867 | - elseif (preg_match('~^(.+)\.ttf$~', $entry, $matches) === 1) |
|
868 | - $ttfont_list[] = $entry; |
|
869 | 895 | } |
870 | 896 | |
871 | - if (empty($font_list)) |
|
872 | - return false; |
|
897 | + if (empty($font_list)) { |
|
898 | + return false; |
|
899 | + } |
|
873 | 900 | |
874 | 901 | // For non-hard things don't even change fonts. |
875 | 902 | if (!$varyFonts) |
876 | 903 | { |
877 | 904 | $font_list = array($font_list[0]); |
878 | 905 | // Try use Screenge if we can - it looks good! |
879 | - if (in_array('AnonymousPro.ttf', $ttfont_list)) |
|
880 | - $ttfont_list = array('AnonymousPro.ttf'); |
|
881 | - else |
|
882 | - $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
906 | + if (in_array('AnonymousPro.ttf', $ttfont_list)) { |
|
907 | + $ttfont_list = array('AnonymousPro.ttf'); |
|
908 | + } else { |
|
909 | + $ttfont_list = empty($ttfont_list) ? array() : array($ttfont_list[0]); |
|
910 | + } |
|
883 | 911 | |
884 | 912 | } |
885 | 913 | |
@@ -897,14 +925,16 @@ discard block |
||
897 | 925 | } |
898 | 926 | |
899 | 927 | // Load all fonts and determine the maximum font height. |
900 | - foreach ($loaded_fonts as $font_index => $dummy) |
|
901 | - $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
928 | + foreach ($loaded_fonts as $font_index => $dummy) { |
|
929 | + $loaded_fonts[$font_index] = imageloadfont($settings['default_theme_dir'] . '/fonts/' . $font_list[$font_index]); |
|
930 | + } |
|
902 | 931 | |
903 | 932 | // Determine the dimensions of each character. |
904 | - if ($imageType == 4 || $imageType == 5) |
|
905 | - $extra = 80; |
|
906 | - else |
|
907 | - $extra = 45; |
|
933 | + if ($imageType == 4 || $imageType == 5) { |
|
934 | + $extra = 80; |
|
935 | + } else { |
|
936 | + $extra = 45; |
|
937 | + } |
|
908 | 938 | |
909 | 939 | $total_width = $character_spacing * strlen($code) + $extra; |
910 | 940 | $max_height = 0; |
@@ -925,13 +955,15 @@ discard block |
||
925 | 955 | imagefilledrectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $bg_color); |
926 | 956 | |
927 | 957 | // Randomize the foreground color a little. |
928 | - for ($i = 0; $i < 3; $i++) |
|
929 | - $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
958 | + for ($i = 0; $i < 3; $i++) { |
|
959 | + $foreground_color[$i] = mt_rand(max($foreground_color[$i] - 3, 0), min($foreground_color[$i] + 3, 255)); |
|
960 | + } |
|
930 | 961 | $fg_color = imagecolorallocate($code_image, $foreground_color[0], $foreground_color[1], $foreground_color[2]); |
931 | 962 | |
932 | 963 | // Color for the dots. |
933 | - for ($i = 0; $i < 3; $i++) |
|
934 | - $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
964 | + for ($i = 0; $i < 3; $i++) { |
|
965 | + $dotbgcolor[$i] = $background_color[$i] < $foreground_color[$i] ? mt_rand(0, max($foreground_color[$i] - 20, 0)) : mt_rand(min($foreground_color[$i] + 20, 255), 255); |
|
966 | + } |
|
935 | 967 | $randomness_color = imagecolorallocate($code_image, $dotbgcolor[0], $dotbgcolor[1], $dotbgcolor[2]); |
936 | 968 | |
937 | 969 | // Some squares/rectanges for new extreme level |
@@ -957,10 +989,11 @@ discard block |
||
957 | 989 | $can_do_ttf = function_exists('imagettftext'); |
958 | 990 | |
959 | 991 | // How much rotation will we give? |
960 | - if ($rotationType == 'none') |
|
961 | - $angle = 0; |
|
962 | - else |
|
963 | - $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
992 | + if ($rotationType == 'none') { |
|
993 | + $angle = 0; |
|
994 | + } else { |
|
995 | + $angle = mt_rand(-100, 100) / ($rotationType == 'high' ? 6 : 10); |
|
996 | + } |
|
964 | 997 | |
965 | 998 | // What color shall we do it? |
966 | 999 | if ($fontColorType == 'cyclic') |
@@ -974,51 +1007,56 @@ discard block |
||
974 | 1007 | array(0, 0, 0), |
975 | 1008 | array(143, 39, 31), |
976 | 1009 | ); |
977 | - if (!isset($last_index)) |
|
978 | - $last_index = -1; |
|
1010 | + if (!isset($last_index)) { |
|
1011 | + $last_index = -1; |
|
1012 | + } |
|
979 | 1013 | $new_index = $last_index; |
980 | - while ($last_index == $new_index) |
|
981 | - $new_index = mt_rand(0, count($colors) - 1); |
|
1014 | + while ($last_index == $new_index) { |
|
1015 | + $new_index = mt_rand(0, count($colors) - 1); |
|
1016 | + } |
|
982 | 1017 | $char_fg_color = $colors[$new_index]; |
983 | 1018 | $last_index = $new_index; |
1019 | + } elseif ($fontColorType == 'random') { |
|
1020 | + $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
1021 | + } else { |
|
1022 | + $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
984 | 1023 | } |
985 | - elseif ($fontColorType == 'random') |
|
986 | - $char_fg_color = array(mt_rand(max($foreground_color[0] - 2, 0), $foreground_color[0]), mt_rand(max($foreground_color[1] - 2, 0), $foreground_color[1]), mt_rand(max($foreground_color[2] - 2, 0), $foreground_color[2])); |
|
987 | - else |
|
988 | - $char_fg_color = array($foreground_color[0], $foreground_color[1], $foreground_color[2]); |
|
989 | 1024 | |
990 | 1025 | if (!empty($can_do_ttf)) |
991 | 1026 | { |
992 | 1027 | // GD2 handles font size differently. |
993 | - if ($fontSizeRandom) |
|
994 | - $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
995 | - else |
|
996 | - $font_size = $gd2 ? 18 : 24; |
|
1028 | + if ($fontSizeRandom) { |
|
1029 | + $font_size = $gd2 ? mt_rand(17, 19) : mt_rand(18, 25); |
|
1030 | + } else { |
|
1031 | + $font_size = $gd2 ? 18 : 24; |
|
1032 | + } |
|
997 | 1033 | |
998 | 1034 | // Work out the sizes - also fix the character width cause TTF not quite so wide! |
999 | 1035 | $font_x = $fontHorSpace == 'minus' && $cur_x > 0 ? $cur_x - 3 : $cur_x + 5; |
1000 | 1036 | $font_y = $max_height - ($fontVerPos == 'vrandom' ? mt_rand(2, 8) : ($fontVerPos == 'random' ? mt_rand(3, 5) : 5)); |
1001 | 1037 | |
1002 | 1038 | // What font face? |
1003 | - if (!empty($ttfont_list)) |
|
1004 | - $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1039 | + if (!empty($ttfont_list)) { |
|
1040 | + $fontface = $settings['default_theme_dir'] . '/fonts/' . $ttfont_list[mt_rand(0, count($ttfont_list) - 1)]; |
|
1041 | + } |
|
1005 | 1042 | |
1006 | 1043 | // What color are we to do it in? |
1007 | 1044 | $is_reverse = $showReverseChars ? mt_rand(0, 1) : false; |
1008 | 1045 | $char_color = function_exists('imagecolorallocatealpha') && $fontTrans ? imagecolorallocatealpha($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2], 50) : imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2]); |
1009 | 1046 | |
1010 | 1047 | $fontcord = @imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $char_color, $fontface, $character['id']); |
1011 | - if (empty($fontcord)) |
|
1012 | - $can_do_ttf = false; |
|
1013 | - elseif ($is_reverse) |
|
1048 | + if (empty($fontcord)) { |
|
1049 | + $can_do_ttf = false; |
|
1050 | + } elseif ($is_reverse) |
|
1014 | 1051 | { |
1015 | 1052 | imagefilledpolygon($code_image, $fontcord, 4, $fg_color); |
1016 | 1053 | // Put the character back! |
1017 | 1054 | imagettftext($code_image, $font_size, $angle, $font_x, $font_y, $randomness_color, $fontface, $character['id']); |
1018 | 1055 | } |
1019 | 1056 | |
1020 | - if ($can_do_ttf) |
|
1021 | - $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1057 | + if ($can_do_ttf) { |
|
1058 | + $cur_x = max($fontcord[2], $fontcord[4]) + ($angle == 0 ? 0 : 3); |
|
1059 | + } |
|
1022 | 1060 | } |
1023 | 1061 | |
1024 | 1062 | if (!$can_do_ttf) |
@@ -1037,8 +1075,9 @@ discard block |
||
1037 | 1075 | } |
1038 | 1076 | |
1039 | 1077 | // Sorry, no rotation available. |
1040 | - else |
|
1041 | - imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1078 | + else { |
|
1079 | + imagechar($code_image, $loaded_fonts[$character['font']], $cur_x, floor(($max_height - $character['height']) / 2), $character['id'], imagecolorallocate($code_image, $char_fg_color[0], $char_fg_color[1], $char_fg_color[2])); |
|
1080 | + } |
|
1042 | 1081 | $cur_x += $character['width'] + $character_spacing; |
1043 | 1082 | } |
1044 | 1083 | } |
@@ -1051,17 +1090,22 @@ discard block |
||
1051 | 1090 | } |
1052 | 1091 | |
1053 | 1092 | // Make the background color transparent on the hard image. |
1054 | - if (!$simpleBGColor) |
|
1055 | - imagecolortransparent($code_image, $bg_color); |
|
1056 | - if ($hasBorder) |
|
1057 | - imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1093 | + if (!$simpleBGColor) { |
|
1094 | + imagecolortransparent($code_image, $bg_color); |
|
1095 | + } |
|
1096 | + if ($hasBorder) { |
|
1097 | + imagerectangle($code_image, 0, 0, $total_width - 1, $max_height - 1, $fg_color); |
|
1098 | + } |
|
1058 | 1099 | |
1059 | 1100 | // Add some noise to the background? |
1060 | 1101 | if ($noiseType != 'none') |
1061 | 1102 | { |
1062 | - for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) |
|
1063 | - for ($j = mt_rand(0, 10); $j < $total_width; $j += mt_rand(1, 10)) |
|
1064 | - imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1103 | + for ($i = mt_rand(0, 2); $i < $max_height; $i += mt_rand(1, 2)) { |
|
1104 | + for ($j = mt_rand(0, 10); |
|
1105 | + } |
|
1106 | + $j < $total_width; $j += mt_rand(1, 10)) { |
|
1107 | + imagesetpixel($code_image, $j, $i, mt_rand(0, 1) ? $fg_color : $randomness_color); |
|
1108 | + } |
|
1065 | 1109 | |
1066 | 1110 | // Put in some lines too? |
1067 | 1111 | if ($noiseType != 'extreme') |
@@ -1074,8 +1118,7 @@ discard block |
||
1074 | 1118 | $x1 = mt_rand(0, $total_width); |
1075 | 1119 | $x2 = mt_rand(0, $total_width); |
1076 | 1120 | $y1 = 0; $y2 = $max_height; |
1077 | - } |
|
1078 | - else |
|
1121 | + } else |
|
1079 | 1122 | { |
1080 | 1123 | $y1 = mt_rand(0, $max_height); |
1081 | 1124 | $y2 = mt_rand(0, $max_height); |
@@ -1084,8 +1127,7 @@ discard block |
||
1084 | 1127 | imagesetthickness($code_image, mt_rand(1, 2)); |
1085 | 1128 | imageline($code_image, $x1, $y1, $x2, $y2, mt_rand(0, 1) ? $fg_color : $randomness_color); |
1086 | 1129 | } |
1087 | - } |
|
1088 | - else |
|
1130 | + } else |
|
1089 | 1131 | { |
1090 | 1132 | // Put in some ellipse |
1091 | 1133 | $num_ellipse = $noiseType == 'extreme' ? mt_rand(6, 12) : mt_rand(2, 6); |
@@ -1105,8 +1147,7 @@ discard block |
||
1105 | 1147 | { |
1106 | 1148 | header('Content-type: image/gif'); |
1107 | 1149 | imagegif($code_image); |
1108 | - } |
|
1109 | - else |
|
1150 | + } else |
|
1110 | 1151 | { |
1111 | 1152 | header('Content-type: image/png'); |
1112 | 1153 | imagepng($code_image); |
@@ -1129,25 +1170,29 @@ discard block |
||
1129 | 1170 | { |
1130 | 1171 | global $settings; |
1131 | 1172 | |
1132 | - if (!is_dir($settings['default_theme_dir'] . '/fonts')) |
|
1133 | - return false; |
|
1173 | + if (!is_dir($settings['default_theme_dir'] . '/fonts')) { |
|
1174 | + return false; |
|
1175 | + } |
|
1134 | 1176 | |
1135 | 1177 | // Get a list of the available font directories. |
1136 | 1178 | $font_dir = dir($settings['default_theme_dir'] . '/fonts'); |
1137 | 1179 | $font_list = array(); |
1138 | - while ($entry = $font_dir->read()) |
|
1139 | - if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1180 | + while ($entry = $font_dir->read()) { |
|
1181 | + if ($entry[0] !== '.' && is_dir($settings['default_theme_dir'] . '/fonts/' . $entry) && file_exists($settings['default_theme_dir'] . '/fonts/' . $entry . '.gdf')) |
|
1140 | 1182 | $font_list[] = $entry; |
1183 | + } |
|
1141 | 1184 | |
1142 | - if (empty($font_list)) |
|
1143 | - return false; |
|
1185 | + if (empty($font_list)) { |
|
1186 | + return false; |
|
1187 | + } |
|
1144 | 1188 | |
1145 | 1189 | // Pick a random font. |
1146 | 1190 | $random_font = $font_list[array_rand($font_list)]; |
1147 | 1191 | |
1148 | 1192 | // Check if the given letter exists. |
1149 | - if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) |
|
1150 | - return false; |
|
1193 | + if (!file_exists($settings['default_theme_dir'] . '/fonts/' . $random_font . '/' . $letter . '.png')) { |
|
1194 | + return false; |
|
1195 | + } |
|
1151 | 1196 | |
1152 | 1197 | // Include it! |
1153 | 1198 | header('Content-type: image/png'); |