@@ -30,8 +30,9 @@ discard block |
||
30 | 30 | * @version 2.1 Beta 4 |
31 | 31 | */ |
32 | 32 | |
33 | -if (!defined('SMF')) |
|
33 | +if (!defined('SMF')) { |
|
34 | 34 | die('No direct access...'); |
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Subaction handler - manages the action and delegates control to the proper |
@@ -103,12 +104,12 @@ discard block |
||
103 | 104 | cache_put_data('minimized_css', null); |
104 | 105 | |
105 | 106 | // Follow the sa or just go to administration. |
106 | - if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) |
|
107 | - call_helper($subActions[$_GET['sa']]); |
|
108 | - |
|
109 | - else |
|
110 | - call_helper($subActions['admin']); |
|
111 | -} |
|
107 | + if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']])) { |
|
108 | + call_helper($subActions[$_GET['sa']]); |
|
109 | + } else { |
|
110 | + call_helper($subActions['admin']); |
|
111 | + } |
|
112 | + } |
|
112 | 113 | |
113 | 114 | /** |
114 | 115 | * This function allows administration of themes and their settings, |
@@ -130,15 +131,16 @@ discard block |
||
130 | 131 | checkSession(); |
131 | 132 | validateToken('admin-tm'); |
132 | 133 | |
133 | - if (isset($_POST['options']['known_themes'])) |
|
134 | - foreach ($_POST['options']['known_themes'] as $key => $id) |
|
134 | + if (isset($_POST['options']['known_themes'])) { |
|
135 | + foreach ($_POST['options']['known_themes'] as $key => $id) |
|
135 | 136 | $_POST['options']['known_themes'][$key] = (int) $id; |
137 | + } else { |
|
138 | + fatal_lang_error('themes_none_selectable', false); |
|
139 | + } |
|
136 | 140 | |
137 | - else |
|
138 | - fatal_lang_error('themes_none_selectable', false); |
|
139 | - |
|
140 | - if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) |
|
141 | - fatal_lang_error('themes_default_selectable', false); |
|
141 | + if (!in_array($_POST['options']['theme_guests'], $_POST['options']['known_themes'])) { |
|
142 | + fatal_lang_error('themes_default_selectable', false); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | // Commit the new settings. |
144 | 146 | updateSettings(array( |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | 'theme_guests' => $_POST['options']['theme_guests'], |
147 | 149 | 'knownThemes' => implode(',', $_POST['options']['known_themes']), |
148 | 150 | )); |
149 | - if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) |
|
150 | - updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
151 | + if ((int) $_POST['theme_reset'] == 0 || in_array($_POST['theme_reset'], $_POST['options']['known_themes'])) { |
|
152 | + updateMemberData(null, array('id_theme' => (int) $_POST['theme_reset'])); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=admin'); |
153 | 156 | } |
@@ -166,8 +169,9 @@ discard block |
||
166 | 169 | // Look for a non existent theme directory. (ie theme87.) |
167 | 170 | $theme_dir = $boarddir . '/Themes/theme'; |
168 | 171 | $i = 1; |
169 | - while (file_exists($theme_dir . $i)) |
|
170 | - $i++; |
|
172 | + while (file_exists($theme_dir . $i)) { |
|
173 | + $i++; |
|
174 | + } |
|
171 | 175 | |
172 | 176 | $context['new_theme_name'] = 'theme' . $i; |
173 | 177 | |
@@ -189,8 +193,9 @@ discard block |
||
189 | 193 | loadLanguage('Admin'); |
190 | 194 | isAllowedTo('admin_forum'); |
191 | 195 | |
192 | - if (isset($_REQUEST['th'])) |
|
193 | - return SetThemeSettings(); |
|
196 | + if (isset($_REQUEST['th'])) { |
|
197 | + return SetThemeSettings(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if (isset($_POST['save'])) |
196 | 201 | { |
@@ -274,12 +279,13 @@ discard block |
||
274 | 279 | $context['themes'] = array(); |
275 | 280 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
276 | 281 | { |
277 | - if (!isset($context['themes'][$row['id_theme']])) |
|
278 | - $context['themes'][$row['id_theme']] = array( |
|
282 | + if (!isset($context['themes'][$row['id_theme']])) { |
|
283 | + $context['themes'][$row['id_theme']] = array( |
|
279 | 284 | 'id' => $row['id_theme'], |
280 | 285 | 'num_default_options' => 0, |
281 | 286 | 'num_members' => 0, |
282 | 287 | ); |
288 | + } |
|
283 | 289 | $context['themes'][$row['id_theme']][$row['variable']] = $row['value']; |
284 | 290 | } |
285 | 291 | $smcFunc['db_free_result']($request); |
@@ -293,8 +299,9 @@ discard block |
||
293 | 299 | 'guest_member' => -1, |
294 | 300 | ) |
295 | 301 | ); |
296 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
297 | - $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
302 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
303 | + $context['themes'][$row['id_theme']]['num_default_options'] = $row['value']; |
|
304 | + } |
|
298 | 305 | $smcFunc['db_free_result']($request); |
299 | 306 | |
300 | 307 | // Need to make sure we don't do custom fields. |
@@ -305,8 +312,9 @@ discard block |
||
305 | 312 | ) |
306 | 313 | ); |
307 | 314 | $customFields = array(); |
308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
309 | - $customFields[] = $row['col_name']; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $customFields[] = $row['col_name']; |
|
317 | + } |
|
310 | 318 | $smcFunc['db_free_result']($request); |
311 | 319 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
312 | 320 | |
@@ -321,14 +329,16 @@ discard block |
||
321 | 329 | 'custom_fields' => empty($customFields) ? array() : $customFields, |
322 | 330 | ) |
323 | 331 | ); |
324 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
325 | - $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $context['themes'][$row['id_theme']]['num_members'] = $row['value']; |
|
334 | + } |
|
326 | 335 | $smcFunc['db_free_result']($request); |
327 | 336 | |
328 | 337 | // There has to be a Settings template! |
329 | - foreach ($context['themes'] as $k => $v) |
|
330 | - if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
338 | + foreach ($context['themes'] as $k => $v) { |
|
339 | + if (empty($v['theme_dir']) || (!file_exists($v['theme_dir'] . '/Settings.template.php') && empty($v['num_members']))) |
|
331 | 340 | unset($context['themes'][$k]); |
341 | + } |
|
332 | 342 | |
333 | 343 | loadTemplate('Themes'); |
334 | 344 | $context['sub_template'] = 'reset_list'; |
@@ -343,16 +353,19 @@ discard block |
||
343 | 353 | checkSession(); |
344 | 354 | validateToken('admin-sto'); |
345 | 355 | |
346 | - if (empty($_POST['options'])) |
|
347 | - $_POST['options'] = array(); |
|
348 | - if (empty($_POST['default_options'])) |
|
349 | - $_POST['default_options'] = array(); |
|
356 | + if (empty($_POST['options'])) { |
|
357 | + $_POST['options'] = array(); |
|
358 | + } |
|
359 | + if (empty($_POST['default_options'])) { |
|
360 | + $_POST['default_options'] = array(); |
|
361 | + } |
|
350 | 362 | |
351 | 363 | // Set up the sql query. |
352 | 364 | $setValues = array(); |
353 | 365 | |
354 | - foreach ($_POST['options'] as $opt => $val) |
|
355 | - $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
366 | + foreach ($_POST['options'] as $opt => $val) { |
|
367 | + $setValues[] = array(-1, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
368 | + } |
|
356 | 369 | |
357 | 370 | $old_settings = array(); |
358 | 371 | foreach ($_POST['default_options'] as $opt => $val) |
@@ -366,8 +379,8 @@ discard block |
||
366 | 379 | if (!empty($setValues)) |
367 | 380 | { |
368 | 381 | // Are there options in non-default themes set that should be cleared? |
369 | - if (!empty($old_settings)) |
|
370 | - $smcFunc['db_query']('', ' |
|
382 | + if (!empty($old_settings)) { |
|
383 | + $smcFunc['db_query']('', ' |
|
371 | 384 | DELETE FROM {db_prefix}themes |
372 | 385 | WHERE id_theme != {int:default_theme} |
373 | 386 | AND id_member = {int:guest_member} |
@@ -378,6 +391,7 @@ discard block |
||
378 | 391 | 'old_settings' => $old_settings, |
379 | 392 | ) |
380 | 393 | ); |
394 | + } |
|
381 | 395 | |
382 | 396 | $smcFunc['db_insert']('replace', |
383 | 397 | '{db_prefix}themes', |
@@ -391,8 +405,7 @@ discard block |
||
391 | 405 | cache_put_data('theme_settings-1', null, 90); |
392 | 406 | |
393 | 407 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
394 | - } |
|
395 | - elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
408 | + } elseif (isset($_POST['submit']) && $_POST['who'] == 1) |
|
396 | 409 | { |
397 | 410 | checkSession(); |
398 | 411 | validateToken('admin-sto'); |
@@ -405,9 +418,9 @@ discard block |
||
405 | 418 | $old_settings = array(); |
406 | 419 | foreach ($_POST['default_options'] as $opt => $val) |
407 | 420 | { |
408 | - if ($_POST['default_options_master'][$opt] == 0) |
|
409 | - continue; |
|
410 | - elseif ($_POST['default_options_master'][$opt] == 1) |
|
421 | + if ($_POST['default_options_master'][$opt] == 0) { |
|
422 | + continue; |
|
423 | + } elseif ($_POST['default_options_master'][$opt] == 1) |
|
411 | 424 | { |
412 | 425 | // Delete then insert for ease of database compatibility! |
413 | 426 | $smcFunc['db_query']('substring', ' |
@@ -433,8 +446,7 @@ discard block |
||
433 | 446 | ); |
434 | 447 | |
435 | 448 | $old_settings[] = $opt; |
436 | - } |
|
437 | - elseif ($_POST['default_options_master'][$opt] == 2) |
|
449 | + } elseif ($_POST['default_options_master'][$opt] == 2) |
|
438 | 450 | { |
439 | 451 | $smcFunc['db_query']('', ' |
440 | 452 | DELETE FROM {db_prefix}themes |
@@ -449,8 +461,8 @@ discard block |
||
449 | 461 | } |
450 | 462 | |
451 | 463 | // Delete options from other themes. |
452 | - if (!empty($old_settings)) |
|
453 | - $smcFunc['db_query']('', ' |
|
464 | + if (!empty($old_settings)) { |
|
465 | + $smcFunc['db_query']('', ' |
|
454 | 466 | DELETE FROM {db_prefix}themes |
455 | 467 | WHERE id_theme != {int:default_theme} |
456 | 468 | AND id_member > {int:no_member} |
@@ -461,12 +473,13 @@ discard block |
||
461 | 473 | 'old_settings' => $old_settings, |
462 | 474 | ) |
463 | 475 | ); |
476 | + } |
|
464 | 477 | |
465 | 478 | foreach ($_POST['options'] as $opt => $val) |
466 | 479 | { |
467 | - if ($_POST['options_master'][$opt] == 0) |
|
468 | - continue; |
|
469 | - elseif ($_POST['options_master'][$opt] == 1) |
|
480 | + if ($_POST['options_master'][$opt] == 0) { |
|
481 | + continue; |
|
482 | + } elseif ($_POST['options_master'][$opt] == 1) |
|
470 | 483 | { |
471 | 484 | // Delete then insert for ease of database compatibility - again! |
472 | 485 | $smcFunc['db_query']('substring', ' |
@@ -491,8 +504,7 @@ discard block |
||
491 | 504 | 'value' => (is_array($val) ? implode(',', $val) : $val), |
492 | 505 | ) |
493 | 506 | ); |
494 | - } |
|
495 | - elseif ($_POST['options_master'][$opt] == 2) |
|
507 | + } elseif ($_POST['options_master'][$opt] == 2) |
|
496 | 508 | { |
497 | 509 | $smcFunc['db_query']('', ' |
498 | 510 | DELETE FROM {db_prefix}themes |
@@ -509,8 +521,7 @@ discard block |
||
509 | 521 | } |
510 | 522 | |
511 | 523 | redirectexit('action=admin;area=theme;' . $context['session_var'] . '=' . $context['session_id'] . ';sa=reset'); |
512 | - } |
|
513 | - elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
524 | + } elseif (!empty($_GET['who']) && $_GET['who'] == 2) |
|
514 | 525 | { |
515 | 526 | checkSession('get'); |
516 | 527 | validateToken('admin-stor', 'request'); |
@@ -525,8 +536,9 @@ discard block |
||
525 | 536 | ) |
526 | 537 | ); |
527 | 538 | $customFields = array(); |
528 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
529 | - $customFields[] = $row['col_name']; |
|
539 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
540 | + $customFields[] = $row['col_name']; |
|
541 | + } |
|
530 | 542 | $smcFunc['db_free_result']($request); |
531 | 543 | } |
532 | 544 | $customFieldsQuery = empty($customFields) ? '' : ('AND variable NOT IN ({array_string:custom_fields})'); |
@@ -581,13 +593,13 @@ discard block |
||
581 | 593 | ) |
582 | 594 | ); |
583 | 595 | $context['theme_options'] = array(); |
584 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
585 | - $context['theme_options'][$row['variable']] = $row['value']; |
|
596 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
597 | + $context['theme_options'][$row['variable']] = $row['value']; |
|
598 | + } |
|
586 | 599 | $smcFunc['db_free_result']($request); |
587 | 600 | |
588 | 601 | $context['theme_options_reset'] = false; |
589 | - } |
|
590 | - else |
|
602 | + } else |
|
591 | 603 | { |
592 | 604 | $context['theme_options'] = array(); |
593 | 605 | $context['theme_options_reset'] = true; |
@@ -596,30 +608,32 @@ discard block |
||
596 | 608 | foreach ($context['options'] as $i => $setting) |
597 | 609 | { |
598 | 610 | // Just skip separators |
599 | - if (!is_array($setting)) |
|
600 | - continue; |
|
611 | + if (!is_array($setting)) { |
|
612 | + continue; |
|
613 | + } |
|
601 | 614 | |
602 | 615 | // Is this disabled? |
603 | 616 | if ($setting['id'] == 'calendar_start_day' && empty($modSettings['cal_enabled'])) |
604 | 617 | { |
605 | 618 | unset($context['options'][$i]); |
606 | 619 | continue; |
607 | - } |
|
608 | - elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
620 | + } elseif (($setting['id'] == 'topics_per_page' || $setting['id'] == 'messages_per_page') && !empty($modSettings['disableCustomPerPage'])) |
|
609 | 621 | { |
610 | 622 | unset($context['options'][$i]); |
611 | 623 | continue; |
612 | 624 | } |
613 | 625 | |
614 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
615 | - $context['options'][$i]['type'] = 'checkbox'; |
|
616 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
617 | - $context['options'][$i]['type'] = 'number'; |
|
618 | - elseif ($setting['type'] == 'string') |
|
619 | - $context['options'][$i]['type'] = 'text'; |
|
626 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
627 | + $context['options'][$i]['type'] = 'checkbox'; |
|
628 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
629 | + $context['options'][$i]['type'] = 'number'; |
|
630 | + } elseif ($setting['type'] == 'string') { |
|
631 | + $context['options'][$i]['type'] = 'text'; |
|
632 | + } |
|
620 | 633 | |
621 | - if (isset($setting['options'])) |
|
622 | - $context['options'][$i]['type'] = 'list'; |
|
634 | + if (isset($setting['options'])) { |
|
635 | + $context['options'][$i]['type'] = 'list'; |
|
636 | + } |
|
623 | 637 | |
624 | 638 | $context['options'][$i]['value'] = !isset($context['theme_options'][$setting['id']]) ? '' : $context['theme_options'][$setting['id']]; |
625 | 639 | } |
@@ -644,8 +658,9 @@ discard block |
||
644 | 658 | { |
645 | 659 | global $txt, $context, $settings, $modSettings, $smcFunc; |
646 | 660 | |
647 | - if (empty($_GET['th']) && empty($_GET['id'])) |
|
648 | - return ThemeAdmin(); |
|
661 | + if (empty($_GET['th']) && empty($_GET['id'])) { |
|
662 | + return ThemeAdmin(); |
|
663 | + } |
|
649 | 664 | |
650 | 665 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
651 | 666 | |
@@ -656,8 +671,9 @@ discard block |
||
656 | 671 | isAllowedTo('admin_forum'); |
657 | 672 | |
658 | 673 | // Validate inputs/user. |
659 | - if (empty($_GET['th'])) |
|
660 | - fatal_lang_error('no_theme', false); |
|
674 | + if (empty($_GET['th'])) { |
|
675 | + fatal_lang_error('no_theme', false); |
|
676 | + } |
|
661 | 677 | |
662 | 678 | // Fetch the smiley sets... |
663 | 679 | $sets = explode(',', 'none,' . $modSettings['smiley_sets_known']); |
@@ -665,8 +681,9 @@ discard block |
||
665 | 681 | $context['smiley_sets'] = array( |
666 | 682 | '' => $txt['smileys_no_default'] |
667 | 683 | ); |
668 | - foreach ($sets as $i => $set) |
|
669 | - $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
684 | + foreach ($sets as $i => $set) { |
|
685 | + $context['smiley_sets'][$set] = $smcFunc['htmlspecialchars']($set_names[$i]); |
|
686 | + } |
|
670 | 687 | |
671 | 688 | $old_id = $settings['theme_id']; |
672 | 689 | $old_settings = $settings; |
@@ -691,8 +708,9 @@ discard block |
||
691 | 708 | if (file_exists($settings['theme_dir'] . '/index.template.php')) |
692 | 709 | { |
693 | 710 | $file_contents = implode('', file($settings['theme_dir'] . '/index.template.php')); |
694 | - if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) |
|
695 | - eval('global $settings;' . $matches[0]); |
|
711 | + if (preg_match('~\$settings\[\'theme_variants\'\]\s*=(.+?);~', $file_contents, $matches)) { |
|
712 | + eval('global $settings;' . $matches[0]); |
|
713 | + } |
|
696 | 714 | } |
697 | 715 | |
698 | 716 | // Let mods hook into the theme settings. |
@@ -704,37 +722,45 @@ discard block |
||
704 | 722 | checkSession(); |
705 | 723 | validateToken('admin-sts'); |
706 | 724 | |
707 | - if (empty($_POST['options'])) |
|
708 | - $_POST['options'] = array(); |
|
709 | - if (empty($_POST['default_options'])) |
|
710 | - $_POST['default_options'] = array(); |
|
725 | + if (empty($_POST['options'])) { |
|
726 | + $_POST['options'] = array(); |
|
727 | + } |
|
728 | + if (empty($_POST['default_options'])) { |
|
729 | + $_POST['default_options'] = array(); |
|
730 | + } |
|
711 | 731 | |
712 | 732 | // Make sure items are cast correctly. |
713 | 733 | foreach ($context['theme_settings'] as $item) |
714 | 734 | { |
715 | 735 | // Disregard this item if this is just a separator. |
716 | - if (!is_array($item)) |
|
717 | - continue; |
|
736 | + if (!is_array($item)) { |
|
737 | + continue; |
|
738 | + } |
|
718 | 739 | |
719 | 740 | foreach (array('options', 'default_options') as $option) |
720 | 741 | { |
721 | - if (!isset($_POST[$option][$item['id']])) |
|
722 | - continue; |
|
742 | + if (!isset($_POST[$option][$item['id']])) { |
|
743 | + continue; |
|
744 | + } |
|
723 | 745 | // Checkbox. |
724 | - elseif (empty($item['type'])) |
|
725 | - $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
746 | + elseif (empty($item['type'])) { |
|
747 | + $_POST[$option][$item['id']] = $_POST[$option][$item['id']] ? 1 : 0; |
|
748 | + } |
|
726 | 749 | // Number |
727 | - elseif ($item['type'] == 'number') |
|
728 | - $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
750 | + elseif ($item['type'] == 'number') { |
|
751 | + $_POST[$option][$item['id']] = (int) $_POST[$option][$item['id']]; |
|
752 | + } |
|
729 | 753 | } |
730 | 754 | } |
731 | 755 | |
732 | 756 | // Set up the sql query. |
733 | 757 | $inserts = array(); |
734 | - foreach ($_POST['options'] as $opt => $val) |
|
735 | - $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
736 | - foreach ($_POST['default_options'] as $opt => $val) |
|
737 | - $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
758 | + foreach ($_POST['options'] as $opt => $val) { |
|
759 | + $inserts[] = array(0, $_GET['th'], $opt, is_array($val) ? implode(',', $val) : $val); |
|
760 | + } |
|
761 | + foreach ($_POST['default_options'] as $opt => $val) { |
|
762 | + $inserts[] = array(0, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
|
763 | + } |
|
738 | 764 | // If we're actually inserting something.. |
739 | 765 | if (!empty($inserts)) |
740 | 766 | { |
@@ -760,8 +786,9 @@ discard block |
||
760 | 786 | |
761 | 787 | foreach ($settings as $setting => $dummy) |
762 | 788 | { |
763 | - if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) |
|
764 | - $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
789 | + if (!in_array($setting, array('theme_url', 'theme_dir', 'images_url', 'template_dirs'))) { |
|
790 | + $settings[$setting] = htmlspecialchars__recursive($settings[$setting]); |
|
791 | + } |
|
765 | 792 | } |
766 | 793 | |
767 | 794 | $context['settings'] = $context['theme_settings']; |
@@ -770,18 +797,21 @@ discard block |
||
770 | 797 | foreach ($context['settings'] as $i => $setting) |
771 | 798 | { |
772 | 799 | // Separators are dummies, so leave them alone. |
773 | - if (!is_array($setting)) |
|
774 | - continue; |
|
800 | + if (!is_array($setting)) { |
|
801 | + continue; |
|
802 | + } |
|
775 | 803 | |
776 | - if (!isset($setting['type']) || $setting['type'] == 'bool') |
|
777 | - $context['settings'][$i]['type'] = 'checkbox'; |
|
778 | - elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') |
|
779 | - $context['settings'][$i]['type'] = 'number'; |
|
780 | - elseif ($setting['type'] == 'string') |
|
781 | - $context['settings'][$i]['type'] = 'text'; |
|
804 | + if (!isset($setting['type']) || $setting['type'] == 'bool') { |
|
805 | + $context['settings'][$i]['type'] = 'checkbox'; |
|
806 | + } elseif ($setting['type'] == 'int' || $setting['type'] == 'integer') { |
|
807 | + $context['settings'][$i]['type'] = 'number'; |
|
808 | + } elseif ($setting['type'] == 'string') { |
|
809 | + $context['settings'][$i]['type'] = 'text'; |
|
810 | + } |
|
782 | 811 | |
783 | - if (isset($setting['options'])) |
|
784 | - $context['settings'][$i]['type'] = 'list'; |
|
812 | + if (isset($setting['options'])) { |
|
813 | + $context['settings'][$i]['type'] = 'list'; |
|
814 | + } |
|
785 | 815 | |
786 | 816 | $context['settings'][$i]['value'] = !isset($settings[$setting['id']]) ? '' : $settings[$setting['id']]; |
787 | 817 | } |
@@ -834,8 +864,9 @@ discard block |
||
834 | 864 | $themeID = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
835 | 865 | |
836 | 866 | // You can't delete the default theme! |
837 | - if ($themeID == 1) |
|
838 | - fatal_lang_error('no_access', false); |
|
867 | + if ($themeID == 1) { |
|
868 | + fatal_lang_error('no_access', false); |
|
869 | + } |
|
839 | 870 | |
840 | 871 | $theme_info = get_single_theme($themeID); |
841 | 872 | |
@@ -843,8 +874,9 @@ discard block |
||
843 | 874 | remove_theme($themeID); |
844 | 875 | |
845 | 876 | // And remove all its files and folders too. |
846 | - if (!empty($theme_info) && !empty($theme_info['theme_dir'])) |
|
847 | - remove_dir($theme_info['theme_dir']); |
|
877 | + if (!empty($theme_info) && !empty($theme_info['theme_dir'])) { |
|
878 | + remove_dir($theme_info['theme_dir']); |
|
879 | + } |
|
848 | 880 | |
849 | 881 | // Go back to the list page. |
850 | 882 | redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id'] . ';done=removing'); |
@@ -869,12 +901,14 @@ discard block |
||
869 | 901 | $enableThemes = explode(',', $modSettings['enableThemes']); |
870 | 902 | |
871 | 903 | // Are we disabling it? |
872 | - if (isset($_GET['disabled'])) |
|
873 | - $enableThemes = array_diff($enableThemes, array($themeID)); |
|
904 | + if (isset($_GET['disabled'])) { |
|
905 | + $enableThemes = array_diff($enableThemes, array($themeID)); |
|
906 | + } |
|
874 | 907 | |
875 | 908 | // Nope? then enable it! |
876 | - else |
|
877 | - $enableThemes[] = (string) $themeID; |
|
909 | + else { |
|
910 | + $enableThemes[] = (string) $themeID; |
|
911 | + } |
|
878 | 912 | |
879 | 913 | // Update the setting. |
880 | 914 | $enableThemes = strtr(implode(',', $enableThemes), array(',,' => ',')); |
@@ -909,18 +943,21 @@ discard block |
||
909 | 943 | |
910 | 944 | $_SESSION['id_theme'] = 0; |
911 | 945 | |
912 | - if (isset($_GET['id'])) |
|
913 | - $_GET['th'] = $_GET['id']; |
|
946 | + if (isset($_GET['id'])) { |
|
947 | + $_GET['th'] = $_GET['id']; |
|
948 | + } |
|
914 | 949 | |
915 | 950 | // Saving a variant cause JS doesn't work - pretend it did ;) |
916 | 951 | if (isset($_POST['save'])) |
917 | 952 | { |
918 | 953 | // Which theme? |
919 | - foreach ($_POST['save'] as $k => $v) |
|
920 | - $_GET['th'] = (int) $k; |
|
954 | + foreach ($_POST['save'] as $k => $v) { |
|
955 | + $_GET['th'] = (int) $k; |
|
956 | + } |
|
921 | 957 | |
922 | - if (isset($_POST['vrt'][$k])) |
|
923 | - $_GET['vrt'] = $_POST['vrt'][$k]; |
|
958 | + if (isset($_POST['vrt'][$k])) { |
|
959 | + $_GET['vrt'] = $_POST['vrt'][$k]; |
|
960 | + } |
|
924 | 961 | } |
925 | 962 | |
926 | 963 | // Have we made a decision, or are we just browsing? |
@@ -998,8 +1035,9 @@ discard block |
||
998 | 1035 | else |
999 | 1036 | { |
1000 | 1037 | // The forum's default theme is always 0 and we |
1001 | - if (isset($_GET['th']) && $_GET['th'] == 0) |
|
1002 | - $_GET['th'] = $modSettings['theme_guests']; |
|
1038 | + if (isset($_GET['th']) && $_GET['th'] == 0) { |
|
1039 | + $_GET['th'] = $modSettings['theme_guests']; |
|
1040 | + } |
|
1003 | 1041 | |
1004 | 1042 | updateMemberData((int) $_REQUEST['u'], array('id_theme' => (int) $_GET['th'])); |
1005 | 1043 | |
@@ -1013,8 +1051,9 @@ discard block |
||
1013 | 1051 | ); |
1014 | 1052 | cache_put_data('theme_settings-' . $_GET['th'] . ':' . (int) $_REQUEST['u'], null, 90); |
1015 | 1053 | |
1016 | - if ($user_info['id'] == $_REQUEST['u']) |
|
1017 | - $_SESSION['id_variant'] = 0; |
|
1054 | + if ($user_info['id'] == $_REQUEST['u']) { |
|
1055 | + $_SESSION['id_variant'] = 0; |
|
1056 | + } |
|
1018 | 1057 | } |
1019 | 1058 | |
1020 | 1059 | redirectexit('action=profile;u=' . (int) $_REQUEST['u'] . ';area=theme'); |
@@ -1083,12 +1122,13 @@ discard block |
||
1083 | 1122 | ); |
1084 | 1123 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1085 | 1124 | { |
1086 | - if (!isset($context['available_themes'][$row['id_theme']])) |
|
1087 | - $context['available_themes'][$row['id_theme']] = array( |
|
1125 | + if (!isset($context['available_themes'][$row['id_theme']])) { |
|
1126 | + $context['available_themes'][$row['id_theme']] = array( |
|
1088 | 1127 | 'id' => $row['id_theme'], |
1089 | 1128 | 'selected' => $context['current_theme'] == $row['id_theme'], |
1090 | 1129 | 'num_users' => 0 |
1091 | 1130 | ); |
1131 | + } |
|
1092 | 1132 | $context['available_themes'][$row['id_theme']][$row['variable']] = $row['value']; |
1093 | 1133 | } |
1094 | 1134 | $smcFunc['db_free_result']($request); |
@@ -1101,9 +1141,9 @@ discard block |
||
1101 | 1141 | 'num_users' => 0 |
1102 | 1142 | ); |
1103 | 1143 | $guest_theme = 0; |
1144 | + } else { |
|
1145 | + $guest_theme = $modSettings['theme_guests']; |
|
1104 | 1146 | } |
1105 | - else |
|
1106 | - $guest_theme = $modSettings['theme_guests']; |
|
1107 | 1147 | |
1108 | 1148 | $request = $smcFunc['db_query']('', ' |
1109 | 1149 | SELECT id_theme, COUNT(*) AS the_count |
@@ -1116,15 +1156,17 @@ discard block |
||
1116 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1117 | 1157 | { |
1118 | 1158 | // Figure out which theme it is they are REALLY using. |
1119 | - if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) |
|
1120 | - $row['id_theme'] = $guest_theme; |
|
1121 | - elseif (empty($modSettings['theme_allow'])) |
|
1122 | - $row['id_theme'] = $guest_theme; |
|
1159 | + if (!empty($modSettings['knownThemes']) && !in_array($row['id_theme'], explode(',', $modSettings['knownThemes']))) { |
|
1160 | + $row['id_theme'] = $guest_theme; |
|
1161 | + } elseif (empty($modSettings['theme_allow'])) { |
|
1162 | + $row['id_theme'] = $guest_theme; |
|
1163 | + } |
|
1123 | 1164 | |
1124 | - if (isset($context['available_themes'][$row['id_theme']])) |
|
1125 | - $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1126 | - else |
|
1127 | - $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1165 | + if (isset($context['available_themes'][$row['id_theme']])) { |
|
1166 | + $context['available_themes'][$row['id_theme']]['num_users'] += $row['the_count']; |
|
1167 | + } else { |
|
1168 | + $context['available_themes'][$guest_theme]['num_users'] += $row['the_count']; |
|
1169 | + } |
|
1128 | 1170 | } |
1129 | 1171 | $smcFunc['db_free_result']($request); |
1130 | 1172 | |
@@ -1143,8 +1185,9 @@ discard block |
||
1143 | 1185 | 'id_member' => isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? array(-1, $context['current_member']) : array(-1), |
1144 | 1186 | ) |
1145 | 1187 | ); |
1146 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1147 | - $variant_preferences[$row['id_theme']] = $row['value']; |
|
1188 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1189 | + $variant_preferences[$row['id_theme']] = $row['value']; |
|
1190 | + } |
|
1148 | 1191 | $smcFunc['db_free_result']($request); |
1149 | 1192 | } |
1150 | 1193 | |
@@ -1155,17 +1198,18 @@ discard block |
||
1155 | 1198 | foreach ($context['available_themes'] as $id_theme => $theme_data) |
1156 | 1199 | { |
1157 | 1200 | // Don't try to load the forum or board default theme's data... it doesn't have any! |
1158 | - if ($id_theme == 0) |
|
1159 | - continue; |
|
1201 | + if ($id_theme == 0) { |
|
1202 | + continue; |
|
1203 | + } |
|
1160 | 1204 | |
1161 | 1205 | // The thumbnail needs the correct path. |
1162 | 1206 | $settings['images_url'] = &$theme_data['images_url']; |
1163 | 1207 | |
1164 | - if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) |
|
1165 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1166 | - elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) |
|
1167 | - include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1168 | - else |
|
1208 | + if (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php')) { |
|
1209 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'); |
|
1210 | + } elseif (file_exists($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php')) { |
|
1211 | + include($theme_data['theme_dir'] . '/languages/Settings.' . $language . '.php'); |
|
1212 | + } else |
|
1169 | 1213 | { |
1170 | 1214 | $txt['theme_thumbnail_href'] = $theme_data['images_url'] . '/thumbnail.png'; |
1171 | 1215 | $txt['theme_description'] = ''; |
@@ -1190,15 +1234,17 @@ discard block |
||
1190 | 1234 | loadLanguage('Settings'); |
1191 | 1235 | |
1192 | 1236 | $context['available_themes'][$id_theme]['variants'] = array(); |
1193 | - foreach ($settings['theme_variants'] as $variant) |
|
1194 | - $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1237 | + foreach ($settings['theme_variants'] as $variant) { |
|
1238 | + $context['available_themes'][$id_theme]['variants'][$variant] = array( |
|
1195 | 1239 | 'label' => isset($txt['variant_' . $variant]) ? $txt['variant_' . $variant] : $variant, |
1196 | 1240 | 'thumbnail' => !file_exists($theme_data['theme_dir'] . '/images/thumbnail.png') || file_exists($theme_data['theme_dir'] . '/images/thumbnail_' . $variant . '.png') ? $theme_data['images_url'] . '/thumbnail_' . $variant . '.png' : ($theme_data['images_url'] . '/thumbnail.png'), |
1197 | 1241 | ); |
1242 | + } |
|
1198 | 1243 | |
1199 | 1244 | $context['available_themes'][$id_theme]['selected_variant'] = isset($_GET['vrt']) ? $_GET['vrt'] : (!empty($variant_preferences[$id_theme]) ? $variant_preferences[$id_theme] : (!empty($settings['default_variant']) ? $settings['default_variant'] : $settings['theme_variants'][0])); |
1200 | - if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) |
|
1201 | - $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1245 | + if (!isset($context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail'])) { |
|
1246 | + $context['available_themes'][$id_theme]['selected_variant'] = $settings['theme_variants'][0]; |
|
1247 | + } |
|
1202 | 1248 | |
1203 | 1249 | $context['available_themes'][$id_theme]['thumbnail_href'] = $context['available_themes'][$id_theme]['variants'][$context['available_themes'][$id_theme]['selected_variant']]['thumbnail']; |
1204 | 1250 | // Allow themes to override the text. |
@@ -1214,8 +1260,9 @@ discard block |
||
1214 | 1260 | // As long as we're not doing the default theme... |
1215 | 1261 | if (!isset($_REQUEST['u']) || $_REQUEST['u'] >= 0) |
1216 | 1262 | { |
1217 | - if ($guest_theme != 0) |
|
1218 | - $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1263 | + if ($guest_theme != 0) { |
|
1264 | + $context['available_themes'][0] = $context['available_themes'][$guest_theme]; |
|
1265 | + } |
|
1219 | 1266 | |
1220 | 1267 | $context['available_themes'][0]['id'] = 0; |
1221 | 1268 | $context['available_themes'][0]['name'] = $txt['theme_forum_default']; |
@@ -1264,14 +1311,16 @@ discard block |
||
1264 | 1311 | $action = $smcFunc['htmlspecialchars'](trim($_GET['do'])); |
1265 | 1312 | |
1266 | 1313 | // Got any info from the specific form? |
1267 | - if (!isset($_POST['save_' . $action])) |
|
1268 | - fatal_lang_error('theme_install_no_action', false); |
|
1314 | + if (!isset($_POST['save_' . $action])) { |
|
1315 | + fatal_lang_error('theme_install_no_action', false); |
|
1316 | + } |
|
1269 | 1317 | |
1270 | 1318 | validateToken('admin-t-' . $action); |
1271 | 1319 | |
1272 | 1320 | // Hopefully the themes directory is writable, or we might have a problem. |
1273 | - if (!is_writable($themedir)) |
|
1274 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1321 | + if (!is_writable($themedir)) { |
|
1322 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1323 | + } |
|
1275 | 1324 | |
1276 | 1325 | // Call the function and handle the result. |
1277 | 1326 | $result = $subActions[$action](); |
@@ -1286,9 +1335,10 @@ discard block |
||
1286 | 1335 | } |
1287 | 1336 | |
1288 | 1337 | // Nope, show a nice error. |
1289 | - else |
|
1290 | - fatal_lang_error('theme_install_no_action', false); |
|
1291 | -} |
|
1338 | + else { |
|
1339 | + fatal_lang_error('theme_install_no_action', false); |
|
1340 | + } |
|
1341 | + } |
|
1292 | 1342 | |
1293 | 1343 | /** |
1294 | 1344 | * Installs a theme from a theme package. |
@@ -1304,8 +1354,9 @@ discard block |
||
1304 | 1354 | $dirtemp = $themedir . '/temp'; |
1305 | 1355 | |
1306 | 1356 | // Make sure the temp dir doesn't already exist |
1307 | - if (file_exists($dirtemp)) |
|
1308 | - remove_dir($dirtemp); |
|
1357 | + if (file_exists($dirtemp)) { |
|
1358 | + remove_dir($dirtemp); |
|
1359 | + } |
|
1309 | 1360 | |
1310 | 1361 | // Create the temp dir. |
1311 | 1362 | mkdir($dirtemp, 0777); |
@@ -1317,17 +1368,20 @@ discard block |
||
1317 | 1368 | smf_chmod($dirtemp, '0755'); |
1318 | 1369 | |
1319 | 1370 | // How about now? |
1320 | - if (!is_writable($dirtemp)) |
|
1321 | - fatal_lang_error('theme_install_write_error', 'critical'); |
|
1371 | + if (!is_writable($dirtemp)) { |
|
1372 | + fatal_lang_error('theme_install_write_error', 'critical'); |
|
1373 | + } |
|
1322 | 1374 | } |
1323 | 1375 | |
1324 | 1376 | // This happens when the admin session is gone and the user has to login again. |
1325 | - if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) |
|
1326 | - redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1377 | + if (!isset($_FILES) || !isset($_FILES['theme_gz']) || empty($_FILES['theme_gz'])) { |
|
1378 | + redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']); |
|
1379 | + } |
|
1327 | 1380 | |
1328 | 1381 | // Another error check layer, something went wrong with the upload. |
1329 | - if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) |
|
1330 | - fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1382 | + if (isset($_FILES['theme_gz']['error']) && $_FILES['theme_gz']['error'] != 0) { |
|
1383 | + fatal_lang_error('theme_install_error_file_' . $_FILES['theme_gz']['error'], false); |
|
1384 | + } |
|
1331 | 1385 | |
1332 | 1386 | // Get the theme's name. |
1333 | 1387 | $name = pathinfo($_FILES['theme_gz']['name'], PATHINFO_FILENAME); |
@@ -1358,11 +1412,10 @@ discard block |
||
1358 | 1412 | |
1359 | 1413 | // return all the info. |
1360 | 1414 | return $context['to_install']; |
1415 | + } else { |
|
1416 | + fatal_lang_error('theme_install_error_title', false); |
|
1417 | + } |
|
1361 | 1418 | } |
1362 | - |
|
1363 | - else |
|
1364 | - fatal_lang_error('theme_install_error_title', false); |
|
1365 | -} |
|
1366 | 1419 | |
1367 | 1420 | /** |
1368 | 1421 | * Makes a copy from the default theme, assigns a name for it and installs it. |
@@ -1376,15 +1429,17 @@ discard block |
||
1376 | 1429 | global $forum_version; |
1377 | 1430 | |
1378 | 1431 | // There's gotta be something to work with. |
1379 | - if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) |
|
1380 | - fatal_lang_error('theme_install_error_title', false); |
|
1432 | + if (!isset($_REQUEST['copy']) || empty($_REQUEST['copy'])) { |
|
1433 | + fatal_lang_error('theme_install_error_title', false); |
|
1434 | + } |
|
1381 | 1435 | |
1382 | 1436 | // Get a cleaner version. |
1383 | 1437 | $name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']); |
1384 | 1438 | |
1385 | 1439 | // Is there a theme already named like this? |
1386 | - if (file_exists($themedir . '/' . $name)) |
|
1387 | - fatal_lang_error('theme_install_already_dir', false); |
|
1440 | + if (file_exists($themedir . '/' . $name)) { |
|
1441 | + fatal_lang_error('theme_install_already_dir', false); |
|
1442 | + } |
|
1388 | 1443 | |
1389 | 1444 | // This is a brand new theme so set all possible values. |
1390 | 1445 | $context['to_install'] = array( |
@@ -1404,8 +1459,9 @@ discard block |
||
1404 | 1459 | |
1405 | 1460 | // Buy some time. |
1406 | 1461 | @set_time_limit(600); |
1407 | - if (function_exists('apache_reset_timeout')) |
|
1408 | - @apache_reset_timeout(); |
|
1462 | + if (function_exists('apache_reset_timeout')) { |
|
1463 | + @apache_reset_timeout(); |
|
1464 | + } |
|
1409 | 1465 | |
1410 | 1466 | // Create subdirectories for css and javascript files. |
1411 | 1467 | mkdir($context['to_install']['theme_dir'] . '/css', 0777); |
@@ -1441,12 +1497,13 @@ discard block |
||
1441 | 1497 | |
1442 | 1498 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1443 | 1499 | { |
1444 | - if ($row['variable'] == 'theme_templates') |
|
1445 | - $theme_templates = $row['value']; |
|
1446 | - elseif ($row['variable'] == 'theme_layers') |
|
1447 | - $theme_layers = $row['value']; |
|
1448 | - else |
|
1449 | - continue; |
|
1500 | + if ($row['variable'] == 'theme_templates') { |
|
1501 | + $theme_templates = $row['value']; |
|
1502 | + } elseif ($row['variable'] == 'theme_layers') { |
|
1503 | + $theme_layers = $row['value']; |
|
1504 | + } else { |
|
1505 | + continue; |
|
1506 | + } |
|
1450 | 1507 | } |
1451 | 1508 | |
1452 | 1509 | $smcFunc['db_free_result']($request); |
@@ -1505,12 +1562,14 @@ discard block |
||
1505 | 1562 | global $themedir, $themeurl, $context; |
1506 | 1563 | |
1507 | 1564 | // Cannot use the theme dir as a theme dir. |
1508 | - if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) |
|
1509 | - fatal_lang_error('theme_install_invalid_dir', false); |
|
1565 | + if (!isset($_REQUEST['theme_dir']) || empty($_REQUEST['theme_dir']) || rtrim(realpath($_REQUEST['theme_dir']), '/\\') == realpath($themedir)) { |
|
1566 | + fatal_lang_error('theme_install_invalid_dir', false); |
|
1567 | + } |
|
1510 | 1568 | |
1511 | 1569 | // Check is there is "something" on the dir. |
1512 | - elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) |
|
1513 | - fatal_lang_error('theme_install_error', false); |
|
1570 | + elseif (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) { |
|
1571 | + fatal_lang_error('theme_install_error', false); |
|
1572 | + } |
|
1514 | 1573 | |
1515 | 1574 | $name = basename($_REQUEST['theme_dir']); |
1516 | 1575 | $name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $name); |
@@ -1554,24 +1613,27 @@ discard block |
||
1554 | 1613 | } |
1555 | 1614 | |
1556 | 1615 | // Any special layers? |
1557 | - if (isset($settings['catch_action']['layers'])) |
|
1558 | - $context['template_layers'] = $settings['catch_action']['layers']; |
|
1616 | + if (isset($settings['catch_action']['layers'])) { |
|
1617 | + $context['template_layers'] = $settings['catch_action']['layers']; |
|
1618 | + } |
|
1559 | 1619 | |
1560 | 1620 | // Any function to call? |
1561 | 1621 | if (isset($settings['catch_action']['function'])) |
1562 | 1622 | { |
1563 | 1623 | $hook = $settings['catch_action']['function']; |
1564 | 1624 | |
1565 | - if (!isset($settings['catch_action']['filename'])) |
|
1566 | - $settings['catch_action']['filename'] = ''; |
|
1625 | + if (!isset($settings['catch_action']['filename'])) { |
|
1626 | + $settings['catch_action']['filename'] = ''; |
|
1627 | + } |
|
1567 | 1628 | |
1568 | 1629 | add_integration_function('integrate_wrap_action', $hook, false, $settings['catch_action']['filename'], false); |
1569 | 1630 | call_integration_hook('integrate_wrap_action'); |
1570 | 1631 | } |
1571 | 1632 | // And finally, the main sub template ;). |
1572 | - if (isset($settings['catch_action']['sub_template'])) |
|
1573 | - $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1574 | -} |
|
1633 | + if (isset($settings['catch_action']['sub_template'])) { |
|
1634 | + $context['sub_template'] = $settings['catch_action']['sub_template']; |
|
1635 | + } |
|
1636 | + } |
|
1575 | 1637 | |
1576 | 1638 | /** |
1577 | 1639 | * Set an option via javascript. |
@@ -1590,12 +1652,14 @@ discard block |
||
1590 | 1652 | checkSession('get'); |
1591 | 1653 | |
1592 | 1654 | // This good-for-nothing pixel is being used to keep the session alive. |
1593 | - if (empty($_GET['var']) || !isset($_GET['val'])) |
|
1594 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1655 | + if (empty($_GET['var']) || !isset($_GET['val'])) { |
|
1656 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1657 | + } |
|
1595 | 1658 | |
1596 | 1659 | // Sorry, guests can't go any further than this. |
1597 | - if ($user_info['is_guest'] || $user_info['id'] == 0) |
|
1598 | - obExit(false); |
|
1660 | + if ($user_info['is_guest'] || $user_info['id'] == 0) { |
|
1661 | + obExit(false); |
|
1662 | + } |
|
1599 | 1663 | |
1600 | 1664 | $reservedVars = array( |
1601 | 1665 | 'actual_theme_url', |
@@ -1618,8 +1682,9 @@ discard block |
||
1618 | 1682 | ); |
1619 | 1683 | |
1620 | 1684 | // Can't change reserved vars. |
1621 | - if (in_array(strtolower($_GET['var']), $reservedVars)) |
|
1622 | - redirectexit($settings['images_url'] . '/blank.png'); |
|
1685 | + if (in_array(strtolower($_GET['var']), $reservedVars)) { |
|
1686 | + redirectexit($settings['images_url'] . '/blank.png'); |
|
1687 | + } |
|
1623 | 1688 | |
1624 | 1689 | // Use a specific theme? |
1625 | 1690 | if (isset($_GET['th']) || isset($_GET['id'])) |
@@ -1635,8 +1700,9 @@ discard block |
||
1635 | 1700 | { |
1636 | 1701 | $options['admin_preferences'] = !empty($options['admin_preferences']) ? $smcFunc['json_decode']($options['admin_preferences'], true) : array(); |
1637 | 1702 | // New thingy... |
1638 | - if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) |
|
1639 | - $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1703 | + if (isset($_GET['admin_key']) && strlen($_GET['admin_key']) < 5) { |
|
1704 | + $options['admin_preferences'][$_GET['admin_key']] = $_GET['val']; |
|
1705 | + } |
|
1640 | 1706 | |
1641 | 1707 | // Change the value to be something nice, |
1642 | 1708 | $_GET['val'] = $smcFunc['json_encode']($options['admin_preferences']); |
@@ -1666,8 +1732,9 @@ discard block |
||
1666 | 1732 | global $context, $scripturl, $boarddir, $smcFunc, $txt; |
1667 | 1733 | |
1668 | 1734 | // @todo Should this be removed? |
1669 | - if (isset($_REQUEST['preview'])) |
|
1670 | - die('die() with fire'); |
|
1735 | + if (isset($_REQUEST['preview'])) { |
|
1736 | + die('die() with fire'); |
|
1737 | + } |
|
1671 | 1738 | |
1672 | 1739 | isAllowedTo('admin_forum'); |
1673 | 1740 | loadTemplate('Themes'); |
@@ -1681,11 +1748,11 @@ discard block |
||
1681 | 1748 | foreach ($context['themes'] as $key => $theme) |
1682 | 1749 | { |
1683 | 1750 | // There has to be a Settings template! |
1684 | - if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) |
|
1685 | - unset($context['themes'][$key]); |
|
1686 | - |
|
1687 | - else |
|
1688 | - $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1751 | + if (!file_exists($theme['theme_dir'] . '/index.template.php') && !file_exists($theme['theme_dir'] . '/css/index.css')) { |
|
1752 | + unset($context['themes'][$key]); |
|
1753 | + } else { |
|
1754 | + $context['themes'][$key]['can_edit_style'] = file_exists($theme['theme_dir'] . '/css/index.css'); |
|
1755 | + } |
|
1689 | 1756 | } |
1690 | 1757 | |
1691 | 1758 | $context['sub_template'] = 'edit_list'; |
@@ -1700,22 +1767,24 @@ discard block |
||
1700 | 1767 | $context['theme_id'] = $currentTheme['id']; |
1701 | 1768 | $context['browse_title'] = sprintf($txt['themeadmin_browsing_theme'], $currentTheme['name']); |
1702 | 1769 | |
1703 | - if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) |
|
1704 | - fatal_lang_error('theme_edit_missing', false); |
|
1770 | + if (!file_exists($currentTheme['theme_dir'] . '/index.template.php') && !file_exists($currentTheme['theme_dir'] . '/css/index.css')) { |
|
1771 | + fatal_lang_error('theme_edit_missing', false); |
|
1772 | + } |
|
1705 | 1773 | |
1706 | 1774 | if (!isset($_REQUEST['filename'])) |
1707 | 1775 | { |
1708 | 1776 | if (isset($_GET['directory'])) |
1709 | 1777 | { |
1710 | - if (substr($_GET['directory'], 0, 1) == '.') |
|
1711 | - $_GET['directory'] = ''; |
|
1712 | - else |
|
1778 | + if (substr($_GET['directory'], 0, 1) == '.') { |
|
1779 | + $_GET['directory'] = ''; |
|
1780 | + } else |
|
1713 | 1781 | { |
1714 | 1782 | $_GET['directory'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_GET['directory']); |
1715 | 1783 | |
1716 | 1784 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_GET['directory']); |
1717 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1718 | - $_GET['directory'] = ''; |
|
1785 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1786 | + $_GET['directory'] = ''; |
|
1787 | + } |
|
1719 | 1788 | } |
1720 | 1789 | } |
1721 | 1790 | |
@@ -1734,37 +1803,39 @@ discard block |
||
1734 | 1803 | 'href' => $scripturl . '?action=admin;area=theme;th=' . $_GET['th'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=edit;directory=' . $temp, |
1735 | 1804 | 'size' => '', |
1736 | 1805 | )); |
1806 | + } else { |
|
1807 | + $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1737 | 1808 | } |
1738 | - else |
|
1739 | - $context['theme_files'] = get_file_listing($currentTheme['theme_dir'], ''); |
|
1740 | 1809 | |
1741 | 1810 | $context['sub_template'] = 'edit_browse'; |
1742 | 1811 | |
1743 | 1812 | return; |
1744 | - } |
|
1745 | - else |
|
1813 | + } else |
|
1746 | 1814 | { |
1747 | - if (substr($_REQUEST['filename'], 0, 1) == '.') |
|
1748 | - $_REQUEST['filename'] = ''; |
|
1749 | - else |
|
1815 | + if (substr($_REQUEST['filename'], 0, 1) == '.') { |
|
1816 | + $_REQUEST['filename'] = ''; |
|
1817 | + } else |
|
1750 | 1818 | { |
1751 | 1819 | $_REQUEST['filename'] = preg_replace(array('~^[\./\\:\0\n\r]+~', '~[\\\\]~', '~/[\./]+~'), array('', '/', '/'), $_REQUEST['filename']); |
1752 | 1820 | |
1753 | 1821 | $temp = realpath($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
1754 | - if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) |
|
1755 | - $_REQUEST['filename'] = ''; |
|
1822 | + if (empty($temp) || substr($temp, 0, strlen(realpath($currentTheme['theme_dir']))) != realpath($currentTheme['theme_dir'])) { |
|
1823 | + $_REQUEST['filename'] = ''; |
|
1824 | + } |
|
1756 | 1825 | } |
1757 | 1826 | |
1758 | - if (empty($_REQUEST['filename'])) |
|
1759 | - fatal_lang_error('theme_edit_missing', false); |
|
1827 | + if (empty($_REQUEST['filename'])) { |
|
1828 | + fatal_lang_error('theme_edit_missing', false); |
|
1829 | + } |
|
1760 | 1830 | } |
1761 | 1831 | |
1762 | 1832 | if (isset($_POST['save'])) |
1763 | 1833 | { |
1764 | 1834 | if (checkSession('post', '', false) == '' && validateToken('admin-te-' . md5($_GET['th'] . '-' . $_REQUEST['filename']), 'post', false) == true) |
1765 | 1835 | { |
1766 | - if (is_array($_POST['entire_file'])) |
|
1767 | - $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1836 | + if (is_array($_POST['entire_file'])) { |
|
1837 | + $_POST['entire_file'] = implode("\n", $_POST['entire_file']); |
|
1838 | + } |
|
1768 | 1839 | |
1769 | 1840 | $_POST['entire_file'] = rtrim(strtr($_POST['entire_file'], array("\r" => '', ' ' => "\t"))); |
1770 | 1841 | |
@@ -1776,10 +1847,11 @@ discard block |
||
1776 | 1847 | fclose($fp); |
1777 | 1848 | |
1778 | 1849 | $error = @file_get_contents($currentTheme['theme_url'] . '/tmp_' . session_id() . '.php'); |
1779 | - if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) |
|
1780 | - $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1781 | - else |
|
1782 | - unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1850 | + if (preg_match('~ <b>(\d+)</b><br( /)?' . '>$~i', $error) != 0) { |
|
1851 | + $error_file = $currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'; |
|
1852 | + } else { |
|
1853 | + unlink($currentTheme['theme_dir'] . '/tmp_' . session_id() . '.php'); |
|
1854 | + } |
|
1783 | 1855 | } |
1784 | 1856 | |
1785 | 1857 | if (!isset($error_file)) |
@@ -1800,10 +1872,11 @@ discard block |
||
1800 | 1872 | $context['sub_template'] = 'edit_file'; |
1801 | 1873 | |
1802 | 1874 | // Recycle the submitted data. |
1803 | - if (is_array($_POST['entire_file'])) |
|
1804 | - $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1805 | - else |
|
1806 | - $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1875 | + if (is_array($_POST['entire_file'])) { |
|
1876 | + $context['entire_file'] = $smcFunc['htmlspecialchars'](implode("\n", $_POST['entire_file'])); |
|
1877 | + } else { |
|
1878 | + $context['entire_file'] = $smcFunc['htmlspecialchars']($_POST['entire_file']); |
|
1879 | + } |
|
1807 | 1880 | |
1808 | 1881 | $context['edit_filename'] = $smcFunc['htmlspecialchars']($_POST['filename']); |
1809 | 1882 | |
@@ -1826,17 +1899,17 @@ discard block |
||
1826 | 1899 | $context['sub_template'] = 'edit_style'; |
1827 | 1900 | |
1828 | 1901 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(file_get_contents($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']), array("\t" => ' '))); |
1829 | - } |
|
1830 | - elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1902 | + } elseif (substr($_REQUEST['filename'], -13) == '.template.php') |
|
1831 | 1903 | { |
1832 | 1904 | $context['sub_template'] = 'edit_template'; |
1833 | 1905 | |
1834 | - if (!isset($error_file)) |
|
1835 | - $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1836 | - else |
|
1906 | + if (!isset($error_file)) { |
|
1907 | + $file_data = file($currentTheme['theme_dir'] . '/' . $_REQUEST['filename']); |
|
1908 | + } else |
|
1837 | 1909 | { |
1838 | - if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) |
|
1839 | - $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1910 | + if (preg_match('~(<b>.+?</b>:.+?<b>).+?(</b>.+?<b>\d+</b>)<br( /)?' . '>$~i', $error, $match) != 0) { |
|
1911 | + $context['parse_error'] = $match[1] . $_REQUEST['filename'] . $match[2]; |
|
1912 | + } |
|
1840 | 1913 | $file_data = file($error_file); |
1841 | 1914 | unlink($error_file); |
1842 | 1915 | } |
@@ -1850,8 +1923,9 @@ discard block |
||
1850 | 1923 | // Try to format the functions a little nicer... |
1851 | 1924 | $context['file_parts'][$j]['data'] = trim($context['file_parts'][$j]['data']) . "\n"; |
1852 | 1925 | |
1853 | - if (empty($context['file_parts'][$j]['lines'])) |
|
1854 | - unset($context['file_parts'][$j]); |
|
1926 | + if (empty($context['file_parts'][$j]['lines'])) { |
|
1927 | + unset($context['file_parts'][$j]); |
|
1928 | + } |
|
1855 | 1929 | $context['file_parts'][++$j] = array('lines' => 0, 'line' => $i + 1, 'data' => ''); |
1856 | 1930 | } |
1857 | 1931 | |
@@ -1860,8 +1934,7 @@ discard block |
||
1860 | 1934 | } |
1861 | 1935 | |
1862 | 1936 | $context['entire_file'] = $smcFunc['htmlspecialchars'](strtr(implode('', $file_data), array("\t" => ' '))); |
1863 | - } |
|
1864 | - else |
|
1937 | + } else |
|
1865 | 1938 | { |
1866 | 1939 | $context['sub_template'] = 'edit_file'; |
1867 | 1940 | |
@@ -1887,8 +1960,9 @@ discard block |
||
1887 | 1960 | |
1888 | 1961 | $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id']; |
1889 | 1962 | |
1890 | - if (empty($_GET['th'])) |
|
1891 | - fatal_lang_error('theme_install_invalid_id'); |
|
1963 | + if (empty($_GET['th'])) { |
|
1964 | + fatal_lang_error('theme_install_invalid_id'); |
|
1965 | + } |
|
1892 | 1966 | |
1893 | 1967 | // Get the theme info. |
1894 | 1968 | $theme = get_single_theme($_GET['th']); |
@@ -1896,25 +1970,24 @@ discard block |
||
1896 | 1970 | |
1897 | 1971 | if (isset($_REQUEST['template']) && preg_match('~[\./\\\\:\0]~', $_REQUEST['template']) == 0) |
1898 | 1972 | { |
1899 | - if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) |
|
1900 | - $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1901 | - |
|
1902 | - else |
|
1903 | - fatal_lang_error('no_access', false); |
|
1973 | + if (file_exists($settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php')) { |
|
1974 | + $filename = $settings['default_theme_dir'] . '/' . $_REQUEST['template'] . '.template.php'; |
|
1975 | + } else { |
|
1976 | + fatal_lang_error('no_access', false); |
|
1977 | + } |
|
1904 | 1978 | |
1905 | 1979 | $fp = fopen($theme['theme_dir'] . '/' . $_REQUEST['template'] . '.template.php', 'w'); |
1906 | 1980 | fwrite($fp, file_get_contents($filename)); |
1907 | 1981 | fclose($fp); |
1908 | 1982 | |
1909 | 1983 | redirectexit('action=admin;area=theme;th=' . $context['theme_id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';sa=copy'); |
1910 | - } |
|
1911 | - elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1984 | + } elseif (isset($_REQUEST['lang_file']) && preg_match('~^[^\./\\\\:\0]\.[^\./\\\\:\0]$~', $_REQUEST['lang_file']) != 0) |
|
1912 | 1985 | { |
1913 | - if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) |
|
1914 | - $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1915 | - |
|
1916 | - else |
|
1917 | - fatal_lang_error('no_access', false); |
|
1986 | + if (file_exists($settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php')) { |
|
1987 | + $filename = $settings['default_theme_dir'] . '/languages/' . $_REQUEST['template'] . '.php'; |
|
1988 | + } else { |
|
1989 | + fatal_lang_error('no_access', false); |
|
1990 | + } |
|
1918 | 1991 | |
1919 | 1992 | $fp = fopen($theme['theme_dir'] . '/languages/' . $_REQUEST['lang_file'] . '.php', 'w'); |
1920 | 1993 | fwrite($fp, file_get_contents($filename)); |
@@ -1929,16 +2002,18 @@ discard block |
||
1929 | 2002 | $dir = dir($settings['default_theme_dir']); |
1930 | 2003 | while ($entry = $dir->read()) |
1931 | 2004 | { |
1932 | - if (substr($entry, -13) == '.template.php') |
|
1933 | - $templates[] = substr($entry, 0, -13); |
|
2005 | + if (substr($entry, -13) == '.template.php') { |
|
2006 | + $templates[] = substr($entry, 0, -13); |
|
2007 | + } |
|
1934 | 2008 | } |
1935 | 2009 | $dir->close(); |
1936 | 2010 | |
1937 | 2011 | $dir = dir($settings['default_theme_dir'] . '/languages'); |
1938 | 2012 | while ($entry = $dir->read()) |
1939 | 2013 | { |
1940 | - if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) |
|
1941 | - $lang_files[] = $matches[1]; |
|
2014 | + if (preg_match('~^([^\.]+\.[^\.]+)\.php$~', $entry, $matches)) { |
|
2015 | + $lang_files[] = $matches[1]; |
|
2016 | + } |
|
1942 | 2017 | } |
1943 | 2018 | $dir->close(); |
1944 | 2019 | |
@@ -1946,21 +2021,23 @@ discard block |
||
1946 | 2021 | natcasesort($lang_files); |
1947 | 2022 | |
1948 | 2023 | $context['available_templates'] = array(); |
1949 | - foreach ($templates as $template) |
|
1950 | - $context['available_templates'][$template] = array( |
|
2024 | + foreach ($templates as $template) { |
|
2025 | + $context['available_templates'][$template] = array( |
|
1951 | 2026 | 'filename' => $template . '.template.php', |
1952 | 2027 | 'value' => $template, |
1953 | 2028 | 'already_exists' => false, |
1954 | 2029 | 'can_copy' => is_writable($theme['theme_dir']), |
1955 | 2030 | ); |
2031 | + } |
|
1956 | 2032 | $context['available_language_files'] = array(); |
1957 | - foreach ($lang_files as $file) |
|
1958 | - $context['available_language_files'][$file] = array( |
|
2033 | + foreach ($lang_files as $file) { |
|
2034 | + $context['available_language_files'][$file] = array( |
|
1959 | 2035 | 'filename' => $file . '.php', |
1960 | 2036 | 'value' => $file, |
1961 | 2037 | 'already_exists' => false, |
1962 | 2038 | 'can_copy' => file_exists($theme['theme_dir'] . '/languages') ? is_writable($theme['theme_dir'] . '/languages') : is_writable($theme['theme_dir']), |
1963 | 2039 | ); |
2040 | + } |
|
1964 | 2041 | |
1965 | 2042 | $dir = dir($theme['theme_dir']); |
1966 | 2043 | while ($entry = $dir->read()) |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Begin the registration process. |
@@ -29,19 +30,23 @@ discard block |
||
29 | 30 | global $language, $scripturl, $smcFunc, $sourcedir, $cur_profile; |
30 | 31 | |
31 | 32 | // Is this an incoming AJAX check? |
32 | - if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') |
|
33 | - return RegisterCheckUsername(); |
|
33 | + if (isset($_GET['sa']) && $_GET['sa'] == 'usernamecheck') { |
|
34 | + return RegisterCheckUsername(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // Check if the administrator has it disabled. |
36 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') |
|
37 | - fatal_lang_error('registration_disabled', false); |
|
38 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == '3') { |
|
39 | + fatal_lang_error('registration_disabled', false); |
|
40 | + } |
|
38 | 41 | |
39 | 42 | // If this user is an admin - redirect them to the admin registration page. |
40 | - if (allowedTo('moderate_forum') && !$user_info['is_guest']) |
|
41 | - redirectexit('action=admin;area=regcenter;sa=register'); |
|
43 | + if (allowedTo('moderate_forum') && !$user_info['is_guest']) { |
|
44 | + redirectexit('action=admin;area=regcenter;sa=register'); |
|
45 | + } |
|
42 | 46 | // You are not a guest, so you are a member - and members don't get to register twice! |
43 | - elseif (empty($user_info['is_guest'])) |
|
44 | - redirectexit(); |
|
47 | + elseif (empty($user_info['is_guest'])) { |
|
48 | + redirectexit(); |
|
49 | + } |
|
45 | 50 | |
46 | 51 | loadLanguage('Login'); |
47 | 52 | loadTemplate('Register'); |
@@ -82,16 +87,18 @@ discard block |
||
82 | 87 | } |
83 | 88 | } |
84 | 89 | // Make sure they don't squeeze through without agreeing. |
85 | - elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) |
|
86 | - $current_step = 1; |
|
90 | + elseif ($current_step > 1 && $context['require_agreement'] && !$context['registration_passed_agreement']) { |
|
91 | + $current_step = 1; |
|
92 | + } |
|
87 | 93 | |
88 | 94 | // Show the user the right form. |
89 | 95 | $context['sub_template'] = $current_step == 1 ? 'registration_agreement' : 'registration_form'; |
90 | 96 | $context['page_title'] = $current_step == 1 ? $txt['registration_agreement'] : $txt['registration_form']; |
91 | 97 | |
92 | 98 | // Kinda need this. |
93 | - if ($context['sub_template'] == 'registration_form') |
|
94 | - loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
99 | + if ($context['sub_template'] == 'registration_form') { |
|
100 | + loadJavaScriptFile('register.js', array('defer' => false), 'smf_register'); |
|
101 | + } |
|
95 | 102 | |
96 | 103 | // Add the register chain to the link tree. |
97 | 104 | $context['linktree'][] = array( |
@@ -100,24 +107,26 @@ discard block |
||
100 | 107 | ); |
101 | 108 | |
102 | 109 | // Prepare the time gate! Do it like so, in case later steps want to reset the limit for any reason, but make sure the time is the current one. |
103 | - if (!isset($_SESSION['register'])) |
|
104 | - $_SESSION['register'] = array( |
|
110 | + if (!isset($_SESSION['register'])) { |
|
111 | + $_SESSION['register'] = array( |
|
105 | 112 | 'timenow' => time(), |
106 | 113 | 'limit' => 10, // minimum number of seconds required on this page for registration |
107 | 114 | ); |
108 | - else |
|
109 | - $_SESSION['register']['timenow'] = time(); |
|
115 | + } else { |
|
116 | + $_SESSION['register']['timenow'] = time(); |
|
117 | + } |
|
110 | 118 | |
111 | 119 | // If you have to agree to the agreement, it needs to be fetched from the file. |
112 | 120 | if ($context['require_agreement']) |
113 | 121 | { |
114 | 122 | // Have we got a localized one? |
115 | - if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) |
|
116 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
117 | - elseif (file_exists($boarddir . '/agreement.txt')) |
|
118 | - $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
119 | - else |
|
120 | - $context['agreement'] = ''; |
|
123 | + if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt')) { |
|
124 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']); |
|
125 | + } elseif (file_exists($boarddir . '/agreement.txt')) { |
|
126 | + $context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement'); |
|
127 | + } else { |
|
128 | + $context['agreement'] = ''; |
|
129 | + } |
|
121 | 130 | |
122 | 131 | // Nothing to show, lets disable registration and inform the admin of this error |
123 | 132 | if (empty($context['agreement'])) |
@@ -133,8 +142,9 @@ discard block |
||
133 | 142 | $selectedLanguage = empty($_SESSION['language']) ? $language : $_SESSION['language']; |
134 | 143 | |
135 | 144 | // Do we have any languages? |
136 | - if (empty($context['languages'])) |
|
137 | - getLanguages(); |
|
145 | + if (empty($context['languages'])) { |
|
146 | + getLanguages(); |
|
147 | + } |
|
138 | 148 | |
139 | 149 | // Try to find our selected language. |
140 | 150 | foreach ($context['languages'] as $key => $lang) |
@@ -142,8 +152,9 @@ discard block |
||
142 | 152 | $context['languages'][$key]['name'] = strtr($lang['name'], array('-utf8' => '')); |
143 | 153 | |
144 | 154 | // Found it! |
145 | - if ($selectedLanguage == $lang['filename']) |
|
146 | - $context['languages'][$key]['selected'] = true; |
|
155 | + if ($selectedLanguage == $lang['filename']) { |
|
156 | + $context['languages'][$key]['selected'] = true; |
|
157 | + } |
|
147 | 158 | } |
148 | 159 | } |
149 | 160 | |
@@ -170,16 +181,19 @@ discard block |
||
170 | 181 | if (in_array('website', $reg_fields)) |
171 | 182 | { |
172 | 183 | unset($reg_fields['website']); |
173 | - if (isset($_POST['website_title'])) |
|
174 | - $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
175 | - if (isset($_POST['website_url'])) |
|
176 | - $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
184 | + if (isset($_POST['website_title'])) { |
|
185 | + $cur_profile['website_title'] = $smcFunc['htmlspecialchars']($_POST['website_title']); |
|
186 | + } |
|
187 | + if (isset($_POST['website_url'])) { |
|
188 | + $cur_profile['website_url'] = $smcFunc['htmlspecialchars']($_POST['website_url']); |
|
189 | + } |
|
177 | 190 | } |
178 | 191 | |
179 | 192 | // We might have had some submissions on this front - go check. |
180 | - foreach ($reg_fields as $field) |
|
181 | - if (isset($_POST[$field])) |
|
193 | + foreach ($reg_fields as $field) { |
|
194 | + if (isset($_POST[$field])) |
|
182 | 195 | $cur_profile[$field] = $smcFunc['htmlspecialchars']($_POST[$field]); |
196 | + } |
|
183 | 197 | |
184 | 198 | // Load all the fields in question. |
185 | 199 | setupProfileContext($reg_fields); |
@@ -196,8 +210,9 @@ discard block |
||
196 | 210 | $context['visual_verification_id'] = $verificationOptions['id']; |
197 | 211 | } |
198 | 212 | // Otherwise we have nothing to show. |
199 | - else |
|
200 | - $context['visual_verification'] = false; |
|
213 | + else { |
|
214 | + $context['visual_verification'] = false; |
|
215 | + } |
|
201 | 216 | |
202 | 217 | |
203 | 218 | $context += array( |
@@ -208,8 +223,9 @@ discard block |
||
208 | 223 | |
209 | 224 | // Were there any errors? |
210 | 225 | $context['registration_errors'] = array(); |
211 | - if (!empty($reg_errors)) |
|
212 | - $context['registration_errors'] = $reg_errors; |
|
226 | + if (!empty($reg_errors)) { |
|
227 | + $context['registration_errors'] = $reg_errors; |
|
228 | + } |
|
213 | 229 | |
214 | 230 | createToken('register'); |
215 | 231 | } |
@@ -226,27 +242,32 @@ discard block |
||
226 | 242 | validateToken('register'); |
227 | 243 | |
228 | 244 | // Check to ensure we're forcing SSL for authentication |
229 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
230 | - fatal_lang_error('register_ssl_required'); |
|
245 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
246 | + fatal_lang_error('register_ssl_required'); |
|
247 | + } |
|
231 | 248 | |
232 | 249 | // Start collecting together any errors. |
233 | 250 | $reg_errors = array(); |
234 | 251 | |
235 | 252 | // You can't register if it's disabled. |
236 | - if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) |
|
237 | - fatal_lang_error('registration_disabled', false); |
|
253 | + if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) { |
|
254 | + fatal_lang_error('registration_disabled', false); |
|
255 | + } |
|
238 | 256 | |
239 | 257 | // Well, if you don't agree, you can't register. |
240 | - if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) |
|
241 | - redirectexit(); |
|
258 | + if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) { |
|
259 | + redirectexit(); |
|
260 | + } |
|
242 | 261 | |
243 | 262 | // Make sure they came from *somewhere*, have a session. |
244 | - if (!isset($_SESSION['old_url'])) |
|
245 | - redirectexit('action=signup'); |
|
263 | + if (!isset($_SESSION['old_url'])) { |
|
264 | + redirectexit('action=signup'); |
|
265 | + } |
|
246 | 266 | |
247 | 267 | // If we don't require an agreement, we need a extra check for coppa. |
248 | - if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) |
|
249 | - $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
268 | + if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) { |
|
269 | + $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']); |
|
270 | + } |
|
250 | 271 | // Are they under age, and under age users are banned? |
251 | 272 | if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) |
252 | 273 | { |
@@ -255,8 +276,9 @@ discard block |
||
255 | 276 | } |
256 | 277 | |
257 | 278 | // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up. |
258 | - if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) |
|
259 | - redirectexit('action=signup'); |
|
279 | + if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) { |
|
280 | + redirectexit('action=signup'); |
|
281 | + } |
|
260 | 282 | // Failing that, check the time on it. |
261 | 283 | if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) |
262 | 284 | { |
@@ -276,15 +298,17 @@ discard block |
||
276 | 298 | if (is_array($context['visual_verification'])) |
277 | 299 | { |
278 | 300 | loadLanguage('Errors'); |
279 | - foreach ($context['visual_verification'] as $error) |
|
280 | - $reg_errors[] = $txt['error_' . $error]; |
|
301 | + foreach ($context['visual_verification'] as $error) { |
|
302 | + $reg_errors[] = $txt['error_' . $error]; |
|
303 | + } |
|
281 | 304 | } |
282 | 305 | } |
283 | 306 | |
284 | 307 | foreach ($_POST as $key => $value) |
285 | 308 | { |
286 | - if (!is_array($_POST[$key])) |
|
287 | - $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
309 | + if (!is_array($_POST[$key])) { |
|
310 | + $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
|
311 | + } |
|
288 | 312 | } |
289 | 313 | |
290 | 314 | // Collect all extra registration fields someone might have filled in. |
@@ -314,12 +338,14 @@ discard block |
||
314 | 338 | $reg_fields = explode(',', $modSettings['registration_fields']); |
315 | 339 | |
316 | 340 | // Website is a little different |
317 | - if (in_array('website', $reg_fields)) |
|
318 | - $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
341 | + if (in_array('website', $reg_fields)) { |
|
342 | + $possible_strings = array_merge(array('website_url', 'website_title'), $possible_strings); |
|
343 | + } |
|
319 | 344 | } |
320 | 345 | |
321 | - if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') |
|
322 | - $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
346 | + if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') { |
|
347 | + $_POST['secret_answer'] = md5($_POST['secret_answer']); |
|
348 | + } |
|
323 | 349 | |
324 | 350 | // Needed for isReservedName() and registerMember(). |
325 | 351 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -328,8 +354,9 @@ discard block |
||
328 | 354 | if (isset($_POST['real_name'])) |
329 | 355 | { |
330 | 356 | // Are you already allowed to edit the displayed name? |
331 | - if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) |
|
332 | - $canEditDisplayName = true; |
|
357 | + if (allowedTo('profile_displayed_name') || allowedTo('moderate_forum')) { |
|
358 | + $canEditDisplayName = true; |
|
359 | + } |
|
333 | 360 | |
334 | 361 | // If you are a guest, will you be allowed to once you register? |
335 | 362 | else |
@@ -353,33 +380,38 @@ discard block |
||
353 | 380 | $_POST['real_name'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['real_name'])); |
354 | 381 | |
355 | 382 | // Only set it if we are sure it is good |
356 | - if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) |
|
357 | - $possible_strings[] = 'real_name'; |
|
383 | + if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && $smcFunc['strlen']($_POST['real_name']) < 60) { |
|
384 | + $possible_strings[] = 'real_name'; |
|
385 | + } |
|
358 | 386 | } |
359 | 387 | } |
360 | 388 | |
361 | 389 | // Handle a string as a birthdate... |
362 | - if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') |
|
363 | - $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
390 | + if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') { |
|
391 | + $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate'])); |
|
392 | + } |
|
364 | 393 | // Or birthdate parts... |
365 | - elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) |
|
366 | - $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
394 | + elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) { |
|
395 | + $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']); |
|
396 | + } |
|
367 | 397 | |
368 | 398 | // Validate the passed language file. |
369 | 399 | if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) |
370 | 400 | { |
371 | 401 | // Do we have any languages? |
372 | - if (empty($context['languages'])) |
|
373 | - getLanguages(); |
|
402 | + if (empty($context['languages'])) { |
|
403 | + getLanguages(); |
|
404 | + } |
|
374 | 405 | |
375 | 406 | // Did we find it? |
376 | - if (isset($context['languages'][$_POST['lngfile']])) |
|
377 | - $_SESSION['language'] = $_POST['lngfile']; |
|
378 | - else |
|
407 | + if (isset($context['languages'][$_POST['lngfile']])) { |
|
408 | + $_SESSION['language'] = $_POST['lngfile']; |
|
409 | + } else { |
|
410 | + unset($_POST['lngfile']); |
|
411 | + } |
|
412 | + } else { |
|
379 | 413 | unset($_POST['lngfile']); |
380 | 414 | } |
381 | - else |
|
382 | - unset($_POST['lngfile']); |
|
383 | 415 | |
384 | 416 | // Set the options needed for registration. |
385 | 417 | $regOptions = array( |
@@ -399,22 +431,27 @@ discard block |
||
399 | 431 | ); |
400 | 432 | |
401 | 433 | // Include the additional options that might have been filled in. |
402 | - foreach ($possible_strings as $var) |
|
403 | - if (isset($_POST[$var])) |
|
434 | + foreach ($possible_strings as $var) { |
|
435 | + if (isset($_POST[$var])) |
|
404 | 436 | $regOptions['extra_register_vars'][$var] = $smcFunc['htmlspecialchars']($_POST[$var], ENT_QUOTES); |
405 | - foreach ($possible_ints as $var) |
|
406 | - if (isset($_POST[$var])) |
|
437 | + } |
|
438 | + foreach ($possible_ints as $var) { |
|
439 | + if (isset($_POST[$var])) |
|
407 | 440 | $regOptions['extra_register_vars'][$var] = (int) $_POST[$var]; |
408 | - foreach ($possible_floats as $var) |
|
409 | - if (isset($_POST[$var])) |
|
441 | + } |
|
442 | + foreach ($possible_floats as $var) { |
|
443 | + if (isset($_POST[$var])) |
|
410 | 444 | $regOptions['extra_register_vars'][$var] = (float) $_POST[$var]; |
411 | - foreach ($possible_bools as $var) |
|
412 | - if (isset($_POST[$var])) |
|
445 | + } |
|
446 | + foreach ($possible_bools as $var) { |
|
447 | + if (isset($_POST[$var])) |
|
413 | 448 | $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1; |
449 | + } |
|
414 | 450 | |
415 | 451 | // Registration options are always default options... |
416 | - if (isset($_POST['default_options'])) |
|
417 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
452 | + if (isset($_POST['default_options'])) { |
|
453 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
454 | + } |
|
418 | 455 | $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array(); |
419 | 456 | |
420 | 457 | // Make sure they are clean, dammit! |
@@ -434,12 +471,14 @@ discard block |
||
434 | 471 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
435 | 472 | { |
436 | 473 | // Don't allow overriding of the theme variables. |
437 | - if (isset($regOptions['theme_vars'][$row['col_name']])) |
|
438 | - unset($regOptions['theme_vars'][$row['col_name']]); |
|
474 | + if (isset($regOptions['theme_vars'][$row['col_name']])) { |
|
475 | + unset($regOptions['theme_vars'][$row['col_name']]); |
|
476 | + } |
|
439 | 477 | |
440 | 478 | // Not actually showing it then? |
441 | - if (!$row['show_reg']) |
|
442 | - continue; |
|
479 | + if (!$row['show_reg']) { |
|
480 | + continue; |
|
481 | + } |
|
443 | 482 | |
444 | 483 | // Prepare the value! |
445 | 484 | $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : ''; |
@@ -448,24 +487,27 @@ discard block |
||
448 | 487 | if (!in_array($row['field_type'], array('check', 'select', 'radio'))) |
449 | 488 | { |
450 | 489 | // Is it too long? |
451 | - if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) |
|
452 | - $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
490 | + if ($row['field_length'] && $row['field_length'] < $smcFunc['strlen']($value)) { |
|
491 | + $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length'])); |
|
492 | + } |
|
453 | 493 | |
454 | 494 | // Any masks to apply? |
455 | 495 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
456 | 496 | { |
457 | - if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
|
458 | - $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
459 | - elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) |
|
460 | - $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
461 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
462 | - $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
497 | + if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) { |
|
498 | + $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name'])); |
|
499 | + } elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value)) { |
|
500 | + $custom_field_errors[] = array('custom_field_not_number', array($row['field_name'])); |
|
501 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) { |
|
502 | + $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name'])); |
|
503 | + } |
|
463 | 504 | } |
464 | 505 | } |
465 | 506 | |
466 | 507 | // Is this required but not there? |
467 | - if (trim($value) == '' && $row['show_reg'] > 1) |
|
468 | - $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
508 | + if (trim($value) == '' && $row['show_reg'] > 1) { |
|
509 | + $custom_field_errors[] = array('custom_field_empty', array($row['field_name'])); |
|
510 | + } |
|
469 | 511 | } |
470 | 512 | $smcFunc['db_free_result']($request); |
471 | 513 | |
@@ -473,8 +515,9 @@ discard block |
||
473 | 515 | if (!empty($custom_field_errors)) |
474 | 516 | { |
475 | 517 | loadLanguage('Errors'); |
476 | - foreach ($custom_field_errors as $error) |
|
477 | - $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
518 | + foreach ($custom_field_errors as $error) { |
|
519 | + $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]); |
|
520 | + } |
|
478 | 521 | } |
479 | 522 | |
480 | 523 | // Lets check for other errors before trying to register the member. |
@@ -519,8 +562,9 @@ discard block |
||
519 | 562 | } |
520 | 563 | |
521 | 564 | // If COPPA has been selected then things get complicated, setup the template. |
522 | - if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) |
|
523 | - redirectexit('action=coppa;member=' . $memberID); |
|
565 | + if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) { |
|
566 | + redirectexit('action=coppa;member=' . $memberID); |
|
567 | + } |
|
524 | 568 | // Basic template variable setup. |
525 | 569 | elseif (!empty($modSettings['registration_method'])) |
526 | 570 | { |
@@ -532,8 +576,7 @@ discard block |
||
532 | 576 | 'sub_template' => 'after', |
533 | 577 | 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration'] |
534 | 578 | ); |
535 | - } |
|
536 | - else |
|
579 | + } else |
|
537 | 580 | { |
538 | 581 | call_integration_hook('integrate_activate', array($regOptions['username'])); |
539 | 582 | |
@@ -553,16 +596,18 @@ discard block |
||
553 | 596 | global $context, $txt, $modSettings, $scripturl, $sourcedir, $smcFunc, $language, $user_info; |
554 | 597 | |
555 | 598 | // Logged in users should not bother to activate their accounts |
556 | - if (!empty($user_info['id'])) |
|
557 | - redirectexit(); |
|
599 | + if (!empty($user_info['id'])) { |
|
600 | + redirectexit(); |
|
601 | + } |
|
558 | 602 | |
559 | 603 | loadLanguage('Login'); |
560 | 604 | loadTemplate('Login'); |
561 | 605 | |
562 | 606 | if (empty($_REQUEST['u']) && empty($_POST['user'])) |
563 | 607 | { |
564 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') |
|
565 | - fatal_lang_error('no_access', false); |
|
608 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == '3') { |
|
609 | + fatal_lang_error('no_access', false); |
|
610 | + } |
|
566 | 611 | |
567 | 612 | $context['member_id'] = 0; |
568 | 613 | $context['sub_template'] = 'resend'; |
@@ -602,11 +647,13 @@ discard block |
||
602 | 647 | // Change their email address? (they probably tried a fake one first :P.) |
603 | 648 | if (isset($_POST['new_email'], $_REQUEST['passwd']) && hash_password($row['member_name'], $_REQUEST['passwd']) == $row['passwd'] && ($row['is_activated'] == 0 || $row['is_activated'] == 2)) |
604 | 649 | { |
605 | - if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) |
|
606 | - fatal_lang_error('no_access', false); |
|
650 | + if (empty($modSettings['registration_method']) || $modSettings['registration_method'] == 3) { |
|
651 | + fatal_lang_error('no_access', false); |
|
652 | + } |
|
607 | 653 | |
608 | - if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) |
|
609 | - fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
654 | + if (!filter_var($_POST['new_email'], FILTER_VALIDATE_EMAIL)) { |
|
655 | + fatal_error(sprintf($txt['valid_email_needed'], $smcFunc['htmlspecialchars']($_POST['new_email'])), false); |
|
656 | + } |
|
610 | 657 | |
611 | 658 | // Make sure their email isn't banned. |
612 | 659 | isBannedEmail($_POST['new_email'], 'cannot_register', $txt['ban_register_prohibited']); |
@@ -622,8 +669,9 @@ discard block |
||
622 | 669 | ) |
623 | 670 | ); |
624 | 671 | |
625 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
626 | - fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
672 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
673 | + fatal_lang_error('email_in_use', false, array($smcFunc['htmlspecialchars']($_POST['new_email']))); |
|
674 | + } |
|
627 | 675 | $smcFunc['db_free_result']($request); |
628 | 676 | |
629 | 677 | updateMemberData($row['id_member'], array('email_address' => $_POST['new_email'])); |
@@ -661,9 +709,9 @@ discard block |
||
661 | 709 | // Quit if this code is not right. |
662 | 710 | if (empty($_REQUEST['code']) || $row['validation_code'] != $_REQUEST['code']) |
663 | 711 | { |
664 | - if (!empty($row['is_activated'])) |
|
665 | - fatal_lang_error('already_activated', false); |
|
666 | - elseif ($row['validation_code'] == '') |
|
712 | + if (!empty($row['is_activated'])) { |
|
713 | + fatal_lang_error('already_activated', false); |
|
714 | + } elseif ($row['validation_code'] == '') |
|
667 | 715 | { |
668 | 716 | loadLanguage('Profile'); |
669 | 717 | fatal_error(sprintf($txt['registration_not_approved'], $scripturl . '?action=activate;user=' . $row['member_name']), false); |
@@ -713,8 +761,9 @@ discard block |
||
713 | 761 | loadTemplate('Register'); |
714 | 762 | |
715 | 763 | // No User ID?? |
716 | - if (!isset($_GET['member'])) |
|
717 | - fatal_lang_error('no_access', false); |
|
764 | + if (!isset($_GET['member'])) { |
|
765 | + fatal_lang_error('no_access', false); |
|
766 | + } |
|
718 | 767 | |
719 | 768 | // Get the user details... |
720 | 769 | $request = $smcFunc['db_query']('', ' |
@@ -727,8 +776,9 @@ discard block |
||
727 | 776 | 'is_coppa' => 5, |
728 | 777 | ) |
729 | 778 | ); |
730 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
731 | - fatal_lang_error('no_access', false); |
|
779 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
780 | + fatal_lang_error('no_access', false); |
|
781 | + } |
|
732 | 782 | list ($username) = $smcFunc['db_fetch_row']($request); |
733 | 783 | $smcFunc['db_free_result']($request); |
734 | 784 | |
@@ -766,8 +816,7 @@ discard block |
||
766 | 816 | echo $data; |
767 | 817 | obExit(false); |
768 | 818 | } |
769 | - } |
|
770 | - else |
|
819 | + } else |
|
771 | 820 | { |
772 | 821 | $context += array( |
773 | 822 | 'page_title' => $txt['coppa_title'], |
@@ -820,8 +869,9 @@ discard block |
||
820 | 869 | { |
821 | 870 | require_once($sourcedir . '/Subs-Graphics.php'); |
822 | 871 | |
823 | - if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) |
|
824 | - header('HTTP/1.1 400 Bad Request'); |
|
872 | + if (in_array('gd', get_loaded_extensions()) && !showCodeImage($code)) { |
|
873 | + header('HTTP/1.1 400 Bad Request'); |
|
874 | + } |
|
825 | 875 | |
826 | 876 | // Otherwise just show a pre-defined letter. |
827 | 877 | elseif (isset($_REQUEST['letter'])) |
@@ -839,14 +889,13 @@ discard block |
||
839 | 889 | header('Content-Type: image/gif'); |
840 | 890 | die("\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"); |
841 | 891 | } |
842 | - } |
|
843 | - |
|
844 | - elseif ($_REQUEST['format'] === '.wav') |
|
892 | + } elseif ($_REQUEST['format'] === '.wav') |
|
845 | 893 | { |
846 | 894 | require_once($sourcedir . '/Subs-Sound.php'); |
847 | 895 | |
848 | - if (!createWaveFile($code)) |
|
849 | - header('HTTP/1.1 400 Bad Request'); |
|
896 | + if (!createWaveFile($code)) { |
|
897 | + header('HTTP/1.1 400 Bad Request'); |
|
898 | + } |
|
850 | 899 | } |
851 | 900 | |
852 | 901 | // We all die one day... |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array The truncated array |
25 | 25 | */ |
26 | -function truncateArray($arr, $max_length=1900) |
|
26 | +function truncateArray($arr, $max_length = 1900) |
|
27 | 27 | { |
28 | 28 | $curr_length = 0; |
29 | 29 | foreach ($arr as $key => $value) |
30 | 30 | if (is_array($value)) |
31 | 31 | foreach ($value as $key2 => $value2) |
32 | - $curr_length += strlen ($value2); |
|
32 | + $curr_length += strlen($value2); |
|
33 | 33 | else |
34 | - $curr_length += strlen ($value); |
|
34 | + $curr_length += strlen($value); |
|
35 | 35 | if ($curr_length <= $max_length) |
36 | 36 | return $arr; |
37 | 37 | else |
38 | 38 | { |
39 | 39 | // Truncate each element's value to a reasonable length |
40 | - $param_max = floor($max_length/count($arr)); |
|
40 | + $param_max = floor($max_length / count($arr)); |
|
41 | 41 | foreach ($arr as $key => &$value) |
42 | 42 | if (is_array($value)) |
43 | 43 | foreach ($value as $key2 => &$value2) |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | if (filemtime($cachedir . '/db_last_error.php') === $last_db_error_change) |
208 | 208 | { |
209 | 209 | // Write the change |
210 | - $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
210 | + $write_db_change = '<' . '?' . "php\n" . '$db_last_error = ' . time() . ';' . "\n" . '?' . '>'; |
|
211 | 211 | $written_bytes = file_put_contents($cachedir . '/db_last_error.php', $write_db_change, LOCK_EX); |
212 | 212 | |
213 | 213 | // survey says ... |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br> |
281 | 281 | ', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br> |
282 | 282 | ', $txt['debug_hooks'], empty($context['debug']['hooks']) ? 0 : count($context['debug']['hooks']) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_hooks\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_hooks" style="display: none;"><em>' . implode('</em>, <em>', $context['debug']['hooks']), '</em></span>)', '<br> |
283 | - ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
|
283 | + ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">' . $txt['debug_show'] . '</a><span id="debug_instances" style="display: none;"><em>' . implode('</em>, <em>', array_keys($context['debug']['instances'])) . '</em></span>)' . '<br>') : ''), ' |
|
284 | 284 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
285 | 285 | |
286 | 286 | if (function_exists('memory_get_peak_usage')) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Truncate the GET array to a specified length |
@@ -26,24 +27,28 @@ discard block |
||
26 | 27 | function truncateArray($arr, $max_length=1900) |
27 | 28 | { |
28 | 29 | $curr_length = 0; |
29 | - foreach ($arr as $key => $value) |
|
30 | - if (is_array($value)) |
|
30 | + foreach ($arr as $key => $value) { |
|
31 | + if (is_array($value)) |
|
31 | 32 | foreach ($value as $key2 => $value2) |
32 | 33 | $curr_length += strlen ($value2); |
33 | - else |
|
34 | - $curr_length += strlen ($value); |
|
35 | - if ($curr_length <= $max_length) |
|
36 | - return $arr; |
|
37 | - else |
|
34 | + } |
|
35 | + else { |
|
36 | + $curr_length += strlen ($value); |
|
37 | + } |
|
38 | + if ($curr_length <= $max_length) { |
|
39 | + return $arr; |
|
40 | + } else |
|
38 | 41 | { |
39 | 42 | // Truncate each element's value to a reasonable length |
40 | 43 | $param_max = floor($max_length/count($arr)); |
41 | - foreach ($arr as $key => &$value) |
|
42 | - if (is_array($value)) |
|
44 | + foreach ($arr as $key => &$value) { |
|
45 | + if (is_array($value)) |
|
43 | 46 | foreach ($value as $key2 => &$value2) |
44 | 47 | $value2 = substr($value2, 0, $param_max - strlen($key) - 5); |
45 | - else |
|
46 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
48 | + } |
|
49 | + else { |
|
50 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
51 | + } |
|
47 | 52 | return $arr; |
48 | 53 | } |
49 | 54 | } |
@@ -65,8 +70,9 @@ discard block |
||
65 | 70 | // Don't update for every page - this isn't wholly accurate but who cares. |
66 | 71 | if ($topic) |
67 | 72 | { |
68 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
69 | - $force = false; |
|
73 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
74 | + $force = false; |
|
75 | + } |
|
70 | 76 | $_SESSION['last_topic_id'] = $topic; |
71 | 77 | } |
72 | 78 | } |
@@ -79,22 +85,24 @@ discard block |
||
79 | 85 | } |
80 | 86 | |
81 | 87 | // Don't mark them as online more than every so often. |
82 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
83 | - return; |
|
88 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
89 | + return; |
|
90 | + } |
|
84 | 91 | |
85 | 92 | if (!empty($modSettings['who_enabled'])) |
86 | 93 | { |
87 | 94 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
88 | 95 | |
89 | 96 | // In the case of a dlattach action, session_var may not be set. |
90 | - if (!isset($context['session_var'])) |
|
91 | - $context['session_var'] = $_SESSION['session_var']; |
|
97 | + if (!isset($context['session_var'])) { |
|
98 | + $context['session_var'] = $_SESSION['session_var']; |
|
99 | + } |
|
92 | 100 | |
93 | 101 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
94 | 102 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
103 | + } else { |
|
104 | + $encoded_get = ''; |
|
95 | 105 | } |
96 | - else |
|
97 | - $encoded_get = ''; |
|
98 | 106 | |
99 | 107 | // Guests use 0, members use their session ID. |
100 | 108 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -134,17 +142,18 @@ discard block |
||
134 | 142 | ); |
135 | 143 | |
136 | 144 | // Guess it got deleted. |
137 | - if ($smcFunc['db_affected_rows']() == 0) |
|
145 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
146 | + $_SESSION['log_time'] = 0; |
|
147 | + } |
|
148 | + } else { |
|
138 | 149 | $_SESSION['log_time'] = 0; |
139 | 150 | } |
140 | - else |
|
141 | - $_SESSION['log_time'] = 0; |
|
142 | 151 | |
143 | 152 | // Otherwise, we have to delete and insert. |
144 | 153 | if (empty($_SESSION['log_time'])) |
145 | 154 | { |
146 | - if ($do_delete || !empty($user_info['id'])) |
|
147 | - $smcFunc['db_query']('', ' |
|
155 | + if ($do_delete || !empty($user_info['id'])) { |
|
156 | + $smcFunc['db_query']('', ' |
|
148 | 157 | DELETE FROM {db_prefix}log_online |
149 | 158 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
150 | 159 | array( |
@@ -152,6 +161,7 @@ discard block |
||
152 | 161 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
153 | 162 | ) |
154 | 163 | ); |
164 | + } |
|
155 | 165 | |
156 | 166 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
157 | 167 | '{db_prefix}log_online', |
@@ -165,21 +175,24 @@ discard block |
||
165 | 175 | $_SESSION['log_time'] = time(); |
166 | 176 | |
167 | 177 | // Well, they are online now. |
168 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
169 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
178 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
179 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
180 | + } |
|
170 | 181 | |
171 | 182 | // Set their login time, if not already done within the last minute. |
172 | 183 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
173 | 184 | { |
174 | 185 | // Don't count longer than 15 minutes. |
175 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
176 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
186 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
187 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
188 | + } |
|
177 | 189 | |
178 | 190 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
179 | 191 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
180 | 192 | |
181 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
182 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
193 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
194 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
195 | + } |
|
183 | 196 | |
184 | 197 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
185 | 198 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -216,8 +229,7 @@ discard block |
||
216 | 229 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
217 | 230 | // Copy the file back and run for your life! |
218 | 231 | @copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php'); |
219 | - } |
|
220 | - else |
|
232 | + } else |
|
221 | 233 | { |
222 | 234 | @touch($boarddir . '/' . 'Settings.php'); |
223 | 235 | return true; |
@@ -237,22 +249,27 @@ discard block |
||
237 | 249 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
238 | 250 | |
239 | 251 | // Add to Settings.php if you want to show the debugging information. |
240 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
241 | - return; |
|
252 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
253 | + return; |
|
254 | + } |
|
242 | 255 | |
243 | - if (empty($_SESSION['view_queries'])) |
|
244 | - $_SESSION['view_queries'] = 0; |
|
245 | - if (empty($context['debug']['language_files'])) |
|
246 | - $context['debug']['language_files'] = array(); |
|
247 | - if (empty($context['debug']['sheets'])) |
|
248 | - $context['debug']['sheets'] = array(); |
|
256 | + if (empty($_SESSION['view_queries'])) { |
|
257 | + $_SESSION['view_queries'] = 0; |
|
258 | + } |
|
259 | + if (empty($context['debug']['language_files'])) { |
|
260 | + $context['debug']['language_files'] = array(); |
|
261 | + } |
|
262 | + if (empty($context['debug']['sheets'])) { |
|
263 | + $context['debug']['sheets'] = array(); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | $files = get_included_files(); |
251 | 267 | $total_size = 0; |
252 | 268 | for ($i = 0, $n = count($files); $i < $n; $i++) |
253 | 269 | { |
254 | - if (file_exists($files[$i])) |
|
255 | - $total_size += filesize($files[$i]); |
|
270 | + if (file_exists($files[$i])) { |
|
271 | + $total_size += filesize($files[$i]); |
|
272 | + } |
|
256 | 273 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
257 | 274 | } |
258 | 275 | |
@@ -261,8 +278,9 @@ discard block |
||
261 | 278 | { |
262 | 279 | foreach ($db_cache as $q => $query_data) |
263 | 280 | { |
264 | - if (!empty($query_data['w'])) |
|
265 | - $warnings += count($query_data['w']); |
|
281 | + if (!empty($query_data['w'])) { |
|
282 | + $warnings += count($query_data['w']); |
|
283 | + } |
|
266 | 284 | } |
267 | 285 | |
268 | 286 | $_SESSION['debug'] = &$db_cache; |
@@ -283,12 +301,14 @@ discard block |
||
283 | 301 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
284 | 302 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
285 | 303 | |
286 | - if (function_exists('memory_get_peak_usage')) |
|
287 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
304 | + if (function_exists('memory_get_peak_usage')) { |
|
305 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
306 | + } |
|
288 | 307 | |
289 | 308 | // What tokens are active? |
290 | - if (isset($_SESSION['token'])) |
|
291 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
309 | + if (isset($_SESSION['token'])) { |
|
310 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
311 | + } |
|
292 | 312 | |
293 | 313 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
294 | 314 | { |
@@ -302,10 +322,12 @@ discard block |
||
302 | 322 | $total_t += $cache_hit['t']; |
303 | 323 | $total_s += $cache_hit['s']; |
304 | 324 | } |
305 | - if (!isset($cache_misses)) |
|
306 | - $cache_misses = array(); |
|
307 | - foreach ($cache_misses as $missed) |
|
308 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
325 | + if (!isset($cache_misses)) { |
|
326 | + $cache_misses = array(); |
|
327 | + } |
|
328 | + foreach ($cache_misses as $missed) { |
|
329 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
330 | + } |
|
309 | 331 | |
310 | 332 | echo ' |
311 | 333 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -316,38 +338,44 @@ discard block |
||
316 | 338 | <a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
317 | 339 | <br>'; |
318 | 340 | |
319 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
320 | - foreach ($db_cache as $q => $query_data) |
|
341 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
342 | + foreach ($db_cache as $q => $query_data) |
|
321 | 343 | { |
322 | 344 | $is_select = strpos(trim($query_data['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($query_data['q'])) != 0; |
345 | + } |
|
323 | 346 | // Temporary tables created in earlier queries are not explainable. |
324 | 347 | if ($is_select) |
325 | 348 | { |
326 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
327 | - if (strpos(trim($query_data['q']), $tmp) !== false) |
|
349 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
350 | + if (strpos(trim($query_data['q']), $tmp) !== false) |
|
328 | 351 | { |
329 | 352 | $is_select = false; |
353 | + } |
|
330 | 354 | break; |
331 | 355 | } |
332 | 356 | } |
333 | 357 | // But actual creation of the temporary tables are. |
334 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) |
|
335 | - $is_select = true; |
|
358 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) { |
|
359 | + $is_select = true; |
|
360 | + } |
|
336 | 361 | |
337 | 362 | // Make the filenames look a bit better. |
338 | - if (isset($query_data['f'])) |
|
339 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
363 | + if (isset($query_data['f'])) { |
|
364 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
365 | + } |
|
340 | 366 | |
341 | 367 | echo ' |
342 | 368 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($query_data['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
343 | 369 | '; |
344 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
345 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
370 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
371 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
372 | + } |
|
346 | 373 | |
347 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
348 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
349 | - elseif (isset($query_data['t'])) |
|
350 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
374 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
375 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
376 | + } elseif (isset($query_data['t'])) { |
|
377 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
378 | + } |
|
351 | 379 | echo ' |
352 | 380 | <br>'; |
353 | 381 | } |
@@ -372,12 +400,14 @@ discard block |
||
372 | 400 | global $modSettings, $smcFunc; |
373 | 401 | static $cache_stats = array(); |
374 | 402 | |
375 | - if (empty($modSettings['trackStats'])) |
|
376 | - return false; |
|
377 | - if (!empty($stats)) |
|
378 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
379 | - elseif (empty($cache_stats)) |
|
380 | - return false; |
|
403 | + if (empty($modSettings['trackStats'])) { |
|
404 | + return false; |
|
405 | + } |
|
406 | + if (!empty($stats)) { |
|
407 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
408 | + } elseif (empty($cache_stats)) { |
|
409 | + return false; |
|
410 | + } |
|
381 | 411 | |
382 | 412 | $setStringUpdate = ''; |
383 | 413 | $insert_keys = array(); |
@@ -390,10 +420,11 @@ discard block |
||
390 | 420 | $setStringUpdate .= ' |
391 | 421 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
392 | 422 | |
393 | - if ($change === '+') |
|
394 | - $cache_stats[$field] = 1; |
|
395 | - else |
|
396 | - $update_parameters[$field] = $change; |
|
423 | + if ($change === '+') { |
|
424 | + $cache_stats[$field] = 1; |
|
425 | + } else { |
|
426 | + $update_parameters[$field] = $change; |
|
427 | + } |
|
397 | 428 | $insert_keys[$field] = 'int'; |
398 | 429 | } |
399 | 430 | |
@@ -457,43 +488,50 @@ discard block |
||
457 | 488 | ); |
458 | 489 | |
459 | 490 | // Make sure this particular log is enabled first... |
460 | - if (empty($modSettings['modlog_enabled'])) |
|
461 | - unset ($log_types['moderate']); |
|
462 | - if (empty($modSettings['userlog_enabled'])) |
|
463 | - unset ($log_types['user']); |
|
464 | - if (empty($modSettings['adminlog_enabled'])) |
|
465 | - unset ($log_types['admin']); |
|
491 | + if (empty($modSettings['modlog_enabled'])) { |
|
492 | + unset ($log_types['moderate']); |
|
493 | + } |
|
494 | + if (empty($modSettings['userlog_enabled'])) { |
|
495 | + unset ($log_types['user']); |
|
496 | + } |
|
497 | + if (empty($modSettings['adminlog_enabled'])) { |
|
498 | + unset ($log_types['admin']); |
|
499 | + } |
|
466 | 500 | |
467 | 501 | call_integration_hook('integrate_log_types', array(&$log_types)); |
468 | 502 | |
469 | 503 | foreach ($logs as $log) |
470 | 504 | { |
471 | - if (!isset($log_types[$log['log_type']])) |
|
472 | - return false; |
|
505 | + if (!isset($log_types[$log['log_type']])) { |
|
506 | + return false; |
|
507 | + } |
|
473 | 508 | |
474 | - if (!is_array($log['extra'])) |
|
475 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
509 | + if (!is_array($log['extra'])) { |
|
510 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
511 | + } |
|
476 | 512 | |
477 | 513 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
478 | 514 | if (isset($log['extra']['topic'])) |
479 | 515 | { |
480 | - if (!is_numeric($log['extra']['topic'])) |
|
481 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
516 | + if (!is_numeric($log['extra']['topic'])) { |
|
517 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
518 | + } |
|
482 | 519 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
483 | 520 | unset($log['extra']['topic']); |
521 | + } else { |
|
522 | + $topic_id = 0; |
|
484 | 523 | } |
485 | - else |
|
486 | - $topic_id = 0; |
|
487 | 524 | |
488 | 525 | if (isset($log['extra']['message'])) |
489 | 526 | { |
490 | - if (!is_numeric($log['extra']['message'])) |
|
491 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
527 | + if (!is_numeric($log['extra']['message'])) { |
|
528 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
529 | + } |
|
492 | 530 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
493 | 531 | unset($log['extra']['message']); |
532 | + } else { |
|
533 | + $msg_id = 0; |
|
494 | 534 | } |
495 | - else |
|
496 | - $msg_id = 0; |
|
497 | 535 | |
498 | 536 | // @todo cache this? |
499 | 537 | // Is there an associated report on this? |
@@ -520,23 +558,26 @@ discard block |
||
520 | 558 | $smcFunc['db_free_result']($request); |
521 | 559 | } |
522 | 560 | |
523 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
524 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
561 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
562 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
563 | + } |
|
525 | 564 | |
526 | 565 | if (isset($log['extra']['board'])) |
527 | 566 | { |
528 | - if (!is_numeric($log['extra']['board'])) |
|
529 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
567 | + if (!is_numeric($log['extra']['board'])) { |
|
568 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
569 | + } |
|
530 | 570 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
531 | 571 | unset($log['extra']['board']); |
572 | + } else { |
|
573 | + $board_id = 0; |
|
532 | 574 | } |
533 | - else |
|
534 | - $board_id = 0; |
|
535 | 575 | |
536 | 576 | if (isset($log['extra']['board_to'])) |
537 | 577 | { |
538 | - if (!is_numeric($log['extra']['board_to'])) |
|
539 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
578 | + if (!is_numeric($log['extra']['board_to'])) { |
|
579 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
580 | + } |
|
540 | 581 | if (empty($board_id)) |
541 | 582 | { |
542 | 583 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -544,10 +585,11 @@ discard block |
||
544 | 585 | } |
545 | 586 | } |
546 | 587 | |
547 | - if (isset($log['extra']['member_affected'])) |
|
548 | - $memID = $log['extra']['member_affected']; |
|
549 | - else |
|
550 | - $memID = $user_info['id']; |
|
588 | + if (isset($log['extra']['member_affected'])) { |
|
589 | + $memID = $log['extra']['member_affected']; |
|
590 | + } else { |
|
591 | + $memID = $user_info['id']; |
|
592 | + } |
|
551 | 593 | |
552 | 594 | $inserts[] = array( |
553 | 595 | time(), $log_types[$log['log_type']], $memID, $user_info['ip'], $log['action'], |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | // INET. |
361 | 361 | elseif ($param_info['type'] == 'inet') |
362 | 362 | { |
363 | - if(count($search_params[$param_name]) === 1) |
|
363 | + if (count($search_params[$param_name]) === 1) |
|
364 | 364 | { |
365 | 365 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
366 | 366 | $where_params[$param_name] = $search_params[$param_name][0]; |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | elseif (count($search_params[$param_name]) === 2) |
369 | 369 | { |
370 | 370 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
371 | - $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
|
372 | - $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
|
371 | + $where_params[$param_name . '_low'] = $search_params[$param_name]['low']; |
|
372 | + $where_params[$param_name . '_high'] = $search_params[$param_name]['high']; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * The main 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 | |
@@ -276,14 +282,15 @@ discard block |
||
276 | 282 | call_integration_hook('integrate_view_members_params', array(&$params)); |
277 | 283 | |
278 | 284 | $search_params = array(); |
279 | - if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) |
|
280 | - $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
281 | - elseif (!empty($_POST)) |
|
285 | + if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) { |
|
286 | + $search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true); |
|
287 | + } elseif (!empty($_POST)) |
|
282 | 288 | { |
283 | 289 | $search_params['types'] = $_POST['types']; |
284 | - foreach ($params as $param_name => $param_info) |
|
285 | - if (isset($_POST[$param_name])) |
|
290 | + foreach ($params as $param_name => $param_info) { |
|
291 | + if (isset($_POST[$param_name])) |
|
286 | 292 | $search_params[$param_name] = $_POST[$param_name]; |
293 | + } |
|
287 | 294 | } |
288 | 295 | |
289 | 296 | $search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null; |
@@ -296,34 +303,38 @@ discard block |
||
296 | 303 | foreach ($params as $param_name => $param_info) |
297 | 304 | { |
298 | 305 | // Not filled in? |
299 | - if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') |
|
300 | - continue; |
|
306 | + if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') { |
|
307 | + continue; |
|
308 | + } |
|
301 | 309 | |
302 | 310 | // Make sure numeric values are really numeric. |
303 | - if (in_array($param_info['type'], array('int', 'age'))) |
|
304 | - $search_params[$param_name] = (int) $search_params[$param_name]; |
|
311 | + if (in_array($param_info['type'], array('int', 'age'))) { |
|
312 | + $search_params[$param_name] = (int) $search_params[$param_name]; |
|
313 | + } |
|
305 | 314 | // Date values have to match the specified format. |
306 | 315 | elseif ($param_info['type'] == 'date') |
307 | 316 | { |
308 | 317 | // Check if this date format is valid. |
309 | - if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) |
|
310 | - continue; |
|
318 | + if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) { |
|
319 | + continue; |
|
320 | + } |
|
311 | 321 | |
312 | 322 | $search_params[$param_name] = strtotime($search_params[$param_name]); |
313 | - } |
|
314 | - elseif ($param_info['type'] == 'inet') |
|
323 | + } elseif ($param_info['type'] == 'inet') |
|
315 | 324 | { |
316 | 325 | $search_params[$param_name] = ip2range($search_params[$param_name]); |
317 | - if (empty($search_params[$param_name])) |
|
318 | - continue; |
|
326 | + if (empty($search_params[$param_name])) { |
|
327 | + continue; |
|
328 | + } |
|
319 | 329 | } |
320 | 330 | |
321 | 331 | // Those values that are in some kind of range (<, <=, =, >=, >). |
322 | 332 | if (!empty($param_info['range'])) |
323 | 333 | { |
324 | 334 | // Default to '=', just in case... |
325 | - if (empty($range_trans[$search_params['types'][$param_name]])) |
|
326 | - $search_params['types'][$param_name] = '='; |
|
335 | + if (empty($range_trans[$search_params['types'][$param_name]])) { |
|
336 | + $search_params['types'][$param_name] = '='; |
|
337 | + } |
|
327 | 338 | |
328 | 339 | // Handle special case 'age'. |
329 | 340 | if ($param_info['type'] == 'age') |
@@ -351,16 +362,17 @@ discard block |
||
351 | 362 | elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=') |
352 | 363 | { |
353 | 364 | $query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400); |
365 | + } else { |
|
366 | + $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
354 | 367 | } |
355 | - else |
|
356 | - $query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name]; |
|
357 | 368 | } |
358 | 369 | // Checkboxes. |
359 | 370 | elseif ($param_info['type'] == 'checkbox') |
360 | 371 | { |
361 | 372 | // Each checkbox or no checkbox at all is checked -> ignore. |
362 | - if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) |
|
363 | - continue; |
|
373 | + if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) { |
|
374 | + continue; |
|
375 | + } |
|
364 | 376 | |
365 | 377 | $query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})'; |
366 | 378 | $where_params[$param_name . '_check'] = $search_params[$param_name]; |
@@ -372,24 +384,23 @@ discard block |
||
372 | 384 | { |
373 | 385 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; |
374 | 386 | $where_params[$param_name] = $search_params[$param_name][0]; |
375 | - } |
|
376 | - elseif (count($search_params[$param_name]) === 2) |
|
387 | + } elseif (count($search_params[$param_name]) === 2) |
|
377 | 388 | { |
378 | 389 | $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; |
379 | 390 | $where_params[$param_name.'_low'] = $search_params[$param_name]['low']; |
380 | 391 | $where_params[$param_name.'_high'] = $search_params[$param_name]['high']; |
381 | 392 | } |
382 | 393 | |
383 | - } |
|
384 | - elseif ($param_info['type'] != 'groups') |
|
394 | + } elseif ($param_info['type'] != 'groups') |
|
385 | 395 | { |
386 | 396 | // Replace the wildcard characters ('*' and '?') into MySQL ones. |
387 | 397 | $parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))); |
388 | 398 | |
389 | - if ($smcFunc['db_case_sensitive']) |
|
390 | - $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
391 | - else |
|
392 | - $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
399 | + if ($smcFunc['db_case_sensitive']) { |
|
400 | + $query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})'; |
|
401 | + } else { |
|
402 | + $query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})'; |
|
403 | + } |
|
393 | 404 | $where_params[$param_name . '_normal'] = '%' . $parameter . '%'; |
394 | 405 | } |
395 | 406 | } |
@@ -405,16 +416,18 @@ discard block |
||
405 | 416 | } |
406 | 417 | |
407 | 418 | // Additional membergroups (these are only relevant if not all primary groups where selected!). |
408 | - if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) |
|
409 | - foreach ($search_params['membergroups'][2] as $mg) |
|
419 | + if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) { |
|
420 | + foreach ($search_params['membergroups'][2] as $mg) |
|
410 | 421 | { |
411 | 422 | $mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0'; |
423 | + } |
|
412 | 424 | $where_params['add_group_' . $mg] = $mg; |
413 | 425 | } |
414 | 426 | |
415 | 427 | // Combine the one or two membergroup parts into one query part linked with an OR. |
416 | - if (!empty($mg_query_parts)) |
|
417 | - $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
428 | + if (!empty($mg_query_parts)) { |
|
429 | + $query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')'; |
|
430 | + } |
|
418 | 431 | |
419 | 432 | // Get all selected post count related membergroups. |
420 | 433 | if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups'])) |
@@ -426,9 +439,9 @@ discard block |
||
426 | 439 | // Construct the where part of the query. |
427 | 440 | $where = empty($query_parts) ? '1=1' : implode(' |
428 | 441 | AND ', $query_parts); |
442 | + } else { |
|
443 | + $search_url_params = null; |
|
429 | 444 | } |
430 | - else |
|
431 | - $search_url_params = null; |
|
432 | 445 | |
433 | 446 | // Construct the additional URL part with the query info in it. |
434 | 447 | $context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : ''; |
@@ -551,28 +564,32 @@ discard block |
||
551 | 564 | 'function' => function($rowData) use ($txt) |
552 | 565 | { |
553 | 566 | // Calculate number of days since last online. |
554 | - if (empty($rowData['last_login'])) |
|
555 | - $difference = $txt['never']; |
|
556 | - else |
|
567 | + if (empty($rowData['last_login'])) { |
|
568 | + $difference = $txt['never']; |
|
569 | + } else |
|
557 | 570 | { |
558 | 571 | $num_days_difference = jeffsdatediff($rowData['last_login']); |
559 | 572 | |
560 | 573 | // Today. |
561 | - if (empty($num_days_difference)) |
|
562 | - $difference = $txt['viewmembers_today']; |
|
574 | + if (empty($num_days_difference)) { |
|
575 | + $difference = $txt['viewmembers_today']; |
|
576 | + } |
|
563 | 577 | |
564 | 578 | // Yesterday. |
565 | - elseif ($num_days_difference == 1) |
|
566 | - $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
579 | + elseif ($num_days_difference == 1) { |
|
580 | + $difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']); |
|
581 | + } |
|
567 | 582 | |
568 | 583 | // X days ago. |
569 | - else |
|
570 | - $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
584 | + else { |
|
585 | + $difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']); |
|
586 | + } |
|
571 | 587 | } |
572 | 588 | |
573 | 589 | // Show it in italics if they're not activated... |
574 | - if ($rowData['is_activated'] % 10 != 1) |
|
575 | - $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
590 | + if ($rowData['is_activated'] % 10 != 1) { |
|
591 | + $difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference); |
|
592 | + } |
|
576 | 593 | |
577 | 594 | return $difference; |
578 | 595 | }, |
@@ -624,8 +641,9 @@ discard block |
||
624 | 641 | ); |
625 | 642 | |
626 | 643 | // Without enough permissions, don't show 'delete members' checkboxes. |
627 | - if (!allowedTo('profile_remove_any')) |
|
628 | - unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
644 | + if (!allowedTo('profile_remove_any')) { |
|
645 | + unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']); |
|
646 | + } |
|
629 | 647 | |
630 | 648 | require_once($sourcedir . '/Subs-List.php'); |
631 | 649 | createList($listOptions); |
@@ -668,17 +686,18 @@ discard block |
||
668 | 686 | ); |
669 | 687 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
670 | 688 | { |
671 | - if ($row['min_posts'] == -1) |
|
672 | - $context['membergroups'][] = array( |
|
689 | + if ($row['min_posts'] == -1) { |
|
690 | + $context['membergroups'][] = array( |
|
673 | 691 | 'id' => $row['id_group'], |
674 | 692 | 'name' => $row['group_name'], |
675 | 693 | 'can_be_additional' => true |
676 | 694 | ); |
677 | - else |
|
678 | - $context['postgroups'][] = array( |
|
695 | + } else { |
|
696 | + $context['postgroups'][] = array( |
|
679 | 697 | 'id' => $row['id_group'], |
680 | 698 | 'name' => $row['group_name'] |
681 | 699 | ); |
700 | + } |
|
682 | 701 | } |
683 | 702 | $smcFunc['db_free_result']($request); |
684 | 703 | |
@@ -705,8 +724,9 @@ discard block |
||
705 | 724 | $context['page_title'] = $txt['admin_members']; |
706 | 725 | $context['sub_template'] = 'admin_browse'; |
707 | 726 | $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve'); |
708 | - if (isset($context['tabs'][$context['browse_type']])) |
|
709 | - $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
727 | + if (isset($context['tabs'][$context['browse_type']])) { |
|
728 | + $context['tabs'][$context['browse_type']]['is_selected'] = true; |
|
729 | + } |
|
710 | 730 | |
711 | 731 | // Allowed filters are those we can have, in theory. |
712 | 732 | $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2); |
@@ -717,18 +737,20 @@ discard block |
||
717 | 737 | foreach ($context['activation_numbers'] as $type => $amount) |
718 | 738 | { |
719 | 739 | // We have some of these... |
720 | - if (in_array($type, $context['allowed_filters']) && $amount > 0) |
|
721 | - $context['available_filters'][] = array( |
|
740 | + if (in_array($type, $context['allowed_filters']) && $amount > 0) { |
|
741 | + $context['available_filters'][] = array( |
|
722 | 742 | 'type' => $type, |
723 | 743 | 'amount' => $amount, |
724 | 744 | 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', |
725 | 745 | 'selected' => $type == $context['current_filter'] |
726 | 746 | ); |
747 | + } |
|
727 | 748 | } |
728 | 749 | |
729 | 750 | // If the filter was not sent, set it to whatever has people in it! |
730 | - if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) |
|
731 | - $context['current_filter'] = $context['available_filters'][0]['type']; |
|
751 | + if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) { |
|
752 | + $context['current_filter'] = $context['available_filters'][0]['type']; |
|
753 | + } |
|
732 | 754 | |
733 | 755 | // This little variable is used to determine if we should flag where we are looking. |
734 | 756 | $context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1; |
@@ -743,44 +765,47 @@ discard block |
||
743 | 765 | ); |
744 | 766 | |
745 | 767 | // Are we showing duplicate information? |
746 | - if (isset($_GET['showdupes'])) |
|
747 | - $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
768 | + if (isset($_GET['showdupes'])) { |
|
769 | + $_SESSION['showdupes'] = (int) $_GET['showdupes']; |
|
770 | + } |
|
748 | 771 | $context['show_duplicates'] = !empty($_SESSION['showdupes']); |
749 | 772 | |
750 | 773 | // Determine which actions we should allow on this page. |
751 | 774 | if ($context['browse_type'] == 'approve') |
752 | 775 | { |
753 | 776 | // If we are approving deleted accounts we have a slightly different list... actually a mirror ;) |
754 | - if ($context['current_filter'] == 4) |
|
755 | - $context['allowed_actions'] = array( |
|
777 | + if ($context['current_filter'] == 4) { |
|
778 | + $context['allowed_actions'] = array( |
|
756 | 779 | 'reject' => $txt['admin_browse_w_approve_deletion'], |
757 | 780 | 'ok' => $txt['admin_browse_w_reject'], |
758 | 781 | ); |
759 | - else |
|
760 | - $context['allowed_actions'] = array( |
|
782 | + } else { |
|
783 | + $context['allowed_actions'] = array( |
|
761 | 784 | 'ok' => $txt['admin_browse_w_approve'], |
762 | 785 | 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], |
763 | 786 | 'require_activation' => $txt['admin_browse_w_approve_require_activate'], |
764 | 787 | 'reject' => $txt['admin_browse_w_reject'], |
765 | 788 | 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'], |
766 | 789 | ); |
767 | - } |
|
768 | - elseif ($context['browse_type'] == 'activate') |
|
769 | - $context['allowed_actions'] = array( |
|
790 | + } |
|
791 | + } elseif ($context['browse_type'] == 'activate') { |
|
792 | + $context['allowed_actions'] = array( |
|
770 | 793 | 'ok' => $txt['admin_browse_w_activate'], |
771 | 794 | 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], |
772 | 795 | 'delete' => $txt['admin_browse_w_delete'], |
773 | 796 | 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], |
774 | 797 | 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'], |
775 | 798 | ); |
799 | + } |
|
776 | 800 | |
777 | 801 | // Create an option list for actions allowed to be done with selected members. |
778 | 802 | $allowed_actions = ' |
779 | 803 | <option selected value="">' . $txt['admin_browse_with_selected'] . ':</option> |
780 | 804 | <option value="" disabled>-----------------------------</option>'; |
781 | - foreach ($context['allowed_actions'] as $key => $desc) |
|
782 | - $allowed_actions .= ' |
|
805 | + foreach ($context['allowed_actions'] as $key => $desc) { |
|
806 | + $allowed_actions .= ' |
|
783 | 807 | <option value="' . $key . '">' . $desc . '</option>'; |
808 | + } |
|
784 | 809 | |
785 | 810 | // Setup the Javascript function for selecting an action for the list. |
786 | 811 | $javascript = ' |
@@ -792,15 +817,16 @@ discard block |
||
792 | 817 | var message = "";'; |
793 | 818 | |
794 | 819 | // We have special messages for approving deletion of accounts - it's surprisingly logical - honest. |
795 | - if ($context['current_filter'] == 4) |
|
796 | - $javascript .= ' |
|
820 | + if ($context['current_filter'] == 4) { |
|
821 | + $javascript .= ' |
|
797 | 822 | if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
798 | 823 | message = "' . $txt['admin_browse_w_delete'] . '"; |
799 | 824 | else |
800 | 825 | message = "' . $txt['admin_browse_w_reject'] . '";'; |
826 | + } |
|
801 | 827 | // Otherwise a nice standard message. |
802 | - else |
|
803 | - $javascript .= ' |
|
828 | + else { |
|
829 | + $javascript .= ' |
|
804 | 830 | if (document.forms.postForm.todo.value.indexOf("delete") != -1) |
805 | 831 | message = "' . $txt['admin_browse_w_delete'] . '"; |
806 | 832 | else if (document.forms.postForm.todo.value.indexOf("reject") != -1) |
@@ -809,6 +835,7 @@ discard block |
||
809 | 835 | message = "' . $txt['admin_browse_w_remind'] . '"; |
810 | 836 | else |
811 | 837 | message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";'; |
838 | + } |
|
812 | 839 | $javascript .= ' |
813 | 840 | if (confirm(message + " ' . $txt['admin_browse_warn'] . '")) |
814 | 841 | document.forms.postForm.submit(); |
@@ -941,10 +968,11 @@ discard block |
||
941 | 968 | $member_links = array(); |
942 | 969 | foreach ($rowData['duplicate_members'] as $member) |
943 | 970 | { |
944 | - if ($member['id']) |
|
945 | - $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
946 | - else |
|
947 | - $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
971 | + if ($member['id']) { |
|
972 | + $member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>'; |
|
973 | + } else { |
|
974 | + $member_links[] = $member['name'] . ' (' . $txt['guest'] . ')'; |
|
975 | + } |
|
948 | 976 | } |
949 | 977 | return implode(', ', $member_links); |
950 | 978 | }, |
@@ -993,14 +1021,16 @@ discard block |
||
993 | 1021 | ); |
994 | 1022 | |
995 | 1023 | // Pick what column to actually include if we're showing duplicates. |
996 | - if ($context['show_duplicates']) |
|
997 | - unset($listOptions['columns']['email']); |
|
998 | - else |
|
999 | - unset($listOptions['columns']['duplicates']); |
|
1024 | + if ($context['show_duplicates']) { |
|
1025 | + unset($listOptions['columns']['email']); |
|
1026 | + } else { |
|
1027 | + unset($listOptions['columns']['duplicates']); |
|
1028 | + } |
|
1000 | 1029 | |
1001 | 1030 | // Only show hostname on duplicates as it takes a lot of time. |
1002 | - if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) |
|
1003 | - unset($listOptions['columns']['hostname']); |
|
1031 | + if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) { |
|
1032 | + unset($listOptions['columns']['hostname']); |
|
1033 | + } |
|
1004 | 1034 | |
1005 | 1035 | // Is there any need to show filters? |
1006 | 1036 | if (isset($context['available_filters']) && count($context['available_filters']) > 1) |
@@ -1008,9 +1038,10 @@ discard block |
||
1008 | 1038 | $filterOptions = ' |
1009 | 1039 | <strong>' . $txt['admin_browse_filter_by'] . ':</strong> |
1010 | 1040 | <select name="filter" onchange="this.form.submit();">'; |
1011 | - foreach ($context['available_filters'] as $filter) |
|
1012 | - $filterOptions .= ' |
|
1041 | + foreach ($context['available_filters'] as $filter) { |
|
1042 | + $filterOptions .= ' |
|
1013 | 1043 | <option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>'; |
1044 | + } |
|
1014 | 1045 | $filterOptions .= ' |
1015 | 1046 | </select> |
1016 | 1047 | <noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>'; |
@@ -1022,12 +1053,13 @@ discard block |
||
1022 | 1053 | } |
1023 | 1054 | |
1024 | 1055 | // What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at. |
1025 | - if (!empty($context['show_filter']) && !empty($context['available_filters'])) |
|
1026 | - $listOptions['additional_rows'][] = array( |
|
1056 | + if (!empty($context['show_filter']) && !empty($context['available_filters'])) { |
|
1057 | + $listOptions['additional_rows'][] = array( |
|
1027 | 1058 | 'position' => 'above_column_headers', |
1028 | 1059 | 'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'], |
1029 | 1060 | 'class' => 'smalltext floatright', |
1030 | 1061 | ); |
1062 | + } |
|
1031 | 1063 | |
1032 | 1064 | // Now that we have all the options, create the list. |
1033 | 1065 | require_once($sourcedir . '/Subs-List.php'); |
@@ -1057,12 +1089,14 @@ discard block |
||
1057 | 1089 | $current_filter = (int) $_REQUEST['orig_filter']; |
1058 | 1090 | |
1059 | 1091 | // If we are applying a filter do just that - then redirect. |
1060 | - if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) |
|
1061 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1092 | + if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) { |
|
1093 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']); |
|
1094 | + } |
|
1062 | 1095 | |
1063 | 1096 | // Nothing to do? |
1064 | - if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) |
|
1065 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1097 | + if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) { |
|
1098 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1099 | + } |
|
1066 | 1100 | |
1067 | 1101 | // Are we dealing with members who have been waiting for > set amount of time? |
1068 | 1102 | if (isset($_POST['time_passed'])) |
@@ -1075,8 +1109,9 @@ discard block |
||
1075 | 1109 | else |
1076 | 1110 | { |
1077 | 1111 | $members = array(); |
1078 | - foreach ($_POST['todoAction'] as $id) |
|
1079 | - $members[] = (int) $id; |
|
1112 | + foreach ($_POST['todoAction'] as $id) { |
|
1113 | + $members[] = (int) $id; |
|
1114 | + } |
|
1080 | 1115 | $condition = ' |
1081 | 1116 | AND id_member IN ({array_int:members})'; |
1082 | 1117 | } |
@@ -1097,8 +1132,9 @@ discard block |
||
1097 | 1132 | $member_count = $smcFunc['db_num_rows']($request); |
1098 | 1133 | |
1099 | 1134 | // If no results then just return! |
1100 | - if ($member_count == 0) |
|
1101 | - redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1135 | + if ($member_count == 0) { |
|
1136 | + redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
|
1137 | + } |
|
1102 | 1138 | |
1103 | 1139 | $member_info = array(); |
1104 | 1140 | $members = array(); |
@@ -1137,8 +1173,9 @@ discard block |
||
1137 | 1173 | // Do we have to let the integration code know about the activations? |
1138 | 1174 | if (!empty($modSettings['integrate_activate'])) |
1139 | 1175 | { |
1140 | - foreach ($member_info as $member) |
|
1141 | - call_integration_hook('integrate_activate', array($member['username'])); |
|
1176 | + foreach ($member_info as $member) { |
|
1177 | + call_integration_hook('integrate_activate', array($member['username'])); |
|
1178 | + } |
|
1142 | 1179 | } |
1143 | 1180 | |
1144 | 1181 | // Check for email. |
@@ -1268,20 +1305,23 @@ discard block |
||
1268 | 1305 | $log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member'; |
1269 | 1306 | |
1270 | 1307 | require_once($sourcedir . '/Logging.php'); |
1271 | - foreach ($member_info as $member) |
|
1272 | - logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1308 | + foreach ($member_info as $member) { |
|
1309 | + logAction($log_action, array('member' => $member['id']), 'admin'); |
|
1310 | + } |
|
1273 | 1311 | } |
1274 | 1312 | |
1275 | 1313 | // Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers). |
1276 | - if (in_array($current_filter, array(3, 4, 5))) |
|
1277 | - updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1314 | + if (in_array($current_filter, array(3, 4, 5))) { |
|
1315 | + updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0))); |
|
1316 | + } |
|
1278 | 1317 | |
1279 | 1318 | // Update the member's stats. (but, we know the member didn't change their name.) |
1280 | 1319 | updateStats('member', false); |
1281 | 1320 | |
1282 | 1321 | // If they haven't been deleted, update the post group statistics on them... |
1283 | - if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) |
|
1284 | - updateStats('postgroups', $members); |
|
1322 | + if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) { |
|
1323 | + updateStats('postgroups', $members); |
|
1324 | + } |
|
1285 | 1325 | |
1286 | 1326 | redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']); |
1287 | 1327 | } |
@@ -1306,10 +1346,11 @@ discard block |
||
1306 | 1346 | $dis = time() - $old; |
1307 | 1347 | |
1308 | 1348 | // Before midnight? |
1309 | - if ($dis < $sinceMidnight) |
|
1310 | - return 0; |
|
1311 | - else |
|
1312 | - $dis -= $sinceMidnight; |
|
1349 | + if ($dis < $sinceMidnight) { |
|
1350 | + return 0; |
|
1351 | + } else { |
|
1352 | + $dis -= $sinceMidnight; |
|
1353 | + } |
|
1313 | 1354 | |
1314 | 1355 | // Divide out the seconds in a day to get the number of days. |
1315 | 1356 | return ceil($dis / (24 * 60 * 60)); |