@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
171 | 179 | { |
172 | - if ($id_member_started == $user_info['id']) |
|
173 | - isAllowedTo('move_own'); |
|
174 | - else |
|
175 | - isAllowedTo('move_any'); |
|
180 | + if ($id_member_started == $user_info['id']) { |
|
181 | + isAllowedTo('move_own'); |
|
182 | + } else { |
|
183 | + isAllowedTo('move_any'); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | |
178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | 'blank_redirect' => '', |
198 | 207 | ) |
199 | 208 | ); |
200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
201 | - fatal_lang_error('no_board'); |
|
209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
210 | + fatal_lang_error('no_board'); |
|
211 | + } |
|
202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
203 | 213 | $smcFunc['db_free_result']($request); |
204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
210 | 220 | { |
211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
212 | 222 | // Keep checking the length. |
213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
225 | + } |
|
215 | 226 | |
216 | 227 | // If it's still valid move onwards and upwards. |
217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
221 | 232 | // Get a response prefix, but in the forum's default language. |
222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
223 | 234 | { |
224 | - if ($language === $user_info['language']) |
|
225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
226 | - else |
|
235 | + if ($language === $user_info['language']) { |
|
236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
237 | + } else |
|
227 | 238 | { |
228 | 239 | loadLanguage('index', $language, false); |
229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
263 | 274 | if (isset($_POST['postRedirect'])) |
264 | 275 | { |
265 | 276 | // Should be in the boardwide language. |
266 | - if ($user_info['language'] != $language) |
|
267 | - loadLanguage('index', $language); |
|
277 | + if ($user_info['language'] != $language) { |
|
278 | + loadLanguage('index', $language); |
|
279 | + } |
|
268 | 280 | |
269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
328 | 340 | $posters = array(); |
329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
330 | 342 | { |
331 | - if (!isset($posters[$row['id_member']])) |
|
332 | - $posters[$row['id_member']] = 0; |
|
343 | + if (!isset($posters[$row['id_member']])) { |
|
344 | + $posters[$row['id_member']] = 0; |
|
345 | + } |
|
333 | 346 | |
334 | 347 | $posters[$row['id_member']]++; |
335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
338 | 351 | foreach ($posters as $id_member => $posts) |
339 | 352 | { |
340 | 353 | // The board we're moving from counted posts, but not to. |
341 | - if (empty($pcounter_from)) |
|
342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
354 | + if (empty($pcounter_from)) { |
|
355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
356 | + } |
|
343 | 357 | // The reverse: from didn't, to did. |
344 | - else |
|
345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
358 | + else { |
|
359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
360 | + } |
|
346 | 361 | } |
347 | 362 | } |
348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
350 | 365 | moveTopics($topic, $_POST['toboard']); |
351 | 366 | |
352 | 367 | // Log that they moved this topic. |
353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
370 | + } |
|
355 | 371 | // Notify people that this topic has been moved? |
356 | 372 | sendNotifications($topic, 'move'); |
357 | 373 | |
358 | 374 | // Why not go back to the original board in case they want to keep moving? |
359 | - if (!isset($_REQUEST['goback'])) |
|
360 | - redirectexit('board=' . $board . '.0'); |
|
361 | - else |
|
362 | - redirectexit('topic=' . $topic . '.0'); |
|
363 | -} |
|
375 | + if (!isset($_REQUEST['goback'])) { |
|
376 | + redirectexit('board=' . $board . '.0'); |
|
377 | + } else { |
|
378 | + redirectexit('topic=' . $topic . '.0'); |
|
379 | + } |
|
380 | + } |
|
364 | 381 | |
365 | 382 | /** |
366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
377 | 394 | |
378 | 395 | // Empty array? |
379 | - if (empty($topics)) |
|
380 | - return; |
|
396 | + if (empty($topics)) { |
|
397 | + return; |
|
398 | + } |
|
381 | 399 | |
382 | 400 | // Only a single topic. |
383 | - if (is_numeric($topics)) |
|
384 | - $topics = array($topics); |
|
401 | + if (is_numeric($topics)) { |
|
402 | + $topics = array($topics); |
|
403 | + } |
|
385 | 404 | |
386 | 405 | $fromBoards = array(); |
387 | 406 | |
388 | 407 | // Destination board empty or equal to 0? |
389 | - if (empty($toBoard)) |
|
390 | - return; |
|
408 | + if (empty($toBoard)) { |
|
409 | + return; |
|
410 | + } |
|
391 | 411 | |
392 | 412 | // Are we moving to the recycle board? |
393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
395 | 415 | // Callback for search APIs to do their thing |
396 | 416 | require_once($sourcedir . '/Search.php'); |
397 | 417 | $searchAPI = findSearchAPI(); |
398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
420 | + } |
|
400 | 421 | |
401 | 422 | // Determine the source boards... |
402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
410 | 431 | ) |
411 | 432 | ); |
412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
414 | - return; |
|
434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
435 | + return; |
|
436 | + } |
|
415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
416 | 438 | { |
417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
430 | 452 | |
431 | 453 | // Add the topics to the right type. |
432 | - if ($row['approved']) |
|
433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
434 | - else |
|
435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
454 | + if ($row['approved']) { |
|
455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
456 | + } else { |
|
457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
458 | + } |
|
436 | 459 | } |
437 | 460 | $smcFunc['db_free_result']($request); |
438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
558 | 581 | ) |
559 | 582 | ); |
560 | 583 | $approval_msgs = array(); |
561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
562 | - $approval_msgs[] = $row['id_msg']; |
|
584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
585 | + $approval_msgs[] = $row['id_msg']; |
|
586 | + } |
|
563 | 587 | $smcFunc['db_free_result']($request); |
564 | 588 | |
565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
566 | - if (!empty($approval_msgs)) |
|
567 | - $smcFunc['db_query']('', ' |
|
590 | + if (!empty($approval_msgs)) { |
|
591 | + $smcFunc['db_query']('', ' |
|
568 | 592 | DELETE FROM {db_prefix}approval_queue |
569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
573 | 597 | 'id_attach' => 0, |
574 | 598 | ) |
575 | 599 | ); |
600 | + } |
|
576 | 601 | |
577 | 602 | // Get all the current max and mins. |
578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
607 | 632 | { |
608 | 633 | // If not, update. |
609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
610 | - $smcFunc['db_query']('', ' |
|
634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
635 | + $smcFunc['db_query']('', ' |
|
611 | 636 | UPDATE {db_prefix}topics |
612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
617 | 642 | 'selected_topic' => $row['id_topic'], |
618 | 643 | ) |
619 | 644 | ); |
645 | + } |
|
620 | 646 | } |
621 | 647 | $smcFunc['db_free_result']($request); |
622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
675 | 701 | } |
676 | 702 | |
677 | 703 | // Update the cache? |
678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
679 | - foreach ($topics as $topic_id) |
|
704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
705 | + foreach ($topics as $topic_id) |
|
680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
707 | + } |
|
681 | 708 | |
682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
701 | 728 | { |
702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
703 | 730 | |
704 | - if (isset($_GET['current_board'])) |
|
705 | - $move_from = (int) $_GET['current_board']; |
|
731 | + if (isset($_GET['current_board'])) { |
|
732 | + $move_from = (int) $_GET['current_board']; |
|
733 | + } |
|
706 | 734 | |
707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
708 | - return true; |
|
735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
736 | + return true; |
|
737 | + } |
|
709 | 738 | |
710 | - if ($move_from == $board) |
|
711 | - return true; |
|
712 | - else |
|
739 | + if ($move_from == $board) { |
|
740 | + return true; |
|
741 | + } else |
|
713 | 742 | { |
714 | 743 | $request = $smcFunc['db_query']('', ' |
715 | 744 | SELECT m.subject, b.name |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 3 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
65 | 68 | @ini_set('session.serialize_handler', 'php'); |
66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
67 | 70 | @ini_set('session.gc_probability', '1'); |
71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
68 | 73 | } |
69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
71 | 74 | |
72 | 75 | // Use cache setting sessions? |
73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
74 | - call_integration_hook('integrate_session_handlers'); |
|
76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
77 | + call_integration_hook('integrate_session_handlers'); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | session_start(); |
77 | 81 | |
78 | 82 | // Change it so the cache settings are a little looser than default. |
79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
80 | - header('Cache-Control: private'); |
|
83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
84 | + header('Cache-Control: private'); |
|
85 | + } |
|
81 | 86 | } |
82 | 87 | |
83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | { |
124 | 129 | global $smcFunc; |
125 | 130 | |
126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
127 | - return ''; |
|
131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
132 | + return ''; |
|
133 | + } |
|
128 | 134 | |
129 | 135 | // Look for it in the database. |
130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | { |
154 | 160 | global $smcFunc; |
155 | 161 | |
156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
157 | - return false; |
|
162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
163 | + return false; |
|
164 | + } |
|
158 | 165 | |
159 | 166 | // First try to update an existing row... |
160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
169 | 176 | ); |
170 | 177 | |
171 | 178 | // If that didn't work, try inserting a new one. |
172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
173 | - $smcFunc['db_insert']('ignore', |
|
179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
180 | + $smcFunc['db_insert']('ignore', |
|
174 | 181 | '{db_prefix}sessions', |
175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
176 | 183 | array($session_id, $data, time()), |
177 | 184 | array('session_id') |
178 | 185 | ); |
186 | + } |
|
179 | 187 | |
180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
190 | 198 | { |
191 | 199 | global $smcFunc; |
192 | 200 | |
193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
194 | - return false; |
|
201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
202 | + return false; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | // Just delete the row... |
197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
217 | 226 | global $modSettings, $smcFunc; |
218 | 227 | |
219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
231 | + } |
|
222 | 232 | |
223 | 233 | // Clean up after yerself ;). |
224 | 234 | $smcFunc['db_query']('', ' |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
35 | 36 | |
36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
37 | 38 | { |
38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
39 | - $modSettings['enableCompressedOutput'] = 0; |
|
40 | - |
|
41 | - else |
|
42 | - ob_start('ob_gzhandler'); |
|
39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
40 | + $modSettings['enableCompressedOutput'] = 0; |
|
41 | + } else { |
|
42 | + ob_start('ob_gzhandler'); |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | |
45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | } |
72 | 73 | |
73 | 74 | // Use cache when possible. |
74 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
75 | - list($file, $thumbFile) = $cache; |
|
75 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
76 | + list($file, $thumbFile) = $cache; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | // Get the info from the DB. |
78 | 80 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
81 | 83 | $attachRequest = null; |
82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
84 | - $request = $attachRequest; |
|
85 | - |
|
86 | - else |
|
85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
86 | + $request = $attachRequest; |
|
87 | + } else |
|
87 | 88 | { |
88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,14 @@ discard block |
||
176 | 177 | } |
177 | 178 | |
178 | 179 | // Cache it. |
179 | - if (!empty($file) || !empty($thumbFile)) |
|
180 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
180 | + if (!empty($file) || !empty($thumbFile)) { |
|
181 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
182 | + } |
|
181 | 183 | } |
182 | 184 | |
183 | 185 | // Update the download counter (unless it's a thumbnail). |
184 | - if ($file['attachment_type'] != 3 && empty($showThumb)) |
|
185 | - $smcFunc['db_query']('attach_download_increase', ' |
|
186 | + if ($file['attachment_type'] != 3 && empty($showThumb)) { |
|
187 | + $smcFunc['db_query']('attach_download_increase', ' |
|
186 | 188 | UPDATE LOW_PRIORITY {db_prefix}attachments |
187 | 189 | SET downloads = downloads + 1 |
188 | 190 | WHERE id_attach = {int:id_attach}', |
@@ -190,10 +192,12 @@ discard block |
||
190 | 192 | 'id_attach' => $attachId, |
191 | 193 | ) |
192 | 194 | ); |
195 | + } |
|
193 | 196 | |
194 | 197 | // Replace the normal file with its thumbnail if it has one! |
195 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
196 | - $file = $thumbFile; |
|
198 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
199 | + $file = $thumbFile; |
|
200 | + } |
|
197 | 201 | |
198 | 202 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
199 | 203 | if (!file_exists($file['filePath'])) |
@@ -232,8 +236,9 @@ discard block |
||
232 | 236 | // Send the attachment headers. |
233 | 237 | header('Pragma: '); |
234 | 238 | |
235 | - if (!isBrowser('gecko')) |
|
236 | - header('Content-Transfer-Encoding: binary'); |
|
239 | + if (!isBrowser('gecko')) { |
|
240 | + header('Content-Transfer-Encoding: binary'); |
|
241 | + } |
|
237 | 242 | |
238 | 243 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
239 | 244 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -242,18 +247,19 @@ discard block |
||
242 | 247 | header('ETag: ' . $eTag); |
243 | 248 | |
244 | 249 | // Make sure the mime type warrants an inline display. |
245 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
246 | - unset($_REQUEST['image']); |
|
250 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
251 | + unset($_REQUEST['image']); |
|
252 | + } |
|
247 | 253 | |
248 | 254 | // Does this have a mime type? |
249 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
250 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
251 | - |
|
252 | - else |
|
255 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
256 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
255 | - if (isset($_REQUEST['image'])) |
|
256 | - unset($_REQUEST['image']); |
|
260 | + if (isset($_REQUEST['image'])) { |
|
261 | + unset($_REQUEST['image']); |
|
262 | + } |
|
257 | 263 | } |
258 | 264 | |
259 | 265 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -261,24 +267,22 @@ discard block |
||
261 | 267 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
262 | 268 | |
263 | 269 | // Different browsers like different standards... |
264 | - if (isBrowser('firefox')) |
|
265 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
266 | - |
|
267 | - elseif (isBrowser('opera')) |
|
268 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
269 | - |
|
270 | - elseif (isBrowser('ie')) |
|
271 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
272 | - |
|
273 | - else |
|
274 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
270 | + if (isBrowser('firefox')) { |
|
271 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
272 | + } elseif (isBrowser('opera')) { |
|
273 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
274 | + } elseif (isBrowser('ie')) { |
|
275 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
276 | + } else { |
|
277 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
278 | + } |
|
275 | 279 | |
276 | 280 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
277 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
278 | - header('Cache-Control: no-cache'); |
|
279 | - |
|
280 | - else |
|
281 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
281 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
282 | + header('Cache-Control: no-cache'); |
|
283 | + } else { |
|
284 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
285 | + } |
|
282 | 286 | |
283 | 287 | header('Content-Length: ' . filesize($file['filePath'])); |
284 | 288 | |
@@ -289,8 +293,9 @@ discard block |
||
289 | 293 | if (filesize($file['filePath']) > 4194304) |
290 | 294 | { |
291 | 295 | // Forcibly end any output buffering going on. |
292 | - while (@ob_get_level() > 0) |
|
293 | - @ob_end_clean(); |
|
296 | + while (@ob_get_level() > 0) { |
|
297 | + @ob_end_clean(); |
|
298 | + } |
|
294 | 299 | |
295 | 300 | $fp = fopen($file['filePath'], 'rb'); |
296 | 301 | while (!feof($fp)) |
@@ -302,8 +307,9 @@ discard block |
||
302 | 307 | } |
303 | 308 | |
304 | 309 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
305 | - elseif (@readfile($file['filePath']) === null) |
|
306 | - echo file_get_contents($file['filePath']); |
|
310 | + elseif (@readfile($file['filePath']) === null) { |
|
311 | + echo file_get_contents($file['filePath']); |
|
312 | + } |
|
307 | 313 | |
308 | 314 | die(); |
309 | 315 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Mark a board or multiple boards read. |
@@ -28,14 +29,16 @@ discard block |
||
28 | 29 | global $user_info, $modSettings, $smcFunc; |
29 | 30 | |
30 | 31 | // Force $boards to be an array. |
31 | - if (!is_array($boards)) |
|
32 | - $boards = array($boards); |
|
33 | - else |
|
34 | - $boards = array_unique($boards); |
|
32 | + if (!is_array($boards)) { |
|
33 | + $boards = array($boards); |
|
34 | + } else { |
|
35 | + $boards = array_unique($boards); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // No boards, nothing to mark as read. |
37 | - if (empty($boards)) |
|
38 | - return; |
|
39 | + if (empty($boards)) { |
|
40 | + return; |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Allow the user to mark a board as unread. |
41 | 44 | if ($unread) |
@@ -65,8 +68,9 @@ discard block |
||
65 | 68 | else |
66 | 69 | { |
67 | 70 | $markRead = array(); |
68 | - foreach ($boards as $board) |
|
69 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
71 | + foreach ($boards as $board) { |
|
72 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $board); |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Update log_mark_read and log_boards. |
72 | 76 | $smcFunc['db_insert']('replace', |
@@ -99,8 +103,9 @@ discard block |
||
99 | 103 | list ($lowest_topic) = $smcFunc['db_fetch_row']($result); |
100 | 104 | $smcFunc['db_free_result']($result); |
101 | 105 | |
102 | - if (empty($lowest_topic)) |
|
103 | - return; |
|
106 | + if (empty($lowest_topic)) { |
|
107 | + return; |
|
108 | + } |
|
104 | 109 | |
105 | 110 | // @todo SLOW This query seems to eat it sometimes. |
106 | 111 | $result = $smcFunc['db_query']('', ' |
@@ -118,12 +123,13 @@ discard block |
||
118 | 123 | ) |
119 | 124 | ); |
120 | 125 | $topics = array(); |
121 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
122 | - $topics[] = $row['id_topic']; |
|
126 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
127 | + $topics[] = $row['id_topic']; |
|
128 | + } |
|
123 | 129 | $smcFunc['db_free_result']($result); |
124 | 130 | |
125 | - if (!empty($topics)) |
|
126 | - $smcFunc['db_query']('', ' |
|
131 | + if (!empty($topics)) { |
|
132 | + $smcFunc['db_query']('', ' |
|
127 | 133 | DELETE FROM {db_prefix}log_topics |
128 | 134 | WHERE id_member = {int:current_member} |
129 | 135 | AND id_topic IN ({array_int:topic_list})', |
@@ -132,7 +138,8 @@ discard block |
||
132 | 138 | 'topic_list' => $topics, |
133 | 139 | ) |
134 | 140 | ); |
135 | -} |
|
141 | + } |
|
142 | + } |
|
136 | 143 | |
137 | 144 | /** |
138 | 145 | * Mark one or more boards as read. |
@@ -157,23 +164,26 @@ discard block |
||
157 | 164 | ) |
158 | 165 | ); |
159 | 166 | $boards = array(); |
160 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
161 | - $boards[] = $row['id_board']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
168 | + $boards[] = $row['id_board']; |
|
169 | + } |
|
162 | 170 | $smcFunc['db_free_result']($result); |
163 | 171 | |
164 | - if (!empty($boards)) |
|
165 | - markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
172 | + if (!empty($boards)) { |
|
173 | + markBoardsRead($boards, isset($_REQUEST['unread'])); |
|
174 | + } |
|
166 | 175 | |
167 | 176 | $_SESSION['id_msg_last_visit'] = $modSettings['maxMsgID']; |
168 | - if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) |
|
169 | - redirectexit('action=unread'); |
|
177 | + if (!empty($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'action=unread') !== false) { |
|
178 | + redirectexit('action=unread'); |
|
179 | + } |
|
170 | 180 | |
171 | - if (isset($_SESSION['topicseen_cache'])) |
|
172 | - $_SESSION['topicseen_cache'] = array(); |
|
181 | + if (isset($_SESSION['topicseen_cache'])) { |
|
182 | + $_SESSION['topicseen_cache'] = array(); |
|
183 | + } |
|
173 | 184 | |
174 | 185 | redirectexit(); |
175 | - } |
|
176 | - elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
186 | + } elseif (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'unreadreplies') |
|
177 | 187 | { |
178 | 188 | // Make sure all the topics are integers! |
179 | 189 | $topics = array_map('intval', explode('-', $_REQUEST['topics'])); |
@@ -189,13 +199,15 @@ discard block |
||
189 | 199 | ) |
190 | 200 | ); |
191 | 201 | $logged_topics = array(); |
192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
193 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
202 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
203 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
204 | + } |
|
194 | 205 | $smcFunc['db_free_result']($request); |
195 | 206 | |
196 | 207 | $markRead = array(); |
197 | - foreach ($topics as $id_topic) |
|
198 | - $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
208 | + foreach ($topics as $id_topic) { |
|
209 | + $markRead[] = array($modSettings['maxMsgID'], $user_info['id'], $id_topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
210 | + } |
|
199 | 211 | |
200 | 212 | $smcFunc['db_insert']('replace', |
201 | 213 | '{db_prefix}log_topics', |
@@ -204,8 +216,9 @@ discard block |
||
204 | 216 | array('id_member', 'id_topic') |
205 | 217 | ); |
206 | 218 | |
207 | - if (isset($_SESSION['topicseen_cache'])) |
|
208 | - $_SESSION['topicseen_cache'] = array(); |
|
219 | + if (isset($_SESSION['topicseen_cache'])) { |
|
220 | + $_SESSION['topicseen_cache'] = array(); |
|
221 | + } |
|
209 | 222 | |
210 | 223 | redirectexit('action=unreadreplies'); |
211 | 224 | } |
@@ -230,11 +243,13 @@ discard block |
||
230 | 243 | if (!empty($_GET['t'])) |
231 | 244 | { |
232 | 245 | // If they read the whole topic, go back to the beginning. |
233 | - if ($_GET['t'] >= $topicinfo['id_last_msg']) |
|
234 | - $earlyMsg = 0; |
|
246 | + if ($_GET['t'] >= $topicinfo['id_last_msg']) { |
|
247 | + $earlyMsg = 0; |
|
248 | + } |
|
235 | 249 | // If they want to mark the whole thing read, same. |
236 | - elseif ($_GET['t'] <= $topicinfo['id_first_msg']) |
|
237 | - $earlyMsg = 0; |
|
250 | + elseif ($_GET['t'] <= $topicinfo['id_first_msg']) { |
|
251 | + $earlyMsg = 0; |
|
252 | + } |
|
238 | 253 | // Otherwise, get the latest message before the named one. |
239 | 254 | else |
240 | 255 | { |
@@ -255,9 +270,9 @@ discard block |
||
255 | 270 | } |
256 | 271 | } |
257 | 272 | // Marking read from first page? That's the whole topic. |
258 | - elseif ($_REQUEST['start'] == 0) |
|
259 | - $earlyMsg = 0; |
|
260 | - else |
|
273 | + elseif ($_REQUEST['start'] == 0) { |
|
274 | + $earlyMsg = 0; |
|
275 | + } else |
|
261 | 276 | { |
262 | 277 | $result = $smcFunc['db_query']('', ' |
263 | 278 | SELECT id_msg |
@@ -285,8 +300,7 @@ discard block |
||
285 | 300 | ); |
286 | 301 | |
287 | 302 | redirectexit('board=' . $board . '.0'); |
288 | - } |
|
289 | - else |
|
303 | + } else |
|
290 | 304 | { |
291 | 305 | $categories = array(); |
292 | 306 | $boards = array(); |
@@ -294,17 +308,20 @@ discard block |
||
294 | 308 | if (isset($_REQUEST['c'])) |
295 | 309 | { |
296 | 310 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
297 | - foreach ($_REQUEST['c'] as $c) |
|
298 | - $categories[] = (int) $c; |
|
311 | + foreach ($_REQUEST['c'] as $c) { |
|
312 | + $categories[] = (int) $c; |
|
313 | + } |
|
299 | 314 | } |
300 | 315 | if (isset($_REQUEST['boards'])) |
301 | 316 | { |
302 | 317 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
303 | - foreach ($_REQUEST['boards'] as $b) |
|
304 | - $boards[] = (int) $b; |
|
318 | + foreach ($_REQUEST['boards'] as $b) { |
|
319 | + $boards[] = (int) $b; |
|
320 | + } |
|
321 | + } |
|
322 | + if (!empty($board)) { |
|
323 | + $boards[] = (int) $board; |
|
305 | 324 | } |
306 | - if (!empty($board)) |
|
307 | - $boards[] = (int) $board; |
|
308 | 325 | |
309 | 326 | if (isset($_REQUEST['children']) && !empty($boards)) |
310 | 327 | { |
@@ -324,9 +341,10 @@ discard block |
||
324 | 341 | 'board_list' => $boards, |
325 | 342 | ) |
326 | 343 | ); |
327 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
328 | - if (in_array($row['id_parent'], $boards)) |
|
344 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
345 | + if (in_array($row['id_parent'], $boards)) |
|
329 | 346 | $boards[] = $row['id_board']; |
347 | + } |
|
330 | 348 | $smcFunc['db_free_result']($request); |
331 | 349 | } |
332 | 350 | |
@@ -343,8 +361,9 @@ discard block |
||
343 | 361 | $clauseParameters['board_list'] = $boards; |
344 | 362 | } |
345 | 363 | |
346 | - if (empty($clauses)) |
|
347 | - redirectexit(); |
|
364 | + if (empty($clauses)) { |
|
365 | + redirectexit(); |
|
366 | + } |
|
348 | 367 | |
349 | 368 | $request = $smcFunc['db_query']('', ' |
350 | 369 | SELECT b.id_board |
@@ -355,19 +374,22 @@ discard block |
||
355 | 374 | )) |
356 | 375 | ); |
357 | 376 | $boards = array(); |
358 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
359 | - $boards[] = $row['id_board']; |
|
377 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
378 | + $boards[] = $row['id_board']; |
|
379 | + } |
|
360 | 380 | $smcFunc['db_free_result']($request); |
361 | 381 | |
362 | - if (empty($boards)) |
|
363 | - redirectexit(); |
|
382 | + if (empty($boards)) { |
|
383 | + redirectexit(); |
|
384 | + } |
|
364 | 385 | |
365 | 386 | markBoardsRead($boards, isset($_REQUEST['unread'])); |
366 | 387 | |
367 | 388 | foreach ($boards as $b) |
368 | 389 | { |
369 | - if (isset($_SESSION['topicseen_cache'][$b])) |
|
370 | - $_SESSION['topicseen_cache'][$b] = array(); |
|
390 | + if (isset($_SESSION['topicseen_cache'][$b])) { |
|
391 | + $_SESSION['topicseen_cache'][$b] = array(); |
|
392 | + } |
|
371 | 393 | } |
372 | 394 | |
373 | 395 | if (!isset($_REQUEST['unread'])) |
@@ -385,8 +407,9 @@ discard block |
||
385 | 407 | if ($smcFunc['db_num_rows']($result) > 0) |
386 | 408 | { |
387 | 409 | $logBoardInserts = ''; |
388 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
389 | - $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
410 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
411 | + $logBoardInserts[] = array($modSettings['maxMsgID'], $user_info['id'], $row['id_board']); |
|
412 | + } |
|
390 | 413 | |
391 | 414 | $smcFunc['db_insert']('replace', |
392 | 415 | '{db_prefix}log_boards', |
@@ -397,17 +420,18 @@ discard block |
||
397 | 420 | } |
398 | 421 | $smcFunc['db_free_result']($result); |
399 | 422 | |
400 | - if (empty($board)) |
|
401 | - redirectexit(); |
|
402 | - else |
|
403 | - redirectexit('board=' . $board . '.0'); |
|
404 | - } |
|
405 | - else |
|
423 | + if (empty($board)) { |
|
424 | + redirectexit(); |
|
425 | + } else { |
|
426 | + redirectexit('board=' . $board . '.0'); |
|
427 | + } |
|
428 | + } else |
|
406 | 429 | { |
407 | - if (empty($board_info['parent'])) |
|
408 | - redirectexit(); |
|
409 | - else |
|
410 | - redirectexit('board=' . $board_info['parent'] . '.0'); |
|
430 | + if (empty($board_info['parent'])) { |
|
431 | + redirectexit(); |
|
432 | + } else { |
|
433 | + redirectexit('board=' . $board_info['parent'] . '.0'); |
|
434 | + } |
|
411 | 435 | } |
412 | 436 | } |
413 | 437 | } |
@@ -432,11 +456,13 @@ discard block |
||
432 | 456 | 'selected_message' => (int) $messageID, |
433 | 457 | ) |
434 | 458 | ); |
435 | - if ($smcFunc['db_num_rows']($result) > 0) |
|
436 | - list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
459 | + if ($smcFunc['db_num_rows']($result) > 0) { |
|
460 | + list ($memberID) = $smcFunc['db_fetch_row']($result); |
|
461 | + } |
|
437 | 462 | // The message doesn't even exist. |
438 | - else |
|
439 | - $memberID = 0; |
|
463 | + else { |
|
464 | + $memberID = 0; |
|
465 | + } |
|
440 | 466 | $smcFunc['db_free_result']($result); |
441 | 467 | |
442 | 468 | return (int) $memberID; |
@@ -457,8 +483,9 @@ discard block |
||
457 | 483 | getBoardTree(); |
458 | 484 | |
459 | 485 | // Make sure given boards and categories exist. |
460 | - if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) |
|
461 | - fatal_lang_error('no_board'); |
|
486 | + if (!isset($boards[$board_id]) || (isset($boardOptions['target_board']) && !isset($boards[$boardOptions['target_board']])) || (isset($boardOptions['target_category']) && !isset($cat_tree[$boardOptions['target_category']]))) { |
|
487 | + fatal_lang_error('no_board'); |
|
488 | + } |
|
462 | 489 | |
463 | 490 | $id = $board_id; |
464 | 491 | call_integration_hook('integrate_pre_modify_board', array($id, &$boardOptions)); |
@@ -486,8 +513,9 @@ discard block |
||
486 | 513 | $child_level = 0; |
487 | 514 | $id_parent = 0; |
488 | 515 | $after = 0; |
489 | - foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) |
|
490 | - $after = max($after, $boards[$id_board]['order']); |
|
516 | + foreach ($cat_tree[$id_cat]['children'] as $id_board => $dummy) { |
|
517 | + $after = max($after, $boards[$id_board]['order']); |
|
518 | + } |
|
491 | 519 | } |
492 | 520 | |
493 | 521 | // Make the board a child of a given board. |
@@ -498,17 +526,19 @@ discard block |
||
498 | 526 | $id_parent = $boardOptions['target_board']; |
499 | 527 | |
500 | 528 | // People can be creative, in many ways... |
501 | - if (isChildOf($id_parent, $board_id)) |
|
502 | - fatal_lang_error('mboards_parent_own_child_error', false); |
|
503 | - elseif ($id_parent == $board_id) |
|
504 | - fatal_lang_error('mboards_board_own_child_error', false); |
|
529 | + if (isChildOf($id_parent, $board_id)) { |
|
530 | + fatal_lang_error('mboards_parent_own_child_error', false); |
|
531 | + } elseif ($id_parent == $board_id) { |
|
532 | + fatal_lang_error('mboards_board_own_child_error', false); |
|
533 | + } |
|
505 | 534 | |
506 | 535 | $after = $boards[$boardOptions['target_board']]['order']; |
507 | 536 | |
508 | 537 | // Check if there are already children and (if so) get the max board order. |
509 | - if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) |
|
510 | - foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
538 | + if (!empty($boards[$id_parent]['tree']['children']) && empty($boardOptions['move_first_child'])) { |
|
539 | + foreach ($boards[$id_parent]['tree']['children'] as $childBoard_id => $dummy) |
|
511 | 540 | $after = max($after, $boards[$childBoard_id]['order']); |
541 | + } |
|
512 | 542 | } |
513 | 543 | |
514 | 544 | // Place a board before or after another board, on the same child level. |
@@ -521,8 +551,9 @@ discard block |
||
521 | 551 | } |
522 | 552 | |
523 | 553 | // Oops...? |
524 | - else |
|
525 | - trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
554 | + else { |
|
555 | + trigger_error('modifyBoard(): The move_to value \'' . $boardOptions['move_to'] . '\' is incorrect', E_USER_ERROR); |
|
556 | + } |
|
526 | 557 | |
527 | 558 | // Get a list of children of this board. |
528 | 559 | $childList = array(); |
@@ -531,14 +562,16 @@ discard block |
||
531 | 562 | // See if there are changes that affect children. |
532 | 563 | $childUpdates = array(); |
533 | 564 | $levelDiff = $child_level - $boards[$board_id]['level']; |
534 | - if ($levelDiff != 0) |
|
535 | - $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
536 | - if ($id_cat != $boards[$board_id]['category']) |
|
537 | - $childUpdates[] = 'id_cat = {int:category}'; |
|
565 | + if ($levelDiff != 0) { |
|
566 | + $childUpdates[] = 'child_level = child_level ' . ($levelDiff > 0 ? '+ ' : '') . '{int:level_diff}'; |
|
567 | + } |
|
568 | + if ($id_cat != $boards[$board_id]['category']) { |
|
569 | + $childUpdates[] = 'id_cat = {int:category}'; |
|
570 | + } |
|
538 | 571 | |
539 | 572 | // Fix the children of this board. |
540 | - if (!empty($childList) && !empty($childUpdates)) |
|
541 | - $smcFunc['db_query']('', ' |
|
573 | + if (!empty($childList) && !empty($childUpdates)) { |
|
574 | + $smcFunc['db_query']('', ' |
|
542 | 575 | UPDATE {db_prefix}boards |
543 | 576 | SET ' . implode(', |
544 | 577 | ', $childUpdates) . ' |
@@ -549,6 +582,7 @@ discard block |
||
549 | 582 | 'level_diff' => $levelDiff, |
550 | 583 | ) |
551 | 584 | ); |
585 | + } |
|
552 | 586 | |
553 | 587 | // Make some room for this spot. |
554 | 588 | $smcFunc['db_query']('', ' |
@@ -644,8 +678,8 @@ discard block |
||
644 | 678 | call_integration_hook('integrate_modify_board', array($id, &$boardUpdates, &$boardUpdateParameters)); |
645 | 679 | |
646 | 680 | // Do the updates (if any). |
647 | - if (!empty($boardUpdates)) |
|
648 | - $smcFunc['db_query']('', ' |
|
681 | + if (!empty($boardUpdates)) { |
|
682 | + $smcFunc['db_query']('', ' |
|
649 | 683 | UPDATE {db_prefix}boards |
650 | 684 | SET |
651 | 685 | ' . implode(', |
@@ -655,6 +689,7 @@ discard block |
||
655 | 689 | 'selected_board' => $board_id, |
656 | 690 | )) |
657 | 691 | ); |
692 | + } |
|
658 | 693 | |
659 | 694 | // Set moderators of this board. |
660 | 695 | if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string'])) |
@@ -679,13 +714,15 @@ discard block |
||
679 | 714 | { |
680 | 715 | $moderators[$k] = trim($moderators[$k]); |
681 | 716 | |
682 | - if (strlen($moderators[$k]) == 0) |
|
683 | - unset($moderators[$k]); |
|
717 | + if (strlen($moderators[$k]) == 0) { |
|
718 | + unset($moderators[$k]); |
|
719 | + } |
|
684 | 720 | } |
685 | 721 | |
686 | 722 | // Find all the id_member's for the member_name's in the list. |
687 | - if (empty($boardOptions['moderators'])) |
|
688 | - $boardOptions['moderators'] = array(); |
|
723 | + if (empty($boardOptions['moderators'])) { |
|
724 | + $boardOptions['moderators'] = array(); |
|
725 | + } |
|
689 | 726 | if (!empty($moderators)) |
690 | 727 | { |
691 | 728 | $request = $smcFunc['db_query']('', ' |
@@ -698,8 +735,9 @@ discard block |
||
698 | 735 | 'limit' => count($moderators), |
699 | 736 | ) |
700 | 737 | ); |
701 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
702 | - $boardOptions['moderators'][] = $row['id_member']; |
|
738 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
739 | + $boardOptions['moderators'][] = $row['id_member']; |
|
740 | + } |
|
703 | 741 | $smcFunc['db_free_result']($request); |
704 | 742 | } |
705 | 743 | } |
@@ -708,8 +746,9 @@ discard block |
||
708 | 746 | if (!empty($boardOptions['moderators'])) |
709 | 747 | { |
710 | 748 | $inserts = array(); |
711 | - foreach ($boardOptions['moderators'] as $moderator) |
|
712 | - $inserts[] = array($board_id, $moderator); |
|
749 | + foreach ($boardOptions['moderators'] as $moderator) { |
|
750 | + $inserts[] = array($board_id, $moderator); |
|
751 | + } |
|
713 | 752 | |
714 | 753 | $smcFunc['db_insert']('insert', |
715 | 754 | '{db_prefix}moderators', |
@@ -739,14 +778,16 @@ discard block |
||
739 | 778 | { |
740 | 779 | $moderator_groups[$k] = trim($moderator_groups[$k]); |
741 | 780 | |
742 | - if (strlen($moderator_groups[$k]) == 0) |
|
743 | - unset($moderator_groups[$k]); |
|
781 | + if (strlen($moderator_groups[$k]) == 0) { |
|
782 | + unset($moderator_groups[$k]); |
|
783 | + } |
|
744 | 784 | } |
745 | 785 | |
746 | 786 | /* Find all the id_group's for all the group names in the list |
747 | 787 | But skip any invalid ones (invisible/post groups/Administrator/Moderator) */ |
748 | - if (empty($boardOptions['moderator_groups'])) |
|
749 | - $boardOptions['moderator_groups'] = array(); |
|
788 | + if (empty($boardOptions['moderator_groups'])) { |
|
789 | + $boardOptions['moderator_groups'] = array(); |
|
790 | + } |
|
750 | 791 | if (!empty($moderator_groups)) |
751 | 792 | { |
752 | 793 | $request = $smcFunc['db_query']('', ' |
@@ -777,8 +818,9 @@ discard block |
||
777 | 818 | if (!empty($boardOptions['moderator_groups'])) |
778 | 819 | { |
779 | 820 | $inserts = array(); |
780 | - foreach ($boardOptions['moderator_groups'] as $moderator_group) |
|
781 | - $inserts[] = array($board_id, $moderator_group); |
|
821 | + foreach ($boardOptions['moderator_groups'] as $moderator_group) { |
|
822 | + $inserts[] = array($board_id, $moderator_group); |
|
823 | + } |
|
782 | 824 | |
783 | 825 | $smcFunc['db_insert']('insert', |
784 | 826 | '{db_prefix}moderator_groups', |
@@ -792,14 +834,16 @@ discard block |
||
792 | 834 | updateSettings(array('settings_updated' => time())); |
793 | 835 | } |
794 | 836 | |
795 | - if (isset($boardOptions['move_to'])) |
|
796 | - reorderBoards(); |
|
837 | + if (isset($boardOptions['move_to'])) { |
|
838 | + reorderBoards(); |
|
839 | + } |
|
797 | 840 | |
798 | 841 | clean_cache('data'); |
799 | 842 | |
800 | - if (empty($boardOptions['dont_log'])) |
|
801 | - logAction('edit_board', array('board' => $board_id), 'admin'); |
|
802 | -} |
|
843 | + if (empty($boardOptions['dont_log'])) { |
|
844 | + logAction('edit_board', array('board' => $board_id), 'admin'); |
|
845 | + } |
|
846 | + } |
|
803 | 847 | |
804 | 848 | /** |
805 | 849 | * Create a new board and set its properties and position. |
@@ -815,11 +859,13 @@ discard block |
||
815 | 859 | global $boards, $smcFunc; |
816 | 860 | |
817 | 861 | // Trigger an error if one of the required values is not set. |
818 | - if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) |
|
819 | - trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
862 | + if (!isset($boardOptions['board_name']) || trim($boardOptions['board_name']) == '' || !isset($boardOptions['move_to']) || !isset($boardOptions['target_category'])) { |
|
863 | + trigger_error('createBoard(): One or more of the required options is not set', E_USER_ERROR); |
|
864 | + } |
|
820 | 865 | |
821 | - if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) |
|
822 | - trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
866 | + if (in_array($boardOptions['move_to'], array('child', 'before', 'after')) && !isset($boardOptions['target_board'])) { |
|
867 | + trigger_error('createBoard(): Target board is not set', E_USER_ERROR); |
|
868 | + } |
|
823 | 869 | |
824 | 870 | // Set every optional value to its default value. |
825 | 871 | $boardOptions += array( |
@@ -853,8 +899,9 @@ discard block |
||
853 | 899 | ); |
854 | 900 | $board_id = $smcFunc['db_insert_id']('{db_prefix}boards', 'id_board'); |
855 | 901 | |
856 | - if (empty($board_id)) |
|
857 | - return 0; |
|
902 | + if (empty($board_id)) { |
|
903 | + return 0; |
|
904 | + } |
|
858 | 905 | |
859 | 906 | // Change the board according to the given specifications. |
860 | 907 | modifyBoard($board_id, $boardOptions); |
@@ -917,8 +964,9 @@ discard block |
||
917 | 964 | global $sourcedir, $boards, $smcFunc; |
918 | 965 | |
919 | 966 | // No boards to delete? Return! |
920 | - if (empty($boards_to_remove)) |
|
921 | - return; |
|
967 | + if (empty($boards_to_remove)) { |
|
968 | + return; |
|
969 | + } |
|
922 | 970 | |
923 | 971 | getBoardTree(); |
924 | 972 | |
@@ -929,12 +977,14 @@ discard block |
||
929 | 977 | { |
930 | 978 | // Get a list of the child boards that will also be removed. |
931 | 979 | $child_boards_to_remove = array(); |
932 | - foreach ($boards_to_remove as $board_to_remove) |
|
933 | - recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
980 | + foreach ($boards_to_remove as $board_to_remove) { |
|
981 | + recursiveBoards($child_boards_to_remove, $boards[$board_to_remove]['tree']); |
|
982 | + } |
|
934 | 983 | |
935 | 984 | // Merge the children with their parents. |
936 | - if (!empty($child_boards_to_remove)) |
|
937 | - $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
985 | + if (!empty($child_boards_to_remove)) { |
|
986 | + $boards_to_remove = array_unique(array_merge($boards_to_remove, $child_boards_to_remove)); |
|
987 | + } |
|
938 | 988 | } |
939 | 989 | // Move the children to a safe home. |
940 | 990 | else |
@@ -942,10 +992,11 @@ discard block |
||
942 | 992 | foreach ($boards_to_remove as $id_board) |
943 | 993 | { |
944 | 994 | // @todo Separate category? |
945 | - if ($moveChildrenTo === 0) |
|
946 | - fixChildren($id_board, 0, 0); |
|
947 | - else |
|
948 | - fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
995 | + if ($moveChildrenTo === 0) { |
|
996 | + fixChildren($id_board, 0, 0); |
|
997 | + } else { |
|
998 | + fixChildren($id_board, $boards[$moveChildrenTo]['level'] + 1, $moveChildrenTo); |
|
999 | + } |
|
949 | 1000 | } |
950 | 1001 | } |
951 | 1002 | |
@@ -959,8 +1010,9 @@ discard block |
||
959 | 1010 | ) |
960 | 1011 | ); |
961 | 1012 | $topics = array(); |
962 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
963 | - $topics[] = $row['id_topic']; |
|
1013 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1014 | + $topics[] = $row['id_topic']; |
|
1015 | + } |
|
964 | 1016 | $smcFunc['db_free_result']($request); |
965 | 1017 | |
966 | 1018 | require_once($sourcedir . '/RemoveTopic.php'); |
@@ -1048,8 +1100,9 @@ discard block |
||
1048 | 1100 | clean_cache('data'); |
1049 | 1101 | |
1050 | 1102 | // Let's do some serious logging. |
1051 | - foreach ($boards_to_remove as $id_board) |
|
1052 | - logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1103 | + foreach ($boards_to_remove as $id_board) { |
|
1104 | + logAction('delete_board', array('boardname' => $boards[$id_board]['name']), 'admin'); |
|
1105 | + } |
|
1053 | 1106 | |
1054 | 1107 | reorderBoards(); |
1055 | 1108 | } |
@@ -1068,8 +1121,8 @@ discard block |
||
1068 | 1121 | $board_order = 0; |
1069 | 1122 | foreach ($cat_tree as $catID => $dummy) |
1070 | 1123 | { |
1071 | - foreach ($boardList[$catID] as $boardID) |
|
1072 | - if ($boards[$boardID]['order'] != ++$board_order) |
|
1124 | + foreach ($boardList[$catID] as $boardID) { |
|
1125 | + if ($boards[$boardID]['order'] != ++$board_order) |
|
1073 | 1126 | $smcFunc['db_query']('', ' |
1074 | 1127 | UPDATE {db_prefix}boards |
1075 | 1128 | SET board_order = {int:new_order} |
@@ -1079,6 +1132,7 @@ discard block |
||
1079 | 1132 | 'selected_board' => $boardID, |
1080 | 1133 | ) |
1081 | 1134 | ); |
1135 | + } |
|
1082 | 1136 | } |
1083 | 1137 | |
1084 | 1138 | // Empty the board order cache |
@@ -1107,8 +1161,9 @@ discard block |
||
1107 | 1161 | ) |
1108 | 1162 | ); |
1109 | 1163 | $children = array(); |
1110 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1111 | - $children[] = $row['id_board']; |
|
1164 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1165 | + $children[] = $row['id_board']; |
|
1166 | + } |
|
1112 | 1167 | $smcFunc['db_free_result']($result); |
1113 | 1168 | |
1114 | 1169 | // ...and set it to a new parent and child_level. |
@@ -1124,9 +1179,10 @@ discard block |
||
1124 | 1179 | ); |
1125 | 1180 | |
1126 | 1181 | // Recursively fix the children of the children. |
1127 | - foreach ($children as $child) |
|
1128 | - fixChildren($child, $newLevel + 1, $child); |
|
1129 | -} |
|
1182 | + foreach ($children as $child) { |
|
1183 | + fixChildren($child, $newLevel + 1, $child); |
|
1184 | + } |
|
1185 | + } |
|
1130 | 1186 | |
1131 | 1187 | /** |
1132 | 1188 | * Tries to load up the entire board order and category very very quickly |
@@ -1143,8 +1199,9 @@ discard block |
||
1143 | 1199 | 'boards' => array(), |
1144 | 1200 | ); |
1145 | 1201 | |
1146 | - if (!empty($tree_order['boards'])) |
|
1147 | - return $tree_order; |
|
1202 | + if (!empty($tree_order['boards'])) { |
|
1203 | + return $tree_order; |
|
1204 | + } |
|
1148 | 1205 | |
1149 | 1206 | if (($cached = cache_get_data('board_order', 86400)) !== null) |
1150 | 1207 | { |
@@ -1160,8 +1217,9 @@ discard block |
||
1160 | 1217 | ); |
1161 | 1218 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1162 | 1219 | { |
1163 | - if (!in_array($row['id_cat'], $tree_order['cats'])) |
|
1164 | - $tree_order['cats'][] = $row['id_cat']; |
|
1220 | + if (!in_array($row['id_cat'], $tree_order['cats'])) { |
|
1221 | + $tree_order['cats'][] = $row['id_cat']; |
|
1222 | + } |
|
1165 | 1223 | $tree_order['boards'][] = $row['id_board']; |
1166 | 1224 | } |
1167 | 1225 | $smcFunc['db_free_result']($request); |
@@ -1181,16 +1239,19 @@ discard block |
||
1181 | 1239 | $tree = getTreeOrder(); |
1182 | 1240 | |
1183 | 1241 | $ordered = array(); |
1184 | - foreach ($tree['boards'] as $board) |
|
1185 | - if (!empty($boards[$board])) |
|
1242 | + foreach ($tree['boards'] as $board) { |
|
1243 | + if (!empty($boards[$board])) |
|
1186 | 1244 | { |
1187 | 1245 | $ordered[$board] = $boards[$board]; |
1246 | + } |
|
1188 | 1247 | |
1189 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) |
|
1190 | - sortBoards($ordered[$board]['boards']); |
|
1248 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['boards'])) { |
|
1249 | + sortBoards($ordered[$board]['boards']); |
|
1250 | + } |
|
1191 | 1251 | |
1192 | - if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) |
|
1193 | - sortBoards($ordered[$board]['children']); |
|
1252 | + if (is_array($ordered[$board]) && !empty($ordered[$board]['children'])) { |
|
1253 | + sortBoards($ordered[$board]['children']); |
|
1254 | + } |
|
1194 | 1255 | } |
1195 | 1256 | |
1196 | 1257 | $boards = $ordered; |
@@ -1206,12 +1267,14 @@ discard block |
||
1206 | 1267 | $tree = getTreeOrder(); |
1207 | 1268 | |
1208 | 1269 | $ordered = array(); |
1209 | - foreach ($tree['cats'] as $cat) |
|
1210 | - if (!empty($categories[$cat])) |
|
1270 | + foreach ($tree['cats'] as $cat) { |
|
1271 | + if (!empty($categories[$cat])) |
|
1211 | 1272 | { |
1212 | 1273 | $ordered[$cat] = $categories[$cat]; |
1213 | - if (!empty($ordered[$cat]['boards'])) |
|
1214 | - sortBoards($ordered[$cat]['boards']); |
|
1274 | + } |
|
1275 | + if (!empty($ordered[$cat]['boards'])) { |
|
1276 | + sortBoards($ordered[$cat]['boards']); |
|
1277 | + } |
|
1215 | 1278 | } |
1216 | 1279 | |
1217 | 1280 | $categories = $ordered; |
@@ -1227,8 +1290,9 @@ discard block |
||
1227 | 1290 | { |
1228 | 1291 | global $smcFunc, $scripturl, $txt; |
1229 | 1292 | |
1230 | - if (empty($boards)) |
|
1231 | - return array(); |
|
1293 | + if (empty($boards)) { |
|
1294 | + return array(); |
|
1295 | + } |
|
1232 | 1296 | |
1233 | 1297 | $request = $smcFunc['db_query']('', ' |
1234 | 1298 | SELECT mem.id_member, mem.real_name, mo.id_board |
@@ -1242,8 +1306,9 @@ discard block |
||
1242 | 1306 | $moderators = array(); |
1243 | 1307 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1244 | 1308 | { |
1245 | - if (empty($moderators[$row['id_board']])) |
|
1246 | - $moderators[$row['id_board']] = array(); |
|
1309 | + if (empty($moderators[$row['id_board']])) { |
|
1310 | + $moderators[$row['id_board']] = array(); |
|
1311 | + } |
|
1247 | 1312 | |
1248 | 1313 | $moderators[$row['id_board']][] = array( |
1249 | 1314 | 'id' => $row['id_member'], |
@@ -1267,8 +1332,9 @@ discard block |
||
1267 | 1332 | { |
1268 | 1333 | global $smcFunc, $scripturl, $txt; |
1269 | 1334 | |
1270 | - if (empty($boards)) |
|
1271 | - return array(); |
|
1335 | + if (empty($boards)) { |
|
1336 | + return array(); |
|
1337 | + } |
|
1272 | 1338 | |
1273 | 1339 | $request = $smcFunc['db_query']('', ' |
1274 | 1340 | SELECT mg.id_group, mg.group_name, bg.id_board |
@@ -1282,8 +1348,9 @@ discard block |
||
1282 | 1348 | $groups = array(); |
1283 | 1349 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1284 | 1350 | { |
1285 | - if (empty($groups[$row['id_board']])) |
|
1286 | - $groups[$row['id_board']] = array(); |
|
1351 | + if (empty($groups[$row['id_board']])) { |
|
1352 | + $groups[$row['id_board']] = array(); |
|
1353 | + } |
|
1287 | 1354 | |
1288 | 1355 | $groups[$row['id_board']][] = array( |
1289 | 1356 | 'id' => $row['id_group'], |
@@ -1345,8 +1412,9 @@ discard block |
||
1345 | 1412 | |
1346 | 1413 | if (!empty($row['id_board'])) |
1347 | 1414 | { |
1348 | - if ($row['child_level'] != $curLevel) |
|
1349 | - $prevBoard = 0; |
|
1415 | + if ($row['child_level'] != $curLevel) { |
|
1416 | + $prevBoard = 0; |
|
1417 | + } |
|
1350 | 1418 | |
1351 | 1419 | $boards[$row['id_board']] = array( |
1352 | 1420 | 'id' => $row['id_board'], |
@@ -1378,16 +1446,16 @@ discard block |
||
1378 | 1446 | 'children' => array() |
1379 | 1447 | ); |
1380 | 1448 | $boards[$row['id_board']]['tree'] = &$cat_tree[$row['id_cat']]['children'][$row['id_board']]; |
1381 | - } |
|
1382 | - else |
|
1449 | + } else |
|
1383 | 1450 | { |
1384 | 1451 | // Parent doesn't exist! |
1385 | - if (!isset($boards[$row['id_parent']]['tree'])) |
|
1386 | - fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1452 | + if (!isset($boards[$row['id_parent']]['tree'])) { |
|
1453 | + fatal_lang_error('no_valid_parent', false, array($row['board_name'])); |
|
1454 | + } |
|
1387 | 1455 | |
1388 | 1456 | // Wrong childlevel...we can silently fix this... |
1389 | - if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) |
|
1390 | - $smcFunc['db_query']('', ' |
|
1457 | + if ($boards[$row['id_parent']]['tree']['node']['level'] != $row['child_level'] - 1) { |
|
1458 | + $smcFunc['db_query']('', ' |
|
1391 | 1459 | UPDATE {db_prefix}boards |
1392 | 1460 | SET child_level = {int:new_child_level} |
1393 | 1461 | WHERE id_board = {int:selected_board}', |
@@ -1396,6 +1464,7 @@ discard block |
||
1396 | 1464 | 'selected_board' => $row['id_board'], |
1397 | 1465 | ) |
1398 | 1466 | ); |
1467 | + } |
|
1399 | 1468 | |
1400 | 1469 | $boards[$row['id_parent']]['tree']['children'][$row['id_board']] = array( |
1401 | 1470 | 'node' => &$boards[$row['id_board']], |
@@ -1426,8 +1495,9 @@ discard block |
||
1426 | 1495 | */ |
1427 | 1496 | function recursiveBoards(&$_boardList, &$_tree) |
1428 | 1497 | { |
1429 | - if (empty($_tree['children'])) |
|
1430 | - return; |
|
1498 | + if (empty($_tree['children'])) { |
|
1499 | + return; |
|
1500 | + } |
|
1431 | 1501 | |
1432 | 1502 | foreach ($_tree['children'] as $id => $node) |
1433 | 1503 | { |
@@ -1446,11 +1516,13 @@ discard block |
||
1446 | 1516 | { |
1447 | 1517 | global $boards; |
1448 | 1518 | |
1449 | - if (empty($boards[$child]['parent'])) |
|
1450 | - return false; |
|
1519 | + if (empty($boards[$child]['parent'])) { |
|
1520 | + return false; |
|
1521 | + } |
|
1451 | 1522 | |
1452 | - if ($boards[$child]['parent'] == $parent) |
|
1453 | - return true; |
|
1523 | + if ($boards[$child]['parent'] == $parent) { |
|
1524 | + return true; |
|
1525 | + } |
|
1454 | 1526 | |
1455 | 1527 | return isChildOf($boards[$child]['parent'], $parent); |
1456 | 1528 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Load the $modSettings array. |
@@ -25,13 +26,14 @@ discard block |
||
25 | 26 | global $cache_enable, $sourcedir, $context; |
26 | 27 | |
27 | 28 | // Most database systems have not set UTF-8 as their default input charset. |
28 | - if (!empty($db_character_set)) |
|
29 | - $smcFunc['db_query']('', ' |
|
29 | + if (!empty($db_character_set)) { |
|
30 | + $smcFunc['db_query']('', ' |
|
30 | 31 | SET NAMES {string:db_character_set}', |
31 | 32 | array( |
32 | 33 | 'db_character_set' => $db_character_set, |
33 | 34 | ) |
34 | 35 | ); |
36 | + } |
|
35 | 37 | |
36 | 38 | // We need some caching support, maybe. |
37 | 39 | loadCacheAccelerator(); |
@@ -46,27 +48,35 @@ discard block |
||
46 | 48 | ) |
47 | 49 | ); |
48 | 50 | $modSettings = array(); |
49 | - if (!$request) |
|
50 | - display_db_error(); |
|
51 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
52 | - $modSettings[$row[0]] = $row[1]; |
|
51 | + if (!$request) { |
|
52 | + display_db_error(); |
|
53 | + } |
|
54 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
55 | + $modSettings[$row[0]] = $row[1]; |
|
56 | + } |
|
53 | 57 | $smcFunc['db_free_result']($request); |
54 | 58 | |
55 | 59 | // Do a few things to protect against missing settings or settings with invalid values... |
56 | - if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) |
|
57 | - $modSettings['defaultMaxTopics'] = 20; |
|
58 | - if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) |
|
59 | - $modSettings['defaultMaxMessages'] = 15; |
|
60 | - if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) |
|
61 | - $modSettings['defaultMaxMembers'] = 30; |
|
62 | - if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) |
|
63 | - $modSettings['defaultMaxListItems'] = 15; |
|
60 | + if (empty($modSettings['defaultMaxTopics']) || $modSettings['defaultMaxTopics'] <= 0 || $modSettings['defaultMaxTopics'] > 999) { |
|
61 | + $modSettings['defaultMaxTopics'] = 20; |
|
62 | + } |
|
63 | + if (empty($modSettings['defaultMaxMessages']) || $modSettings['defaultMaxMessages'] <= 0 || $modSettings['defaultMaxMessages'] > 999) { |
|
64 | + $modSettings['defaultMaxMessages'] = 15; |
|
65 | + } |
|
66 | + if (empty($modSettings['defaultMaxMembers']) || $modSettings['defaultMaxMembers'] <= 0 || $modSettings['defaultMaxMembers'] > 999) { |
|
67 | + $modSettings['defaultMaxMembers'] = 30; |
|
68 | + } |
|
69 | + if (empty($modSettings['defaultMaxListItems']) || $modSettings['defaultMaxListItems'] <= 0 || $modSettings['defaultMaxListItems'] > 999) { |
|
70 | + $modSettings['defaultMaxListItems'] = 15; |
|
71 | + } |
|
64 | 72 | |
65 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
66 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
73 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
74 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
75 | + } |
|
67 | 76 | |
68 | - if (!empty($cache_enable)) |
|
69 | - cache_put_data('modSettings', $modSettings, 90); |
|
77 | + if (!empty($cache_enable)) { |
|
78 | + cache_put_data('modSettings', $modSettings, 90); |
|
79 | + } |
|
70 | 80 | } |
71 | 81 | |
72 | 82 | $modSettings['cache_enable'] = $cache_enable; |
@@ -86,8 +96,9 @@ discard block |
||
86 | 96 | }; |
87 | 97 | $fix_utf8mb4 = function($string) use ($utf8) |
88 | 98 | { |
89 | - if (!$utf8) |
|
90 | - return $string; |
|
99 | + if (!$utf8) { |
|
100 | + return $string; |
|
101 | + } |
|
91 | 102 | |
92 | 103 | $i = 0; |
93 | 104 | $len = strlen($string); |
@@ -99,18 +110,15 @@ discard block |
||
99 | 110 | { |
100 | 111 | $new_string .= $string[$i]; |
101 | 112 | $i++; |
102 | - } |
|
103 | - elseif ($ord < 224) |
|
113 | + } elseif ($ord < 224) |
|
104 | 114 | { |
105 | 115 | $new_string .= $string[$i] . $string[$i + 1]; |
106 | 116 | $i += 2; |
107 | - } |
|
108 | - elseif ($ord < 240) |
|
117 | + } elseif ($ord < 240) |
|
109 | 118 | { |
110 | 119 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
111 | 120 | $i += 3; |
112 | - } |
|
113 | - elseif ($ord < 248) |
|
121 | + } elseif ($ord < 248) |
|
114 | 122 | { |
115 | 123 | // Magic happens. |
116 | 124 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -154,8 +162,7 @@ discard block |
||
154 | 162 | { |
155 | 163 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
156 | 164 | return is_int($result) ? $result + $offset : false; |
157 | - } |
|
158 | - else |
|
165 | + } else |
|
159 | 166 | { |
160 | 167 | $needle_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|"|&|<|>| |.)~' . ($utf8 ? 'u' : '') . '', $ent_check($needle), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
161 | 168 | $needle_size = count($needle_arr); |
@@ -164,8 +171,9 @@ discard block |
||
164 | 171 | while ((int) $result === $result) |
165 | 172 | { |
166 | 173 | $offset += $result; |
167 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
168 | - return $offset; |
|
174 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
175 | + return $offset; |
|
176 | + } |
|
169 | 177 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
170 | 178 | } |
171 | 179 | return false; |
@@ -203,8 +211,9 @@ discard block |
||
203 | 211 | $string = $ent_check($string); |
204 | 212 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
205 | 213 | $string = $matches[0]; |
206 | - while (strlen($string) > $length) |
|
207 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
214 | + while (strlen($string) > $length) { |
|
215 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
216 | + } |
|
208 | 217 | return $string; |
209 | 218 | }, |
210 | 219 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -214,23 +223,25 @@ discard block |
||
214 | 223 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
215 | 224 | { |
216 | 225 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
217 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
218 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
226 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
227 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
228 | + } |
|
219 | 229 | return implode('', $words); |
220 | 230 | } : 'ucwords', |
221 | 231 | ); |
222 | 232 | |
223 | 233 | // Setting the timezone is a requirement for some functions. |
224 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
225 | - date_default_timezone_set($modSettings['default_timezone']); |
|
226 | - else |
|
234 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
235 | + date_default_timezone_set($modSettings['default_timezone']); |
|
236 | + } else |
|
227 | 237 | { |
228 | 238 | // Get PHP's default timezone, if set |
229 | 239 | $ini_tz = ini_get('date.timezone'); |
230 | - if (!empty($ini_tz)) |
|
231 | - $modSettings['default_timezone'] = $ini_tz; |
|
232 | - else |
|
233 | - $modSettings['default_timezone'] = ''; |
|
240 | + if (!empty($ini_tz)) { |
|
241 | + $modSettings['default_timezone'] = $ini_tz; |
|
242 | + } else { |
|
243 | + $modSettings['default_timezone'] = ''; |
|
244 | + } |
|
234 | 245 | |
235 | 246 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
236 | 247 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -248,22 +259,26 @@ discard block |
||
248 | 259 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
249 | 260 | { |
250 | 261 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
251 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
252 | - $modSettings['load_average'] = (float) $matches[1]; |
|
253 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
254 | - $modSettings['load_average'] = (float) $matches[1]; |
|
255 | - else |
|
256 | - unset($modSettings['load_average']); |
|
262 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
263 | + $modSettings['load_average'] = (float) $matches[1]; |
|
264 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
265 | + $modSettings['load_average'] = (float) $matches[1]; |
|
266 | + } else { |
|
267 | + unset($modSettings['load_average']); |
|
268 | + } |
|
257 | 269 | |
258 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
259 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
270 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
271 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
272 | + } |
|
260 | 273 | } |
261 | 274 | |
262 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
263 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
275 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
276 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
277 | + } |
|
264 | 278 | |
265 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
266 | - display_loadavg_error(); |
|
279 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
280 | + display_loadavg_error(); |
|
281 | + } |
|
267 | 282 | } |
268 | 283 | |
269 | 284 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -284,8 +299,9 @@ discard block |
||
284 | 299 | if (defined('SMF_INTEGRATION_SETTINGS')) |
285 | 300 | { |
286 | 301 | $integration_settings = smf_json_decode(SMF_INTEGRATION_SETTINGS, true); |
287 | - foreach ($integration_settings as $hook => $function) |
|
288 | - add_integration_function($hook, $function, '', false); |
|
302 | + foreach ($integration_settings as $hook => $function) { |
|
303 | + add_integration_function($hook, $function, '', false); |
|
304 | + } |
|
289 | 305 | } |
290 | 306 | |
291 | 307 | // Any files to pre include? |
@@ -295,8 +311,9 @@ discard block |
||
295 | 311 | foreach ($pre_includes as $include) |
296 | 312 | { |
297 | 313 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
298 | - if (file_exists($include)) |
|
299 | - require_once($include); |
|
314 | + if (file_exists($include)) { |
|
315 | + require_once($include); |
|
316 | + } |
|
300 | 317 | } |
301 | 318 | } |
302 | 319 | |
@@ -400,27 +417,28 @@ discard block |
||
400 | 417 | break; |
401 | 418 | } |
402 | 419 | } |
420 | + } else { |
|
421 | + $id_member = 0; |
|
403 | 422 | } |
404 | - else |
|
405 | - $id_member = 0; |
|
406 | 423 | |
407 | 424 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
408 | 425 | { |
409 | 426 | $cookie_data = smf_json_decode($_COOKIE[$cookiename], true, false); |
410 | 427 | |
411 | - if (empty($cookie_data)) |
|
412 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
428 | + if (empty($cookie_data)) { |
|
429 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
430 | + } |
|
413 | 431 | |
414 | 432 | list ($id_member, $password) = $cookie_data; |
415 | 433 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
416 | - } |
|
417 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
434 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
418 | 435 | { |
419 | 436 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
420 | 437 | $cookie_data = smf_json_decode($_SESSION['login_' . $cookiename]); |
421 | 438 | |
422 | - if (empty($cookie_data)) |
|
423 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
439 | + if (empty($cookie_data)) { |
|
440 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
441 | + } |
|
424 | 442 | |
425 | 443 | list ($id_member, $password, $login_span) = $cookie_data; |
426 | 444 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -445,30 +463,34 @@ discard block |
||
445 | 463 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
446 | 464 | $smcFunc['db_free_result']($request); |
447 | 465 | |
448 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
449 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
466 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
467 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
468 | + } |
|
450 | 469 | |
451 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
452 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
470 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
471 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
472 | + } |
|
453 | 473 | } |
454 | 474 | |
455 | 475 | // Did we find 'im? If not, junk it. |
456 | 476 | if (!empty($user_settings)) |
457 | 477 | { |
458 | 478 | // As much as the password should be right, we can assume the integration set things up. |
459 | - if (!empty($already_verified) && $already_verified === true) |
|
460 | - $check = true; |
|
479 | + if (!empty($already_verified) && $already_verified === true) { |
|
480 | + $check = true; |
|
481 | + } |
|
461 | 482 | // SHA-512 hash should be 128 characters long. |
462 | - elseif (strlen($password) == 128) |
|
463 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
464 | - else |
|
465 | - $check = false; |
|
483 | + elseif (strlen($password) == 128) { |
|
484 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
485 | + } else { |
|
486 | + $check = false; |
|
487 | + } |
|
466 | 488 | |
467 | 489 | // Wrong password or not activated - either way, you're going nowhere. |
468 | 490 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
491 | + } else { |
|
492 | + $id_member = 0; |
|
469 | 493 | } |
470 | - else |
|
471 | - $id_member = 0; |
|
472 | 494 | |
473 | 495 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
474 | 496 | if (!$id_member) |
@@ -490,13 +512,15 @@ discard block |
||
490 | 512 | { |
491 | 513 | $tfa_data = smf_json_decode($_COOKIE[$tfacookie]); |
492 | 514 | |
493 | - if (is_null($tfa_data)) |
|
494 | - $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
515 | + if (is_null($tfa_data)) { |
|
516 | + $tfa_data = safe_unserialize($_COOKIE[$tfacookie]); |
|
517 | + } |
|
495 | 518 | |
496 | 519 | list ($tfamember, $tfasecret) = $tfa_data; |
497 | 520 | |
498 | - if ((int) $tfamember != $id_member) |
|
499 | - $tfasecret = null; |
|
521 | + if ((int) $tfamember != $id_member) { |
|
522 | + $tfasecret = null; |
|
523 | + } |
|
500 | 524 | } |
501 | 525 | |
502 | 526 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -516,10 +540,12 @@ discard block |
||
516 | 540 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
517 | 541 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
518 | 542 | { |
519 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
543 | + if ($modSettings['tfa_mode'] == 2) { |
|
544 | + //only do this if we are just forcing SOME membergroups |
|
520 | 545 | { |
521 | 546 | //Build an array of ALL user membergroups. |
522 | 547 | $full_groups = array($user_settings['id_group']); |
548 | + } |
|
523 | 549 | if (!empty($user_settings['additional_groups'])) |
524 | 550 | { |
525 | 551 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -539,15 +565,17 @@ discard block |
||
539 | 565 | ); |
540 | 566 | $row = $smcFunc['db_fetch_assoc']($request); |
541 | 567 | $smcFunc['db_free_result']($request); |
568 | + } else { |
|
569 | + $row['total'] = 1; |
|
542 | 570 | } |
543 | - else |
|
544 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
571 | + //simplifies logics in the next "if" |
|
545 | 572 | |
546 | 573 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
547 | 574 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
548 | 575 | |
549 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
550 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
576 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
577 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
578 | + } |
|
551 | 579 | } |
552 | 580 | } |
553 | 581 | |
@@ -584,33 +612,37 @@ discard block |
||
584 | 612 | updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'])); |
585 | 613 | $user_settings['last_login'] = time(); |
586 | 614 | |
587 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
588 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
615 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
616 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
617 | + } |
|
589 | 618 | |
590 | - if (!empty($modSettings['cache_enable'])) |
|
591 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
619 | + if (!empty($modSettings['cache_enable'])) { |
|
620 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
621 | + } |
|
592 | 622 | } |
623 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
624 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
593 | 625 | } |
594 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
595 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
596 | 626 | |
597 | 627 | $username = $user_settings['member_name']; |
598 | 628 | |
599 | - if (empty($user_settings['additional_groups'])) |
|
600 | - $user_info = array( |
|
629 | + if (empty($user_settings['additional_groups'])) { |
|
630 | + $user_info = array( |
|
601 | 631 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
602 | 632 | ); |
603 | - else |
|
604 | - $user_info = array( |
|
633 | + } else { |
|
634 | + $user_info = array( |
|
605 | 635 | 'groups' => array_merge( |
606 | 636 | array($user_settings['id_group'], $user_settings['id_post_group']), |
607 | 637 | explode(',', $user_settings['additional_groups']) |
608 | 638 | ) |
609 | 639 | ); |
640 | + } |
|
610 | 641 | |
611 | 642 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
612 | - foreach ($user_info['groups'] as $k => $v) |
|
613 | - $user_info['groups'][$k] = (int) $v; |
|
643 | + foreach ($user_info['groups'] as $k => $v) { |
|
644 | + $user_info['groups'][$k] = (int) $v; |
|
645 | + } |
|
614 | 646 | |
615 | 647 | // This is a logged in user, so definitely not a spider. |
616 | 648 | $user_info['possibly_robot'] = false; |
@@ -624,8 +656,7 @@ discard block |
||
624 | 656 | $time_system = new DateTime('now', $tz_system); |
625 | 657 | $time_user = new DateTime('now', $tz_user); |
626 | 658 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
627 | - } |
|
628 | - else |
|
659 | + } else |
|
629 | 660 | { |
630 | 661 | // !!! Compatibility. |
631 | 662 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -639,16 +670,18 @@ discard block |
||
639 | 670 | $user_info = array('groups' => array(-1)); |
640 | 671 | $user_settings = array(); |
641 | 672 | |
642 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
643 | - $_COOKIE[$cookiename] = ''; |
|
673 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
674 | + $_COOKIE[$cookiename] = ''; |
|
675 | + } |
|
644 | 676 | |
645 | 677 | // Expire the 2FA cookie |
646 | 678 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
647 | 679 | { |
648 | 680 | $tfa_data = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
649 | 681 | |
650 | - if (is_null($tfa_data)) |
|
651 | - $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
682 | + if (is_null($tfa_data)) { |
|
683 | + $tfa_data = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
684 | + } |
|
652 | 685 | |
653 | 686 | list ($id, $user, $exp, $state, $preserve) = $tfa_data; |
654 | 687 | |
@@ -660,19 +693,20 @@ discard block |
||
660 | 693 | } |
661 | 694 | |
662 | 695 | // Create a login token if it doesn't exist yet. |
663 | - if (!isset($_SESSION['token']['post-login'])) |
|
664 | - createToken('login'); |
|
665 | - else |
|
666 | - list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
696 | + if (!isset($_SESSION['token']['post-login'])) { |
|
697 | + createToken('login'); |
|
698 | + } else { |
|
699 | + list ($context['login_token_var'],,, $context['login_token']) = $_SESSION['token']['post-login']; |
|
700 | + } |
|
667 | 701 | |
668 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
669 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
670 | 704 | { |
671 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
672 | 706 | $user_info['possibly_robot'] = SpiderCheck(); |
707 | + } elseif (!empty($modSettings['spider_mode'])) { |
|
708 | + $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
673 | 709 | } |
674 | - elseif (!empty($modSettings['spider_mode'])) |
|
675 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
676 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
677 | 711 | else |
678 | 712 | { |
@@ -720,8 +754,9 @@ discard block |
||
720 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
721 | 755 | |
722 | 756 | // Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems. |
723 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
724 | - unset($user_info['ignoreboards'][$tmp]); |
|
757 | + if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) { |
|
758 | + unset($user_info['ignoreboards'][$tmp]); |
|
759 | + } |
|
725 | 760 | |
726 | 761 | // Allow the user to change their language. |
727 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -734,31 +769,36 @@ discard block |
||
734 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
735 | 770 | |
736 | 771 | // Make it permanent for members. |
737 | - if (!empty($user_info['id'])) |
|
738 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
739 | - else |
|
740 | - $_SESSION['language'] = $user_info['language']; |
|
772 | + if (!empty($user_info['id'])) { |
|
773 | + updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
774 | + } else { |
|
775 | + $_SESSION['language'] = $user_info['language']; |
|
776 | + } |
|
777 | + } elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) { |
|
778 | + $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
741 | 779 | } |
742 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
743 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
744 | 780 | } |
745 | 781 | |
746 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
747 | - if ($user_info['is_admin']) |
|
748 | - $user_info['query_see_board'] = '1=1'; |
|
783 | + if ($user_info['is_admin']) { |
|
784 | + $user_info['query_see_board'] = '1=1'; |
|
785 | + } |
|
749 | 786 | // Otherwise just the groups in $user_info['groups']. |
750 | - else |
|
751 | - $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
787 | + else { |
|
788 | + $user_info['query_see_board'] = '((FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0)' . (!empty($modSettings['deny_boards_access']) ? ' AND (FIND_IN_SET(' . implode(', b.deny_member_groups) = 0 AND FIND_IN_SET(', $user_info['groups']) . ', b.deny_member_groups) = 0)' : '') . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')'; |
|
789 | + } |
|
752 | 790 | |
753 | 791 | // Build the list of boards they WANT to see. |
754 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
755 | 793 | |
756 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
757 | - if (empty($user_info['ignoreboards'])) |
|
758 | - $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
795 | + if (empty($user_info['ignoreboards'])) { |
|
796 | + $user_info['query_wanna_see_board'] = $user_info['query_see_board']; |
|
797 | + } |
|
759 | 798 | // Ok I guess they don't want to see all the boards |
760 | - else |
|
761 | - $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
799 | + else { |
|
800 | + $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))'; |
|
801 | + } |
|
762 | 802 | |
763 | 803 | call_integration_hook('integrate_user_info'); |
764 | 804 | } |
@@ -816,9 +856,9 @@ discard block |
||
816 | 856 | } |
817 | 857 | |
818 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
819 | - if (!empty($topic)) |
|
820 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
821 | - else |
|
859 | + if (!empty($topic)) { |
|
860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
861 | + } else |
|
822 | 862 | { |
823 | 863 | loadPermissions(); |
824 | 864 | loadTheme(); |
@@ -836,10 +876,11 @@ discard block |
||
836 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
837 | 877 | { |
838 | 878 | // @todo SLOW? |
839 | - if (!empty($topic)) |
|
840 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
841 | - else |
|
842 | - $temp = cache_get_data('board-' . $board, 120); |
|
879 | + if (!empty($topic)) { |
|
880 | + $temp = cache_get_data('topic_board-' . $topic, 120); |
|
881 | + } else { |
|
882 | + $temp = cache_get_data('board-' . $board, 120); |
|
883 | + } |
|
843 | 884 | |
844 | 885 | if (!empty($temp)) |
845 | 886 | { |
@@ -877,8 +918,9 @@ discard block |
||
877 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
878 | 919 | |
879 | 920 | // Set the current board. |
880 | - if (!empty($row['id_board'])) |
|
881 | - $board = $row['id_board']; |
|
921 | + if (!empty($row['id_board'])) { |
|
922 | + $board = $row['id_board']; |
|
923 | + } |
|
882 | 924 | |
883 | 925 | // Basic operating information. (globals... :/) |
884 | 926 | $board_info = array( |
@@ -914,21 +956,23 @@ discard block |
||
914 | 956 | |
915 | 957 | do |
916 | 958 | { |
917 | - if (!empty($row['id_moderator'])) |
|
918 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
959 | + if (!empty($row['id_moderator'])) { |
|
960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
919 | 961 | 'id' => $row['id_moderator'], |
920 | 962 | 'name' => $row['real_name'], |
921 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
922 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
923 | 965 | ); |
966 | + } |
|
924 | 967 | |
925 | - if (!empty($row['id_moderator_group'])) |
|
926 | - $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
968 | + if (!empty($row['id_moderator_group'])) { |
|
969 | + $board_info['moderator_groups'][$row['id_moderator_group']] = array( |
|
927 | 970 | 'id' => $row['id_moderator_group'], |
928 | 971 | 'name' => $row['group_name'], |
929 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
930 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
931 | 974 | ); |
975 | + } |
|
932 | 976 | } |
933 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
934 | 978 | |
@@ -960,12 +1004,12 @@ discard block |
||
960 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
961 | 1005 | { |
962 | 1006 | // @todo SLOW? |
963 | - if (!empty($topic)) |
|
964 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1007 | + if (!empty($topic)) { |
|
1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1009 | + } |
|
965 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
966 | 1011 | } |
967 | - } |
|
968 | - else |
|
1012 | + } else |
|
969 | 1013 | { |
970 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
971 | 1015 | $board_info = array( |
@@ -979,8 +1023,9 @@ discard block |
||
979 | 1023 | $smcFunc['db_free_result']($request); |
980 | 1024 | } |
981 | 1025 | |
982 | - if (!empty($topic)) |
|
983 | - $_GET['board'] = (int) $board; |
|
1026 | + if (!empty($topic)) { |
|
1027 | + $_GET['board'] = (int) $board; |
|
1028 | + } |
|
984 | 1029 | |
985 | 1030 | if (!empty($board)) |
986 | 1031 | { |
@@ -990,10 +1035,12 @@ discard block |
||
990 | 1035 | // Now check if the user is a moderator. |
991 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
992 | 1037 | |
993 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
994 | - $board_info['error'] = 'access'; |
|
995 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
996 | - $board_info['error'] = 'access'; |
|
1038 | + if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) { |
|
1039 | + $board_info['error'] = 'access'; |
|
1040 | + } |
|
1041 | + if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) { |
|
1042 | + $board_info['error'] = 'access'; |
|
1043 | + } |
|
997 | 1044 | |
998 | 1045 | // Build up the linktree. |
999 | 1046 | $context['linktree'] = array_merge( |
@@ -1016,8 +1063,9 @@ discard block |
||
1016 | 1063 | $context['current_board'] = $board; |
1017 | 1064 | |
1018 | 1065 | // No posting in redirection boards! |
1019 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1020 | - $board_info['error'] == 'post_in_redirect'; |
|
1066 | + if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) { |
|
1067 | + $board_info['error'] == 'post_in_redirect'; |
|
1068 | + } |
|
1021 | 1069 | |
1022 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1023 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1043,24 +1091,23 @@ discard block |
||
1043 | 1091 | ob_end_clean(); |
1044 | 1092 | header('HTTP/1.1 403 Forbidden'); |
1045 | 1093 | die; |
1046 | - } |
|
1047 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1048 | 1095 | { |
1049 | 1096 | // Slightly different error message here... |
1050 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
1051 | - } |
|
1052 | - elseif ($user_info['is_guest']) |
|
1098 | + } elseif ($user_info['is_guest']) |
|
1053 | 1099 | { |
1054 | 1100 | loadLanguage('Errors'); |
1055 | 1101 | is_not_guest($txt['topic_gone']); |
1102 | + } else { |
|
1103 | + fatal_lang_error('topic_gone', false); |
|
1056 | 1104 | } |
1057 | - else |
|
1058 | - fatal_lang_error('topic_gone', false); |
|
1059 | 1105 | } |
1060 | 1106 | |
1061 | - if ($user_info['is_mod']) |
|
1062 | - $user_info['groups'][] = 3; |
|
1063 | -} |
|
1107 | + if ($user_info['is_mod']) { |
|
1108 | + $user_info['groups'][] = 3; |
|
1109 | + } |
|
1110 | + } |
|
1064 | 1111 | |
1065 | 1112 | /** |
1066 | 1113 | * Load this user's permissions. |
@@ -1081,8 +1128,9 @@ discard block |
||
1081 | 1128 | asort($cache_groups); |
1082 | 1129 | $cache_groups = implode(',', $cache_groups); |
1083 | 1130 | // If it's a spider then cache it different. |
1084 | - if ($user_info['possibly_robot']) |
|
1085 | - $cache_groups .= '-spider'; |
|
1131 | + if ($user_info['possibly_robot']) { |
|
1132 | + $cache_groups .= '-spider'; |
|
1133 | + } |
|
1086 | 1134 | |
1087 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1088 | 1136 | { |
@@ -1090,9 +1138,9 @@ discard block |
||
1090 | 1138 | banPermissions(); |
1091 | 1139 | |
1092 | 1140 | return; |
1141 | + } elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) { |
|
1142 | + list ($user_info['permissions'], $removals) = $temp; |
|
1093 | 1143 | } |
1094 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1095 | - list ($user_info['permissions'], $removals) = $temp; |
|
1096 | 1144 | } |
1097 | 1145 | |
1098 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1114,23 +1162,26 @@ discard block |
||
1114 | 1162 | $removals = array(); |
1115 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1116 | 1164 | { |
1117 | - if (empty($row['add_deny'])) |
|
1118 | - $removals[] = $row['permission']; |
|
1119 | - else |
|
1120 | - $user_info['permissions'][] = $row['permission']; |
|
1165 | + if (empty($row['add_deny'])) { |
|
1166 | + $removals[] = $row['permission']; |
|
1167 | + } else { |
|
1168 | + $user_info['permissions'][] = $row['permission']; |
|
1169 | + } |
|
1121 | 1170 | } |
1122 | 1171 | $smcFunc['db_free_result']($request); |
1123 | 1172 | |
1124 | - if (isset($cache_groups)) |
|
1125 | - cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1173 | + if (isset($cache_groups)) { |
|
1174 | + cache_put_data('permissions:' . $cache_groups, array($user_info['permissions'], $removals), 240); |
|
1175 | + } |
|
1126 | 1176 | } |
1127 | 1177 | |
1128 | 1178 | // Get the board permissions. |
1129 | 1179 | if (!empty($board)) |
1130 | 1180 | { |
1131 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
1132 | - if (!isset($board_info['profile'])) |
|
1133 | - fatal_lang_error('no_board'); |
|
1182 | + if (!isset($board_info['profile'])) { |
|
1183 | + fatal_lang_error('no_board'); |
|
1184 | + } |
|
1134 | 1185 | |
1135 | 1186 | $request = $smcFunc['db_query']('', ' |
1136 | 1187 | SELECT permission, add_deny |
@@ -1146,20 +1197,23 @@ discard block |
||
1146 | 1197 | ); |
1147 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1148 | 1199 | { |
1149 | - if (empty($row['add_deny'])) |
|
1150 | - $removals[] = $row['permission']; |
|
1151 | - else |
|
1152 | - $user_info['permissions'][] = $row['permission']; |
|
1200 | + if (empty($row['add_deny'])) { |
|
1201 | + $removals[] = $row['permission']; |
|
1202 | + } else { |
|
1203 | + $user_info['permissions'][] = $row['permission']; |
|
1204 | + } |
|
1153 | 1205 | } |
1154 | 1206 | $smcFunc['db_free_result']($request); |
1155 | 1207 | } |
1156 | 1208 | |
1157 | 1209 | // Remove all the permissions they shouldn't have ;). |
1158 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1159 | - $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1210 | + if (!empty($modSettings['permission_enable_deny'])) { |
|
1211 | + $user_info['permissions'] = array_diff($user_info['permissions'], $removals); |
|
1212 | + } |
|
1160 | 1213 | |
1161 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1162 | - cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1214 | + if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) { |
|
1215 | + cache_put_data('permissions:' . $cache_groups . ':' . $board, array($user_info['permissions'], null), 240); |
|
1216 | + } |
|
1163 | 1217 | |
1164 | 1218 | // Banned? Watch, don't touch.. |
1165 | 1219 | banPermissions(); |
@@ -1171,17 +1225,18 @@ discard block |
||
1171 | 1225 | { |
1172 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
1173 | 1227 | rebuildModCache(); |
1228 | + } else { |
|
1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1174 | 1230 | } |
1175 | - else |
|
1176 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1177 | 1231 | |
1178 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1179 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
1180 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
1181 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1182 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
1183 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1184 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1239 | + } |
|
1185 | 1240 | } |
1186 | 1241 | } |
1187 | 1242 | |
@@ -1199,8 +1254,9 @@ discard block |
||
1199 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1200 | 1255 | |
1201 | 1256 | // Can't just look for no users :P. |
1202 | - if (empty($users)) |
|
1203 | - return array(); |
|
1257 | + if (empty($users)) { |
|
1258 | + return array(); |
|
1259 | + } |
|
1204 | 1260 | |
1205 | 1261 | // Pass the set value |
1206 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1215,8 +1271,9 @@ discard block |
||
1215 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1216 | 1272 | { |
1217 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1218 | - if ($data == null) |
|
1219 | - continue; |
|
1274 | + if ($data == null) { |
|
1275 | + continue; |
|
1276 | + } |
|
1220 | 1277 | |
1221 | 1278 | $loaded_ids[] = $data['id_member']; |
1222 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1280,13 +1337,16 @@ discard block |
||
1280 | 1337 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1281 | 1338 | { |
1282 | 1339 | // Take care of proxying avatar if required, do this here for maximum reach |
1283 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1284 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1340 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1341 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1342 | + } |
|
1285 | 1343 | |
1286 | - if (isset($row['member_ip'])) |
|
1287 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1288 | - if (isset($row['member_ip2'])) |
|
1289 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1344 | + if (isset($row['member_ip'])) { |
|
1345 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1346 | + } |
|
1347 | + if (isset($row['member_ip2'])) { |
|
1348 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1349 | + } |
|
1290 | 1350 | $new_loaded_ids[] = $row['id_member']; |
1291 | 1351 | $loaded_ids[] = $row['id_member']; |
1292 | 1352 | $row['options'] = array(); |
@@ -1305,8 +1365,9 @@ discard block |
||
1305 | 1365 | 'loaded_ids' => $new_loaded_ids, |
1306 | 1366 | ) |
1307 | 1367 | ); |
1308 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1309 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1368 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1369 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1370 | + } |
|
1310 | 1371 | $smcFunc['db_free_result']($request); |
1311 | 1372 | } |
1312 | 1373 | |
@@ -1317,10 +1378,11 @@ discard block |
||
1317 | 1378 | { |
1318 | 1379 | foreach ($loaded_ids as $a_member) |
1319 | 1380 | { |
1320 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1321 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1322 | - else |
|
1323 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1381 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1382 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1383 | + } else { |
|
1384 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1385 | + } |
|
1324 | 1386 | |
1325 | 1387 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1326 | 1388 | |
@@ -1333,8 +1395,9 @@ discard block |
||
1333 | 1395 | |
1334 | 1396 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1335 | 1397 | { |
1336 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1337 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1398 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1399 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1400 | + } |
|
1338 | 1401 | } |
1339 | 1402 | |
1340 | 1403 | // Are we loading any moderators? If so, fix their group data... |
@@ -1360,14 +1423,17 @@ discard block |
||
1360 | 1423 | foreach ($temp_mods as $id) |
1361 | 1424 | { |
1362 | 1425 | // By popular demand, don't show admins or global moderators as moderators. |
1363 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1364 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1426 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1427 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1428 | + } |
|
1365 | 1429 | |
1366 | 1430 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1367 | - if (!empty($row['icons'])) |
|
1368 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1369 | - if (!empty($row['member_group_color'])) |
|
1370 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1431 | + if (!empty($row['icons'])) { |
|
1432 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1433 | + } |
|
1434 | + if (!empty($row['member_group_color'])) { |
|
1435 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1436 | + } |
|
1371 | 1437 | } |
1372 | 1438 | } |
1373 | 1439 | |
@@ -1389,12 +1455,14 @@ discard block |
||
1389 | 1455 | static $loadedLanguages = array(); |
1390 | 1456 | |
1391 | 1457 | // If this person's data is already loaded, skip it. |
1392 | - if (isset($dataLoaded[$user])) |
|
1393 | - return true; |
|
1458 | + if (isset($dataLoaded[$user])) { |
|
1459 | + return true; |
|
1460 | + } |
|
1394 | 1461 | |
1395 | 1462 | // We can't load guests or members not loaded by loadMemberData()! |
1396 | - if ($user == 0) |
|
1397 | - return false; |
|
1463 | + if ($user == 0) { |
|
1464 | + return false; |
|
1465 | + } |
|
1398 | 1466 | if (!isset($user_profile[$user])) |
1399 | 1467 | { |
1400 | 1468 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1420,12 +1488,16 @@ discard block |
||
1420 | 1488 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1421 | 1489 | |
1422 | 1490 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1423 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1491 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1492 | + //icon is set and exists |
|
1424 | 1493 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1425 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1494 | + } elseif (isset($profile['icons'][1])) { |
|
1495 | + //icon is set and doesn't exist, fallback to default |
|
1426 | 1496 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1427 | - else //not set, bye bye |
|
1497 | + } else { |
|
1498 | + //not set, bye bye |
|
1428 | 1499 | $group_icon_url = ''; |
1500 | + } |
|
1429 | 1501 | |
1430 | 1502 | // These minimal values are always loaded |
1431 | 1503 | $memberContext[$user] = array( |
@@ -1444,8 +1516,9 @@ discard block |
||
1444 | 1516 | if ($context['loadMemberContext_set'] != 'minimal') |
1445 | 1517 | { |
1446 | 1518 | // Go the extra mile and load the user's native language name. |
1447 | - if (empty($loadedLanguages)) |
|
1448 | - $loadedLanguages = getLanguages(); |
|
1519 | + if (empty($loadedLanguages)) { |
|
1520 | + $loadedLanguages = getLanguages(); |
|
1521 | + } |
|
1449 | 1522 | |
1450 | 1523 | $memberContext[$user] += array( |
1451 | 1524 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1499,31 +1572,33 @@ discard block |
||
1499 | 1572 | { |
1500 | 1573 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1501 | 1574 | { |
1502 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1503 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1504 | - else |
|
1505 | - $image = get_gravatar_url($profile['email_address']); |
|
1506 | - } |
|
1507 | - else |
|
1575 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1576 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1577 | + } else { |
|
1578 | + $image = get_gravatar_url($profile['email_address']); |
|
1579 | + } |
|
1580 | + } else |
|
1508 | 1581 | { |
1509 | 1582 | // So it's stored in the member table? |
1510 | 1583 | if (!empty($profile['avatar'])) |
1511 | 1584 | { |
1512 | 1585 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1586 | + } elseif (!empty($profile['filename'])) { |
|
1587 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1513 | 1588 | } |
1514 | - elseif (!empty($profile['filename'])) |
|
1515 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1516 | 1589 | // Right... no avatar...use the default one |
1517 | - else |
|
1518 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1590 | + else { |
|
1591 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1592 | + } |
|
1519 | 1593 | } |
1520 | - if (!empty($image)) |
|
1521 | - $memberContext[$user]['avatar'] = array( |
|
1594 | + if (!empty($image)) { |
|
1595 | + $memberContext[$user]['avatar'] = array( |
|
1522 | 1596 | 'name' => $profile['avatar'], |
1523 | 1597 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1524 | 1598 | 'href' => $image, |
1525 | 1599 | 'url' => $image, |
1526 | 1600 | ); |
1601 | + } |
|
1527 | 1602 | } |
1528 | 1603 | |
1529 | 1604 | // Are we also loading the members custom fields into context? |
@@ -1531,35 +1606,41 @@ discard block |
||
1531 | 1606 | { |
1532 | 1607 | $memberContext[$user]['custom_fields'] = array(); |
1533 | 1608 | |
1534 | - if (!isset($context['display_fields'])) |
|
1535 | - $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
1609 | + if (!isset($context['display_fields'])) { |
|
1610 | + $context['display_fields'] = smf_json_decode($modSettings['displayFields'], true); |
|
1611 | + } |
|
1536 | 1612 | |
1537 | 1613 | foreach ($context['display_fields'] as $custom) |
1538 | 1614 | { |
1539 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1540 | - continue; |
|
1615 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1616 | + continue; |
|
1617 | + } |
|
1541 | 1618 | |
1542 | 1619 | $value = $profile['options'][$custom['col_name']]; |
1543 | 1620 | |
1544 | 1621 | // Don't show the "disabled" option for the "gender" field. |
1545 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1546 | - continue; |
|
1622 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1623 | + continue; |
|
1624 | + } |
|
1547 | 1625 | |
1548 | 1626 | // BBC? |
1549 | - if ($custom['bbc']) |
|
1550 | - $value = parse_bbc($value); |
|
1627 | + if ($custom['bbc']) { |
|
1628 | + $value = parse_bbc($value); |
|
1629 | + } |
|
1551 | 1630 | // ... or checkbox? |
1552 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1553 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1631 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1632 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1633 | + } |
|
1554 | 1634 | |
1555 | 1635 | // Enclosing the user input within some other text? |
1556 | - if (!empty($custom['enclose'])) |
|
1557 | - $value = strtr($custom['enclose'], array( |
|
1636 | + if (!empty($custom['enclose'])) { |
|
1637 | + $value = strtr($custom['enclose'], array( |
|
1558 | 1638 | '{SCRIPTURL}' => $scripturl, |
1559 | 1639 | '{IMAGES_URL}' => $settings['images_url'], |
1560 | 1640 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1561 | 1641 | '{INPUT}' => $value, |
1562 | 1642 | )); |
1643 | + } |
|
1563 | 1644 | |
1564 | 1645 | $memberContext[$user]['custom_fields'][] = array( |
1565 | 1646 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1586,8 +1667,9 @@ discard block |
||
1586 | 1667 | global $smcFunc, $txt, $scripturl, $settings; |
1587 | 1668 | |
1588 | 1669 | // Do not waste my time... |
1589 | - if (empty($users) || empty($params)) |
|
1590 | - return false; |
|
1670 | + if (empty($users) || empty($params)) { |
|
1671 | + return false; |
|
1672 | + } |
|
1591 | 1673 | |
1592 | 1674 | // Make sure it's an array. |
1593 | 1675 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1611,31 +1693,36 @@ discard block |
||
1611 | 1693 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1612 | 1694 | { |
1613 | 1695 | // BBC? |
1614 | - if (!empty($row['bbc'])) |
|
1615 | - $row['value'] = parse_bbc($row['value']); |
|
1696 | + if (!empty($row['bbc'])) { |
|
1697 | + $row['value'] = parse_bbc($row['value']); |
|
1698 | + } |
|
1616 | 1699 | |
1617 | 1700 | // ... or checkbox? |
1618 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1619 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1701 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1702 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1703 | + } |
|
1620 | 1704 | |
1621 | 1705 | // Enclosing the user input within some other text? |
1622 | - if (!empty($row['enclose'])) |
|
1623 | - $row['value'] = strtr($row['enclose'], array( |
|
1706 | + if (!empty($row['enclose'])) { |
|
1707 | + $row['value'] = strtr($row['enclose'], array( |
|
1624 | 1708 | '{SCRIPTURL}' => $scripturl, |
1625 | 1709 | '{IMAGES_URL}' => $settings['images_url'], |
1626 | 1710 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1627 | 1711 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1628 | 1712 | )); |
1713 | + } |
|
1629 | 1714 | |
1630 | 1715 | // Send a simple array if there is just 1 param |
1631 | - if (count($params) == 1) |
|
1632 | - $return[$row['id_member']] = $row; |
|
1716 | + if (count($params) == 1) { |
|
1717 | + $return[$row['id_member']] = $row; |
|
1718 | + } |
|
1633 | 1719 | |
1634 | 1720 | // More than 1? knock yourself out... |
1635 | 1721 | else |
1636 | 1722 | { |
1637 | - if (!isset($return[$row['id_member']])) |
|
1638 | - $return[$row['id_member']] = array(); |
|
1723 | + if (!isset($return[$row['id_member']])) { |
|
1724 | + $return[$row['id_member']] = array(); |
|
1725 | + } |
|
1639 | 1726 | |
1640 | 1727 | $return[$row['id_member']][$row['variable']] = $row; |
1641 | 1728 | } |
@@ -1669,8 +1756,9 @@ discard block |
||
1669 | 1756 | global $context; |
1670 | 1757 | |
1671 | 1758 | // Don't know any browser! |
1672 | - if (empty($context['browser'])) |
|
1673 | - detectBrowser(); |
|
1759 | + if (empty($context['browser'])) { |
|
1760 | + detectBrowser(); |
|
1761 | + } |
|
1674 | 1762 | |
1675 | 1763 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1676 | 1764 | } |
@@ -1688,8 +1776,9 @@ discard block |
||
1688 | 1776 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1689 | 1777 | |
1690 | 1778 | // The theme was specified by parameter. |
1691 | - if (!empty($id_theme)) |
|
1692 | - $id_theme = (int) $id_theme; |
|
1779 | + if (!empty($id_theme)) { |
|
1780 | + $id_theme = (int) $id_theme; |
|
1781 | + } |
|
1693 | 1782 | // The theme was specified by REQUEST. |
1694 | 1783 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1695 | 1784 | { |
@@ -1697,51 +1786,58 @@ discard block |
||
1697 | 1786 | $_SESSION['id_theme'] = $id_theme; |
1698 | 1787 | } |
1699 | 1788 | // The theme was specified by REQUEST... previously. |
1700 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1701 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1789 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1790 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1791 | + } |
|
1702 | 1792 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1703 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1704 | - $id_theme = $user_info['theme']; |
|
1793 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1794 | + $id_theme = $user_info['theme']; |
|
1795 | + } |
|
1705 | 1796 | // The theme was specified by the board. |
1706 | - elseif (!empty($board_info['theme'])) |
|
1707 | - $id_theme = $board_info['theme']; |
|
1797 | + elseif (!empty($board_info['theme'])) { |
|
1798 | + $id_theme = $board_info['theme']; |
|
1799 | + } |
|
1708 | 1800 | // The theme is the forum's default. |
1709 | - else |
|
1710 | - $id_theme = $modSettings['theme_guests']; |
|
1801 | + else { |
|
1802 | + $id_theme = $modSettings['theme_guests']; |
|
1803 | + } |
|
1711 | 1804 | |
1712 | 1805 | // Verify the id_theme... no foul play. |
1713 | 1806 | // Always allow the board specific theme, if they are overriding. |
1714 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1715 | - $id_theme = $board_info['theme']; |
|
1807 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1808 | + $id_theme = $board_info['theme']; |
|
1809 | + } |
|
1716 | 1810 | // If they have specified a particular theme to use with SSI allow it to be used. |
1717 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1718 | - $id_theme = (int) $id_theme; |
|
1719 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1811 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1812 | + $id_theme = (int) $id_theme; |
|
1813 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1720 | 1814 | { |
1721 | 1815 | $themes = explode(',', $modSettings['enableThemes']); |
1722 | - if (!in_array($id_theme, $themes)) |
|
1723 | - $id_theme = $modSettings['theme_guests']; |
|
1724 | - else |
|
1816 | + if (!in_array($id_theme, $themes)) { |
|
1817 | + $id_theme = $modSettings['theme_guests']; |
|
1818 | + } else { |
|
1819 | + $id_theme = (int) $id_theme; |
|
1820 | + } |
|
1821 | + } else { |
|
1725 | 1822 | $id_theme = (int) $id_theme; |
1726 | 1823 | } |
1727 | - else |
|
1728 | - $id_theme = (int) $id_theme; |
|
1729 | 1824 | |
1730 | 1825 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1731 | 1826 | |
1732 | 1827 | // Disable image proxy if we don't have SSL enabled |
1733 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1734 | - $image_proxy_enabled = false; |
|
1828 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1829 | + $image_proxy_enabled = false; |
|
1830 | + } |
|
1735 | 1831 | |
1736 | 1832 | if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2 && ($temp = cache_get_data('theme_settings-' . $id_theme . ':' . $member, 60)) != null && time() - 60 > $modSettings['settings_updated']) |
1737 | 1833 | { |
1738 | 1834 | $themeData = $temp; |
1739 | 1835 | $flag = true; |
1836 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1837 | + $themeData = $temp + array($member => array()); |
|
1838 | + } else { |
|
1839 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1740 | 1840 | } |
1741 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1742 | - $themeData = $temp + array($member => array()); |
|
1743 | - else |
|
1744 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1745 | 1841 | |
1746 | 1842 | if (empty($flag)) |
1747 | 1843 | { |
@@ -1760,31 +1856,37 @@ discard block |
||
1760 | 1856 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1761 | 1857 | { |
1762 | 1858 | // There are just things we shouldn't be able to change as members. |
1763 | - if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) |
|
1764 | - continue; |
|
1859 | + if ($row['id_member'] != 0 && in_array($row['variable'], array('actual_theme_url', 'actual_images_url', 'base_theme_dir', 'base_theme_url', 'default_images_url', 'default_theme_dir', 'default_theme_url', 'default_template', 'images_url', 'number_recent_posts', 'smiley_sets_default', 'theme_dir', 'theme_id', 'theme_layers', 'theme_templates', 'theme_url'))) { |
|
1860 | + continue; |
|
1861 | + } |
|
1765 | 1862 | |
1766 | 1863 | // If this is the theme_dir of the default theme, store it. |
1767 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1768 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1864 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1865 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1866 | + } |
|
1769 | 1867 | |
1770 | 1868 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1771 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1772 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1869 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1870 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1871 | + } |
|
1773 | 1872 | } |
1774 | 1873 | $smcFunc['db_free_result']($result); |
1775 | 1874 | |
1776 | - if (!empty($themeData[-1])) |
|
1777 | - foreach ($themeData[-1] as $k => $v) |
|
1875 | + if (!empty($themeData[-1])) { |
|
1876 | + foreach ($themeData[-1] as $k => $v) |
|
1778 | 1877 | { |
1779 | 1878 | if (!isset($themeData[$member][$k])) |
1780 | 1879 | $themeData[$member][$k] = $v; |
1880 | + } |
|
1781 | 1881 | } |
1782 | 1882 | |
1783 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1784 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1883 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1884 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1885 | + } |
|
1785 | 1886 | // Only if we didn't already load that part of the cache... |
1786 | - elseif (!isset($temp)) |
|
1787 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1887 | + elseif (!isset($temp)) { |
|
1888 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1889 | + } |
|
1788 | 1890 | } |
1789 | 1891 | |
1790 | 1892 | $settings = $themeData[0]; |
@@ -1801,20 +1903,24 @@ discard block |
||
1801 | 1903 | $settings['template_dirs'][] = $settings['theme_dir']; |
1802 | 1904 | |
1803 | 1905 | // Based on theme (if there is one). |
1804 | - if (!empty($settings['base_theme_dir'])) |
|
1805 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1906 | + if (!empty($settings['base_theme_dir'])) { |
|
1907 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1908 | + } |
|
1806 | 1909 | |
1807 | 1910 | // Lastly the default theme. |
1808 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1809 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1911 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1912 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1913 | + } |
|
1810 | 1914 | |
1811 | - if (!$initialize) |
|
1812 | - return; |
|
1915 | + if (!$initialize) { |
|
1916 | + return; |
|
1917 | + } |
|
1813 | 1918 | |
1814 | 1919 | // Check to see if we're forcing SSL |
1815 | 1920 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1816 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1817 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1921 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1922 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1923 | + } |
|
1818 | 1924 | |
1819 | 1925 | // Check to see if they're accessing it from the wrong place. |
1820 | 1926 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1822,8 +1928,9 @@ discard block |
||
1822 | 1928 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1823 | 1929 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1824 | 1930 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1825 | - if ($temp != '/') |
|
1826 | - $detected_url .= $temp; |
|
1931 | + if ($temp != '/') { |
|
1932 | + $detected_url .= $temp; |
|
1933 | + } |
|
1827 | 1934 | } |
1828 | 1935 | if (isset($detected_url) && $detected_url != $boardurl) |
1829 | 1936 | { |
@@ -1835,8 +1942,9 @@ discard block |
||
1835 | 1942 | foreach ($aliases as $alias) |
1836 | 1943 | { |
1837 | 1944 | // Rip off all the boring parts, spaces, etc. |
1838 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1839 | - $do_fix = true; |
|
1945 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1946 | + $do_fix = true; |
|
1947 | + } |
|
1840 | 1948 | } |
1841 | 1949 | } |
1842 | 1950 | |
@@ -1844,20 +1952,22 @@ discard block |
||
1844 | 1952 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1845 | 1953 | { |
1846 | 1954 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1847 | - if (empty($_GET)) |
|
1848 | - redirectexit('wwwRedirect'); |
|
1849 | - else |
|
1955 | + if (empty($_GET)) { |
|
1956 | + redirectexit('wwwRedirect'); |
|
1957 | + } else |
|
1850 | 1958 | { |
1851 | 1959 | list ($k, $v) = each($_GET); |
1852 | 1960 | |
1853 | - if ($k != 'wwwRedirect') |
|
1854 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1961 | + if ($k != 'wwwRedirect') { |
|
1962 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1963 | + } |
|
1855 | 1964 | } |
1856 | 1965 | } |
1857 | 1966 | |
1858 | 1967 | // #3 is just a check for SSL... |
1859 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1860 | - $do_fix = true; |
|
1968 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1969 | + $do_fix = true; |
|
1970 | + } |
|
1861 | 1971 | |
1862 | 1972 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1863 | 1973 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1891,8 +2001,9 @@ discard block |
||
1891 | 2001 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1892 | 2002 | } |
1893 | 2003 | } |
1894 | - foreach ($context['linktree'] as $k => $dummy) |
|
1895 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2004 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2005 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2006 | + } |
|
1896 | 2007 | } |
1897 | 2008 | } |
1898 | 2009 | // Set up the contextual user array. |
@@ -1911,16 +2022,16 @@ discard block |
||
1911 | 2022 | 'email' => $user_info['email'], |
1912 | 2023 | 'ignoreusers' => $user_info['ignoreusers'], |
1913 | 2024 | ); |
1914 | - if (!$context['user']['is_guest']) |
|
1915 | - $context['user']['name'] = $user_info['name']; |
|
1916 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1917 | - $context['user']['name'] = $txt['guest_title']; |
|
2025 | + if (!$context['user']['is_guest']) { |
|
2026 | + $context['user']['name'] = $user_info['name']; |
|
2027 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2028 | + $context['user']['name'] = $txt['guest_title']; |
|
2029 | + } |
|
1918 | 2030 | |
1919 | 2031 | // Determine the current smiley set. |
1920 | 2032 | $user_info['smiley_set'] = (!in_array($user_info['smiley_set'], explode(',', $modSettings['smiley_sets_known'])) && $user_info['smiley_set'] != 'none') || empty($modSettings['smiley_sets_enable']) ? (!empty($settings['smiley_sets_default']) ? $settings['smiley_sets_default'] : $modSettings['smiley_sets_default']) : $user_info['smiley_set']; |
1921 | 2033 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1922 | - } |
|
1923 | - else |
|
2034 | + } else |
|
1924 | 2035 | { |
1925 | 2036 | $context['user'] = array( |
1926 | 2037 | 'id' => -1, |
@@ -1936,18 +2047,24 @@ discard block |
||
1936 | 2047 | } |
1937 | 2048 | |
1938 | 2049 | // Some basic information... |
1939 | - if (!isset($context['html_headers'])) |
|
1940 | - $context['html_headers'] = ''; |
|
1941 | - if (!isset($context['javascript_files'])) |
|
1942 | - $context['javascript_files'] = array(); |
|
1943 | - if (!isset($context['css_files'])) |
|
1944 | - $context['css_files'] = array(); |
|
1945 | - if (!isset($context['css_header'])) |
|
1946 | - $context['css_header'] = array(); |
|
1947 | - if (!isset($context['javascript_inline'])) |
|
1948 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1949 | - if (!isset($context['javascript_vars'])) |
|
1950 | - $context['javascript_vars'] = array(); |
|
2050 | + if (!isset($context['html_headers'])) { |
|
2051 | + $context['html_headers'] = ''; |
|
2052 | + } |
|
2053 | + if (!isset($context['javascript_files'])) { |
|
2054 | + $context['javascript_files'] = array(); |
|
2055 | + } |
|
2056 | + if (!isset($context['css_files'])) { |
|
2057 | + $context['css_files'] = array(); |
|
2058 | + } |
|
2059 | + if (!isset($context['css_header'])) { |
|
2060 | + $context['css_header'] = array(); |
|
2061 | + } |
|
2062 | + if (!isset($context['javascript_inline'])) { |
|
2063 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2064 | + } |
|
2065 | + if (!isset($context['javascript_vars'])) { |
|
2066 | + $context['javascript_vars'] = array(); |
|
2067 | + } |
|
1951 | 2068 | |
1952 | 2069 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1953 | 2070 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1959,8 +2076,9 @@ discard block |
||
1959 | 2076 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1960 | 2077 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1961 | 2078 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1962 | - if (isset($modSettings['load_average'])) |
|
1963 | - $context['load_average'] = $modSettings['load_average']; |
|
2079 | + if (isset($modSettings['load_average'])) { |
|
2080 | + $context['load_average'] = $modSettings['load_average']; |
|
2081 | + } |
|
1964 | 2082 | |
1965 | 2083 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1966 | 2084 | detectBrowser(); |
@@ -1974,8 +2092,9 @@ discard block |
||
1974 | 2092 | // This allows sticking some HTML on the page output - useful for controls. |
1975 | 2093 | $context['insert_after_template'] = ''; |
1976 | 2094 | |
1977 | - if (!isset($txt)) |
|
1978 | - $txt = array(); |
|
2095 | + if (!isset($txt)) { |
|
2096 | + $txt = array(); |
|
2097 | + } |
|
1979 | 2098 | |
1980 | 2099 | $simpleActions = array( |
1981 | 2100 | 'findmember', |
@@ -2021,9 +2140,10 @@ discard block |
||
2021 | 2140 | |
2022 | 2141 | // See if theres any extra param to check. |
2023 | 2142 | $requiresXML = false; |
2024 | - foreach ($extraParams as $key => $extra) |
|
2025 | - if (isset($_REQUEST[$extra])) |
|
2143 | + foreach ($extraParams as $key => $extra) { |
|
2144 | + if (isset($_REQUEST[$extra])) |
|
2026 | 2145 | $requiresXML = true; |
2146 | + } |
|
2027 | 2147 | |
2028 | 2148 | // Output is fully XML, so no need for the index template. |
2029 | 2149 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2038,37 +2158,39 @@ discard block |
||
2038 | 2158 | { |
2039 | 2159 | loadLanguage('index+Modifications'); |
2040 | 2160 | $context['template_layers'] = array(); |
2041 | - } |
|
2042 | - |
|
2043 | - else |
|
2161 | + } else |
|
2044 | 2162 | { |
2045 | 2163 | // Custom templates to load, or just default? |
2046 | - if (isset($settings['theme_templates'])) |
|
2047 | - $templates = explode(',', $settings['theme_templates']); |
|
2048 | - else |
|
2049 | - $templates = array('index'); |
|
2164 | + if (isset($settings['theme_templates'])) { |
|
2165 | + $templates = explode(',', $settings['theme_templates']); |
|
2166 | + } else { |
|
2167 | + $templates = array('index'); |
|
2168 | + } |
|
2050 | 2169 | |
2051 | 2170 | // Load each template... |
2052 | - foreach ($templates as $template) |
|
2053 | - loadTemplate($template); |
|
2171 | + foreach ($templates as $template) { |
|
2172 | + loadTemplate($template); |
|
2173 | + } |
|
2054 | 2174 | |
2055 | 2175 | // ...and attempt to load their associated language files. |
2056 | 2176 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2057 | 2177 | loadLanguage($required_files, '', false); |
2058 | 2178 | |
2059 | 2179 | // Custom template layers? |
2060 | - if (isset($settings['theme_layers'])) |
|
2061 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2062 | - else |
|
2063 | - $context['template_layers'] = array('html', 'body'); |
|
2180 | + if (isset($settings['theme_layers'])) { |
|
2181 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2182 | + } else { |
|
2183 | + $context['template_layers'] = array('html', 'body'); |
|
2184 | + } |
|
2064 | 2185 | } |
2065 | 2186 | |
2066 | 2187 | // Initialize the theme. |
2067 | 2188 | loadSubTemplate('init', 'ignore'); |
2068 | 2189 | |
2069 | 2190 | // Allow overriding the board wide time/number formats. |
2070 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2071 | - $user_info['time_format'] = $txt['time_format']; |
|
2191 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2192 | + $user_info['time_format'] = $txt['time_format']; |
|
2193 | + } |
|
2072 | 2194 | |
2073 | 2195 | // Set the character set from the template. |
2074 | 2196 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2076,12 +2198,14 @@ discard block |
||
2076 | 2198 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2077 | 2199 | |
2078 | 2200 | // Guests may still need a name. |
2079 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2080 | - $context['user']['name'] = $txt['guest_title']; |
|
2201 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2202 | + $context['user']['name'] = $txt['guest_title']; |
|
2203 | + } |
|
2081 | 2204 | |
2082 | 2205 | // Any theme-related strings that need to be loaded? |
2083 | - if (!empty($settings['require_theme_strings'])) |
|
2084 | - loadLanguage('ThemeStrings', '', false); |
|
2206 | + if (!empty($settings['require_theme_strings'])) { |
|
2207 | + loadLanguage('ThemeStrings', '', false); |
|
2208 | + } |
|
2085 | 2209 | |
2086 | 2210 | // Make a special URL for the language. |
2087 | 2211 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2092,8 +2216,9 @@ discard block |
||
2092 | 2216 | // Here is my luvly Responsive CSS |
2093 | 2217 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2094 | 2218 | |
2095 | - if ($context['right_to_left']) |
|
2096 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2219 | + if ($context['right_to_left']) { |
|
2220 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2221 | + } |
|
2097 | 2222 | |
2098 | 2223 | // We allow theme variants, because we're cool. |
2099 | 2224 | $context['theme_variant'] = ''; |
@@ -2101,14 +2226,17 @@ discard block |
||
2101 | 2226 | if (!empty($settings['theme_variants'])) |
2102 | 2227 | { |
2103 | 2228 | // Overriding - for previews and that ilk. |
2104 | - if (!empty($_REQUEST['variant'])) |
|
2105 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2229 | + if (!empty($_REQUEST['variant'])) { |
|
2230 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2231 | + } |
|
2106 | 2232 | // User selection? |
2107 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2108 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2233 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2234 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2235 | + } |
|
2109 | 2236 | // If not a user variant, select the default. |
2110 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2111 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2237 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2238 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2239 | + } |
|
2112 | 2240 | |
2113 | 2241 | // Do this to keep things easier in the templates. |
2114 | 2242 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2117,20 +2245,23 @@ discard block |
||
2117 | 2245 | if (!empty($context['theme_variant'])) |
2118 | 2246 | { |
2119 | 2247 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2120 | - if ($context['right_to_left']) |
|
2121 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2248 | + if ($context['right_to_left']) { |
|
2249 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2250 | + } |
|
2122 | 2251 | } |
2123 | 2252 | } |
2124 | 2253 | |
2125 | 2254 | // Let's be compatible with old themes! |
2126 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2127 | - $context['template_layers'] = array('main'); |
|
2255 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2256 | + $context['template_layers'] = array('main'); |
|
2257 | + } |
|
2128 | 2258 | |
2129 | 2259 | $context['tabindex'] = 1; |
2130 | 2260 | |
2131 | 2261 | // Compatibility. |
2132 | - if (!isset($settings['theme_version'])) |
|
2133 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2262 | + if (!isset($settings['theme_version'])) { |
|
2263 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2264 | + } |
|
2134 | 2265 | |
2135 | 2266 | // Default JS variables for use in every theme |
2136 | 2267 | $context['javascript_vars'] = array( |
@@ -2149,18 +2280,18 @@ discard block |
||
2149 | 2280 | ); |
2150 | 2281 | |
2151 | 2282 | // Add the JQuery library to the list of files to load. |
2152 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2153 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2154 | - |
|
2155 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2156 | - loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
2157 | - |
|
2158 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2159 | - loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
2283 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2284 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2285 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2286 | + loadJavaScriptFile('jquery-2.1.4.min.js', array('seed' => false), 'smf_jquery'); |
|
2287 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2288 | + loadJavaScriptFile($modSettings['jquery_custom'], array(), 'smf_jquery'); |
|
2289 | + } |
|
2160 | 2290 | |
2161 | 2291 | // Auto loading? template_javascript() will take care of the local half of this. |
2162 | - else |
|
2163 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2292 | + else { |
|
2293 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2294 | + } |
|
2164 | 2295 | |
2165 | 2296 | // Queue our JQuery plugins! |
2166 | 2297 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2183,12 +2314,12 @@ discard block |
||
2183 | 2314 | require_once($sourcedir . '/ScheduledTasks.php'); |
2184 | 2315 | |
2185 | 2316 | // What to do, what to do?! |
2186 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2187 | - AutoTask(); |
|
2188 | - else |
|
2189 | - ReduceMailQueue(); |
|
2190 | - } |
|
2191 | - else |
|
2317 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2318 | + AutoTask(); |
|
2319 | + } else { |
|
2320 | + ReduceMailQueue(); |
|
2321 | + } |
|
2322 | + } else |
|
2192 | 2323 | { |
2193 | 2324 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2194 | 2325 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2239,8 +2370,9 @@ discard block |
||
2239 | 2370 | foreach ($theme_includes as $include) |
2240 | 2371 | { |
2241 | 2372 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2242 | - if (file_exists($include)) |
|
2243 | - require_once($include); |
|
2373 | + if (file_exists($include)) { |
|
2374 | + require_once($include); |
|
2375 | + } |
|
2244 | 2376 | } |
2245 | 2377 | } |
2246 | 2378 | |
@@ -2270,16 +2402,19 @@ discard block |
||
2270 | 2402 | // Do any style sheets first, cause we're easy with those. |
2271 | 2403 | if (!empty($style_sheets)) |
2272 | 2404 | { |
2273 | - if (!is_array($style_sheets)) |
|
2274 | - $style_sheets = array($style_sheets); |
|
2405 | + if (!is_array($style_sheets)) { |
|
2406 | + $style_sheets = array($style_sheets); |
|
2407 | + } |
|
2275 | 2408 | |
2276 | - foreach ($style_sheets as $sheet) |
|
2277 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2409 | + foreach ($style_sheets as $sheet) { |
|
2410 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2411 | + } |
|
2278 | 2412 | } |
2279 | 2413 | |
2280 | 2414 | // No template to load? |
2281 | - if ($template_name === false) |
|
2282 | - return true; |
|
2415 | + if ($template_name === false) { |
|
2416 | + return true; |
|
2417 | + } |
|
2283 | 2418 | |
2284 | 2419 | $loaded = false; |
2285 | 2420 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2294,12 +2429,14 @@ discard block |
||
2294 | 2429 | |
2295 | 2430 | if ($loaded) |
2296 | 2431 | { |
2297 | - if ($db_show_debug === true) |
|
2298 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2432 | + if ($db_show_debug === true) { |
|
2433 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2434 | + } |
|
2299 | 2435 | |
2300 | 2436 | // If they have specified an initialization function for this template, go ahead and call it now. |
2301 | - if (function_exists('template_' . $template_name . '_init')) |
|
2302 | - call_user_func('template_' . $template_name . '_init'); |
|
2437 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2438 | + call_user_func('template_' . $template_name . '_init'); |
|
2439 | + } |
|
2303 | 2440 | } |
2304 | 2441 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2305 | 2442 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2319,13 +2456,14 @@ discard block |
||
2319 | 2456 | loadTemplate($template_name); |
2320 | 2457 | } |
2321 | 2458 | // Cause an error otherwise. |
2322 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2323 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2324 | - elseif ($fatal) |
|
2325 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2326 | - else |
|
2327 | - return false; |
|
2328 | -} |
|
2459 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2460 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2461 | + } elseif ($fatal) { |
|
2462 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load Themes/default/%s.template.php!', (string) $template_name), 'template')); |
|
2463 | + } else { |
|
2464 | + return false; |
|
2465 | + } |
|
2466 | + } |
|
2329 | 2467 | |
2330 | 2468 | /** |
2331 | 2469 | * Load a sub-template. |
@@ -2343,17 +2481,19 @@ discard block |
||
2343 | 2481 | { |
2344 | 2482 | global $context, $txt, $db_show_debug; |
2345 | 2483 | |
2346 | - if ($db_show_debug === true) |
|
2347 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2484 | + if ($db_show_debug === true) { |
|
2485 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2486 | + } |
|
2348 | 2487 | |
2349 | 2488 | // Figure out what the template function is named. |
2350 | 2489 | $theme_function = 'template_' . $sub_template_name; |
2351 | - if (function_exists($theme_function)) |
|
2352 | - $theme_function(); |
|
2353 | - elseif ($fatal === false) |
|
2354 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2355 | - elseif ($fatal !== 'ignore') |
|
2356 | - die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2490 | + if (function_exists($theme_function)) { |
|
2491 | + $theme_function(); |
|
2492 | + } elseif ($fatal === false) { |
|
2493 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2494 | + } elseif ($fatal !== 'ignore') { |
|
2495 | + die(log_error(sprintf(isset($txt['theme_template_error']) ? $txt['theme_template_error'] : 'Unable to load the %s sub template!', (string) $sub_template_name), 'template')); |
|
2496 | + } |
|
2357 | 2497 | |
2358 | 2498 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2359 | 2499 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2390,8 +2530,9 @@ discard block |
||
2390 | 2530 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2391 | 2531 | |
2392 | 2532 | // If this is an external file, automatically set this to false. |
2393 | - if (!empty($params['external'])) |
|
2394 | - $params['minimize'] = false; |
|
2533 | + if (!empty($params['external'])) { |
|
2534 | + $params['minimize'] = false; |
|
2535 | + } |
|
2395 | 2536 | |
2396 | 2537 | // Account for shorthand like admin.css?alp21 filenames |
2397 | 2538 | $has_seed = strpos($fileName, '.css?'); |
@@ -2408,13 +2549,10 @@ discard block |
||
2408 | 2549 | { |
2409 | 2550 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2410 | 2551 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2552 | + } else { |
|
2553 | + $fileUrl = false; |
|
2411 | 2554 | } |
2412 | - |
|
2413 | - else |
|
2414 | - $fileUrl = false; |
|
2415 | - } |
|
2416 | - |
|
2417 | - else |
|
2555 | + } else |
|
2418 | 2556 | { |
2419 | 2557 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2420 | 2558 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2429,12 +2567,14 @@ discard block |
||
2429 | 2567 | } |
2430 | 2568 | |
2431 | 2569 | // Add it to the array for use in the template |
2432 | - if (!empty($fileName)) |
|
2433 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2570 | + if (!empty($fileName)) { |
|
2571 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2572 | + } |
|
2434 | 2573 | |
2435 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2436 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2437 | -} |
|
2574 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2575 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2576 | + } |
|
2577 | + } |
|
2438 | 2578 | |
2439 | 2579 | /** |
2440 | 2580 | * Add a block of inline css code to be executed later |
@@ -2451,8 +2591,9 @@ discard block |
||
2451 | 2591 | global $context; |
2452 | 2592 | |
2453 | 2593 | // Gotta add something... |
2454 | - if (empty($css)) |
|
2455 | - return false; |
|
2594 | + if (empty($css)) { |
|
2595 | + return false; |
|
2596 | + } |
|
2456 | 2597 | |
2457 | 2598 | $context['css_header'][] = $css; |
2458 | 2599 | } |
@@ -2487,8 +2628,9 @@ discard block |
||
2487 | 2628 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2488 | 2629 | |
2489 | 2630 | // If this is an external file, automatically set this to false. |
2490 | - if (!empty($params['external'])) |
|
2491 | - $params['minimize'] = false; |
|
2631 | + if (!empty($params['external'])) { |
|
2632 | + $params['minimize'] = false; |
|
2633 | + } |
|
2492 | 2634 | |
2493 | 2635 | // Account for shorthand like admin.js?alp21 filenames |
2494 | 2636 | $has_seed = strpos($fileName, '.js?'); |
@@ -2505,16 +2647,12 @@ discard block |
||
2505 | 2647 | { |
2506 | 2648 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2507 | 2649 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2508 | - } |
|
2509 | - |
|
2510 | - else |
|
2650 | + } else |
|
2511 | 2651 | { |
2512 | 2652 | $fileUrl = false; |
2513 | 2653 | $filePath = false; |
2514 | 2654 | } |
2515 | - } |
|
2516 | - |
|
2517 | - else |
|
2655 | + } else |
|
2518 | 2656 | { |
2519 | 2657 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2520 | 2658 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2529,9 +2667,10 @@ discard block |
||
2529 | 2667 | } |
2530 | 2668 | |
2531 | 2669 | // Add it to the array for use in the template |
2532 | - if (!empty($fileName)) |
|
2533 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2534 | -} |
|
2670 | + if (!empty($fileName)) { |
|
2671 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2672 | + } |
|
2673 | + } |
|
2535 | 2674 | |
2536 | 2675 | /** |
2537 | 2676 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2545,9 +2684,10 @@ discard block |
||
2545 | 2684 | { |
2546 | 2685 | global $context; |
2547 | 2686 | |
2548 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2549 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2550 | -} |
|
2687 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2688 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2689 | + } |
|
2690 | + } |
|
2551 | 2691 | |
2552 | 2692 | /** |
2553 | 2693 | * Add a block of inline Javascript code to be executed later |
@@ -2564,8 +2704,9 @@ discard block |
||
2564 | 2704 | { |
2565 | 2705 | global $context; |
2566 | 2706 | |
2567 | - if (empty($javascript)) |
|
2568 | - return false; |
|
2707 | + if (empty($javascript)) { |
|
2708 | + return false; |
|
2709 | + } |
|
2569 | 2710 | |
2570 | 2711 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2571 | 2712 | } |
@@ -2586,15 +2727,18 @@ discard block |
||
2586 | 2727 | static $already_loaded = array(); |
2587 | 2728 | |
2588 | 2729 | // Default to the user's language. |
2589 | - if ($lang == '') |
|
2590 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2730 | + if ($lang == '') { |
|
2731 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2732 | + } |
|
2591 | 2733 | |
2592 | 2734 | // Do we want the English version of language file as fallback? |
2593 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2594 | - loadLanguage($template_name, 'english', false); |
|
2735 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2736 | + loadLanguage($template_name, 'english', false); |
|
2737 | + } |
|
2595 | 2738 | |
2596 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2597 | - return $lang; |
|
2739 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2740 | + return $lang; |
|
2741 | + } |
|
2598 | 2742 | |
2599 | 2743 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2600 | 2744 | if (empty($settings['default_theme_dir'])) |
@@ -2605,8 +2749,9 @@ discard block |
||
2605 | 2749 | |
2606 | 2750 | // What theme are we in? |
2607 | 2751 | $theme_name = basename($settings['theme_url']); |
2608 | - if (empty($theme_name)) |
|
2609 | - $theme_name = 'unknown'; |
|
2752 | + if (empty($theme_name)) { |
|
2753 | + $theme_name = 'unknown'; |
|
2754 | + } |
|
2610 | 2755 | |
2611 | 2756 | // For each file open it up and write it out! |
2612 | 2757 | foreach (explode('+', $template_name) as $template) |
@@ -2685,8 +2830,9 @@ discard block |
||
2685 | 2830 | } |
2686 | 2831 | |
2687 | 2832 | // Keep track of what we're up to soldier. |
2688 | - if ($db_show_debug === true) |
|
2689 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2833 | + if ($db_show_debug === true) { |
|
2834 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2835 | + } |
|
2690 | 2836 | |
2691 | 2837 | // Remember what we have loaded, and in which language. |
2692 | 2838 | $already_loaded[$template_name] = $lang; |
@@ -2732,8 +2878,9 @@ discard block |
||
2732 | 2878 | ) |
2733 | 2879 | ); |
2734 | 2880 | // In the EXTREMELY unlikely event this happens, give an error message. |
2735 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2736 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2881 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2882 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2883 | + } |
|
2737 | 2884 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2738 | 2885 | { |
2739 | 2886 | if (!isset($boards[$row['id_board']])) |
@@ -2750,8 +2897,8 @@ discard block |
||
2750 | 2897 | ); |
2751 | 2898 | } |
2752 | 2899 | // If a moderator exists for this board, add that moderator for all children too. |
2753 | - if (!empty($row['id_moderator'])) |
|
2754 | - foreach ($boards as $id => $dummy) |
|
2900 | + if (!empty($row['id_moderator'])) { |
|
2901 | + foreach ($boards as $id => $dummy) |
|
2755 | 2902 | { |
2756 | 2903 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2757 | 2904 | 'id' => $row['id_moderator'], |
@@ -2759,11 +2906,12 @@ discard block |
||
2759 | 2906 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2760 | 2907 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2761 | 2908 | ); |
2909 | + } |
|
2762 | 2910 | } |
2763 | 2911 | |
2764 | 2912 | // If a moderator group exists for this board, add that moderator group for all children too |
2765 | - if (!empty($row['id_moderator_group'])) |
|
2766 | - foreach ($boards as $id => $dummy) |
|
2913 | + if (!empty($row['id_moderator_group'])) { |
|
2914 | + foreach ($boards as $id => $dummy) |
|
2767 | 2915 | { |
2768 | 2916 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2769 | 2917 | 'id' => $row['id_moderator_group'], |
@@ -2771,6 +2919,7 @@ discard block |
||
2771 | 2919 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2772 | 2920 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2773 | 2921 | ); |
2922 | + } |
|
2774 | 2923 | } |
2775 | 2924 | } |
2776 | 2925 | $smcFunc['db_free_result']($result); |
@@ -2798,23 +2947,27 @@ discard block |
||
2798 | 2947 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages' . ($favor_utf8 ? '' : '_all'), !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2799 | 2948 | { |
2800 | 2949 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2801 | - if (empty($smcFunc['ucwords'])) |
|
2802 | - reloadSettings(); |
|
2950 | + if (empty($smcFunc['ucwords'])) { |
|
2951 | + reloadSettings(); |
|
2952 | + } |
|
2803 | 2953 | |
2804 | 2954 | // If we don't have our theme information yet, let's get it. |
2805 | - if (empty($settings['default_theme_dir'])) |
|
2806 | - loadTheme(0, false); |
|
2955 | + if (empty($settings['default_theme_dir'])) { |
|
2956 | + loadTheme(0, false); |
|
2957 | + } |
|
2807 | 2958 | |
2808 | 2959 | // Default language directories to try. |
2809 | 2960 | $language_directories = array( |
2810 | 2961 | $settings['default_theme_dir'] . '/languages', |
2811 | 2962 | ); |
2812 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2813 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2963 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2964 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2965 | + } |
|
2814 | 2966 | |
2815 | 2967 | // We possibly have a base theme directory. |
2816 | - if (!empty($settings['base_theme_dir'])) |
|
2817 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2968 | + if (!empty($settings['base_theme_dir'])) { |
|
2969 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2970 | + } |
|
2818 | 2971 | |
2819 | 2972 | // Remove any duplicates. |
2820 | 2973 | $language_directories = array_unique($language_directories); |
@@ -2828,20 +2981,21 @@ discard block |
||
2828 | 2981 | foreach ($language_directories as $language_dir) |
2829 | 2982 | { |
2830 | 2983 | // Can't look in here... doesn't exist! |
2831 | - if (!file_exists($language_dir)) |
|
2832 | - continue; |
|
2984 | + if (!file_exists($language_dir)) { |
|
2985 | + continue; |
|
2986 | + } |
|
2833 | 2987 | |
2834 | 2988 | $dir = dir($language_dir); |
2835 | 2989 | while ($entry = $dir->read()) |
2836 | 2990 | { |
2837 | 2991 | // Look for the index language file.... |
2838 | - if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) |
|
2839 | - continue; |
|
2840 | - |
|
2841 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2842 | - $langName = $langList[$matches[1]]; |
|
2992 | + if (!preg_match('~^index\.(.+)\.php$~', $entry, $matches)) { |
|
2993 | + continue; |
|
2994 | + } |
|
2843 | 2995 | |
2844 | - else |
|
2996 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
2997 | + $langName = $langList[$matches[1]]; |
|
2998 | + } else |
|
2845 | 2999 | { |
2846 | 3000 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2847 | 3001 | |
@@ -2882,20 +3036,23 @@ discard block |
||
2882 | 3036 | } |
2883 | 3037 | |
2884 | 3038 | // Do we need to store the lang list? |
2885 | - if (empty($langList)) |
|
2886 | - updateSettings(array('langList' => json_encode($catchLang))); |
|
3039 | + if (empty($langList)) { |
|
3040 | + updateSettings(array('langList' => json_encode($catchLang))); |
|
3041 | + } |
|
2887 | 3042 | |
2888 | 3043 | // Favoring UTF8? Then prevent us from selecting non-UTF8 versions. |
2889 | 3044 | if ($favor_utf8) |
2890 | 3045 | { |
2891 | - foreach ($context['languages'] as $lang) |
|
2892 | - if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
3046 | + foreach ($context['languages'] as $lang) { |
|
3047 | + if (substr($lang['filename'], strlen($lang['filename']) - 5, 5) != '-utf8' && isset($context['languages'][$lang['filename'] . '-utf8'])) |
|
2893 | 3048 | unset($context['languages'][$lang['filename']]); |
3049 | + } |
|
2894 | 3050 | } |
2895 | 3051 | |
2896 | 3052 | // Let's cash in on this deal. |
2897 | - if (!empty($modSettings['cache_enable'])) |
|
2898 | - cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3053 | + if (!empty($modSettings['cache_enable'])) { |
|
3054 | + cache_put_data('known_languages' . ($favor_utf8 ? '' : '_all'), $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3055 | + } |
|
2899 | 3056 | } |
2900 | 3057 | |
2901 | 3058 | return $context['languages']; |
@@ -2918,8 +3075,9 @@ discard block |
||
2918 | 3075 | global $modSettings, $options, $txt; |
2919 | 3076 | static $censor_vulgar = null, $censor_proper; |
2920 | 3077 | |
2921 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2922 | - return $text; |
|
3078 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3079 | + return $text; |
|
3080 | + } |
|
2923 | 3081 | |
2924 | 3082 | // If they haven't yet been loaded, load them. |
2925 | 3083 | if ($censor_vulgar == null) |
@@ -2947,9 +3105,9 @@ discard block |
||
2947 | 3105 | { |
2948 | 3106 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2949 | 3107 | $text = $func($censor_vulgar, $censor_proper, $text); |
3108 | + } else { |
|
3109 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2950 | 3110 | } |
2951 | - else |
|
2952 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2953 | 3111 | |
2954 | 3112 | return $text; |
2955 | 3113 | } |
@@ -2975,38 +3133,42 @@ discard block |
||
2975 | 3133 | @ini_set('track_errors', '1'); |
2976 | 3134 | |
2977 | 3135 | // Don't include the file more than once, if $once is true. |
2978 | - if ($once && in_array($filename, $templates)) |
|
2979 | - return; |
|
3136 | + if ($once && in_array($filename, $templates)) { |
|
3137 | + return; |
|
3138 | + } |
|
2980 | 3139 | // Add this file to the include list, whether $once is true or not. |
2981 | - else |
|
2982 | - $templates[] = $filename; |
|
3140 | + else { |
|
3141 | + $templates[] = $filename; |
|
3142 | + } |
|
2983 | 3143 | |
2984 | 3144 | // Are we going to use eval? |
2985 | 3145 | if (empty($modSettings['disableTemplateEval'])) |
2986 | 3146 | { |
2987 | 3147 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
2988 | 3148 | $settings['current_include_filename'] = $filename; |
2989 | - } |
|
2990 | - else |
|
3149 | + } else |
|
2991 | 3150 | { |
2992 | 3151 | $file_found = file_exists($filename); |
2993 | 3152 | |
2994 | - if ($once && $file_found) |
|
2995 | - require_once($filename); |
|
2996 | - elseif ($file_found) |
|
2997 | - require($filename); |
|
3153 | + if ($once && $file_found) { |
|
3154 | + require_once($filename); |
|
3155 | + } elseif ($file_found) { |
|
3156 | + require($filename); |
|
3157 | + } |
|
2998 | 3158 | } |
2999 | 3159 | |
3000 | 3160 | if ($file_found !== true) |
3001 | 3161 | { |
3002 | 3162 | ob_end_clean(); |
3003 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3004 | - @ob_start('ob_gzhandler'); |
|
3005 | - else |
|
3006 | - ob_start(); |
|
3163 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3164 | + @ob_start('ob_gzhandler'); |
|
3165 | + } else { |
|
3166 | + ob_start(); |
|
3167 | + } |
|
3007 | 3168 | |
3008 | - if (isset($_GET['debug'])) |
|
3009 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3169 | + if (isset($_GET['debug'])) { |
|
3170 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3171 | + } |
|
3010 | 3172 | |
3011 | 3173 | // Don't cache error pages!! |
3012 | 3174 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3025,12 +3187,13 @@ discard block |
||
3025 | 3187 | echo '<!DOCTYPE html> |
3026 | 3188 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3027 | 3189 | <head>'; |
3028 | - if (isset($context['character_set'])) |
|
3029 | - echo ' |
|
3190 | + if (isset($context['character_set'])) { |
|
3191 | + echo ' |
|
3030 | 3192 | <meta charset="', $context['character_set'], '">'; |
3193 | + } |
|
3031 | 3194 | |
3032 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3033 | - echo ' |
|
3195 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3196 | + echo ' |
|
3034 | 3197 | <title>', $mtitle, '</title> |
3035 | 3198 | </head> |
3036 | 3199 | <body> |
@@ -3038,8 +3201,8 @@ discard block |
||
3038 | 3201 | ', $mmessage, ' |
3039 | 3202 | </body> |
3040 | 3203 | </html>'; |
3041 | - elseif (!allowedTo('admin_forum')) |
|
3042 | - echo ' |
|
3204 | + } elseif (!allowedTo('admin_forum')) { |
|
3205 | + echo ' |
|
3043 | 3206 | <title>', $txt['template_parse_error'], '</title> |
3044 | 3207 | </head> |
3045 | 3208 | <body> |
@@ -3047,15 +3210,17 @@ discard block |
||
3047 | 3210 | ', $txt['template_parse_error_message'], ' |
3048 | 3211 | </body> |
3049 | 3212 | </html>'; |
3050 | - else |
|
3213 | + } else |
|
3051 | 3214 | { |
3052 | 3215 | require_once($sourcedir . '/Subs-Package.php'); |
3053 | 3216 | |
3054 | 3217 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3055 | - if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) |
|
3056 | - $error = $php_errormsg; |
|
3057 | - if (empty($error)) |
|
3058 | - $error = $txt['template_parse_errmsg']; |
|
3218 | + if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) { |
|
3219 | + $error = $php_errormsg; |
|
3220 | + } |
|
3221 | + if (empty($error)) { |
|
3222 | + $error = $txt['template_parse_errmsg']; |
|
3223 | + } |
|
3059 | 3224 | |
3060 | 3225 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3061 | 3226 | |
@@ -3066,11 +3231,12 @@ discard block |
||
3066 | 3231 | <h3>', $txt['template_parse_error'], '</h3> |
3067 | 3232 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3068 | 3233 | |
3069 | - if (!empty($error)) |
|
3070 | - echo ' |
|
3234 | + if (!empty($error)) { |
|
3235 | + echo ' |
|
3071 | 3236 | <hr> |
3072 | 3237 | |
3073 | 3238 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3239 | + } |
|
3074 | 3240 | |
3075 | 3241 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3076 | 3242 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3080,10 +3246,11 @@ discard block |
||
3080 | 3246 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3081 | 3247 | |
3082 | 3248 | // Fix the PHP code stuff... |
3083 | - if (!isBrowser('gecko')) |
|
3084 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3085 | - else |
|
3086 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3249 | + if (!isBrowser('gecko')) { |
|
3250 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3251 | + } else { |
|
3252 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3253 | + } |
|
3087 | 3254 | |
3088 | 3255 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3089 | 3256 | $j = -1; |
@@ -3091,8 +3258,9 @@ discard block |
||
3091 | 3258 | { |
3092 | 3259 | $j++; |
3093 | 3260 | |
3094 | - if (substr_count($line, '<br>') == 0) |
|
3095 | - continue; |
|
3261 | + if (substr_count($line, '<br>') == 0) { |
|
3262 | + continue; |
|
3263 | + } |
|
3096 | 3264 | |
3097 | 3265 | $n = substr_count($line, '<br>'); |
3098 | 3266 | for ($i = 0; $i < $n; $i++) |
@@ -3111,38 +3279,42 @@ discard block |
||
3111 | 3279 | // Figure out what the color coding was before... |
3112 | 3280 | $line = max($match[1] - 9, 1); |
3113 | 3281 | $last_line = ''; |
3114 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3115 | - if (strpos($data2[$line2], '<') !== false) |
|
3282 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3283 | + if (strpos($data2[$line2], '<') !== false) |
|
3116 | 3284 | { |
3117 | 3285 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3118 | 3286 | $last_line = $color_match[1]; |
3287 | + } |
|
3119 | 3288 | break; |
3120 | 3289 | } |
3121 | 3290 | |
3122 | 3291 | // Show the relevant lines... |
3123 | 3292 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3124 | 3293 | { |
3125 | - if ($line == $match[1]) |
|
3126 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3294 | + if ($line == $match[1]) { |
|
3295 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3296 | + } |
|
3127 | 3297 | |
3128 | 3298 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3129 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3130 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3299 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3300 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3301 | + } |
|
3131 | 3302 | |
3132 | 3303 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3133 | 3304 | { |
3134 | 3305 | $last_line = $color_match[1]; |
3135 | 3306 | echo '</', substr($last_line, 1, 4), '>'; |
3307 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3308 | + $last_line = ''; |
|
3309 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3310 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3136 | 3311 | } |
3137 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3138 | - $last_line = ''; |
|
3139 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3140 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3141 | 3312 | |
3142 | - if ($line == $match[1]) |
|
3143 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3144 | - else |
|
3145 | - echo "\n"; |
|
3313 | + if ($line == $match[1]) { |
|
3314 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3315 | + } else { |
|
3316 | + echo "\n"; |
|
3317 | + } |
|
3146 | 3318 | } |
3147 | 3319 | |
3148 | 3320 | echo '</pre></div>'; |
@@ -3166,8 +3338,9 @@ discard block |
||
3166 | 3338 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3167 | 3339 | |
3168 | 3340 | // Figure out what type of database we are using. |
3169 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3170 | - $db_type = 'mysql'; |
|
3341 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3342 | + $db_type = 'mysql'; |
|
3343 | + } |
|
3171 | 3344 | |
3172 | 3345 | // Load the file for the database. |
3173 | 3346 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3175,8 +3348,9 @@ discard block |
||
3175 | 3348 | $db_options = array(); |
3176 | 3349 | |
3177 | 3350 | // Add in the port if needed |
3178 | - if (!empty($db_port)) |
|
3179 | - $db_options['port'] = $db_port; |
|
3351 | + if (!empty($db_port)) { |
|
3352 | + $db_options['port'] = $db_port; |
|
3353 | + } |
|
3180 | 3354 | |
3181 | 3355 | // If we are in SSI try them first, but don't worry if it doesn't work, we have the normal username and password we can use. |
3182 | 3356 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3195,13 +3369,15 @@ discard block |
||
3195 | 3369 | } |
3196 | 3370 | |
3197 | 3371 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3198 | - if (!$db_connection) |
|
3199 | - display_db_error(); |
|
3372 | + if (!$db_connection) { |
|
3373 | + display_db_error(); |
|
3374 | + } |
|
3200 | 3375 | |
3201 | 3376 | // If in SSI mode fix up the prefix. |
3202 | - if (SMF == 'SSI') |
|
3203 | - db_fix_prefix($db_prefix, $db_name); |
|
3204 | -} |
|
3377 | + if (SMF == 'SSI') { |
|
3378 | + db_fix_prefix($db_prefix, $db_name); |
|
3379 | + } |
|
3380 | + } |
|
3205 | 3381 | |
3206 | 3382 | /** |
3207 | 3383 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3215,10 +3391,11 @@ discard block |
||
3215 | 3391 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3216 | 3392 | |
3217 | 3393 | // Not overriding this and we have a cacheAPI, send it back. |
3218 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3219 | - return $cacheAPI; |
|
3220 | - elseif (is_null($cacheAPI)) |
|
3221 | - $cacheAPI = false; |
|
3394 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3395 | + return $cacheAPI; |
|
3396 | + } elseif (is_null($cacheAPI)) { |
|
3397 | + $cacheAPI = false; |
|
3398 | + } |
|
3222 | 3399 | |
3223 | 3400 | // Make sure our class is in session. |
3224 | 3401 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3239,8 +3416,9 @@ discard block |
||
3239 | 3416 | if (!$testAPI->isSupported()) |
3240 | 3417 | { |
3241 | 3418 | // Can we save ourselves? |
3242 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3243 | - return loadCacheAccelerator(null, false); |
|
3419 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3420 | + return loadCacheAccelerator(null, false); |
|
3421 | + } |
|
3244 | 3422 | return false; |
3245 | 3423 | } |
3246 | 3424 | |
@@ -3252,9 +3430,9 @@ discard block |
||
3252 | 3430 | { |
3253 | 3431 | $cacheAPI = $testAPI; |
3254 | 3432 | return $cacheAPI; |
3433 | + } else { |
|
3434 | + return $testAPI; |
|
3255 | 3435 | } |
3256 | - else |
|
3257 | - return $testAPI; |
|
3258 | 3436 | } |
3259 | 3437 | } |
3260 | 3438 | |
@@ -3274,8 +3452,9 @@ discard block |
||
3274 | 3452 | |
3275 | 3453 | // @todo Why are we doing this if caching is disabled? |
3276 | 3454 | |
3277 | - if (function_exists('call_integration_hook')) |
|
3278 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3455 | + if (function_exists('call_integration_hook')) { |
|
3456 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3457 | + } |
|
3279 | 3458 | |
3280 | 3459 | /* Refresh the cache if either: |
3281 | 3460 | 1. Caching is disabled. |
@@ -3289,16 +3468,19 @@ discard block |
||
3289 | 3468 | require_once($sourcedir . '/' . $file); |
3290 | 3469 | $cache_block = call_user_func_array($function, $params); |
3291 | 3470 | |
3292 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3293 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3471 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3472 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3473 | + } |
|
3294 | 3474 | } |
3295 | 3475 | |
3296 | 3476 | // Some cached data may need a freshening up after retrieval. |
3297 | - if (!empty($cache_block['post_retri_eval'])) |
|
3298 | - eval($cache_block['post_retri_eval']); |
|
3477 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3478 | + eval($cache_block['post_retri_eval']); |
|
3479 | + } |
|
3299 | 3480 | |
3300 | - if (function_exists('call_integration_hook')) |
|
3301 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3481 | + if (function_exists('call_integration_hook')) { |
|
3482 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3483 | + } |
|
3302 | 3484 | |
3303 | 3485 | return $cache_block['data']; |
3304 | 3486 | } |
@@ -3325,8 +3507,9 @@ discard block |
||
3325 | 3507 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
3326 | 3508 | global $cache_hits, $cache_count, $db_show_debug; |
3327 | 3509 | |
3328 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3329 | - return; |
|
3510 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3511 | + return; |
|
3512 | + } |
|
3330 | 3513 | |
3331 | 3514 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3332 | 3515 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3339,12 +3522,14 @@ discard block |
||
3339 | 3522 | $value = $value === null ? null : json_encode($value); |
3340 | 3523 | $cacheAPI->putData($key, $value, $ttl); |
3341 | 3524 | |
3342 | - if (function_exists('call_integration_hook')) |
|
3343 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3525 | + if (function_exists('call_integration_hook')) { |
|
3526 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3527 | + } |
|
3344 | 3528 | |
3345 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3346 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3347 | -} |
|
3529 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3530 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3531 | + } |
|
3532 | + } |
|
3348 | 3533 | |
3349 | 3534 | /** |
3350 | 3535 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3360,8 +3545,9 @@ discard block |
||
3360 | 3545 | global $boardurl, $modSettings, $cache_enable, $cacheAPI; |
3361 | 3546 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3362 | 3547 | |
3363 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3364 | - return; |
|
3548 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3549 | + return; |
|
3550 | + } |
|
3365 | 3551 | |
3366 | 3552 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3367 | 3553 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3381,16 +3567,18 @@ discard block |
||
3381 | 3567 | |
3382 | 3568 | if (empty($value)) |
3383 | 3569 | { |
3384 | - if (!is_array($cache_misses)) |
|
3385 | - $cache_misses = array(); |
|
3570 | + if (!is_array($cache_misses)) { |
|
3571 | + $cache_misses = array(); |
|
3572 | + } |
|
3386 | 3573 | |
3387 | 3574 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3388 | 3575 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3389 | 3576 | } |
3390 | 3577 | } |
3391 | 3578 | |
3392 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3393 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3579 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3580 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3581 | + } |
|
3394 | 3582 | |
3395 | 3583 | return empty($value) ? null : smf_json_decode($value, true); |
3396 | 3584 | } |
@@ -3412,8 +3600,9 @@ discard block |
||
3412 | 3600 | global $cacheAPI; |
3413 | 3601 | |
3414 | 3602 | // If we can't get to the API, can't do this. |
3415 | - if (empty($cacheAPI)) |
|
3416 | - return; |
|
3603 | + if (empty($cacheAPI)) { |
|
3604 | + return; |
|
3605 | + } |
|
3417 | 3606 | |
3418 | 3607 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3419 | 3608 | $cacheAPI->cleanCache($type); |
@@ -3438,8 +3627,9 @@ discard block |
||
3438 | 3627 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3439 | 3628 | |
3440 | 3629 | // Come on! |
3441 | - if (empty($data)) |
|
3442 | - return array(); |
|
3630 | + if (empty($data)) { |
|
3631 | + return array(); |
|
3632 | + } |
|
3443 | 3633 | |
3444 | 3634 | // Set a nice default var. |
3445 | 3635 | $image = ''; |
@@ -3447,11 +3637,11 @@ discard block |
||
3447 | 3637 | // Gravatar has been set as mandatory! |
3448 | 3638 | if (!empty($modSettings['gravatarOverride'])) |
3449 | 3639 | { |
3450 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3451 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3452 | - |
|
3453 | - else if (!empty($data['email'])) |
|
3454 | - $image = get_gravatar_url($data['email']); |
|
3640 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3641 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3642 | + } else if (!empty($data['email'])) { |
|
3643 | + $image = get_gravatar_url($data['email']); |
|
3644 | + } |
|
3455 | 3645 | } |
3456 | 3646 | |
3457 | 3647 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3463,54 +3653,60 @@ discard block |
||
3463 | 3653 | // Gravatar. |
3464 | 3654 | if (stristr($data['avatar'], 'gravatar://')) |
3465 | 3655 | { |
3466 | - if ($data['avatar'] == 'gravatar://') |
|
3467 | - $image = get_gravatar_url($data['email']); |
|
3468 | - |
|
3469 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3470 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3656 | + if ($data['avatar'] == 'gravatar://') { |
|
3657 | + $image = get_gravatar_url($data['email']); |
|
3658 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3659 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3660 | + } |
|
3471 | 3661 | } |
3472 | 3662 | |
3473 | 3663 | // External url. |
3474 | 3664 | else |
3475 | 3665 | { |
3476 | 3666 | // Using ssl? |
3477 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3478 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3667 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3668 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3669 | + } |
|
3479 | 3670 | |
3480 | 3671 | // Just a plain external url. |
3481 | - else |
|
3482 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3672 | + else { |
|
3673 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3674 | + } |
|
3483 | 3675 | } |
3484 | 3676 | } |
3485 | 3677 | |
3486 | 3678 | // Perhaps this user has an attachment as avatar... |
3487 | - else if (!empty($data['filename'])) |
|
3488 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3679 | + else if (!empty($data['filename'])) { |
|
3680 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3681 | + } |
|
3489 | 3682 | |
3490 | 3683 | // Right... no avatar... use our default image. |
3491 | - else |
|
3492 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3684 | + else { |
|
3685 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3686 | + } |
|
3493 | 3687 | } |
3494 | 3688 | |
3495 | 3689 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3496 | 3690 | |
3497 | 3691 | // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. |
3498 | - if (!empty($image)) |
|
3499 | - return array( |
|
3692 | + if (!empty($image)) { |
|
3693 | + return array( |
|
3500 | 3694 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3501 | 3695 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3502 | 3696 | 'href' => $image, |
3503 | 3697 | 'url' => $image, |
3504 | 3698 | ); |
3699 | + } |
|
3505 | 3700 | |
3506 | 3701 | // Fallback to make life easier for everyone... |
3507 | - else |
|
3508 | - return array( |
|
3702 | + else { |
|
3703 | + return array( |
|
3509 | 3704 | 'name' => '', |
3510 | 3705 | 'image' => '', |
3511 | 3706 | 'href' => '', |
3512 | 3707 | 'url' => '', |
3513 | 3708 | ); |
3514 | -} |
|
3709 | + } |
|
3710 | + } |
|
3515 | 3711 | |
3516 | 3712 | ?> |
3517 | 3713 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * This is the dispatcher of smileys administration. |
@@ -91,8 +92,9 @@ discard block |
||
91 | 92 | ); |
92 | 93 | |
93 | 94 | // Some settings may not be enabled, disallow these from the tabs as appropriate. |
94 | - if (empty($modSettings['messageIcons_enable'])) |
|
95 | - $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
95 | + if (empty($modSettings['messageIcons_enable'])) { |
|
96 | + $context[$context['admin_menu_name']]['tab_data']['tabs']['editicons']['disabled'] = true; |
|
97 | + } |
|
96 | 98 | if (empty($modSettings['smiley_enable'])) |
97 | 99 | { |
98 | 100 | $context[$context['admin_menu_name']]['tab_data']['tabs']['addsmiley']['disabled'] = true; |
@@ -125,8 +127,9 @@ discard block |
||
125 | 127 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
126 | 128 | |
127 | 129 | $smiley_context = array(); |
128 | - foreach ($smiley_sets as $i => $set) |
|
129 | - $smiley_context[$set] = $set_names[$i]; |
|
130 | + foreach ($smiley_sets as $i => $set) { |
|
131 | + $smiley_context[$set] = $set_names[$i]; |
|
132 | + } |
|
130 | 133 | |
131 | 134 | // All the settings for the page... |
132 | 135 | $config_vars = array( |
@@ -147,8 +150,9 @@ discard block |
||
147 | 150 | |
148 | 151 | call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); |
149 | 152 | |
150 | - if ($return_config) |
|
151 | - return $config_vars; |
|
153 | + if ($return_config) { |
|
154 | + return $config_vars; |
|
155 | + } |
|
152 | 156 | |
153 | 157 | // Setup the basics of the settings template. |
154 | 158 | require_once($sourcedir . '/ManageServer.php'); |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | foreach ($_POST['smiley_set'] as $id => $val) |
208 | 212 | { |
209 | 213 | // If this is the set you've marked as default, or the only one remaining, you can't delete it |
210 | - if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) |
|
211 | - unset($set_paths[$id], $set_names[$id]); |
|
214 | + if ($modSettings['smiley_sets_default'] != $set_paths[$id] && count($set_paths) != 1 && isset($set_paths[$id], $set_names[$id])) { |
|
215 | + unset($set_paths[$id], $set_names[$id]); |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | |
214 | 219 | // Shortcut... array_merge() on a single array resets the numeric keys |
@@ -222,8 +227,9 @@ discard block |
||
222 | 227 | )); |
223 | 228 | } |
224 | 229 | // Add a new smiley set. |
225 | - elseif (!empty($_POST['add'])) |
|
226 | - $context['sub_action'] = 'modifyset'; |
|
230 | + elseif (!empty($_POST['add'])) { |
|
231 | + $context['sub_action'] = 'modifyset'; |
|
232 | + } |
|
227 | 233 | // Create or modify a smiley set. |
228 | 234 | elseif (isset($_POST['set'])) |
229 | 235 | { |
@@ -233,8 +239,9 @@ discard block |
||
233 | 239 | // Create a new smiley set. |
234 | 240 | if ($_POST['set'] == -1 && isset($_POST['smiley_sets_path'])) |
235 | 241 | { |
236 | - if (in_array($_POST['smiley_sets_path'], $set_paths)) |
|
237 | - fatal_lang_error('smiley_set_already_exists'); |
|
242 | + if (in_array($_POST['smiley_sets_path'], $set_paths)) { |
|
243 | + fatal_lang_error('smiley_set_already_exists'); |
|
244 | + } |
|
238 | 245 | |
239 | 246 | updateSettings(array( |
240 | 247 | 'smiley_sets_known' => $modSettings['smiley_sets_known'] . ',' . $_POST['smiley_sets_path'], |
@@ -246,12 +253,14 @@ discard block |
||
246 | 253 | else |
247 | 254 | { |
248 | 255 | // Make sure the smiley set exists. |
249 | - if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) |
|
250 | - fatal_lang_error('smiley_set_not_found'); |
|
256 | + if (!isset($set_paths[$_POST['set']]) || !isset($set_names[$_POST['set']])) { |
|
257 | + fatal_lang_error('smiley_set_not_found'); |
|
258 | + } |
|
251 | 259 | |
252 | 260 | // Make sure the path is not yet used by another smileyset. |
253 | - if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) |
|
254 | - fatal_lang_error('smiley_set_path_already_used'); |
|
261 | + if (in_array($_POST['smiley_sets_path'], $set_paths) && $_POST['smiley_sets_path'] != $set_paths[$_POST['set']]) { |
|
262 | + fatal_lang_error('smiley_set_path_already_used'); |
|
263 | + } |
|
255 | 264 | |
256 | 265 | $set_paths[$_POST['set']] = $_POST['smiley_sets_path']; |
257 | 266 | $set_names[$_POST['set']] = $_POST['smiley_sets_name']; |
@@ -263,8 +272,9 @@ discard block |
||
263 | 272 | } |
264 | 273 | |
265 | 274 | // The user might have checked to also import smileys. |
266 | - if (!empty($_POST['smiley_sets_import'])) |
|
267 | - ImportSmileys($_POST['smiley_sets_path']); |
|
275 | + if (!empty($_POST['smiley_sets_import'])) { |
|
276 | + ImportSmileys($_POST['smiley_sets_path']); |
|
277 | + } |
|
268 | 278 | } |
269 | 279 | cache_put_data('parsing_smileys', null, 480); |
270 | 280 | cache_put_data('posting_smileys', null, 480); |
@@ -273,13 +283,14 @@ discard block |
||
273 | 283 | // Load all available smileysets... |
274 | 284 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
275 | 285 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
276 | - foreach ($context['smiley_sets'] as $i => $set) |
|
277 | - $context['smiley_sets'][$i] = array( |
|
286 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
287 | + $context['smiley_sets'][$i] = array( |
|
278 | 288 | 'id' => $i, |
279 | 289 | 'path' => $smcFunc['htmlspecialchars']($set), |
280 | 290 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
281 | 291 | 'selected' => $set == $modSettings['smiley_sets_default'] |
282 | 292 | ); |
293 | + } |
|
283 | 294 | |
284 | 295 | // Importing any smileys from an existing set? |
285 | 296 | if ($context['sub_action'] == 'import') |
@@ -290,8 +301,9 @@ discard block |
||
290 | 301 | $_GET['set'] = (int) $_GET['set']; |
291 | 302 | |
292 | 303 | // Sanity check - then import. |
293 | - if (isset($context['smiley_sets'][$_GET['set']])) |
|
294 | - ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
304 | + if (isset($context['smiley_sets'][$_GET['set']])) { |
|
305 | + ImportSmileys(un_htmlspecialchars($context['smiley_sets'][$_GET['set']]['path'])); |
|
306 | + } |
|
295 | 307 | |
296 | 308 | // Force the process to continue. |
297 | 309 | $context['sub_action'] = 'modifyset'; |
@@ -301,15 +313,15 @@ discard block |
||
301 | 313 | if ($context['sub_action'] == 'modifyset') |
302 | 314 | { |
303 | 315 | $_GET['set'] = !isset($_GET['set']) ? -1 : (int) $_GET['set']; |
304 | - if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) |
|
305 | - $context['current_set'] = array( |
|
316 | + if ($_GET['set'] == -1 || !isset($context['smiley_sets'][$_GET['set']])) { |
|
317 | + $context['current_set'] = array( |
|
306 | 318 | 'id' => '-1', |
307 | 319 | 'path' => '', |
308 | 320 | 'name' => '', |
309 | 321 | 'selected' => false, |
310 | 322 | 'is_new' => true, |
311 | 323 | ); |
312 | - else |
|
324 | + } else |
|
313 | 325 | { |
314 | 326 | $context['current_set'] = &$context['smiley_sets'][$_GET['set']]; |
315 | 327 | $context['current_set']['is_new'] = false; |
@@ -321,13 +333,15 @@ discard block |
||
321 | 333 | $dir = dir($modSettings['smileys_dir'] . '/' . $context['current_set']['path']); |
322 | 334 | while ($entry = $dir->read()) |
323 | 335 | { |
324 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
325 | - $smileys[strtolower($entry)] = $entry; |
|
336 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
337 | + $smileys[strtolower($entry)] = $entry; |
|
338 | + } |
|
326 | 339 | } |
327 | 340 | $dir->close(); |
328 | 341 | |
329 | - if (empty($smileys)) |
|
330 | - fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
342 | + if (empty($smileys)) { |
|
343 | + fatal_lang_error('smiley_set_dir_not_found', false, array($context['current_set']['name'])); |
|
344 | + } |
|
331 | 345 | |
332 | 346 | // Exclude the smileys that are already in the database. |
333 | 347 | $request = $smcFunc['db_query']('', ' |
@@ -338,9 +352,10 @@ discard block |
||
338 | 352 | 'smiley_list' => $smileys, |
339 | 353 | ) |
340 | 354 | ); |
341 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
342 | - if (isset($smileys[strtolower($row['filename'])])) |
|
355 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
356 | + if (isset($smileys[strtolower($row['filename'])])) |
|
343 | 357 | unset($smileys[strtolower($row['filename'])]); |
358 | + } |
|
344 | 359 | $smcFunc['db_free_result']($request); |
345 | 360 | |
346 | 361 | $context['current_set']['can_import'] = count($smileys); |
@@ -355,13 +370,14 @@ discard block |
||
355 | 370 | $dir = dir($modSettings['smileys_dir']); |
356 | 371 | while ($entry = $dir->read()) |
357 | 372 | { |
358 | - if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) |
|
359 | - $context['smiley_set_dirs'][] = array( |
|
373 | + if (!in_array($entry, array('.', '..')) && is_dir($modSettings['smileys_dir'] . '/' . $entry)) { |
|
374 | + $context['smiley_set_dirs'][] = array( |
|
360 | 375 | 'id' => $entry, |
361 | 376 | 'path' => $modSettings['smileys_dir'] . '/' . $entry, |
362 | 377 | 'selectable' => $entry == $context['current_set']['path'] || !in_array($entry, explode(',', $modSettings['smiley_sets_known'])), |
363 | 378 | 'current' => $entry == $context['current_set']['path'], |
364 | 379 | ); |
380 | + } |
|
365 | 381 | } |
366 | 382 | $dir->close(); |
367 | 383 | } |
@@ -371,8 +387,9 @@ discard block |
||
371 | 387 | createToken('admin-mss', 'request'); |
372 | 388 | |
373 | 389 | // In case we need to import smileys, we need to add the token in now. |
374 | - if (isset($context['current_set']['import_url'])) |
|
375 | - $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
390 | + if (isset($context['current_set']['import_url'])) { |
|
391 | + $context['current_set']['import_url'] .= ';' . $context['admin-mss_token_var'] . '=' . $context['admin-mss_token']; |
|
392 | + } |
|
376 | 393 | |
377 | 394 | $listOptions = array( |
378 | 395 | 'id' => 'smiley_set_list', |
@@ -510,21 +527,23 @@ discard block |
||
510 | 527 | $cols['name'][] = $set_names[$i]; |
511 | 528 | } |
512 | 529 | $sort_flag = strpos($sort, 'DESC') === false ? SORT_ASC : SORT_DESC; |
513 | - if (substr($sort, 0, 4) === 'name') |
|
514 | - array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
515 | - elseif (substr($sort, 0, 4) === 'path') |
|
516 | - array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
517 | - else |
|
518 | - array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
530 | + if (substr($sort, 0, 4) === 'name') { |
|
531 | + array_multisort($cols['name'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['selected'], $cols['id']); |
|
532 | + } elseif (substr($sort, 0, 4) === 'path') { |
|
533 | + array_multisort($cols['path'], $sort_flag, SORT_REGULAR, $cols['name'], $cols['selected'], $cols['id']); |
|
534 | + } else { |
|
535 | + array_multisort($cols['selected'], $sort_flag, SORT_REGULAR, $cols['path'], $cols['name'], $cols['id']); |
|
536 | + } |
|
519 | 537 | |
520 | 538 | $smiley_sets = array(); |
521 | - foreach ($cols['id'] as $i => $id) |
|
522 | - $smiley_sets[] = array( |
|
539 | + foreach ($cols['id'] as $i => $id) { |
|
540 | + $smiley_sets[] = array( |
|
523 | 541 | 'id' => $id, |
524 | 542 | 'path' => $cols['path'][$i], |
525 | 543 | 'name' => $cols['name'][$i], |
526 | 544 | 'selected' => $cols['path'][$i] == $modSettings['smiley_sets_default'] |
527 | 545 | ); |
546 | + } |
|
528 | 547 | |
529 | 548 | return $smiley_sets; |
530 | 549 | } |
@@ -553,13 +572,14 @@ discard block |
||
553 | 572 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
554 | 573 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
555 | 574 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
556 | - foreach ($context['smiley_sets'] as $i => $set) |
|
557 | - $context['smiley_sets'][$i] = array( |
|
575 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
576 | + $context['smiley_sets'][$i] = array( |
|
558 | 577 | 'id' => $i, |
559 | 578 | 'path' => $smcFunc['htmlspecialchars']($set), |
560 | 579 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
561 | 580 | 'selected' => $set == $modSettings['smiley_sets_default'] |
562 | 581 | ); |
582 | + } |
|
563 | 583 | |
564 | 584 | // Submitting a form? |
565 | 585 | if (isset($_POST[$context['session_var']], $_POST['smiley_code'])) |
@@ -575,8 +595,9 @@ discard block |
||
575 | 595 | $_POST['smiley_filename'] = htmltrim__recursive($_POST['smiley_filename']); |
576 | 596 | |
577 | 597 | // Make sure some code was entered. |
578 | - if (empty($_POST['smiley_code'])) |
|
579 | - fatal_lang_error('smiley_has_no_code'); |
|
598 | + if (empty($_POST['smiley_code'])) { |
|
599 | + fatal_lang_error('smiley_has_no_code'); |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Check whether the new code has duplicates. It should be unique. |
582 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -588,8 +609,9 @@ discard block |
||
588 | 609 | 'smiley_code' => $_POST['smiley_code'], |
589 | 610 | ) |
590 | 611 | ); |
591 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
592 | - fatal_lang_error('smiley_not_unique'); |
|
612 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
613 | + fatal_lang_error('smiley_not_unique'); |
|
614 | + } |
|
593 | 615 | $smcFunc['db_free_result']($request); |
594 | 616 | |
595 | 617 | // If we are uploading - check all the smiley sets are writable! |
@@ -598,38 +620,44 @@ discard block |
||
598 | 620 | $writeErrors = array(); |
599 | 621 | foreach ($context['smiley_sets'] as $set) |
600 | 622 | { |
601 | - if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) |
|
602 | - $writeErrors[] = $set['path']; |
|
623 | + if (!is_writable($context['smileys_dir'] . '/' . un_htmlspecialchars($set['path']))) { |
|
624 | + $writeErrors[] = $set['path']; |
|
625 | + } |
|
626 | + } |
|
627 | + if (!empty($writeErrors)) { |
|
628 | + fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
603 | 629 | } |
604 | - if (!empty($writeErrors)) |
|
605 | - fatal_lang_error('smileys_upload_error_notwritable', true, array(implode(', ', $writeErrors))); |
|
606 | 630 | } |
607 | 631 | |
608 | 632 | // Uploading just one smiley for all of them? |
609 | 633 | if (isset($_POST['sameall']) && isset($_FILES['uploadSmiley']['name']) && $_FILES['uploadSmiley']['name'] != '') |
610 | 634 | { |
611 | - if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) |
|
612 | - fatal_lang_error('smileys_upload_error'); |
|
635 | + if (!is_uploaded_file($_FILES['uploadSmiley']['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['uploadSmiley']['tmp_name']))) { |
|
636 | + fatal_lang_error('smileys_upload_error'); |
|
637 | + } |
|
613 | 638 | |
614 | 639 | // Sorry, no spaces, dots, or anything else but letters allowed. |
615 | 640 | $_FILES['uploadSmiley']['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['uploadSmiley']['name']); |
616 | 641 | |
617 | 642 | // We only allow image files - it's THAT simple - no messing around here... |
618 | - if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) |
|
619 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
643 | + if (!in_array(strtolower(substr(strrchr($_FILES['uploadSmiley']['name'], '.'), 1)), $allowedTypes)) { |
|
644 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
645 | + } |
|
620 | 646 | |
621 | 647 | // We only need the filename... |
622 | 648 | $destName = basename($_FILES['uploadSmiley']['name']); |
623 | 649 | |
624 | 650 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
625 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
626 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
651 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
652 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
653 | + } |
|
627 | 654 | |
628 | 655 | // Check if the file already exists... and if not move it to EVERY smiley set directory. |
629 | 656 | $i = 0; |
630 | 657 | // Keep going until we find a set the file doesn't exist in. (or maybe it exists in all of them?) |
631 | - while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) |
|
632 | - $i++; |
|
658 | + while (isset($context['smiley_sets'][$i]) && file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName)) { |
|
659 | + $i++; |
|
660 | + } |
|
633 | 661 | |
634 | 662 | // Okay, we're going to put the smiley right here, since it's not there yet! |
635 | 663 | if (isset($context['smiley_sets'][$i]['path'])) |
@@ -644,8 +672,9 @@ discard block |
||
644 | 672 | $currentPath = $context['smileys_dir'] . '/' . un_htmlspecialchars($context['smiley_sets'][$i]['path']) . '/' . $destName; |
645 | 673 | |
646 | 674 | // The file is already there! Don't overwrite it! |
647 | - if (file_exists($currentPath)) |
|
648 | - continue; |
|
675 | + if (file_exists($currentPath)) { |
|
676 | + continue; |
|
677 | + } |
|
649 | 678 | |
650 | 679 | // Okay, so copy the first one we made to here. |
651 | 680 | copy($smileyLocation, $currentPath); |
@@ -662,13 +691,15 @@ discard block |
||
662 | 691 | $newName = ''; |
663 | 692 | foreach ($_FILES as $name => $data) |
664 | 693 | { |
665 | - if ($_FILES[$name]['name'] == '') |
|
666 | - fatal_lang_error('smileys_upload_error_blank'); |
|
694 | + if ($_FILES[$name]['name'] == '') { |
|
695 | + fatal_lang_error('smileys_upload_error_blank'); |
|
696 | + } |
|
667 | 697 | |
668 | - if (empty($newName)) |
|
669 | - $newName = basename($_FILES[$name]['name']); |
|
670 | - elseif (basename($_FILES[$name]['name']) != $newName) |
|
671 | - fatal_lang_error('smileys_upload_error_name'); |
|
698 | + if (empty($newName)) { |
|
699 | + $newName = basename($_FILES[$name]['name']); |
|
700 | + } elseif (basename($_FILES[$name]['name']) != $newName) { |
|
701 | + fatal_lang_error('smileys_upload_error_name'); |
|
702 | + } |
|
672 | 703 | } |
673 | 704 | |
674 | 705 | foreach ($context['smiley_sets'] as $i => $set) |
@@ -676,31 +707,36 @@ discard block |
||
676 | 707 | $set['name'] = un_htmlspecialchars($set['name']); |
677 | 708 | $set['path'] = un_htmlspecialchars($set['path']); |
678 | 709 | |
679 | - if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') |
|
680 | - continue; |
|
710 | + if (!isset($_FILES['individual_' . $set['name']]['name']) || $_FILES['individual_' . $set['name']]['name'] == '') { |
|
711 | + continue; |
|
712 | + } |
|
681 | 713 | |
682 | 714 | // Got one... |
683 | - if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) |
|
684 | - fatal_lang_error('smileys_upload_error'); |
|
715 | + if (!is_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name']) || (ini_get('open_basedir') == '' && !file_exists($_FILES['individual_' . $set['name']]['tmp_name']))) { |
|
716 | + fatal_lang_error('smileys_upload_error'); |
|
717 | + } |
|
685 | 718 | |
686 | 719 | // Sorry, no spaces, dots, or anything else but letters allowed. |
687 | 720 | $_FILES['individual_' . $set['name']]['name'] = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $_FILES['individual_' . $set['name']]['name']); |
688 | 721 | |
689 | 722 | // We only allow image files - it's THAT simple - no messing around here... |
690 | - if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) |
|
691 | - fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
723 | + if (!in_array(strtolower(substr(strrchr($_FILES['individual_' . $set['name']]['name'], '.'), 1)), $allowedTypes)) { |
|
724 | + fatal_lang_error('smileys_upload_error_types', false, array(implode(', ', $allowedTypes))); |
|
725 | + } |
|
692 | 726 | |
693 | 727 | // We only need the filename... |
694 | 728 | $destName = basename($_FILES['individual_' . $set['name']]['name']); |
695 | 729 | |
696 | 730 | // Make sure they aren't trying to upload a nasty file - for their own good here! |
697 | - if (in_array(strtolower($destName), $disabledFiles)) |
|
698 | - fatal_lang_error('smileys_upload_error_illegal'); |
|
731 | + if (in_array(strtolower($destName), $disabledFiles)) { |
|
732 | + fatal_lang_error('smileys_upload_error_illegal'); |
|
733 | + } |
|
699 | 734 | |
700 | 735 | // If the file exists - ignore it. |
701 | 736 | $smileyLocation = $context['smileys_dir'] . '/' . $set['path'] . '/' . $destName; |
702 | - if (file_exists($smileyLocation)) |
|
703 | - continue; |
|
737 | + if (file_exists($smileyLocation)) { |
|
738 | + continue; |
|
739 | + } |
|
704 | 740 | |
705 | 741 | // Finally - move the image! |
706 | 742 | move_uploaded_file($_FILES['individual_' . $set['name']]['tmp_name'], $smileyLocation); |
@@ -712,8 +748,9 @@ discard block |
||
712 | 748 | } |
713 | 749 | |
714 | 750 | // Also make sure a filename was given. |
715 | - if (empty($_POST['smiley_filename'])) |
|
716 | - fatal_lang_error('smiley_has_no_filename'); |
|
751 | + if (empty($_POST['smiley_filename'])) { |
|
752 | + fatal_lang_error('smiley_has_no_filename'); |
|
753 | + } |
|
717 | 754 | |
718 | 755 | // Find the position on the right. |
719 | 756 | $smiley_order = '0'; |
@@ -732,8 +769,9 @@ discard block |
||
732 | 769 | list ($smiley_order) = $smcFunc['db_fetch_row']($request); |
733 | 770 | $smcFunc['db_free_result']($request); |
734 | 771 | |
735 | - if (empty($smiley_order)) |
|
736 | - $smiley_order = '0'; |
|
772 | + if (empty($smiley_order)) { |
|
773 | + $smiley_order = '0'; |
|
774 | + } |
|
737 | 775 | } |
738 | 776 | $smcFunc['db_insert']('', |
739 | 777 | '{db_prefix}smileys', |
@@ -761,17 +799,19 @@ discard block |
||
761 | 799 | { |
762 | 800 | foreach ($context['smiley_sets'] as $smiley_set) |
763 | 801 | { |
764 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
765 | - continue; |
|
802 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
803 | + continue; |
|
804 | + } |
|
766 | 805 | |
767 | 806 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
768 | 807 | while ($entry = $dir->read()) |
769 | 808 | { |
770 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
771 | - $context['filenames'][strtolower($entry)] = array( |
|
809 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
810 | + $context['filenames'][strtolower($entry)] = array( |
|
772 | 811 | 'id' => $smcFunc['htmlspecialchars']($entry), |
773 | 812 | 'selected' => false, |
774 | 813 | ); |
814 | + } |
|
775 | 815 | } |
776 | 816 | $dir->close(); |
777 | 817 | } |
@@ -809,17 +849,19 @@ discard block |
||
809 | 849 | // Changing the selected smileys? |
810 | 850 | if (isset($_POST['smiley_action']) && !empty($_POST['checked_smileys'])) |
811 | 851 | { |
812 | - foreach ($_POST['checked_smileys'] as $id => $smiley_id) |
|
813 | - $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
852 | + foreach ($_POST['checked_smileys'] as $id => $smiley_id) { |
|
853 | + $_POST['checked_smileys'][$id] = (int) $smiley_id; |
|
854 | + } |
|
814 | 855 | |
815 | - if ($_POST['smiley_action'] == 'delete') |
|
816 | - $smcFunc['db_query']('', ' |
|
856 | + if ($_POST['smiley_action'] == 'delete') { |
|
857 | + $smcFunc['db_query']('', ' |
|
817 | 858 | DELETE FROM {db_prefix}smileys |
818 | 859 | WHERE id_smiley IN ({array_int:checked_smileys})', |
819 | 860 | array( |
820 | 861 | 'checked_smileys' => $_POST['checked_smileys'], |
821 | 862 | ) |
822 | 863 | ); |
864 | + } |
|
823 | 865 | // Changing the status of the smiley? |
824 | 866 | else |
825 | 867 | { |
@@ -829,8 +871,8 @@ discard block |
||
829 | 871 | 'hidden' => 1, |
830 | 872 | 'popup' => 2 |
831 | 873 | ); |
832 | - if (isset($displayTypes[$_POST['smiley_action']])) |
|
833 | - $smcFunc['db_query']('', ' |
|
874 | + if (isset($displayTypes[$_POST['smiley_action']])) { |
|
875 | + $smcFunc['db_query']('', ' |
|
834 | 876 | UPDATE {db_prefix}smileys |
835 | 877 | SET hidden = {int:display_type} |
836 | 878 | WHERE id_smiley IN ({array_int:checked_smileys})', |
@@ -839,6 +881,7 @@ discard block |
||
839 | 881 | 'display_type' => $displayTypes[$_POST['smiley_action']], |
840 | 882 | ) |
841 | 883 | ); |
884 | + } |
|
842 | 885 | } |
843 | 886 | } |
844 | 887 | // Create/modify a smiley. |
@@ -864,12 +907,14 @@ discard block |
||
864 | 907 | $_POST['smiley_location'] = empty($_POST['smiley_location']) || $_POST['smiley_location'] > 2 || $_POST['smiley_location'] < 0 ? 0 : (int) $_POST['smiley_location']; |
865 | 908 | |
866 | 909 | // Make sure some code was entered. |
867 | - if (empty($_POST['smiley_code'])) |
|
868 | - fatal_lang_error('smiley_has_no_code'); |
|
910 | + if (empty($_POST['smiley_code'])) { |
|
911 | + fatal_lang_error('smiley_has_no_code'); |
|
912 | + } |
|
869 | 913 | |
870 | 914 | // Also make sure a filename was given. |
871 | - if (empty($_POST['smiley_filename'])) |
|
872 | - fatal_lang_error('smiley_has_no_filename'); |
|
915 | + if (empty($_POST['smiley_filename'])) { |
|
916 | + fatal_lang_error('smiley_has_no_filename'); |
|
917 | + } |
|
873 | 918 | |
874 | 919 | // Check whether the new code has duplicates. It should be unique. |
875 | 920 | $request = $smcFunc['db_query']('', ' |
@@ -883,8 +928,9 @@ discard block |
||
883 | 928 | 'smiley_code' => $_POST['smiley_code'], |
884 | 929 | ) |
885 | 930 | ); |
886 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
887 | - fatal_lang_error('smiley_not_unique'); |
|
931 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
932 | + fatal_lang_error('smiley_not_unique'); |
|
933 | + } |
|
888 | 934 | $smcFunc['db_free_result']($request); |
889 | 935 | |
890 | 936 | $smcFunc['db_query']('', ' |
@@ -913,13 +959,14 @@ discard block |
||
913 | 959 | // Load all known smiley sets. |
914 | 960 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
915 | 961 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
916 | - foreach ($context['smiley_sets'] as $i => $set) |
|
917 | - $context['smiley_sets'][$i] = array( |
|
962 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
963 | + $context['smiley_sets'][$i] = array( |
|
918 | 964 | 'id' => $i, |
919 | 965 | 'path' => $smcFunc['htmlspecialchars']($set), |
920 | 966 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
921 | 967 | 'selected' => $set == $modSettings['smiley_sets_default'] |
922 | 968 | ); |
969 | + } |
|
923 | 970 | |
924 | 971 | // Prepare overview of all (custom) smileys. |
925 | 972 | if ($context['sub_action'] == 'editsmileys') |
@@ -935,9 +982,10 @@ discard block |
||
935 | 982 | // Create a list of options for selecting smiley sets. |
936 | 983 | $smileyset_option_list = ' |
937 | 984 | <select name="set" onchange="changeSet(this.options[this.selectedIndex].value);">'; |
938 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
939 | - $smileyset_option_list .= ' |
|
985 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
986 | + $smileyset_option_list .= ' |
|
940 | 987 | <option value="' . $smiley_set['path'] . '"' . ($modSettings['smiley_sets_default'] == $smiley_set['path'] ? ' selected' : '') . '>' . $smiley_set['name'] . '</option>'; |
988 | + } |
|
941 | 989 | $smileyset_option_list .= ' |
942 | 990 | </select>'; |
943 | 991 | |
@@ -999,12 +1047,13 @@ discard block |
||
999 | 1047 | 'data' => array( |
1000 | 1048 | 'function' => function ($rowData) use ($txt) |
1001 | 1049 | { |
1002 | - if (empty($rowData['hidden'])) |
|
1003 | - return $txt['smileys_location_form']; |
|
1004 | - elseif ($rowData['hidden'] == 1) |
|
1005 | - return $txt['smileys_location_hidden']; |
|
1006 | - else |
|
1007 | - return $txt['smileys_location_popup']; |
|
1050 | + if (empty($rowData['hidden'])) { |
|
1051 | + return $txt['smileys_location_form']; |
|
1052 | + } elseif ($rowData['hidden'] == 1) { |
|
1053 | + return $txt['smileys_location_hidden']; |
|
1054 | + } else { |
|
1055 | + return $txt['smileys_location_popup']; |
|
1056 | + } |
|
1008 | 1057 | }, |
1009 | 1058 | ), |
1010 | 1059 | 'sort' => array( |
@@ -1019,19 +1068,22 @@ discard block |
||
1019 | 1068 | 'data' => array( |
1020 | 1069 | 'function' => function ($rowData) use ($context, $txt, $modSettings, $smcFunc) |
1021 | 1070 | { |
1022 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) |
|
1023 | - return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1071 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'])) { |
|
1072 | + return $smcFunc['htmlspecialchars']($rowData['description']); |
|
1073 | + } |
|
1024 | 1074 | |
1025 | 1075 | // Check if there are smileys missing in some sets. |
1026 | 1076 | $missing_sets = array(); |
1027 | - foreach ($context['smiley_sets'] as $smiley_set) |
|
1028 | - if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1077 | + foreach ($context['smiley_sets'] as $smiley_set) { |
|
1078 | + if (!file_exists(sprintf('%1$s/%2$s/%3$s', $modSettings['smileys_dir'], $smiley_set['path'], $rowData['filename']))) |
|
1029 | 1079 | $missing_sets[] = $smiley_set['path']; |
1080 | + } |
|
1030 | 1081 | |
1031 | 1082 | $description = $smcFunc['htmlspecialchars']($rowData['description']); |
1032 | 1083 | |
1033 | - if (!empty($missing_sets)) |
|
1034 | - $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1084 | + if (!empty($missing_sets)) { |
|
1085 | + $description .= sprintf('<br><span class="smalltext"><strong>%1$s:</strong> %2$s</span>', $txt['smileys_not_found_in_set'], implode(', ', $missing_sets)); |
|
1086 | + } |
|
1035 | 1087 | |
1036 | 1088 | return $description; |
1037 | 1089 | }, |
@@ -1147,13 +1199,14 @@ discard block |
||
1147 | 1199 | $context['smileys_dir_found'] = is_dir($context['smileys_dir']); |
1148 | 1200 | $context['smiley_sets'] = explode(',', $modSettings['smiley_sets_known']); |
1149 | 1201 | $set_names = explode("\n", $modSettings['smiley_sets_names']); |
1150 | - foreach ($context['smiley_sets'] as $i => $set) |
|
1151 | - $context['smiley_sets'][$i] = array( |
|
1202 | + foreach ($context['smiley_sets'] as $i => $set) { |
|
1203 | + $context['smiley_sets'][$i] = array( |
|
1152 | 1204 | 'id' => $i, |
1153 | 1205 | 'path' => $smcFunc['htmlspecialchars']($set), |
1154 | 1206 | 'name' => $smcFunc['htmlspecialchars']($set_names[$i]), |
1155 | 1207 | 'selected' => $set == $modSettings['smiley_sets_default'] |
1156 | 1208 | ); |
1209 | + } |
|
1157 | 1210 | |
1158 | 1211 | $context['selected_set'] = $modSettings['smiley_sets_default']; |
1159 | 1212 | |
@@ -1163,17 +1216,19 @@ discard block |
||
1163 | 1216 | { |
1164 | 1217 | foreach ($context['smiley_sets'] as $smiley_set) |
1165 | 1218 | { |
1166 | - if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) |
|
1167 | - continue; |
|
1219 | + if (!file_exists($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path']))) { |
|
1220 | + continue; |
|
1221 | + } |
|
1168 | 1222 | |
1169 | 1223 | $dir = dir($context['smileys_dir'] . '/' . un_htmlspecialchars($smiley_set['path'])); |
1170 | 1224 | while ($entry = $dir->read()) |
1171 | 1225 | { |
1172 | - if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1173 | - $context['filenames'][strtolower($entry)] = array( |
|
1226 | + if (!in_array($entry, $context['filenames']) && in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1227 | + $context['filenames'][strtolower($entry)] = array( |
|
1174 | 1228 | 'id' => $smcFunc['htmlspecialchars']($entry), |
1175 | 1229 | 'selected' => false, |
1176 | 1230 | ); |
1231 | + } |
|
1177 | 1232 | } |
1178 | 1233 | $dir->close(); |
1179 | 1234 | } |
@@ -1188,8 +1243,9 @@ discard block |
||
1188 | 1243 | 'current_smiley' => (int) $_REQUEST['smiley'], |
1189 | 1244 | ) |
1190 | 1245 | ); |
1191 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1192 | - fatal_lang_error('smiley_not_found'); |
|
1246 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1247 | + fatal_lang_error('smiley_not_found'); |
|
1248 | + } |
|
1193 | 1249 | $context['current_smiley'] = $smcFunc['db_fetch_assoc']($request); |
1194 | 1250 | $smcFunc['db_free_result']($request); |
1195 | 1251 | |
@@ -1197,8 +1253,9 @@ discard block |
||
1197 | 1253 | $context['current_smiley']['filename'] = $smcFunc['htmlspecialchars']($context['current_smiley']['filename']); |
1198 | 1254 | $context['current_smiley']['description'] = $smcFunc['htmlspecialchars']($context['current_smiley']['description']); |
1199 | 1255 | |
1200 | - if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) |
|
1201 | - $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1256 | + if (isset($context['filenames'][strtolower($context['current_smiley']['filename'])])) { |
|
1257 | + $context['filenames'][strtolower($context['current_smiley']['filename'])]['selected'] = true; |
|
1258 | + } |
|
1202 | 1259 | } |
1203 | 1260 | } |
1204 | 1261 | |
@@ -1223,8 +1280,9 @@ discard block |
||
1223 | 1280 | ) |
1224 | 1281 | ); |
1225 | 1282 | $smileys = array(); |
1226 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1227 | - $smileys[] = $row; |
|
1283 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1284 | + $smileys[] = $row; |
|
1285 | + } |
|
1228 | 1286 | $smcFunc['db_free_result']($request); |
1229 | 1287 | |
1230 | 1288 | return $smileys; |
@@ -1264,8 +1322,9 @@ discard block |
||
1264 | 1322 | $_GET['location'] = empty($_GET['location']) || $_GET['location'] != 'popup' ? 0 : 2; |
1265 | 1323 | $_GET['source'] = empty($_GET['source']) ? 0 : (int) $_GET['source']; |
1266 | 1324 | |
1267 | - if (empty($_GET['source'])) |
|
1268 | - fatal_lang_error('smiley_not_found'); |
|
1325 | + if (empty($_GET['source'])) { |
|
1326 | + fatal_lang_error('smiley_not_found'); |
|
1327 | + } |
|
1269 | 1328 | |
1270 | 1329 | if (!empty($_GET['after'])) |
1271 | 1330 | { |
@@ -1281,12 +1340,12 @@ discard block |
||
1281 | 1340 | 'after_smiley' => $_GET['after'], |
1282 | 1341 | ) |
1283 | 1342 | ); |
1284 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
1285 | - fatal_lang_error('smiley_not_found'); |
|
1343 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
1344 | + fatal_lang_error('smiley_not_found'); |
|
1345 | + } |
|
1286 | 1346 | list ($smiley_row, $smiley_order, $smileyLocation) = $smcFunc['db_fetch_row']($request); |
1287 | 1347 | $smcFunc['db_free_result']($request); |
1288 | - } |
|
1289 | - else |
|
1348 | + } else |
|
1290 | 1349 | { |
1291 | 1350 | $smiley_row = (int) $_GET['row']; |
1292 | 1351 | $smiley_order = -1; |
@@ -1360,14 +1419,15 @@ discard block |
||
1360 | 1419 | $context['move_smiley'] = empty($_REQUEST['move']) ? 0 : (int) $_REQUEST['move']; |
1361 | 1420 | |
1362 | 1421 | // Make sure all rows are sequential. |
1363 | - foreach (array_keys($context['smileys']) as $location) |
|
1364 | - $context['smileys'][$location] = array( |
|
1422 | + foreach (array_keys($context['smileys']) as $location) { |
|
1423 | + $context['smileys'][$location] = array( |
|
1365 | 1424 | 'id' => $location, |
1366 | 1425 | 'title' => $location == 'postform' ? $txt['smileys_location_form'] : $txt['smileys_location_popup'], |
1367 | 1426 | 'description' => $location == 'postform' ? $txt['smileys_location_form_description'] : $txt['smileys_location_popup_description'], |
1368 | 1427 | 'last_row' => count($context['smileys'][$location]['rows']), |
1369 | 1428 | 'rows' => array_values($context['smileys'][$location]['rows']), |
1370 | 1429 | ); |
1430 | + } |
|
1371 | 1431 | |
1372 | 1432 | // Check & fix smileys that are not ordered properly in the database. |
1373 | 1433 | foreach (array_keys($context['smileys']) as $location) |
@@ -1392,8 +1452,8 @@ discard block |
||
1392 | 1452 | $context['smileys'][$location]['rows'][$id][0]['row'] = $id; |
1393 | 1453 | } |
1394 | 1454 | // Make sure the smiley order is always sequential. |
1395 | - foreach ($smiley_row as $order_id => $smiley) |
|
1396 | - if ($order_id != $smiley['order']) |
|
1455 | + foreach ($smiley_row as $order_id => $smiley) { |
|
1456 | + if ($order_id != $smiley['order']) |
|
1397 | 1457 | $smcFunc['db_query']('', ' |
1398 | 1458 | UPDATE {db_prefix}smileys |
1399 | 1459 | SET smiley_order = {int:new_order} |
@@ -1403,6 +1463,7 @@ discard block |
||
1403 | 1463 | 'current_smiley' => $smiley['id'], |
1404 | 1464 | ) |
1405 | 1465 | ); |
1466 | + } |
|
1406 | 1467 | } |
1407 | 1468 | } |
1408 | 1469 | |
@@ -1435,19 +1496,20 @@ discard block |
||
1435 | 1496 | $context['filename'] = $base_name; |
1436 | 1497 | |
1437 | 1498 | // Check that the smiley is from simplemachines.org, for now... maybe add mirroring later. |
1438 | - if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) |
|
1439 | - fatal_lang_error('not_on_simplemachines'); |
|
1499 | + if (preg_match('~^http://[\w_\-]+\.simplemachines\.org/~', $_REQUEST['set_gz']) == 0 || strpos($_REQUEST['set_gz'], 'dlattach') !== false) { |
|
1500 | + fatal_lang_error('not_on_simplemachines'); |
|
1501 | + } |
|
1440 | 1502 | |
1441 | 1503 | $destination = $packagesdir . '/' . $base_name; |
1442 | 1504 | |
1443 | - if (file_exists($destination)) |
|
1444 | - fatal_lang_error('package_upload_error_exists'); |
|
1505 | + if (file_exists($destination)) { |
|
1506 | + fatal_lang_error('package_upload_error_exists'); |
|
1507 | + } |
|
1445 | 1508 | |
1446 | 1509 | // Let's copy it to the Packages directory |
1447 | 1510 | file_put_contents($destination, fetch_web_data($_REQUEST['set_gz'])); |
1448 | 1511 | $testing = true; |
1449 | - } |
|
1450 | - elseif (isset($_REQUEST['package'])) |
|
1512 | + } elseif (isset($_REQUEST['package'])) |
|
1451 | 1513 | { |
1452 | 1514 | $base_name = basename($_REQUEST['package']); |
1453 | 1515 | $name = $smcFunc['htmlspecialchars'](strtok(basename($_REQUEST['package']), '.')); |
@@ -1456,12 +1518,14 @@ discard block |
||
1456 | 1518 | $destination = $packagesdir . '/' . basename($_REQUEST['package']); |
1457 | 1519 | } |
1458 | 1520 | |
1459 | - if (empty($destination) || !file_exists($destination)) |
|
1460 | - fatal_lang_error('package_no_file', false); |
|
1521 | + if (empty($destination) || !file_exists($destination)) { |
|
1522 | + fatal_lang_error('package_no_file', false); |
|
1523 | + } |
|
1461 | 1524 | |
1462 | 1525 | // Make sure temp directory exists and is empty. |
1463 | - if (file_exists($packagesdir . '/temp')) |
|
1464 | - deltree($packagesdir . '/temp', false); |
|
1526 | + if (file_exists($packagesdir . '/temp')) { |
|
1527 | + deltree($packagesdir . '/temp', false); |
|
1528 | + } |
|
1465 | 1529 | |
1466 | 1530 | if (!mktree($packagesdir . '/temp', 0755)) |
1467 | 1531 | { |
@@ -1473,31 +1537,37 @@ discard block |
||
1473 | 1537 | create_chmod_control(array($packagesdir . '/temp/delme.tmp'), array('destination_url' => $scripturl . '?action=admin;area=smileys;sa=install;set_gz=' . $_REQUEST['set_gz'], 'crash_on_error' => true)); |
1474 | 1538 | |
1475 | 1539 | deltree($packagesdir . '/temp', false); |
1476 | - if (!mktree($packagesdir . '/temp', 0777)) |
|
1477 | - fatal_lang_error('package_cant_download', false); |
|
1540 | + if (!mktree($packagesdir . '/temp', 0777)) { |
|
1541 | + fatal_lang_error('package_cant_download', false); |
|
1542 | + } |
|
1478 | 1543 | } |
1479 | 1544 | } |
1480 | 1545 | |
1481 | 1546 | $extracted = read_tgz_file($destination, $packagesdir . '/temp'); |
1482 | - if (!$extracted) |
|
1483 | - fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1484 | - if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) |
|
1485 | - foreach ($extracted as $file) |
|
1547 | + if (!$extracted) { |
|
1548 | + fatal_lang_error('packageget_unable', false, array('http://custom.simplemachines.org/mods/index.php?action=search;type=12;basic_search=' . $name)); |
|
1549 | + } |
|
1550 | + if ($extracted && !file_exists($packagesdir . '/temp/package-info.xml')) { |
|
1551 | + foreach ($extracted as $file) |
|
1486 | 1552 | if (basename($file['filename']) == 'package-info.xml') |
1487 | 1553 | { |
1488 | 1554 | $base_path = dirname($file['filename']) . '/'; |
1555 | + } |
|
1489 | 1556 | break; |
1490 | 1557 | } |
1491 | 1558 | |
1492 | - if (!isset($base_path)) |
|
1493 | - $base_path = ''; |
|
1559 | + if (!isset($base_path)) { |
|
1560 | + $base_path = ''; |
|
1561 | + } |
|
1494 | 1562 | |
1495 | - if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) |
|
1496 | - fatal_lang_error('package_get_error_missing_xml', false); |
|
1563 | + if (!file_exists($packagesdir . '/temp/' . $base_path . 'package-info.xml')) { |
|
1564 | + fatal_lang_error('package_get_error_missing_xml', false); |
|
1565 | + } |
|
1497 | 1566 | |
1498 | 1567 | $smileyInfo = getPackageInfo($context['filename']); |
1499 | - if (!is_array($smileyInfo)) |
|
1500 | - fatal_lang_error($smileyInfo); |
|
1568 | + if (!is_array($smileyInfo)) { |
|
1569 | + fatal_lang_error($smileyInfo); |
|
1570 | + } |
|
1501 | 1571 | |
1502 | 1572 | // See if it is installed? |
1503 | 1573 | $request = $smcFunc['db_query']('', ' |
@@ -1513,8 +1583,9 @@ discard block |
||
1513 | 1583 | ) |
1514 | 1584 | ); |
1515 | 1585 | |
1516 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
1517 | - fata_lang_error('package_installed_warning1'); |
|
1586 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
1587 | + fata_lang_error('package_installed_warning1'); |
|
1588 | + } |
|
1518 | 1589 | |
1519 | 1590 | // Everything is fine, now it's time to do something |
1520 | 1591 | $actions = parsePackageInfo($smileyInfo['xml'], true, 'install'); |
@@ -1531,23 +1602,23 @@ discard block |
||
1531 | 1602 | { |
1532 | 1603 | $has_readme = true; |
1533 | 1604 | $type = 'package_' . $action['type']; |
1534 | - if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) |
|
1535 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1536 | - elseif (file_exists($action['filename'])) |
|
1537 | - $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1605 | + if (file_exists($packagesdir . '/temp/' . $base_path . $action['filename'])) { |
|
1606 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($packagesdir . '/temp/' . $base_path . $action['filename']), "\n\r")); |
|
1607 | + } elseif (file_exists($action['filename'])) { |
|
1608 | + $context[$type] = $smcFunc['htmlspecialchars'](trim(file_get_contents($action['filename']), "\n\r")); |
|
1609 | + } |
|
1538 | 1610 | |
1539 | 1611 | if (!empty($action['parse_bbc'])) |
1540 | 1612 | { |
1541 | 1613 | require_once($sourcedir . '/Subs-Post.php'); |
1542 | 1614 | preparsecode($context[$type]); |
1543 | 1615 | $context[$type] = parse_bbc($context[$type]); |
1616 | + } else { |
|
1617 | + $context[$type] = nl2br($context[$type]); |
|
1544 | 1618 | } |
1545 | - else |
|
1546 | - $context[$type] = nl2br($context[$type]); |
|
1547 | 1619 | |
1548 | 1620 | continue; |
1549 | - } |
|
1550 | - elseif ($action['type'] == 'require-dir') |
|
1621 | + } elseif ($action['type'] == 'require-dir') |
|
1551 | 1622 | { |
1552 | 1623 | // Do this one... |
1553 | 1624 | $thisAction = array( |
@@ -1566,12 +1637,12 @@ discard block |
||
1566 | 1637 | ); |
1567 | 1638 | } |
1568 | 1639 | // @todo None given? |
1569 | - if (empty($thisAction['description'])) |
|
1570 | - $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1640 | + if (empty($thisAction['description'])) { |
|
1641 | + $thisAction['description'] = isset($action['description']) ? $action['description'] : ''; |
|
1642 | + } |
|
1571 | 1643 | |
1572 | 1644 | $context['actions'][] = $thisAction; |
1573 | - } |
|
1574 | - elseif ($action['type'] == 'credits') |
|
1645 | + } elseif ($action['type'] == 'credits') |
|
1575 | 1646 | { |
1576 | 1647 | // Time to build the billboard |
1577 | 1648 | $credits_tag = array( |
@@ -1630,12 +1701,14 @@ discard block |
||
1630 | 1701 | cache_put_data('posting_smileys', null, 480); |
1631 | 1702 | } |
1632 | 1703 | |
1633 | - if (file_exists($packagesdir . '/temp')) |
|
1634 | - deltree($packagesdir . '/temp'); |
|
1704 | + if (file_exists($packagesdir . '/temp')) { |
|
1705 | + deltree($packagesdir . '/temp'); |
|
1706 | + } |
|
1635 | 1707 | |
1636 | - if (!$testing) |
|
1637 | - redirectexit('action=admin;area=smileys'); |
|
1638 | -} |
|
1708 | + if (!$testing) { |
|
1709 | + redirectexit('action=admin;area=smileys'); |
|
1710 | + } |
|
1711 | + } |
|
1639 | 1712 | |
1640 | 1713 | /** |
1641 | 1714 | * A function to import new smileys from an existing directory into the database. |
@@ -1646,15 +1719,17 @@ discard block |
||
1646 | 1719 | { |
1647 | 1720 | global $modSettings, $smcFunc; |
1648 | 1721 | |
1649 | - if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) |
|
1650 | - fatal_lang_error('smiley_set_unable_to_import'); |
|
1722 | + if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) { |
|
1723 | + fatal_lang_error('smiley_set_unable_to_import'); |
|
1724 | + } |
|
1651 | 1725 | |
1652 | 1726 | $smileys = array(); |
1653 | 1727 | $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath); |
1654 | 1728 | while ($entry = $dir->read()) |
1655 | 1729 | { |
1656 | - if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) |
|
1657 | - $smileys[strtolower($entry)] = $entry; |
|
1730 | + if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) { |
|
1731 | + $smileys[strtolower($entry)] = $entry; |
|
1732 | + } |
|
1658 | 1733 | } |
1659 | 1734 | $dir->close(); |
1660 | 1735 | |
@@ -1667,9 +1742,10 @@ discard block |
||
1667 | 1742 | 'smiley_list' => $smileys, |
1668 | 1743 | ) |
1669 | 1744 | ); |
1670 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1671 | - if (isset($smileys[strtolower($row['filename'])])) |
|
1745 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1746 | + if (isset($smileys[strtolower($row['filename'])])) |
|
1672 | 1747 | unset($smileys[strtolower($row['filename'])]); |
1748 | + } |
|
1673 | 1749 | $smcFunc['db_free_result']($request); |
1674 | 1750 | |
1675 | 1751 | $request = $smcFunc['db_query']('', ' |
@@ -1686,9 +1762,10 @@ discard block |
||
1686 | 1762 | $smcFunc['db_free_result']($request); |
1687 | 1763 | |
1688 | 1764 | $new_smileys = array(); |
1689 | - foreach ($smileys as $smiley) |
|
1690 | - if (strlen($smiley) <= 48) |
|
1765 | + foreach ($smileys as $smiley) { |
|
1766 | + if (strlen($smiley) <= 48) |
|
1691 | 1767 | $new_smileys[] = array(':' . strtok($smiley, '.') . ':', $smiley, strtok($smiley, '.'), 0, ++$smiley_order); |
1768 | + } |
|
1692 | 1769 | |
1693 | 1770 | if (!empty($new_smileys)) |
1694 | 1771 | { |
@@ -1753,8 +1830,9 @@ discard block |
||
1753 | 1830 | if (isset($_POST['delete']) && !empty($_POST['checked_icons'])) |
1754 | 1831 | { |
1755 | 1832 | $deleteIcons = array(); |
1756 | - foreach ($_POST['checked_icons'] as $icon) |
|
1757 | - $deleteIcons[] = (int) $icon; |
|
1833 | + foreach ($_POST['checked_icons'] as $icon) { |
|
1834 | + $deleteIcons[] = (int) $icon; |
|
1835 | + } |
|
1758 | 1836 | |
1759 | 1837 | // Do the actual delete! |
1760 | 1838 | $smcFunc['db_query']('', ' |
@@ -1771,35 +1849,41 @@ discard block |
||
1771 | 1849 | $_GET['icon'] = (int) $_GET['icon']; |
1772 | 1850 | |
1773 | 1851 | // Do some preperation with the data... like check the icon exists *somewhere* |
1774 | - if (strpos($_POST['icon_filename'], '.png') !== false) |
|
1775 | - $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1776 | - if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) |
|
1777 | - fatal_lang_error('icon_not_found'); |
|
1852 | + if (strpos($_POST['icon_filename'], '.png') !== false) { |
|
1853 | + $_POST['icon_filename'] = substr($_POST['icon_filename'], 0, -4); |
|
1854 | + } |
|
1855 | + if (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon_filename'] . '.png')) { |
|
1856 | + fatal_lang_error('icon_not_found'); |
|
1857 | + } |
|
1778 | 1858 | // There is a 16 character limit on message icons... |
1779 | - elseif (strlen($_POST['icon_filename']) > 16) |
|
1780 | - fatal_lang_error('icon_name_too_long'); |
|
1781 | - elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) |
|
1782 | - fatal_lang_error('icon_after_itself'); |
|
1859 | + elseif (strlen($_POST['icon_filename']) > 16) { |
|
1860 | + fatal_lang_error('icon_name_too_long'); |
|
1861 | + } elseif ($_POST['icon_location'] == $_GET['icon'] && !empty($_GET['icon'])) { |
|
1862 | + fatal_lang_error('icon_after_itself'); |
|
1863 | + } |
|
1783 | 1864 | |
1784 | 1865 | // First do the sorting... if this is an edit reduce the order of everything after it by one ;) |
1785 | 1866 | if ($_GET['icon'] != 0) |
1786 | 1867 | { |
1787 | 1868 | $oldOrder = $context['icons'][$_GET['icon']]['true_order']; |
1788 | - foreach ($context['icons'] as $id => $data) |
|
1789 | - if ($data['true_order'] > $oldOrder) |
|
1869 | + foreach ($context['icons'] as $id => $data) { |
|
1870 | + if ($data['true_order'] > $oldOrder) |
|
1790 | 1871 | $context['icons'][$id]['true_order']--; |
1872 | + } |
|
1791 | 1873 | } |
1792 | 1874 | |
1793 | 1875 | // If there are no existing icons and this is a new one, set the id to 1 (mainly for non-mysql) |
1794 | - if (empty($_GET['icon']) && empty($context['icons'])) |
|
1795 | - $_GET['icon'] = 1; |
|
1876 | + if (empty($_GET['icon']) && empty($context['icons'])) { |
|
1877 | + $_GET['icon'] = 1; |
|
1878 | + } |
|
1796 | 1879 | |
1797 | 1880 | // Get the new order. |
1798 | 1881 | $newOrder = $_POST['icon_location'] == 0 ? 0 : $context['icons'][$_POST['icon_location']]['true_order'] + 1; |
1799 | 1882 | // Do the same, but with the one that used to be after this icon, done to avoid conflict. |
1800 | - foreach ($context['icons'] as $id => $data) |
|
1801 | - if ($data['true_order'] >= $newOrder) |
|
1883 | + foreach ($context['icons'] as $id => $data) { |
|
1884 | + if ($data['true_order'] >= $newOrder) |
|
1802 | 1885 | $context['icons'][$id]['true_order']++; |
1886 | + } |
|
1803 | 1887 | |
1804 | 1888 | // Finally set the current icon's position! |
1805 | 1889 | $context['icons'][$_GET['icon']]['true_order'] = $newOrder; |
@@ -1817,8 +1901,7 @@ discard block |
||
1817 | 1901 | if ($id != 0) |
1818 | 1902 | { |
1819 | 1903 | $iconInsert[] = array($id, $icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1820 | - } |
|
1821 | - else |
|
1904 | + } else |
|
1822 | 1905 | { |
1823 | 1906 | $iconInsert_new[] = array($icon['board_id'], $icon['title'], $icon['filename'], $icon['true_order']); |
1824 | 1907 | } |
@@ -1843,8 +1926,9 @@ discard block |
||
1843 | 1926 | } |
1844 | 1927 | |
1845 | 1928 | // Unless we're adding a new thing, we'll escape |
1846 | - if (!isset($_POST['add'])) |
|
1847 | - redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1929 | + if (!isset($_POST['add'])) { |
|
1930 | + redirectexit('action=admin;area=smileys;sa=editicons'); |
|
1931 | + } |
|
1848 | 1932 | } |
1849 | 1933 | |
1850 | 1934 | $context[$context['admin_menu_name']]['current_subsection'] = 'editicons'; |
@@ -1954,8 +2038,9 @@ discard block |
||
1954 | 2038 | $context['new_icon'] = !isset($_GET['icon']); |
1955 | 2039 | |
1956 | 2040 | // Get the properties of the current icon from the icon list. |
1957 | - if (!$context['new_icon']) |
|
1958 | - $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2041 | + if (!$context['new_icon']) { |
|
2042 | + $context['icon'] = $context['icons'][$_GET['icon']]; |
|
2043 | + } |
|
1959 | 2044 | |
1960 | 2045 | // Get a list of boards needed for assigning this icon to a specific board. |
1961 | 2046 | $boardListOptions = array( |
@@ -1989,8 +2074,9 @@ discard block |
||
1989 | 2074 | ); |
1990 | 2075 | |
1991 | 2076 | $message_icons = array(); |
1992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1993 | - $message_icons[] = $row; |
|
2077 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2078 | + $message_icons[] = $row; |
|
2079 | + } |
|
1994 | 2080 | $smcFunc['db_free_result']($request); |
1995 | 2081 | |
1996 | 2082 | return $message_icons; |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | 'messages', 'moderators', 'package_servers', 'permission_profiles', 'permissions', 'personal_messages', |
53 | 54 | 'pm_recipients', 'poll_choices', 'polls', 'scheduled_tasks', 'sessions', 'settings', 'smileys', |
54 | 55 | 'themes', 'topics'); |
55 | - foreach ($reservedTables as $k => $table_name) |
|
56 | - $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
56 | + foreach ($reservedTables as $k => $table_name) { |
|
57 | + $reservedTables[$k] = strtolower($db_prefix . $table_name); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | // We in turn may need the extra stuff. |
59 | 61 | db_extend('extra'); |
@@ -105,8 +107,9 @@ discard block |
||
105 | 107 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
106 | 108 | |
107 | 109 | // First - no way do we touch SMF tables. |
108 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
109 | - return false; |
|
110 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
111 | + return false; |
|
112 | + } |
|
110 | 113 | |
111 | 114 | // Log that we'll want to remove this on uninstall. |
112 | 115 | $db_package_log[] = array('remove_table', $table_name); |
@@ -116,16 +119,18 @@ discard block |
||
116 | 119 | if (in_array($full_table_name, $tables)) |
117 | 120 | { |
118 | 121 | // This is a sad day... drop the table? If not, return false (error) by default. |
119 | - if ($if_exists == 'overwrite') |
|
120 | - $smcFunc['db_drop_table']($table_name); |
|
121 | - else |
|
122 | - return $if_exists == 'ignore'; |
|
122 | + if ($if_exists == 'overwrite') { |
|
123 | + $smcFunc['db_drop_table']($table_name); |
|
124 | + } else { |
|
125 | + return $if_exists == 'ignore'; |
|
126 | + } |
|
123 | 127 | } |
124 | 128 | |
125 | 129 | // Righty - let's do the damn thing! |
126 | 130 | $table_query = 'CREATE TABLE ' . $table_name . "\n" . '('; |
127 | - foreach ($columns as $column) |
|
128 | - $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
131 | + foreach ($columns as $column) { |
|
132 | + $table_query .= "\n\t" . smf_db_create_query_column($column) . ','; |
|
133 | + } |
|
129 | 134 | |
130 | 135 | // Loop through the indexes next... |
131 | 136 | foreach ($indexes as $index) |
@@ -133,19 +138,21 @@ discard block |
||
133 | 138 | $columns = implode(',', $index['columns']); |
134 | 139 | |
135 | 140 | // Is it the primary? |
136 | - if (isset($index['type']) && $index['type'] == 'primary') |
|
137 | - $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
138 | - else |
|
141 | + if (isset($index['type']) && $index['type'] == 'primary') { |
|
142 | + $table_query .= "\n\t" . 'PRIMARY KEY (' . implode(',', $index['columns']) . '),'; |
|
143 | + } else |
|
139 | 144 | { |
140 | - if (empty($index['name'])) |
|
141 | - $index['name'] = implode('_', $index['columns']); |
|
145 | + if (empty($index['name'])) { |
|
146 | + $index['name'] = implode('_', $index['columns']); |
|
147 | + } |
|
142 | 148 | $table_query .= "\n\t" . (isset($index['type']) && $index['type'] == 'unique' ? 'UNIQUE' : 'KEY') . ' ' . $index['name'] . ' (' . $columns . '),'; |
143 | 149 | } |
144 | 150 | } |
145 | 151 | |
146 | 152 | // No trailing commas! |
147 | - if (substr($table_query, -1) == ',') |
|
148 | - $table_query = substr($table_query, 0, -1); |
|
153 | + if (substr($table_query, -1) == ',') { |
|
154 | + $table_query = substr($table_query, 0, -1); |
|
155 | + } |
|
149 | 156 | |
150 | 157 | // Which engine do we want here? |
151 | 158 | if (empty($engines)) |
@@ -155,8 +162,9 @@ discard block |
||
155 | 162 | |
156 | 163 | while ($row = $smcFunc['db_fetch_assoc']($get_engines)) |
157 | 164 | { |
158 | - if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') |
|
159 | - $engines[] = $row['Engine']; |
|
165 | + if ($row['Support'] == 'YES' || $row['Support'] == 'DEFAULT') { |
|
166 | + $engines[] = $row['Engine']; |
|
167 | + } |
|
160 | 168 | } |
161 | 169 | |
162 | 170 | $smcFunc['db_free_result']($get_engines); |
@@ -170,8 +178,9 @@ discard block |
||
170 | 178 | } |
171 | 179 | |
172 | 180 | $table_query .= ') ENGINE=' . $parameters['engine']; |
173 | - if (!empty($db_character_set) && $db_character_set == 'utf8') |
|
174 | - $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
181 | + if (!empty($db_character_set) && $db_character_set == 'utf8') { |
|
182 | + $table_query .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | // Create the table! |
177 | 186 | $smcFunc['db_query']('', $table_query, |
@@ -203,8 +212,9 @@ discard block |
||
203 | 212 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
204 | 213 | |
205 | 214 | // God no - dropping one of these = bad. |
206 | - if (in_array(strtolower($table_name), $reservedTables)) |
|
207 | - return false; |
|
215 | + if (in_array(strtolower($table_name), $reservedTables)) { |
|
216 | + return false; |
|
217 | + } |
|
208 | 218 | |
209 | 219 | // Does it exist? |
210 | 220 | if (in_array($full_table_name, $smcFunc['db_list_tables']())) |
@@ -245,14 +255,16 @@ discard block |
||
245 | 255 | |
246 | 256 | // Does it exist - if so don't add it again! |
247 | 257 | $columns = $smcFunc['db_list_columns']($table_name, false); |
248 | - foreach ($columns as $column) |
|
249 | - if ($column == $column_info['name']) |
|
258 | + foreach ($columns as $column) { |
|
259 | + if ($column == $column_info['name']) |
|
250 | 260 | { |
251 | 261 | // If we're going to overwrite then use change column. |
252 | 262 | if ($if_exists == 'update') |
253 | 263 | return $smcFunc['db_change_column']($table_name, $column_info['name'], $column_info); |
254 | - else |
|
255 | - return false; |
|
264 | + } |
|
265 | + else { |
|
266 | + return false; |
|
267 | + } |
|
256 | 268 | } |
257 | 269 | |
258 | 270 | // Get the specifics... |
@@ -288,8 +300,8 @@ discard block |
||
288 | 300 | |
289 | 301 | // Does it exist? |
290 | 302 | $columns = $smcFunc['db_list_columns']($table_name, true); |
291 | - foreach ($columns as $column) |
|
292 | - if ($column['name'] == $column_name) |
|
303 | + foreach ($columns as $column) { |
|
304 | + if ($column['name'] == $column_name) |
|
293 | 305 | { |
294 | 306 | $smcFunc['db_query']('', ' |
295 | 307 | ALTER TABLE ' . $table_name . ' |
@@ -298,6 +310,7 @@ discard block |
||
298 | 310 | 'security_override' => true, |
299 | 311 | ) |
300 | 312 | ); |
313 | + } |
|
301 | 314 | |
302 | 315 | return true; |
303 | 316 | } |
@@ -324,37 +337,47 @@ discard block |
||
324 | 337 | // Check it does exist! |
325 | 338 | $columns = $smcFunc['db_list_columns']($table_name, true); |
326 | 339 | $old_info = null; |
327 | - foreach ($columns as $column) |
|
328 | - if ($column['name'] == $old_column) |
|
340 | + foreach ($columns as $column) { |
|
341 | + if ($column['name'] == $old_column) |
|
329 | 342 | $old_info = $column; |
343 | + } |
|
330 | 344 | |
331 | 345 | // Nothing? |
332 | - if ($old_info == null) |
|
333 | - return false; |
|
346 | + if ($old_info == null) { |
|
347 | + return false; |
|
348 | + } |
|
334 | 349 | |
335 | 350 | // Get the right bits. |
336 | - if (!isset($column_info['name'])) |
|
337 | - $column_info['name'] = $old_column; |
|
338 | - if (!isset($column_info['default'])) |
|
339 | - $column_info['default'] = $old_info['default']; |
|
340 | - if (!isset($column_info['null'])) |
|
341 | - $column_info['null'] = $old_info['null']; |
|
342 | - if (!isset($column_info['auto'])) |
|
343 | - $column_info['auto'] = $old_info['auto']; |
|
344 | - if (!isset($column_info['type'])) |
|
345 | - $column_info['type'] = $old_info['type']; |
|
346 | - if (!isset($column_info['size']) || !is_numeric($column_info['size'])) |
|
347 | - $column_info['size'] = $old_info['size']; |
|
348 | - if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) |
|
349 | - $column_info['unsigned'] = ''; |
|
351 | + if (!isset($column_info['name'])) { |
|
352 | + $column_info['name'] = $old_column; |
|
353 | + } |
|
354 | + if (!isset($column_info['default'])) { |
|
355 | + $column_info['default'] = $old_info['default']; |
|
356 | + } |
|
357 | + if (!isset($column_info['null'])) { |
|
358 | + $column_info['null'] = $old_info['null']; |
|
359 | + } |
|
360 | + if (!isset($column_info['auto'])) { |
|
361 | + $column_info['auto'] = $old_info['auto']; |
|
362 | + } |
|
363 | + if (!isset($column_info['type'])) { |
|
364 | + $column_info['type'] = $old_info['type']; |
|
365 | + } |
|
366 | + if (!isset($column_info['size']) || !is_numeric($column_info['size'])) { |
|
367 | + $column_info['size'] = $old_info['size']; |
|
368 | + } |
|
369 | + if (!isset($column_info['unsigned']) || !in_array($column_info['type'], array('int', 'tinyint', 'smallint', 'mediumint', 'bigint'))) { |
|
370 | + $column_info['unsigned'] = ''; |
|
371 | + } |
|
350 | 372 | |
351 | 373 | list ($type, $size) = $smcFunc['db_calculate_type']($column_info['type'], $column_info['size']); |
352 | 374 | |
353 | 375 | // Allow for unsigned integers (mysql only) |
354 | 376 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column_info['unsigned']) ? 'unsigned ' : ''; |
355 | 377 | |
356 | - if ($size !== null) |
|
357 | - $type = $type . '(' . $size . ')'; |
|
378 | + if ($size !== null) { |
|
379 | + $type = $type . '(' . $size . ')'; |
|
380 | + } |
|
358 | 381 | |
359 | 382 | $smcFunc['db_query']('', ' |
360 | 383 | ALTER TABLE ' . $table_name . ' |
@@ -384,21 +407,23 @@ discard block |
||
384 | 407 | $table_name = str_replace('{db_prefix}', $db_prefix, $table_name); |
385 | 408 | |
386 | 409 | // No columns = no index. |
387 | - if (empty($index_info['columns'])) |
|
388 | - return false; |
|
410 | + if (empty($index_info['columns'])) { |
|
411 | + return false; |
|
412 | + } |
|
389 | 413 | $columns = implode(',', $index_info['columns']); |
390 | 414 | |
391 | 415 | // No name - make it up! |
392 | 416 | if (empty($index_info['name'])) |
393 | 417 | { |
394 | 418 | // No need for primary. |
395 | - if (isset($index_info['type']) && $index_info['type'] == 'primary') |
|
396 | - $index_info['name'] = ''; |
|
397 | - else |
|
398 | - $index_info['name'] = implode('_', $index_info['columns']); |
|
419 | + if (isset($index_info['type']) && $index_info['type'] == 'primary') { |
|
420 | + $index_info['name'] = ''; |
|
421 | + } else { |
|
422 | + $index_info['name'] = implode('_', $index_info['columns']); |
|
423 | + } |
|
424 | + } else { |
|
425 | + $index_info['name'] = $index_info['name']; |
|
399 | 426 | } |
400 | - else |
|
401 | - $index_info['name'] = $index_info['name']; |
|
402 | 427 | |
403 | 428 | // Log that we are going to want to remove this! |
404 | 429 | $db_package_log[] = array('remove_index', $table_name, $index_info['name']); |
@@ -411,10 +436,11 @@ discard block |
||
411 | 436 | if ($index['name'] == $index_info['name'] || ($index['type'] == 'primary' && isset($index_info['type']) && $index_info['type'] == 'primary')) |
412 | 437 | { |
413 | 438 | // If we want to overwrite simply remove the current one then continue. |
414 | - if ($if_exists != 'update' || $index['type'] == 'primary') |
|
415 | - return false; |
|
416 | - else |
|
417 | - $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
439 | + if ($if_exists != 'update' || $index['type'] == 'primary') { |
|
440 | + return false; |
|
441 | + } else { |
|
442 | + $smcFunc['db_remove_index']($table_name, $index_info['name']); |
|
443 | + } |
|
418 | 444 | } |
419 | 445 | } |
420 | 446 | |
@@ -428,8 +454,7 @@ discard block |
||
428 | 454 | 'security_override' => true, |
429 | 455 | ) |
430 | 456 | ); |
431 | - } |
|
432 | - else |
|
457 | + } else |
|
433 | 458 | { |
434 | 459 | $smcFunc['db_query']('', ' |
435 | 460 | ALTER TABLE ' . $table_name . ' |
@@ -513,8 +538,7 @@ discard block |
||
513 | 538 | $types = array( |
514 | 539 | 'inet' => 'varbinary', |
515 | 540 | ); |
516 | - } |
|
517 | - else |
|
541 | + } else |
|
518 | 542 | { |
519 | 543 | $types = array( |
520 | 544 | 'varbinary' => 'inet', |
@@ -528,16 +552,15 @@ discard block |
||
528 | 552 | { |
529 | 553 | $type_size = 16; |
530 | 554 | $type_name = 'varbinary'; |
531 | - } |
|
532 | - elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
555 | + } elseif ($type_name == 'varbinary' && $reverse && $type_size == 16) |
|
533 | 556 | { |
534 | 557 | $type_name = 'inet'; |
535 | 558 | $type_size = null; |
559 | + } elseif ($type_name == 'varbinary') { |
|
560 | + $type_name = 'varbinary'; |
|
561 | + } else { |
|
562 | + $type_name = $types[$type_name]; |
|
536 | 563 | } |
537 | - elseif ($type_name == 'varbinary') |
|
538 | - $type_name = 'varbinary'; |
|
539 | - else |
|
540 | - $type_name = $types[$type_name]; |
|
541 | 564 | } |
542 | 565 | |
543 | 566 | return array($type_name, $type_size); |
@@ -605,8 +628,7 @@ discard block |
||
605 | 628 | if (!$detail) |
606 | 629 | { |
607 | 630 | $columns[] = $row['Field']; |
608 | - } |
|
609 | - else |
|
631 | + } else |
|
610 | 632 | { |
611 | 633 | // Is there an auto_increment? |
612 | 634 | $auto = strpos($row['Extra'], 'auto_increment') !== false ? true : false; |
@@ -616,10 +638,10 @@ discard block |
||
616 | 638 | { |
617 | 639 | $type = $matches[1]; |
618 | 640 | $size = $matches[2]; |
619 | - if (!empty($matches[3]) && $matches[3] == 'unsigned') |
|
620 | - $unsigned = true; |
|
621 | - } |
|
622 | - else |
|
641 | + if (!empty($matches[3]) && $matches[3] == 'unsigned') { |
|
642 | + $unsigned = true; |
|
643 | + } |
|
644 | + } else |
|
623 | 645 | { |
624 | 646 | $type = $row['Type']; |
625 | 647 | $size = null; |
@@ -670,19 +692,20 @@ discard block |
||
670 | 692 | $indexes = array(); |
671 | 693 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
672 | 694 | { |
673 | - if (!$detail) |
|
674 | - $indexes[] = $row['Key_name']; |
|
675 | - else |
|
695 | + if (!$detail) { |
|
696 | + $indexes[] = $row['Key_name']; |
|
697 | + } else |
|
676 | 698 | { |
677 | 699 | // What is the type? |
678 | - if ($row['Key_name'] == 'PRIMARY') |
|
679 | - $type = 'primary'; |
|
680 | - elseif (empty($row['Non_unique'])) |
|
681 | - $type = 'unique'; |
|
682 | - elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') |
|
683 | - $type = 'fulltext'; |
|
684 | - else |
|
685 | - $type = 'index'; |
|
700 | + if ($row['Key_name'] == 'PRIMARY') { |
|
701 | + $type = 'primary'; |
|
702 | + } elseif (empty($row['Non_unique'])) { |
|
703 | + $type = 'unique'; |
|
704 | + } elseif (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') { |
|
705 | + $type = 'fulltext'; |
|
706 | + } else { |
|
707 | + $type = 'index'; |
|
708 | + } |
|
686 | 709 | |
687 | 710 | // This is the first column we've seen? |
688 | 711 | if (empty($indexes[$row['Key_name']])) |
@@ -695,10 +718,11 @@ discard block |
||
695 | 718 | } |
696 | 719 | |
697 | 720 | // Is it a partial index? |
698 | - if (!empty($row['Sub_part'])) |
|
699 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
700 | - else |
|
701 | - $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
721 | + if (!empty($row['Sub_part'])) { |
|
722 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name'] . '(' . $row['Sub_part'] . ')'; |
|
723 | + } else { |
|
724 | + $indexes[$row['Key_name']]['columns'][] = $row['Column_name']; |
|
725 | + } |
|
702 | 726 | } |
703 | 727 | } |
704 | 728 | $smcFunc['db_free_result']($result); |
@@ -720,11 +744,11 @@ discard block |
||
720 | 744 | if (!empty($column['auto'])) |
721 | 745 | { |
722 | 746 | $default = 'auto_increment'; |
747 | + } elseif (isset($column['default']) && $column['default'] !== null) { |
|
748 | + $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
749 | + } else { |
|
750 | + $default = ''; |
|
723 | 751 | } |
724 | - elseif (isset($column['default']) && $column['default'] !== null) |
|
725 | - $default = 'default \'' . $smcFunc['db_escape_string']($column['default']) . '\''; |
|
726 | - else |
|
727 | - $default = ''; |
|
728 | 752 | |
729 | 753 | // Sort out the size... and stuff... |
730 | 754 | $column['size'] = isset($column['size']) && is_numeric($column['size']) ? $column['size'] : null; |
@@ -733,8 +757,9 @@ discard block |
||
733 | 757 | // Allow unsigned integers (mysql only) |
734 | 758 | $unsigned = in_array($type, array('int', 'tinyint', 'smallint', 'mediumint', 'bigint')) && !empty($column['unsigned']) ? 'unsigned ' : ''; |
735 | 759 | |
736 | - if ($size !== null) |
|
737 | - $type = $type . '(' . $size . ')'; |
|
760 | + if ($size !== null) { |
|
761 | + $type = $type . '(' . $size . ')'; |
|
762 | + } |
|
738 | 763 | |
739 | 764 | // Now just put it together! |
740 | 765 | return '`' . $column['name'] . '` ' . $type . ' ' . (!empty($unsigned) ? $unsigned : '') . (!empty($column['null']) ? '' : 'NOT NULL') . ' ' . $default; |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
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 | * This defines every profile field known to man. |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $sourcedir, $profile_vars; |
30 | 31 | |
31 | 32 | // Don't load this twice! |
32 | - if (!empty($profile_fields) && !$force_reload) |
|
33 | - return; |
|
33 | + if (!empty($profile_fields) && !$force_reload) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /* This horrific array defines all the profile fields in the whole world! |
36 | 38 | In general each "field" has one array - the key of which is the database column name associated with said field. Each item |
@@ -103,13 +105,14 @@ discard block |
||
103 | 105 | if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0) |
104 | 106 | { |
105 | 107 | // Set to blank? |
106 | - if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) |
|
107 | - $value = '0001-01-01'; |
|
108 | - else |
|
109 | - $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
108 | + if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) { |
|
109 | + $value = '0001-01-01'; |
|
110 | + } else { |
|
111 | + $value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 4 ? 4 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 4 ? 4 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '0001-01-01'; |
|
112 | + } |
|
113 | + } else { |
|
114 | + $value = '0001-01-01'; |
|
110 | 115 | } |
111 | - else |
|
112 | - $value = '0001-01-01'; |
|
113 | 116 | |
114 | 117 | $profile_vars['birthdate'] = $value; |
115 | 118 | $cur_profile['birthdate'] = $value; |
@@ -127,8 +130,7 @@ discard block |
||
127 | 130 | { |
128 | 131 | $value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '0001-01-01'; |
129 | 132 | return true; |
130 | - } |
|
131 | - else |
|
133 | + } else |
|
132 | 134 | { |
133 | 135 | $value = empty($cur_profile['birthdate']) ? '0001-01-01' : $cur_profile['birthdate']; |
134 | 136 | return false; |
@@ -150,10 +152,11 @@ discard block |
||
150 | 152 | return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false)); |
151 | 153 | } |
152 | 154 | // As long as it doesn't equal "N/A"... |
153 | - elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) |
|
154 | - $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
155 | - else |
|
156 | - $value = $cur_profile['date_registered']; |
|
155 | + elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) { |
|
156 | + $value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600; |
|
157 | + } else { |
|
158 | + $value = $cur_profile['date_registered']; |
|
159 | + } |
|
157 | 160 | |
158 | 161 | return true; |
159 | 162 | }, |
@@ -177,8 +180,9 @@ discard block |
||
177 | 180 | { |
178 | 181 | global $context, $old_profile, $profile_vars, $sourcedir, $modSettings; |
179 | 182 | |
180 | - if (strtolower($value) == strtolower($old_profile['email_address'])) |
|
181 | - return false; |
|
183 | + if (strtolower($value) == strtolower($old_profile['email_address'])) { |
|
184 | + return false; |
|
185 | + } |
|
182 | 186 | |
183 | 187 | $isValid = profileValidateEmail($value, $context['id_member']); |
184 | 188 | |
@@ -254,11 +258,11 @@ discard block |
||
254 | 258 | |
255 | 259 | if (isset($context['profile_languages'][$value])) |
256 | 260 | { |
257 | - if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) |
|
258 | - $_SESSION['language'] = $value; |
|
261 | + if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) { |
|
262 | + $_SESSION['language'] = $value; |
|
263 | + } |
|
259 | 264 | return true; |
260 | - } |
|
261 | - else |
|
265 | + } else |
|
262 | 266 | { |
263 | 267 | $value = $cur_profile['lngfile']; |
264 | 268 | return false; |
@@ -282,13 +286,14 @@ discard block |
||
282 | 286 | |
283 | 287 | // Maybe they are trying to change their password as well? |
284 | 288 | $resetPassword = true; |
285 | - if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) |
|
286 | - $resetPassword = false; |
|
289 | + if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) { |
|
290 | + $resetPassword = false; |
|
291 | + } |
|
287 | 292 | |
288 | 293 | // Do the reset... this will send them an email too. |
289 | - if ($resetPassword) |
|
290 | - resetPassword($context['id_member'], $value); |
|
291 | - elseif ($value !== null) |
|
294 | + if ($resetPassword) { |
|
295 | + resetPassword($context['id_member'], $value); |
|
296 | + } elseif ($value !== null) |
|
292 | 297 | { |
293 | 298 | validateUsername($context['id_member'], 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' : ''), ' ', $value))); |
294 | 299 | updateMemberData($context['id_member'], array('member_name' => $value)); |
@@ -312,20 +317,23 @@ discard block |
||
312 | 317 | 'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile) |
313 | 318 | { |
314 | 319 | // If we didn't try it then ignore it! |
315 | - if ($value == '') |
|
316 | - return false; |
|
320 | + if ($value == '') { |
|
321 | + return false; |
|
322 | + } |
|
317 | 323 | |
318 | 324 | // Do the two entries for the password even match? |
319 | - if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) |
|
320 | - return 'bad_new_password'; |
|
325 | + if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) { |
|
326 | + return 'bad_new_password'; |
|
327 | + } |
|
321 | 328 | |
322 | 329 | // Let's get the validation function into play... |
323 | 330 | require_once($sourcedir . '/Subs-Auth.php'); |
324 | 331 | $passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])); |
325 | 332 | |
326 | 333 | // Were there errors? |
327 | - if ($passwordErrors != null) |
|
328 | - return 'password_' . $passwordErrors; |
|
334 | + if ($passwordErrors != null) { |
|
335 | + return 'password_' . $passwordErrors; |
|
336 | + } |
|
329 | 337 | |
330 | 338 | // Set up the new password variable... ready for storage. |
331 | 339 | $value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value)); |
@@ -350,8 +358,9 @@ discard block |
||
350 | 358 | 'permission' => 'profile_blurb', |
351 | 359 | 'input_validate' => function(&$value) use ($smcFunc) |
352 | 360 | { |
353 | - if ($smcFunc['strlen']($value) > 50) |
|
354 | - return 'personal_text_too_long'; |
|
361 | + if ($smcFunc['strlen']($value) > 50) { |
|
362 | + return 'personal_text_too_long'; |
|
363 | + } |
|
355 | 364 | |
356 | 365 | return true; |
357 | 366 | }, |
@@ -386,10 +395,11 @@ discard block |
||
386 | 395 | 'permission' => 'moderate_forum', |
387 | 396 | 'input_validate' => function(&$value) |
388 | 397 | { |
389 | - if (!is_numeric($value)) |
|
390 | - return 'digits_only'; |
|
391 | - else |
|
392 | - $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
398 | + if (!is_numeric($value)) { |
|
399 | + return 'digits_only'; |
|
400 | + } else { |
|
401 | + $value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0; |
|
402 | + } |
|
393 | 403 | return true; |
394 | 404 | }, |
395 | 405 | ), |
@@ -405,15 +415,16 @@ discard block |
||
405 | 415 | { |
406 | 416 | $value = 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' : ''), ' ', $value)); |
407 | 417 | |
408 | - if (trim($value) == '') |
|
409 | - return 'no_name'; |
|
410 | - elseif ($smcFunc['strlen']($value) > 60) |
|
411 | - return 'name_too_long'; |
|
412 | - elseif ($cur_profile['real_name'] != $value) |
|
418 | + if (trim($value) == '') { |
|
419 | + return 'no_name'; |
|
420 | + } elseif ($smcFunc['strlen']($value) > 60) { |
|
421 | + return 'name_too_long'; |
|
422 | + } elseif ($cur_profile['real_name'] != $value) |
|
413 | 423 | { |
414 | 424 | require_once($sourcedir . '/Subs-Members.php'); |
415 | - if (isReservedName($value, $context['id_member'])) |
|
416 | - return 'name_taken'; |
|
425 | + if (isReservedName($value, $context['id_member'])) { |
|
426 | + return 'name_taken'; |
|
427 | + } |
|
417 | 428 | } |
418 | 429 | return true; |
419 | 430 | }, |
@@ -471,8 +482,9 @@ discard block |
||
471 | 482 | 'selected' => $set == $context['member']['smiley_set']['id'] |
472 | 483 | ); |
473 | 484 | |
474 | - if ($context['smiley_sets'][$i]['selected']) |
|
475 | - $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
485 | + if ($context['smiley_sets'][$i]['selected']) { |
|
486 | + $context['member']['smiley_set']['name'] = $set_names[$i]; |
|
487 | + } |
|
476 | 488 | } |
477 | 489 | return true; |
478 | 490 | }, |
@@ -481,8 +493,9 @@ discard block |
||
481 | 493 | global $modSettings; |
482 | 494 | |
483 | 495 | $smiley_sets = explode(',', $modSettings['smiley_sets_known']); |
484 | - if (!in_array($value, $smiley_sets) && $value != 'none') |
|
485 | - $value = ''; |
|
496 | + if (!in_array($value, $smiley_sets) && $value != 'none') { |
|
497 | + $value = ''; |
|
498 | + } |
|
486 | 499 | return true; |
487 | 500 | }, |
488 | 501 | ), |
@@ -497,8 +510,9 @@ discard block |
||
497 | 510 | loadLanguage('Settings'); |
498 | 511 | |
499 | 512 | $context['allow_no_censored'] = false; |
500 | - if ($user_info['is_admin'] || $context['user']['is_owner']) |
|
501 | - $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
513 | + if ($user_info['is_admin'] || $context['user']['is_owner']) { |
|
514 | + $context['allow_no_censored'] = !empty($modSettings['allow_no_censored']); |
|
515 | + } |
|
502 | 516 | |
503 | 517 | return true; |
504 | 518 | }, |
@@ -545,8 +559,9 @@ discard block |
||
545 | 559 | 'input_validate' => function($value) |
546 | 560 | { |
547 | 561 | $tz = smf_list_timezones(); |
548 | - if (!isset($tz[$value])) |
|
549 | - return 'bad_timezone'; |
|
562 | + if (!isset($tz[$value])) { |
|
563 | + return 'bad_timezone'; |
|
564 | + } |
|
550 | 565 | |
551 | 566 | return true; |
552 | 567 | }, |
@@ -561,8 +576,9 @@ discard block |
||
561 | 576 | 'enabled' => !empty($modSettings['titlesEnable']), |
562 | 577 | 'input_validate' => function(&$value) use ($smcFunc) |
563 | 578 | { |
564 | - if ($smcFunc['strlen']($value) > 50) |
|
565 | - return 'user_title_too_long'; |
|
579 | + if ($smcFunc['strlen']($value) > 50) { |
|
580 | + return 'user_title_too_long'; |
|
581 | + } |
|
566 | 582 | |
567 | 583 | return true; |
568 | 584 | }, |
@@ -584,10 +600,12 @@ discard block |
||
584 | 600 | // Fix the URL... |
585 | 601 | 'input_validate' => function(&$value) |
586 | 602 | { |
587 | - if (strlen(trim($value)) > 0 && strpos($value, '://') === false) |
|
588 | - $value = 'http://' . $value; |
|
589 | - if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) |
|
590 | - $value = ''; |
|
603 | + if (strlen(trim($value)) > 0 && strpos($value, '://') === false) { |
|
604 | + $value = 'http://' . $value; |
|
605 | + } |
|
606 | + if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) { |
|
607 | + $value = ''; |
|
608 | + } |
|
591 | 609 | return true; |
592 | 610 | }, |
593 | 611 | 'link_with' => 'website', |
@@ -601,16 +619,19 @@ discard block |
||
601 | 619 | foreach ($profile_fields as $key => $field) |
602 | 620 | { |
603 | 621 | // Do we have permission to do this? |
604 | - if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) |
|
605 | - unset($profile_fields[$key]); |
|
622 | + if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) { |
|
623 | + unset($profile_fields[$key]); |
|
624 | + } |
|
606 | 625 | |
607 | 626 | // Is it enabled? |
608 | - if (isset($field['enabled']) && !$field['enabled']) |
|
609 | - unset($profile_fields[$key]); |
|
627 | + if (isset($field['enabled']) && !$field['enabled']) { |
|
628 | + unset($profile_fields[$key]); |
|
629 | + } |
|
610 | 630 | |
611 | 631 | // Is it specifically disabled? |
612 | - if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) |
|
613 | - unset($profile_fields[$key]); |
|
632 | + if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) { |
|
633 | + unset($profile_fields[$key]); |
|
634 | + } |
|
614 | 635 | } |
615 | 636 | } |
616 | 637 | |
@@ -635,9 +656,10 @@ discard block |
||
635 | 656 | loadProfileFields(true); |
636 | 657 | |
637 | 658 | // First check for any linked sets. |
638 | - foreach ($profile_fields as $key => $field) |
|
639 | - if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
659 | + foreach ($profile_fields as $key => $field) { |
|
660 | + if (isset($field['link_with']) && in_array($field['link_with'], $fields)) |
|
640 | 661 | $fields[] = $key; |
662 | + } |
|
641 | 663 | |
642 | 664 | $i = 0; |
643 | 665 | $last_type = ''; |
@@ -649,38 +671,46 @@ discard block |
||
649 | 671 | $cur_field = &$profile_fields[$field]; |
650 | 672 | |
651 | 673 | // Does it have a preload and does that preload succeed? |
652 | - if (isset($cur_field['preload']) && !$cur_field['preload']()) |
|
653 | - continue; |
|
674 | + if (isset($cur_field['preload']) && !$cur_field['preload']()) { |
|
675 | + continue; |
|
676 | + } |
|
654 | 677 | |
655 | 678 | // If this is anything but complex we need to do more cleaning! |
656 | 679 | if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden') |
657 | 680 | { |
658 | - if (!isset($cur_field['label'])) |
|
659 | - $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
681 | + if (!isset($cur_field['label'])) { |
|
682 | + $cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field; |
|
683 | + } |
|
660 | 684 | |
661 | 685 | // Everything has a value! |
662 | - if (!isset($cur_field['value'])) |
|
663 | - $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
686 | + if (!isset($cur_field['value'])) { |
|
687 | + $cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : ''; |
|
688 | + } |
|
664 | 689 | |
665 | 690 | // Any input attributes? |
666 | 691 | $cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : ''; |
667 | 692 | } |
668 | 693 | |
669 | 694 | // Was there an error with this field on posting? |
670 | - if (isset($context['profile_errors'][$field])) |
|
671 | - $cur_field['is_error'] = true; |
|
695 | + if (isset($context['profile_errors'][$field])) { |
|
696 | + $cur_field['is_error'] = true; |
|
697 | + } |
|
672 | 698 | |
673 | 699 | // Any javascript stuff? |
674 | - if (!empty($cur_field['js_submit'])) |
|
675 | - $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
676 | - if (!empty($cur_field['js'])) |
|
677 | - $context['profile_javascript'] .= $cur_field['js']; |
|
700 | + if (!empty($cur_field['js_submit'])) { |
|
701 | + $context['profile_onsubmit_javascript'] .= $cur_field['js_submit']; |
|
702 | + } |
|
703 | + if (!empty($cur_field['js'])) { |
|
704 | + $context['profile_javascript'] .= $cur_field['js']; |
|
705 | + } |
|
678 | 706 | |
679 | 707 | // Any template stuff? |
680 | - if (!empty($cur_field['prehtml'])) |
|
681 | - $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
682 | - if (!empty($cur_field['posthtml'])) |
|
683 | - $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
708 | + if (!empty($cur_field['prehtml'])) { |
|
709 | + $context['profile_prehtml'] .= $cur_field['prehtml']; |
|
710 | + } |
|
711 | + if (!empty($cur_field['posthtml'])) { |
|
712 | + $context['profile_posthtml'] .= $cur_field['posthtml']; |
|
713 | + } |
|
684 | 714 | |
685 | 715 | // Finally put it into context? |
686 | 716 | if ($cur_field['type'] != 'hidden') |
@@ -713,12 +743,14 @@ discard block |
||
713 | 743 | }, false);' : ''), true); |
714 | 744 | |
715 | 745 | // Any onsubmit javascript? |
716 | - if (!empty($context['profile_onsubmit_javascript'])) |
|
717 | - addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
746 | + if (!empty($context['profile_onsubmit_javascript'])) { |
|
747 | + addInlineJavaScript($context['profile_onsubmit_javascript'], true); |
|
748 | + } |
|
718 | 749 | |
719 | 750 | // Any totally custom stuff? |
720 | - if (!empty($context['profile_javascript'])) |
|
721 | - addInlineJavaScript($context['profile_javascript'], true); |
|
751 | + if (!empty($context['profile_javascript'])) { |
|
752 | + addInlineJavaScript($context['profile_javascript'], true); |
|
753 | + } |
|
722 | 754 | |
723 | 755 | // Free up some memory. |
724 | 756 | unset($profile_fields); |
@@ -739,8 +771,9 @@ discard block |
||
739 | 771 | |
740 | 772 | // This allows variables to call activities when they save - by default just to reload their settings |
741 | 773 | $context['profile_execute_on_save'] = array(); |
742 | - if ($context['user']['is_owner']) |
|
743 | - $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
774 | + if ($context['user']['is_owner']) { |
|
775 | + $context['profile_execute_on_save']['reload_user'] = 'profileReloadUser'; |
|
776 | + } |
|
744 | 777 | |
745 | 778 | // Assume we log nothing. |
746 | 779 | $context['log_changes'] = array(); |
@@ -748,8 +781,9 @@ discard block |
||
748 | 781 | // Cycle through the profile fields working out what to do! |
749 | 782 | foreach ($profile_fields as $key => $field) |
750 | 783 | { |
751 | - if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) |
|
752 | - continue; |
|
784 | + if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) { |
|
785 | + continue; |
|
786 | + } |
|
753 | 787 | |
754 | 788 | // What gets updated? |
755 | 789 | $db_key = isset($field['save_key']) ? $field['save_key'] : $key; |
@@ -777,12 +811,13 @@ discard block |
||
777 | 811 | $field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type']; |
778 | 812 | |
779 | 813 | // Finally, clean up certain types. |
780 | - if ($field['cast_type'] == 'int') |
|
781 | - $_POST[$key] = (int) $_POST[$key]; |
|
782 | - elseif ($field['cast_type'] == 'float') |
|
783 | - $_POST[$key] = (float) $_POST[$key]; |
|
784 | - elseif ($field['cast_type'] == 'check') |
|
785 | - $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
814 | + if ($field['cast_type'] == 'int') { |
|
815 | + $_POST[$key] = (int) $_POST[$key]; |
|
816 | + } elseif ($field['cast_type'] == 'float') { |
|
817 | + $_POST[$key] = (float) $_POST[$key]; |
|
818 | + } elseif ($field['cast_type'] == 'check') { |
|
819 | + $_POST[$key] = !empty($_POST[$key]) ? 1 : 0; |
|
820 | + } |
|
786 | 821 | |
787 | 822 | // If we got here we're doing OK. |
788 | 823 | if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key])) |
@@ -793,11 +828,12 @@ discard block |
||
793 | 828 | $cur_profile[$key] = $_POST[$key]; |
794 | 829 | |
795 | 830 | // Are we logging it? |
796 | - if (!empty($field['log_change']) && isset($old_profile[$key])) |
|
797 | - $context['log_changes'][$key] = array( |
|
831 | + if (!empty($field['log_change']) && isset($old_profile[$key])) { |
|
832 | + $context['log_changes'][$key] = array( |
|
798 | 833 | 'previous' => $old_profile[$key], |
799 | 834 | 'new' => $_POST[$key], |
800 | 835 | ); |
836 | + } |
|
801 | 837 | } |
802 | 838 | |
803 | 839 | // Logging group changes are a bit different... |
@@ -830,10 +866,11 @@ discard block |
||
830 | 866 | { |
831 | 867 | foreach ($groups as $id => $group) |
832 | 868 | { |
833 | - if (isset($context['member_groups'][$group])) |
|
834 | - $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
835 | - else |
|
836 | - unset($additional_groups[$type][$id]); |
|
869 | + if (isset($context['member_groups'][$group])) { |
|
870 | + $additional_groups[$type][$id] = $context['member_groups'][$group]['name']; |
|
871 | + } else { |
|
872 | + unset($additional_groups[$type][$id]); |
|
873 | + } |
|
837 | 874 | } |
838 | 875 | $additional_groups[$type] = implode(', ', $additional_groups[$type]); |
839 | 876 | } |
@@ -844,10 +881,11 @@ discard block |
||
844 | 881 | } |
845 | 882 | |
846 | 883 | // @todo Temporary |
847 | - if ($context['user']['is_owner']) |
|
848 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
849 | - else |
|
850 | - $changeOther = allowedTo('profile_extra_any'); |
|
884 | + if ($context['user']['is_owner']) { |
|
885 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own')); |
|
886 | + } else { |
|
887 | + $changeOther = allowedTo('profile_extra_any'); |
|
888 | + } |
|
851 | 889 | if ($changeOther && empty($post_errors)) |
852 | 890 | { |
853 | 891 | makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
@@ -855,8 +893,9 @@ discard block |
||
855 | 893 | { |
856 | 894 | $custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true); |
857 | 895 | |
858 | - if (!empty($custom_fields_errors)) |
|
859 | - $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
896 | + if (!empty($custom_fields_errors)) { |
|
897 | + $post_errors = array_merge($post_errors, $custom_fields_errors); |
|
898 | + } |
|
860 | 899 | } |
861 | 900 | } |
862 | 901 | |
@@ -882,9 +921,9 @@ discard block |
||
882 | 921 | if ($context['user']['is_owner']) |
883 | 922 | { |
884 | 923 | $changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own')); |
924 | + } else { |
|
925 | + $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
885 | 926 | } |
886 | - else |
|
887 | - $changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any')); |
|
888 | 927 | |
889 | 928 | // Arrays of all the changes - makes things easier. |
890 | 929 | $profile_bools = array(); |
@@ -895,22 +934,25 @@ discard block |
||
895 | 934 | 'ignore_boards', |
896 | 935 | ); |
897 | 936 | |
898 | - if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) |
|
899 | - $_POST['ignore_brd'] = array(); |
|
937 | + if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) { |
|
938 | + $_POST['ignore_brd'] = array(); |
|
939 | + } |
|
900 | 940 | |
901 | 941 | unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing. Kinda like our minds. |
902 | 942 | if (isset($_POST['ignore_brd'])) |
903 | 943 | { |
904 | - if (!is_array($_POST['ignore_brd'])) |
|
905 | - $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
944 | + if (!is_array($_POST['ignore_brd'])) { |
|
945 | + $_POST['ignore_brd'] = array($_POST['ignore_brd']); |
|
946 | + } |
|
906 | 947 | |
907 | 948 | foreach ($_POST['ignore_brd'] as $k => $d) |
908 | 949 | { |
909 | 950 | $d = (int) $d; |
910 | - if ($d != 0) |
|
911 | - $_POST['ignore_brd'][$k] = $d; |
|
912 | - else |
|
913 | - unset($_POST['ignore_brd'][$k]); |
|
951 | + if ($d != 0) { |
|
952 | + $_POST['ignore_brd'][$k] = $d; |
|
953 | + } else { |
|
954 | + unset($_POST['ignore_brd'][$k]); |
|
955 | + } |
|
914 | 956 | } |
915 | 957 | $_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']); |
916 | 958 | unset($_POST['ignore_brd']); |
@@ -923,21 +965,26 @@ discard block |
||
923 | 965 | makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']); |
924 | 966 | //makeAvatarChanges($memID, $post_errors); |
925 | 967 | |
926 | - if (!empty($_REQUEST['sa'])) |
|
927 | - makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
968 | + if (!empty($_REQUEST['sa'])) { |
|
969 | + makeCustomFieldChanges($memID, $_REQUEST['sa'], false); |
|
970 | + } |
|
928 | 971 | |
929 | - foreach ($profile_bools as $var) |
|
930 | - if (isset($_POST[$var])) |
|
972 | + foreach ($profile_bools as $var) { |
|
973 | + if (isset($_POST[$var])) |
|
931 | 974 | $profile_vars[$var] = empty($_POST[$var]) ? '0' : '1'; |
932 | - foreach ($profile_ints as $var) |
|
933 | - if (isset($_POST[$var])) |
|
975 | + } |
|
976 | + foreach ($profile_ints as $var) { |
|
977 | + if (isset($_POST[$var])) |
|
934 | 978 | $profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : ''; |
935 | - foreach ($profile_floats as $var) |
|
936 | - if (isset($_POST[$var])) |
|
979 | + } |
|
980 | + foreach ($profile_floats as $var) { |
|
981 | + if (isset($_POST[$var])) |
|
937 | 982 | $profile_vars[$var] = (float) $_POST[$var]; |
938 | - foreach ($profile_strings as $var) |
|
939 | - if (isset($_POST[$var])) |
|
983 | + } |
|
984 | + foreach ($profile_strings as $var) { |
|
985 | + if (isset($_POST[$var])) |
|
940 | 986 | $profile_vars[$var] = $_POST[$var]; |
987 | + } |
|
941 | 988 | } |
942 | 989 | } |
943 | 990 | |
@@ -971,8 +1018,9 @@ discard block |
||
971 | 1018 | ); |
972 | 1019 | |
973 | 1020 | // Can't change reserved vars. |
974 | - if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) |
|
975 | - fatal_lang_error('no_access', false); |
|
1021 | + if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) { |
|
1022 | + fatal_lang_error('no_access', false); |
|
1023 | + } |
|
976 | 1024 | |
977 | 1025 | // Don't allow any overriding of custom fields with default or non-default options. |
978 | 1026 | $request = $smcFunc['db_query']('', ' |
@@ -984,8 +1032,9 @@ discard block |
||
984 | 1032 | ) |
985 | 1033 | ); |
986 | 1034 | $custom_fields = array(); |
987 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
988 | - $custom_fields[] = $row['col_name']; |
|
1035 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1036 | + $custom_fields[] = $row['col_name']; |
|
1037 | + } |
|
989 | 1038 | $smcFunc['db_free_result']($request); |
990 | 1039 | |
991 | 1040 | // These are the theme changes... |
@@ -994,33 +1043,39 @@ discard block |
||
994 | 1043 | { |
995 | 1044 | foreach ($_POST['options'] as $opt => $val) |
996 | 1045 | { |
997 | - if (in_array($opt, $custom_fields)) |
|
998 | - continue; |
|
1046 | + if (in_array($opt, $custom_fields)) { |
|
1047 | + continue; |
|
1048 | + } |
|
999 | 1049 | |
1000 | 1050 | // These need to be controlled. |
1001 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1002 | - $val = max(0, min($val, 50)); |
|
1051 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1052 | + $val = max(0, min($val, 50)); |
|
1053 | + } |
|
1003 | 1054 | // We don't set this per theme anymore. |
1004 | - elseif ($opt == 'allow_no_censored') |
|
1005 | - continue; |
|
1055 | + elseif ($opt == 'allow_no_censored') { |
|
1056 | + continue; |
|
1057 | + } |
|
1006 | 1058 | |
1007 | 1059 | $themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val); |
1008 | 1060 | } |
1009 | 1061 | } |
1010 | 1062 | |
1011 | 1063 | $erase_options = array(); |
1012 | - if (isset($_POST['default_options']) && is_array($_POST['default_options'])) |
|
1013 | - foreach ($_POST['default_options'] as $opt => $val) |
|
1064 | + if (isset($_POST['default_options']) && is_array($_POST['default_options'])) { |
|
1065 | + foreach ($_POST['default_options'] as $opt => $val) |
|
1014 | 1066 | { |
1015 | 1067 | if (in_array($opt, $custom_fields)) |
1016 | 1068 | continue; |
1069 | + } |
|
1017 | 1070 | |
1018 | 1071 | // These need to be controlled. |
1019 | - if ($opt == 'topics_per_page' || $opt == 'messages_per_page') |
|
1020 | - $val = max(0, min($val, 50)); |
|
1072 | + if ($opt == 'topics_per_page' || $opt == 'messages_per_page') { |
|
1073 | + $val = max(0, min($val, 50)); |
|
1074 | + } |
|
1021 | 1075 | // Only let admins and owners change the censor. |
1022 | - elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) |
|
1023 | - continue; |
|
1076 | + elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) { |
|
1077 | + continue; |
|
1078 | + } |
|
1024 | 1079 | |
1025 | 1080 | $themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val); |
1026 | 1081 | $erase_options[] = $opt; |
@@ -1056,8 +1111,9 @@ discard block |
||
1056 | 1111 | |
1057 | 1112 | // Admins can choose any theme, even if it's not enabled... |
1058 | 1113 | $themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']); |
1059 | - foreach ($themes as $t) |
|
1060 | - cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1114 | + foreach ($themes as $t) { |
|
1115 | + cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60); |
|
1116 | + } |
|
1061 | 1117 | } |
1062 | 1118 | } |
1063 | 1119 | |
@@ -1076,8 +1132,9 @@ discard block |
||
1076 | 1132 | if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards'])) |
1077 | 1133 | { |
1078 | 1134 | // Make sure only integers are deleted. |
1079 | - foreach ($_POST['notify_boards'] as $index => $id) |
|
1080 | - $_POST['notify_boards'][$index] = (int) $id; |
|
1135 | + foreach ($_POST['notify_boards'] as $index => $id) { |
|
1136 | + $_POST['notify_boards'][$index] = (int) $id; |
|
1137 | + } |
|
1081 | 1138 | |
1082 | 1139 | // id_board = 0 is reserved for topic notifications. |
1083 | 1140 | $_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0)); |
@@ -1096,8 +1153,9 @@ discard block |
||
1096 | 1153 | // We are editing topic notifications...... |
1097 | 1154 | elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics'])) |
1098 | 1155 | { |
1099 | - foreach ($_POST['notify_topics'] as $index => $id) |
|
1100 | - $_POST['notify_topics'][$index] = (int) $id; |
|
1156 | + foreach ($_POST['notify_topics'] as $index => $id) { |
|
1157 | + $_POST['notify_topics'][$index] = (int) $id; |
|
1158 | + } |
|
1101 | 1159 | |
1102 | 1160 | // Make sure there are no zeros left. |
1103 | 1161 | $_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0)); |
@@ -1111,16 +1169,18 @@ discard block |
||
1111 | 1169 | 'selected_member' => $memID, |
1112 | 1170 | ) |
1113 | 1171 | ); |
1114 | - foreach ($_POST['notify_topics'] as $topic) |
|
1115 | - setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1172 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1173 | + setNotifyPrefs($memID, array('topic_notify_' . $topic => 0)); |
|
1174 | + } |
|
1116 | 1175 | } |
1117 | 1176 | |
1118 | 1177 | // We are removing topic preferences |
1119 | 1178 | elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics'])) |
1120 | 1179 | { |
1121 | 1180 | $prefs = array(); |
1122 | - foreach ($_POST['notify_topics'] as $topic) |
|
1123 | - $prefs[] = 'topic_notify_' . $topic; |
|
1181 | + foreach ($_POST['notify_topics'] as $topic) { |
|
1182 | + $prefs[] = 'topic_notify_' . $topic; |
|
1183 | + } |
|
1124 | 1184 | deleteNotifyPrefs($memID, $prefs); |
1125 | 1185 | } |
1126 | 1186 | |
@@ -1128,8 +1188,9 @@ discard block |
||
1128 | 1188 | elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards'])) |
1129 | 1189 | { |
1130 | 1190 | $prefs = array(); |
1131 | - foreach ($_POST['notify_boards'] as $board) |
|
1132 | - $prefs[] = 'board_notify_' . $board; |
|
1191 | + foreach ($_POST['notify_boards'] as $board) { |
|
1192 | + $prefs[] = 'board_notify_' . $board; |
|
1193 | + } |
|
1133 | 1194 | deleteNotifyPrefs($memID, $prefs); |
1134 | 1195 | } |
1135 | 1196 | } |
@@ -1150,8 +1211,9 @@ discard block |
||
1150 | 1211 | |
1151 | 1212 | $errors = array(); |
1152 | 1213 | |
1153 | - if ($sanitize && isset($_POST['customfield'])) |
|
1154 | - $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1214 | + if ($sanitize && isset($_POST['customfield'])) { |
|
1215 | + $_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']); |
|
1216 | + } |
|
1155 | 1217 | |
1156 | 1218 | $where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}'; |
1157 | 1219 | |
@@ -1176,48 +1238,49 @@ discard block |
||
1176 | 1238 | - The data is not invisible to users but editable by the owner (or if it is the user is not the owner) |
1177 | 1239 | - The area isn't registration, and if it is that the field is not supposed to be shown there. |
1178 | 1240 | */ |
1179 | - if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) |
|
1180 | - continue; |
|
1241 | + if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) { |
|
1242 | + continue; |
|
1243 | + } |
|
1181 | 1244 | |
1182 | 1245 | // Validate the user data. |
1183 | - if ($row['field_type'] == 'check') |
|
1184 | - $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1185 | - elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1246 | + if ($row['field_type'] == 'check') { |
|
1247 | + $value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0; |
|
1248 | + } elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio') |
|
1186 | 1249 | { |
1187 | 1250 | $value = $row['default_value']; |
1188 | - foreach (explode(',', $row['field_options']) as $k => $v) |
|
1189 | - if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1251 | + foreach (explode(',', $row['field_options']) as $k => $v) { |
|
1252 | + if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k) |
|
1190 | 1253 | $value = $v; |
1254 | + } |
|
1191 | 1255 | } |
1192 | 1256 | // Otherwise some form of text! |
1193 | 1257 | else |
1194 | 1258 | { |
1195 | 1259 | $value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : ''; |
1196 | - if ($row['field_length']) |
|
1197 | - $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1260 | + if ($row['field_length']) { |
|
1261 | + $value = $smcFunc['substr']($value, 0, $row['field_length']); |
|
1262 | + } |
|
1198 | 1263 | |
1199 | 1264 | // Any masks? |
1200 | 1265 | if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') |
1201 | 1266 | { |
1202 | 1267 | if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255)) |
1203 | 1268 | { |
1204 | - if ($returnErrors) |
|
1205 | - $errors[] = 'custom_field_mail_fail'; |
|
1206 | - |
|
1207 | - else |
|
1208 | - $value = ''; |
|
1209 | - } |
|
1210 | - elseif ($row['mask'] == 'number') |
|
1269 | + if ($returnErrors) { |
|
1270 | + $errors[] = 'custom_field_mail_fail'; |
|
1271 | + } else { |
|
1272 | + $value = ''; |
|
1273 | + } |
|
1274 | + } elseif ($row['mask'] == 'number') |
|
1211 | 1275 | { |
1212 | 1276 | $value = (int) $value; |
1213 | - } |
|
1214 | - elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1277 | + } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0) |
|
1215 | 1278 | { |
1216 | - if ($returnErrors) |
|
1217 | - $errors[] = 'custom_field_regex_fail'; |
|
1218 | - |
|
1219 | - else |
|
1220 | - $value = ''; |
|
1279 | + if ($returnErrors) { |
|
1280 | + $errors[] = 'custom_field_regex_fail'; |
|
1281 | + } else { |
|
1282 | + $value = ''; |
|
1283 | + } |
|
1221 | 1284 | } |
1222 | 1285 | } |
1223 | 1286 | } |
@@ -1243,8 +1306,9 @@ discard block |
||
1243 | 1306 | |
1244 | 1307 | $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize)); |
1245 | 1308 | |
1246 | - if (!empty($hook_errors) && is_array($hook_errors)) |
|
1247 | - $errors = array_merge($errors, $hook_errors); |
|
1309 | + if (!empty($hook_errors) && is_array($hook_errors)) { |
|
1310 | + $errors = array_merge($errors, $hook_errors); |
|
1311 | + } |
|
1248 | 1312 | |
1249 | 1313 | // Make those changes! |
1250 | 1314 | if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors)) |
@@ -1262,9 +1326,10 @@ discard block |
||
1262 | 1326 | } |
1263 | 1327 | } |
1264 | 1328 | |
1265 | - if ($returnErrors) |
|
1266 | - return $errors; |
|
1267 | -} |
|
1329 | + if ($returnErrors) { |
|
1330 | + return $errors; |
|
1331 | + } |
|
1332 | + } |
|
1268 | 1333 | |
1269 | 1334 | /** |
1270 | 1335 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1276,8 +1341,9 @@ discard block |
||
1276 | 1341 | global $context, $txt, $modSettings; |
1277 | 1342 | |
1278 | 1343 | // Do a quick check to ensure people aren't getting here illegally! |
1279 | - if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) |
|
1280 | - fatal_lang_error('no_access', false); |
|
1344 | + if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) { |
|
1345 | + fatal_lang_error('no_access', false); |
|
1346 | + } |
|
1281 | 1347 | |
1282 | 1348 | // Can we email the user direct? |
1283 | 1349 | $context['can_moderate_forum'] = allowedTo('moderate_forum'); |
@@ -1307,9 +1373,10 @@ discard block |
||
1307 | 1373 | $context['sub_template'] = $subActions[$context['list_area']][0]; |
1308 | 1374 | $call = call_helper($subActions[$context['list_area']][0], true); |
1309 | 1375 | |
1310 | - if (!empty($call)) |
|
1311 | - call_user_func($call, $memID); |
|
1312 | -} |
|
1376 | + if (!empty($call)) { |
|
1377 | + call_user_func($call, $memID); |
|
1378 | + } |
|
1379 | + } |
|
1313 | 1380 | |
1314 | 1381 | /** |
1315 | 1382 | * Show all the users buddies, as well as a add/delete interface. |
@@ -1323,9 +1390,10 @@ discard block |
||
1323 | 1390 | |
1324 | 1391 | // For making changes! |
1325 | 1392 | $buddiesArray = explode(',', $user_profile[$memID]['buddy_list']); |
1326 | - foreach ($buddiesArray as $k => $dummy) |
|
1327 | - if ($dummy == '') |
|
1393 | + foreach ($buddiesArray as $k => $dummy) { |
|
1394 | + if ($dummy == '') |
|
1328 | 1395 | unset($buddiesArray[$k]); |
1396 | + } |
|
1329 | 1397 | |
1330 | 1398 | // Removing a buddy? |
1331 | 1399 | if (isset($_GET['remove'])) |
@@ -1337,10 +1405,11 @@ discard block |
||
1337 | 1405 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1338 | 1406 | |
1339 | 1407 | // Heh, I'm lazy, do it the easy way... |
1340 | - foreach ($buddiesArray as $key => $buddy) |
|
1341 | - if ($buddy == (int) $_GET['remove']) |
|
1408 | + foreach ($buddiesArray as $key => $buddy) { |
|
1409 | + if ($buddy == (int) $_GET['remove']) |
|
1342 | 1410 | { |
1343 | 1411 | unset($buddiesArray[$key]); |
1412 | + } |
|
1344 | 1413 | $_SESSION['prf-save'] = true; |
1345 | 1414 | } |
1346 | 1415 | |
@@ -1350,8 +1419,7 @@ discard block |
||
1350 | 1419 | |
1351 | 1420 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1352 | 1421 | redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID); |
1353 | - } |
|
1354 | - elseif (isset($_POST['new_buddy'])) |
|
1422 | + } elseif (isset($_POST['new_buddy'])) |
|
1355 | 1423 | { |
1356 | 1424 | checkSession(); |
1357 | 1425 | |
@@ -1364,8 +1432,9 @@ discard block |
||
1364 | 1432 | { |
1365 | 1433 | $new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => ''')); |
1366 | 1434 | |
1367 | - if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1368 | - unset($new_buddies[$k]); |
|
1435 | + if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1436 | + unset($new_buddies[$k]); |
|
1437 | + } |
|
1369 | 1438 | } |
1370 | 1439 | |
1371 | 1440 | call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies)); |
@@ -1385,16 +1454,18 @@ discard block |
||
1385 | 1454 | ) |
1386 | 1455 | ); |
1387 | 1456 | |
1388 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1389 | - $_SESSION['prf-save'] = true; |
|
1457 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1458 | + $_SESSION['prf-save'] = true; |
|
1459 | + } |
|
1390 | 1460 | |
1391 | 1461 | // Add the new member to the buddies array. |
1392 | 1462 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1393 | 1463 | { |
1394 | - if (in_array($row['id_member'], $buddiesArray)) |
|
1395 | - continue; |
|
1396 | - else |
|
1397 | - $buddiesArray[] = (int) $row['id_member']; |
|
1464 | + if (in_array($row['id_member'], $buddiesArray)) { |
|
1465 | + continue; |
|
1466 | + } else { |
|
1467 | + $buddiesArray[] = (int) $row['id_member']; |
|
1468 | + } |
|
1398 | 1469 | } |
1399 | 1470 | $smcFunc['db_free_result']($request); |
1400 | 1471 | |
@@ -1424,18 +1495,20 @@ discard block |
||
1424 | 1495 | |
1425 | 1496 | $context['custom_pf'] = array(); |
1426 | 1497 | $disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
1427 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1428 | - if (!isset($disabled_fields[$row['col_name']])) |
|
1498 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1499 | + if (!isset($disabled_fields[$row['col_name']])) |
|
1429 | 1500 | $context['custom_pf'][$row['col_name']] = array( |
1430 | 1501 | 'label' => $row['field_name'], |
1431 | 1502 | 'type' => $row['field_type'], |
1432 | 1503 | 'bbc' => !empty($row['bbc']), |
1433 | 1504 | 'enclose' => $row['enclose'], |
1434 | 1505 | ); |
1506 | + } |
|
1435 | 1507 | |
1436 | 1508 | // Gotta disable the gender option. |
1437 | - if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') |
|
1438 | - unset($context['custom_pf']['cust_gender']); |
|
1509 | + if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') { |
|
1510 | + unset($context['custom_pf']['cust_gender']); |
|
1511 | + } |
|
1439 | 1512 | |
1440 | 1513 | $smcFunc['db_free_result']($request); |
1441 | 1514 | |
@@ -1452,8 +1525,9 @@ discard block |
||
1452 | 1525 | 'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1, |
1453 | 1526 | ) |
1454 | 1527 | ); |
1455 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1456 | - $buddies[] = $row['id_member']; |
|
1528 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1529 | + $buddies[] = $row['id_member']; |
|
1530 | + } |
|
1457 | 1531 | $smcFunc['db_free_result']($result); |
1458 | 1532 | } |
1459 | 1533 | |
@@ -1481,30 +1555,32 @@ discard block |
||
1481 | 1555 | continue; |
1482 | 1556 | } |
1483 | 1557 | |
1484 | - if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1485 | - $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1486 | - |
|
1487 | - elseif ($column['type'] == 'check') |
|
1488 | - $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1558 | + if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1559 | + $context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key])); |
|
1560 | + } elseif ($column['type'] == 'check') { |
|
1561 | + $context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
1562 | + } |
|
1489 | 1563 | |
1490 | 1564 | // Enclosing the user input within some other text? |
1491 | - if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) |
|
1492 | - $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1565 | + if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) { |
|
1566 | + $context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array( |
|
1493 | 1567 | '{SCRIPTURL}' => $scripturl, |
1494 | 1568 | '{IMAGES_URL}' => $settings['images_url'], |
1495 | 1569 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1496 | 1570 | '{INPUT}' => $context['buddies'][$buddy]['options'][$key], |
1497 | 1571 | )); |
1572 | + } |
|
1498 | 1573 | } |
1499 | 1574 | } |
1500 | 1575 | } |
1501 | 1576 | |
1502 | 1577 | if (isset($_SESSION['prf-save'])) |
1503 | 1578 | { |
1504 | - if ($_SESSION['prf-save'] === true) |
|
1505 | - $context['saved_successful'] = true; |
|
1506 | - else |
|
1507 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1579 | + if ($_SESSION['prf-save'] === true) { |
|
1580 | + $context['saved_successful'] = true; |
|
1581 | + } else { |
|
1582 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1583 | + } |
|
1508 | 1584 | |
1509 | 1585 | unset($_SESSION['prf-save']); |
1510 | 1586 | } |
@@ -1524,9 +1600,10 @@ discard block |
||
1524 | 1600 | |
1525 | 1601 | // For making changes! |
1526 | 1602 | $ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']); |
1527 | - foreach ($ignoreArray as $k => $dummy) |
|
1528 | - if ($dummy == '') |
|
1603 | + foreach ($ignoreArray as $k => $dummy) { |
|
1604 | + if ($dummy == '') |
|
1529 | 1605 | unset($ignoreArray[$k]); |
1606 | + } |
|
1530 | 1607 | |
1531 | 1608 | // Removing a member from the ignore list? |
1532 | 1609 | if (isset($_GET['remove'])) |
@@ -1536,10 +1613,11 @@ discard block |
||
1536 | 1613 | $_SESSION['prf-save'] = $txt['could_not_remove_person']; |
1537 | 1614 | |
1538 | 1615 | // Heh, I'm lazy, do it the easy way... |
1539 | - foreach ($ignoreArray as $key => $id_remove) |
|
1540 | - if ($id_remove == (int) $_GET['remove']) |
|
1616 | + foreach ($ignoreArray as $key => $id_remove) { |
|
1617 | + if ($id_remove == (int) $_GET['remove']) |
|
1541 | 1618 | { |
1542 | 1619 | unset($ignoreArray[$key]); |
1620 | + } |
|
1543 | 1621 | $_SESSION['prf-save'] = true; |
1544 | 1622 | } |
1545 | 1623 | |
@@ -1549,8 +1627,7 @@ discard block |
||
1549 | 1627 | |
1550 | 1628 | // Redirect off the page because we don't like all this ugly query stuff to stick in the history. |
1551 | 1629 | redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID); |
1552 | - } |
|
1553 | - elseif (isset($_POST['new_ignore'])) |
|
1630 | + } elseif (isset($_POST['new_ignore'])) |
|
1554 | 1631 | { |
1555 | 1632 | checkSession(); |
1556 | 1633 | // Prepare the string for extraction... |
@@ -1562,8 +1639,9 @@ discard block |
||
1562 | 1639 | { |
1563 | 1640 | $new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => ''')); |
1564 | 1641 | |
1565 | - if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) |
|
1566 | - unset($new_entries[$k]); |
|
1642 | + if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) { |
|
1643 | + unset($new_entries[$k]); |
|
1644 | + } |
|
1567 | 1645 | } |
1568 | 1646 | |
1569 | 1647 | $_SESSION['prf-save'] = $txt['could_not_add_person']; |
@@ -1581,16 +1659,18 @@ discard block |
||
1581 | 1659 | ) |
1582 | 1660 | ); |
1583 | 1661 | |
1584 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
1585 | - $_SESSION['prf-save'] = true; |
|
1662 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
1663 | + $_SESSION['prf-save'] = true; |
|
1664 | + } |
|
1586 | 1665 | |
1587 | 1666 | // Add the new member to the buddies array. |
1588 | 1667 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1589 | 1668 | { |
1590 | - if (in_array($row['id_member'], $ignoreArray)) |
|
1591 | - continue; |
|
1592 | - else |
|
1593 | - $ignoreArray[] = (int) $row['id_member']; |
|
1669 | + if (in_array($row['id_member'], $ignoreArray)) { |
|
1670 | + continue; |
|
1671 | + } else { |
|
1672 | + $ignoreArray[] = (int) $row['id_member']; |
|
1673 | + } |
|
1594 | 1674 | } |
1595 | 1675 | $smcFunc['db_free_result']($request); |
1596 | 1676 | |
@@ -1619,8 +1699,9 @@ discard block |
||
1619 | 1699 | 'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1, |
1620 | 1700 | ) |
1621 | 1701 | ); |
1622 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1623 | - $ignored[] = $row['id_member']; |
|
1702 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1703 | + $ignored[] = $row['id_member']; |
|
1704 | + } |
|
1624 | 1705 | $smcFunc['db_free_result']($result); |
1625 | 1706 | } |
1626 | 1707 | |
@@ -1639,10 +1720,11 @@ discard block |
||
1639 | 1720 | |
1640 | 1721 | if (isset($_SESSION['prf-save'])) |
1641 | 1722 | { |
1642 | - if ($_SESSION['prf-save'] === true) |
|
1643 | - $context['saved_successful'] = true; |
|
1644 | - else |
|
1645 | - $context['saved_failed'] = $_SESSION['prf-save']; |
|
1723 | + if ($_SESSION['prf-save'] === true) { |
|
1724 | + $context['saved_successful'] = true; |
|
1725 | + } else { |
|
1726 | + $context['saved_failed'] = $_SESSION['prf-save']; |
|
1727 | + } |
|
1646 | 1728 | |
1647 | 1729 | unset($_SESSION['prf-save']); |
1648 | 1730 | } |
@@ -1658,8 +1740,9 @@ discard block |
||
1658 | 1740 | global $context, $txt; |
1659 | 1741 | |
1660 | 1742 | loadThemeOptions($memID); |
1661 | - if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) |
|
1662 | - loadCustomFields($memID, 'account'); |
|
1743 | + if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) { |
|
1744 | + loadCustomFields($memID, 'account'); |
|
1745 | + } |
|
1663 | 1746 | |
1664 | 1747 | $context['sub_template'] = 'edit_options'; |
1665 | 1748 | $context['page_desc'] = $txt['account_info']; |
@@ -1686,8 +1769,9 @@ discard block |
||
1686 | 1769 | global $context, $txt; |
1687 | 1770 | |
1688 | 1771 | loadThemeOptions($memID); |
1689 | - if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) |
|
1690 | - loadCustomFields($memID, 'forumprofile'); |
|
1772 | + if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) { |
|
1773 | + loadCustomFields($memID, 'forumprofile'); |
|
1774 | + } |
|
1691 | 1775 | |
1692 | 1776 | $context['sub_template'] = 'edit_options'; |
1693 | 1777 | $context['page_desc'] = $txt['forumProfile_info']; |
@@ -1720,18 +1804,21 @@ discard block |
||
1720 | 1804 | $dirs = array(); |
1721 | 1805 | $files = array(); |
1722 | 1806 | |
1723 | - if (!$dir) |
|
1724 | - return array(); |
|
1807 | + if (!$dir) { |
|
1808 | + return array(); |
|
1809 | + } |
|
1725 | 1810 | |
1726 | 1811 | while ($line = $dir->read()) |
1727 | 1812 | { |
1728 | - if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) |
|
1729 | - continue; |
|
1813 | + if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) { |
|
1814 | + continue; |
|
1815 | + } |
|
1730 | 1816 | |
1731 | - if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) |
|
1732 | - $dirs[] = $line; |
|
1733 | - else |
|
1734 | - $files[] = $line; |
|
1817 | + if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) { |
|
1818 | + $dirs[] = $line; |
|
1819 | + } else { |
|
1820 | + $files[] = $line; |
|
1821 | + } |
|
1735 | 1822 | } |
1736 | 1823 | $dir->close(); |
1737 | 1824 | |
@@ -1752,14 +1839,15 @@ discard block |
||
1752 | 1839 | foreach ($dirs as $line) |
1753 | 1840 | { |
1754 | 1841 | $tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1); |
1755 | - if (!empty($tmp)) |
|
1756 | - $result[] = array( |
|
1842 | + if (!empty($tmp)) { |
|
1843 | + $result[] = array( |
|
1757 | 1844 | 'filename' => $smcFunc['htmlspecialchars']($line), |
1758 | 1845 | 'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false, |
1759 | 1846 | 'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']', |
1760 | 1847 | 'is_dir' => true, |
1761 | 1848 | 'files' => $tmp |
1762 | 1849 | ); |
1850 | + } |
|
1763 | 1851 | unset($tmp); |
1764 | 1852 | } |
1765 | 1853 | |
@@ -1769,8 +1857,9 @@ discard block |
||
1769 | 1857 | $extension = substr(strrchr($line, '.'), 1); |
1770 | 1858 | |
1771 | 1859 | // Make sure it is an image. |
1772 | - if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) |
|
1773 | - continue; |
|
1860 | + if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) { |
|
1861 | + continue; |
|
1862 | + } |
|
1774 | 1863 | |
1775 | 1864 | $result[] = array( |
1776 | 1865 | 'filename' => $smcFunc['htmlspecialchars']($line), |
@@ -1778,8 +1867,9 @@ discard block |
||
1778 | 1867 | 'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)), |
1779 | 1868 | 'is_dir' => false |
1780 | 1869 | ); |
1781 | - if ($level == 1) |
|
1782 | - $context['avatar_list'][] = $directory . '/' . $line; |
|
1870 | + if ($level == 1) { |
|
1871 | + $context['avatar_list'][] = $directory . '/' . $line; |
|
1872 | + } |
|
1783 | 1873 | } |
1784 | 1874 | |
1785 | 1875 | return $result; |
@@ -1795,8 +1885,9 @@ discard block |
||
1795 | 1885 | global $txt, $context; |
1796 | 1886 | |
1797 | 1887 | loadThemeOptions($memID); |
1798 | - if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) |
|
1799 | - loadCustomFields($memID, 'theme'); |
|
1888 | + if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) { |
|
1889 | + loadCustomFields($memID, 'theme'); |
|
1890 | + } |
|
1800 | 1891 | |
1801 | 1892 | $context['sub_template'] = 'edit_options'; |
1802 | 1893 | $context['page_desc'] = $txt['theme_info']; |
@@ -1850,16 +1941,19 @@ discard block |
||
1850 | 1941 | { |
1851 | 1942 | global $txt, $user_profile, $context, $modSettings, $smcFunc, $sourcedir; |
1852 | 1943 | |
1853 | - if (!isset($context['token_check'])) |
|
1854 | - $context['token_check'] = 'profile-nt' . $memID; |
|
1944 | + if (!isset($context['token_check'])) { |
|
1945 | + $context['token_check'] = 'profile-nt' . $memID; |
|
1946 | + } |
|
1855 | 1947 | |
1856 | 1948 | is_not_guest(); |
1857 | - if (!$context['user']['is_owner']) |
|
1858 | - isAllowedTo('profile_extra_any'); |
|
1949 | + if (!$context['user']['is_owner']) { |
|
1950 | + isAllowedTo('profile_extra_any'); |
|
1951 | + } |
|
1859 | 1952 | |
1860 | 1953 | // Set the post action if we're coming from the profile... |
1861 | - if (!isset($context['action'])) |
|
1862 | - $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1954 | + if (!isset($context['action'])) { |
|
1955 | + $context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID; |
|
1956 | + } |
|
1863 | 1957 | |
1864 | 1958 | // What options are set |
1865 | 1959 | loadThemeOptions($memID); |
@@ -1946,28 +2040,34 @@ discard block |
||
1946 | 2040 | ); |
1947 | 2041 | |
1948 | 2042 | // There are certain things that are disabled at the group level. |
1949 | - if (empty($modSettings['cal_enabled'])) |
|
1950 | - unset($alert_types['calendar']); |
|
2043 | + if (empty($modSettings['cal_enabled'])) { |
|
2044 | + unset($alert_types['calendar']); |
|
2045 | + } |
|
1951 | 2046 | |
1952 | 2047 | // Disable paid subscriptions at group level if they're disabled |
1953 | - if (empty($modSettings['paid_enabled'])) |
|
1954 | - unset($alert_types['paidsubs']); |
|
2048 | + if (empty($modSettings['paid_enabled'])) { |
|
2049 | + unset($alert_types['paidsubs']); |
|
2050 | + } |
|
1955 | 2051 | |
1956 | 2052 | // Disable membergroup requests at group level if they're disabled |
1957 | - if (empty($modSettings['show_group_membership'])) |
|
1958 | - unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2053 | + if (empty($modSettings['show_group_membership'])) { |
|
2054 | + unset($alert_types['groupr'], $alert_types['members']['request_group']); |
|
2055 | + } |
|
1959 | 2056 | |
1960 | 2057 | // Disable mentions if they're disabled |
1961 | - if (empty($modSettings['enable_mentions'])) |
|
1962 | - unset($alert_types['msg']['msg_mention']); |
|
2058 | + if (empty($modSettings['enable_mentions'])) { |
|
2059 | + unset($alert_types['msg']['msg_mention']); |
|
2060 | + } |
|
1963 | 2061 | |
1964 | 2062 | // Disable likes if they're disabled |
1965 | - if (empty($modSettings['enable_likes'])) |
|
1966 | - unset($alert_types['msg']['msg_like']); |
|
2063 | + if (empty($modSettings['enable_likes'])) { |
|
2064 | + unset($alert_types['msg']['msg_like']); |
|
2065 | + } |
|
1967 | 2066 | |
1968 | 2067 | // Disable buddy requests if they're disabled |
1969 | - if (empty($modSettings['enable_buddylist'])) |
|
1970 | - unset($alert_types['members']['buddy_request']); |
|
2068 | + if (empty($modSettings['enable_buddylist'])) { |
|
2069 | + unset($alert_types['members']['buddy_request']); |
|
2070 | + } |
|
1971 | 2071 | |
1972 | 2072 | // Now, now, we could pass this through global but we should really get into the habit of |
1973 | 2073 | // passing content to hooks, not expecting hooks to splatter everything everywhere. |
@@ -1995,15 +2095,17 @@ discard block |
||
1995 | 2095 | $perms_cache['manage_membergroups'] = in_array($memID, $members); |
1996 | 2096 | } |
1997 | 2097 | |
1998 | - if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) |
|
1999 | - unset($alert_types['members']['request_group']); |
|
2098 | + if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) { |
|
2099 | + unset($alert_types['members']['request_group']); |
|
2100 | + } |
|
2000 | 2101 | |
2001 | 2102 | foreach ($alert_types as $group => $items) |
2002 | 2103 | { |
2003 | 2104 | foreach ($items as $alert_key => $alert_value) |
2004 | 2105 | { |
2005 | - if (!isset($alert_value['permission'])) |
|
2006 | - continue; |
|
2106 | + if (!isset($alert_value['permission'])) { |
|
2107 | + continue; |
|
2108 | + } |
|
2007 | 2109 | if (!isset($perms_cache[$alert_value['permission']['name']])) |
2008 | 2110 | { |
2009 | 2111 | $in_board = !empty($alert_value['permission']['is_board']) ? 0 : null; |
@@ -2011,12 +2113,14 @@ discard block |
||
2011 | 2113 | $perms_cache[$alert_value['permission']['name']] = in_array($memID, $members); |
2012 | 2114 | } |
2013 | 2115 | |
2014 | - if (!$perms_cache[$alert_value['permission']['name']]) |
|
2015 | - unset ($alert_types[$group][$alert_key]); |
|
2116 | + if (!$perms_cache[$alert_value['permission']['name']]) { |
|
2117 | + unset ($alert_types[$group][$alert_key]); |
|
2118 | + } |
|
2016 | 2119 | } |
2017 | 2120 | |
2018 | - if (empty($alert_types[$group])) |
|
2019 | - unset ($alert_types[$group]); |
|
2121 | + if (empty($alert_types[$group])) { |
|
2122 | + unset ($alert_types[$group]); |
|
2123 | + } |
|
2020 | 2124 | } |
2021 | 2125 | } |
2022 | 2126 | |
@@ -2048,9 +2152,9 @@ discard block |
||
2048 | 2152 | $update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0; |
2049 | 2153 | break; |
2050 | 2154 | case 'select': |
2051 | - if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) |
|
2052 | - $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2053 | - else |
|
2155 | + if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) { |
|
2156 | + $update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]]; |
|
2157 | + } else |
|
2054 | 2158 | { |
2055 | 2159 | // We didn't have a sane value. Let's grab the first item from the possibles. |
2056 | 2160 | $keys = array_keys($this_option['opts']); |
@@ -2070,23 +2174,28 @@ discard block |
||
2070 | 2174 | $this_value = 0; |
2071 | 2175 | foreach ($context['alert_bits'] as $type => $bitvalue) |
2072 | 2176 | { |
2073 | - if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') |
|
2074 | - $this_value |= $bitvalue; |
|
2177 | + if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') { |
|
2178 | + $this_value |= $bitvalue; |
|
2179 | + } |
|
2180 | + } |
|
2181 | + if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) { |
|
2182 | + $update_prefs[$item_key] = $this_value; |
|
2075 | 2183 | } |
2076 | - if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) |
|
2077 | - $update_prefs[$item_key] = $this_value; |
|
2078 | 2184 | } |
2079 | 2185 | } |
2080 | 2186 | |
2081 | - if (!empty($_POST['opt_alert_timeout'])) |
|
2082 | - $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2187 | + if (!empty($_POST['opt_alert_timeout'])) { |
|
2188 | + $update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout']; |
|
2189 | + } |
|
2083 | 2190 | |
2084 | - if (!empty($_POST['notify_announcements'])) |
|
2085 | - $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2191 | + if (!empty($_POST['notify_announcements'])) { |
|
2192 | + $update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements']; |
|
2193 | + } |
|
2086 | 2194 | |
2087 | 2195 | setNotifyPrefs((int) $memID, $update_prefs); |
2088 | - foreach ($update_prefs as $pref => $value) |
|
2089 | - $context['alert_prefs'][$pref] = $value; |
|
2196 | + foreach ($update_prefs as $pref => $value) { |
|
2197 | + $context['alert_prefs'][$pref] = $value; |
|
2198 | + } |
|
2090 | 2199 | |
2091 | 2200 | makeNotificationChanges($memID); |
2092 | 2201 | |
@@ -2116,8 +2225,9 @@ discard block |
||
2116 | 2225 | |
2117 | 2226 | // Now we're all set up. |
2118 | 2227 | is_not_guest(); |
2119 | - if (!$context['user']['is_owner']) |
|
2120 | - fatal_error('no_access'); |
|
2228 | + if (!$context['user']['is_owner']) { |
|
2229 | + fatal_error('no_access'); |
|
2230 | + } |
|
2121 | 2231 | |
2122 | 2232 | checkSession('get'); |
2123 | 2233 | |
@@ -2149,8 +2259,9 @@ discard block |
||
2149 | 2259 | { |
2150 | 2260 | global $smcFunc; |
2151 | 2261 | |
2152 | - if (empty($toMark) || empty($memID)) |
|
2153 | - return false; |
|
2262 | + if (empty($toMark) || empty($memID)) { |
|
2263 | + return false; |
|
2264 | + } |
|
2154 | 2265 | |
2155 | 2266 | $toMark = (array) $toMark; |
2156 | 2267 | |
@@ -2184,8 +2295,9 @@ discard block |
||
2184 | 2295 | { |
2185 | 2296 | global $smcFunc; |
2186 | 2297 | |
2187 | - if (empty($toDelete)) |
|
2188 | - return false; |
|
2298 | + if (empty($toDelete)) { |
|
2299 | + return false; |
|
2300 | + } |
|
2189 | 2301 | |
2190 | 2302 | $toDelete = (array) $toDelete; |
2191 | 2303 | |
@@ -2220,8 +2332,9 @@ discard block |
||
2220 | 2332 | { |
2221 | 2333 | global $smcFunc; |
2222 | 2334 | |
2223 | - if (empty($memID)) |
|
2224 | - return false; |
|
2335 | + if (empty($memID)) { |
|
2336 | + return false; |
|
2337 | + } |
|
2225 | 2338 | |
2226 | 2339 | $request = $smcFunc['db_query']('', ' |
2227 | 2340 | SELECT id_alert |
@@ -2298,8 +2411,9 @@ discard block |
||
2298 | 2411 | { |
2299 | 2412 | $link = $topic['link']; |
2300 | 2413 | |
2301 | - if ($topic['new']) |
|
2302 | - $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2414 | + if ($topic['new']) { |
|
2415 | + $link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2416 | + } |
|
2303 | 2417 | |
2304 | 2418 | $link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>'; |
2305 | 2419 | |
@@ -2450,8 +2564,9 @@ discard block |
||
2450 | 2564 | { |
2451 | 2565 | $link = $board['link']; |
2452 | 2566 | |
2453 | - if ($board['new']) |
|
2454 | - $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2567 | + if ($board['new']) { |
|
2568 | + $link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>'; |
|
2569 | + } |
|
2455 | 2570 | |
2456 | 2571 | return $link; |
2457 | 2572 | }, |
@@ -2651,8 +2766,8 @@ discard block |
||
2651 | 2766 | ) |
2652 | 2767 | ); |
2653 | 2768 | $notification_boards = array(); |
2654 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2655 | - $notification_boards[] = array( |
|
2769 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2770 | + $notification_boards[] = array( |
|
2656 | 2771 | 'id' => $row['id_board'], |
2657 | 2772 | 'name' => $row['name'], |
2658 | 2773 | 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', |
@@ -2660,6 +2775,7 @@ discard block |
||
2660 | 2775 | 'new' => $row['board_read'] < $row['id_msg_updated'], |
2661 | 2776 | 'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0), |
2662 | 2777 | ); |
2778 | + } |
|
2663 | 2779 | $smcFunc['db_free_result']($request); |
2664 | 2780 | |
2665 | 2781 | return $notification_boards; |
@@ -2674,17 +2790,18 @@ discard block |
||
2674 | 2790 | { |
2675 | 2791 | global $context, $options, $cur_profile, $smcFunc; |
2676 | 2792 | |
2677 | - if (isset($_POST['default_options'])) |
|
2678 | - $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2793 | + if (isset($_POST['default_options'])) { |
|
2794 | + $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options']; |
|
2795 | + } |
|
2679 | 2796 | |
2680 | 2797 | if ($context['user']['is_owner']) |
2681 | 2798 | { |
2682 | 2799 | $context['member']['options'] = $options; |
2683 | - if (isset($_POST['options']) && is_array($_POST['options'])) |
|
2684 | - foreach ($_POST['options'] as $k => $v) |
|
2800 | + if (isset($_POST['options']) && is_array($_POST['options'])) { |
|
2801 | + foreach ($_POST['options'] as $k => $v) |
|
2685 | 2802 | $context['member']['options'][$k] = $v; |
2686 | - } |
|
2687 | - else |
|
2803 | + } |
|
2804 | + } else |
|
2688 | 2805 | { |
2689 | 2806 | $request = $smcFunc['db_query']('', ' |
2690 | 2807 | SELECT id_member, variable, value |
@@ -2705,8 +2822,9 @@ discard block |
||
2705 | 2822 | continue; |
2706 | 2823 | } |
2707 | 2824 | |
2708 | - if (isset($_POST['options'][$row['variable']])) |
|
2709 | - $row['value'] = $_POST['options'][$row['variable']]; |
|
2825 | + if (isset($_POST['options'][$row['variable']])) { |
|
2826 | + $row['value'] = $_POST['options'][$row['variable']]; |
|
2827 | + } |
|
2710 | 2828 | $context['member']['options'][$row['variable']] = $row['value']; |
2711 | 2829 | } |
2712 | 2830 | $smcFunc['db_free_result']($request); |
@@ -2714,8 +2832,9 @@ discard block |
||
2714 | 2832 | // Load up the default theme options for any missing. |
2715 | 2833 | foreach ($temp as $k => $v) |
2716 | 2834 | { |
2717 | - if (!isset($context['member']['options'][$k])) |
|
2718 | - $context['member']['options'][$k] = $v; |
|
2835 | + if (!isset($context['member']['options'][$k])) { |
|
2836 | + $context['member']['options'][$k] = $v; |
|
2837 | + } |
|
2719 | 2838 | } |
2720 | 2839 | } |
2721 | 2840 | } |
@@ -2730,8 +2849,9 @@ discard block |
||
2730 | 2849 | global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir; |
2731 | 2850 | |
2732 | 2851 | // Have the admins enabled this option? |
2733 | - if (empty($modSettings['allow_ignore_boards'])) |
|
2734 | - fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2852 | + if (empty($modSettings['allow_ignore_boards'])) { |
|
2853 | + fatal_lang_error('ignoreboards_disallowed', 'user'); |
|
2854 | + } |
|
2735 | 2855 | |
2736 | 2856 | // Find all the boards this user is allowed to see. |
2737 | 2857 | $request = $smcFunc['db_query']('order_by_board_order', ' |
@@ -2751,12 +2871,13 @@ discard block |
||
2751 | 2871 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2752 | 2872 | { |
2753 | 2873 | // This category hasn't been set up yet.. |
2754 | - if (!isset($context['categories'][$row['id_cat']])) |
|
2755 | - $context['categories'][$row['id_cat']] = array( |
|
2874 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
2875 | + $context['categories'][$row['id_cat']] = array( |
|
2756 | 2876 | 'id' => $row['id_cat'], |
2757 | 2877 | 'name' => $row['cat_name'], |
2758 | 2878 | 'boards' => array() |
2759 | 2879 | ); |
2880 | + } |
|
2760 | 2881 | |
2761 | 2882 | // Set this board up, and let the template know when it's a child. (indent them..) |
2762 | 2883 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -2786,18 +2907,20 @@ discard block |
||
2786 | 2907 | } |
2787 | 2908 | |
2788 | 2909 | $max_boards = ceil(count($temp_boards) / 2); |
2789 | - if ($max_boards == 1) |
|
2790 | - $max_boards = 2; |
|
2910 | + if ($max_boards == 1) { |
|
2911 | + $max_boards = 2; |
|
2912 | + } |
|
2791 | 2913 | |
2792 | 2914 | // Now, alternate them so they can be shown left and right ;). |
2793 | 2915 | $context['board_columns'] = array(); |
2794 | 2916 | for ($i = 0; $i < $max_boards; $i++) |
2795 | 2917 | { |
2796 | 2918 | $context['board_columns'][] = $temp_boards[$i]; |
2797 | - if (isset($temp_boards[$i + $max_boards])) |
|
2798 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2799 | - else |
|
2800 | - $context['board_columns'][] = array(); |
|
2919 | + if (isset($temp_boards[$i + $max_boards])) { |
|
2920 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
2921 | + } else { |
|
2922 | + $context['board_columns'][] = array(); |
|
2923 | + } |
|
2801 | 2924 | } |
2802 | 2925 | |
2803 | 2926 | loadThemeOptions($memID); |
@@ -2866,8 +2989,9 @@ discard block |
||
2866 | 2989 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2867 | 2990 | { |
2868 | 2991 | // We should skip the administrator group if they don't have the admin_forum permission! |
2869 | - if ($row['id_group'] == 1 && !allowedTo('admin_forum')) |
|
2870 | - continue; |
|
2992 | + if ($row['id_group'] == 1 && !allowedTo('admin_forum')) { |
|
2993 | + continue; |
|
2994 | + } |
|
2871 | 2995 | |
2872 | 2996 | $context['member_groups'][$row['id_group']] = array( |
2873 | 2997 | 'id' => $row['id_group'], |
@@ -2913,16 +3037,17 @@ discard block |
||
2913 | 3037 | $context['max_signature_length'] = $context['signature_limits']['max_length']; |
2914 | 3038 | // Warning message for signature image limits? |
2915 | 3039 | $context['signature_warning'] = ''; |
2916 | - if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) |
|
2917 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
2918 | - elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) |
|
2919 | - $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3040 | + if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) { |
|
3041 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']); |
|
3042 | + } elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) { |
|
3043 | + $context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']); |
|
3044 | + } |
|
2920 | 3045 | |
2921 | 3046 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
2922 | 3047 | |
2923 | - if (empty($context['do_preview'])) |
|
2924 | - $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
2925 | - else |
|
3048 | + if (empty($context['do_preview'])) { |
|
3049 | + $context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '<', '>', '"', '''), $cur_profile['signature']); |
|
3050 | + } else |
|
2926 | 3051 | { |
2927 | 3052 | $signature = !empty($_POST['signature']) ? $_POST['signature'] : ''; |
2928 | 3053 | $validation = profileValidateSignature($signature); |
@@ -2932,8 +3057,9 @@ discard block |
||
2932 | 3057 | $context['post_errors'] = array(); |
2933 | 3058 | } |
2934 | 3059 | $context['post_errors'][] = 'signature_not_yet_saved'; |
2935 | - if ($validation !== true && $validation !== false) |
|
2936 | - $context['post_errors'][] = $validation; |
|
3060 | + if ($validation !== true && $validation !== false) { |
|
3061 | + $context['post_errors'][] = $validation; |
|
3062 | + } |
|
2937 | 3063 | |
2938 | 3064 | censorText($context['member']['signature']); |
2939 | 3065 | $context['member']['current_signature'] = $context['member']['signature']; |
@@ -2943,8 +3069,9 @@ discard block |
||
2943 | 3069 | } |
2944 | 3070 | |
2945 | 3071 | // Load the spell checker? |
2946 | - if ($context['show_spellchecking']) |
|
2947 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3072 | + if ($context['show_spellchecking']) { |
|
3073 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
3074 | + } |
|
2948 | 3075 | |
2949 | 3076 | return true; |
2950 | 3077 | } |
@@ -2978,8 +3105,7 @@ discard block |
||
2978 | 3105 | 'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11) |
2979 | 3106 | ); |
2980 | 3107 | $context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']); |
2981 | - } |
|
2982 | - elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
3108 | + } elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload']) |
|
2983 | 3109 | { |
2984 | 3110 | $context['member']['avatar'] += array( |
2985 | 3111 | 'choice' => 'upload', |
@@ -2987,34 +3113,34 @@ discard block |
||
2987 | 3113 | 'external' => 'http://' |
2988 | 3114 | ); |
2989 | 3115 | $context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename']; |
2990 | - } |
|
2991 | - elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) |
|
2992 | - $context['member']['avatar'] += array( |
|
3116 | + } elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) { |
|
3117 | + $context['member']['avatar'] += array( |
|
2993 | 3118 | 'choice' => 'external', |
2994 | 3119 | 'server_pic' => 'blank.png', |
2995 | 3120 | 'external' => $cur_profile['avatar'] |
2996 | 3121 | ); |
2997 | - elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) |
|
2998 | - $context['member']['avatar'] += array( |
|
3122 | + } elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) { |
|
3123 | + $context['member']['avatar'] += array( |
|
2999 | 3124 | 'choice' => 'server_stored', |
3000 | 3125 | 'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'], |
3001 | 3126 | 'external' => 'http://' |
3002 | 3127 | ); |
3003 | - else |
|
3004 | - $context['member']['avatar'] += array( |
|
3128 | + } else { |
|
3129 | + $context['member']['avatar'] += array( |
|
3005 | 3130 | 'choice' => 'none', |
3006 | 3131 | 'server_pic' => 'blank.png', |
3007 | 3132 | 'external' => 'http://' |
3008 | 3133 | ); |
3134 | + } |
|
3009 | 3135 | |
3010 | 3136 | // Get a list of all the avatars. |
3011 | 3137 | if ($context['member']['avatar']['allow_server_stored']) |
3012 | 3138 | { |
3013 | 3139 | $context['avatar_list'] = array(); |
3014 | 3140 | $context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array(); |
3141 | + } else { |
|
3142 | + $context['avatars'] = array(); |
|
3015 | 3143 | } |
3016 | - else |
|
3017 | - $context['avatars'] = array(); |
|
3018 | 3144 | |
3019 | 3145 | // Second level selected avatar... |
3020 | 3146 | $context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1); |
@@ -3043,19 +3169,22 @@ discard block |
||
3043 | 3169 | ) |
3044 | 3170 | ); |
3045 | 3171 | $protected_groups = array(1); |
3046 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3047 | - $protected_groups[] = $row['id_group']; |
|
3172 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3173 | + $protected_groups[] = $row['id_group']; |
|
3174 | + } |
|
3048 | 3175 | $smcFunc['db_free_result']($request); |
3049 | 3176 | |
3050 | 3177 | $protected_groups = array_unique($protected_groups); |
3051 | 3178 | } |
3052 | 3179 | |
3053 | 3180 | // The account page allows the change of your id_group - but not to a protected group! |
3054 | - if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) |
|
3055 | - $value = (int) $value; |
|
3181 | + if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) { |
|
3182 | + $value = (int) $value; |
|
3183 | + } |
|
3056 | 3184 | // ... otherwise it's the old group sir. |
3057 | - else |
|
3058 | - $value = $old_profile['id_group']; |
|
3185 | + else { |
|
3186 | + $value = $old_profile['id_group']; |
|
3187 | + } |
|
3059 | 3188 | |
3060 | 3189 | // Find the additional membergroups (if any) |
3061 | 3190 | if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups'])) |
@@ -3064,16 +3193,18 @@ discard block |
||
3064 | 3193 | foreach ($_POST['additional_groups'] as $group_id) |
3065 | 3194 | { |
3066 | 3195 | $group_id = (int) $group_id; |
3067 | - if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) |
|
3068 | - $additional_groups[] = $group_id; |
|
3196 | + if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) { |
|
3197 | + $additional_groups[] = $group_id; |
|
3198 | + } |
|
3069 | 3199 | } |
3070 | 3200 | |
3071 | 3201 | // Put the protected groups back in there if you don't have permission to take them away. |
3072 | 3202 | $old_additional_groups = explode(',', $old_profile['additional_groups']); |
3073 | 3203 | foreach ($old_additional_groups as $group_id) |
3074 | 3204 | { |
3075 | - if (!empty($protected_groups) && in_array($group_id, $protected_groups)) |
|
3076 | - $additional_groups[] = $group_id; |
|
3205 | + if (!empty($protected_groups) && in_array($group_id, $protected_groups)) { |
|
3206 | + $additional_groups[] = $group_id; |
|
3207 | + } |
|
3077 | 3208 | } |
3078 | 3209 | |
3079 | 3210 | if (implode(',', $additional_groups) !== $old_profile['additional_groups']) |
@@ -3105,18 +3236,20 @@ discard block |
||
3105 | 3236 | list ($another) = $smcFunc['db_fetch_row']($request); |
3106 | 3237 | $smcFunc['db_free_result']($request); |
3107 | 3238 | |
3108 | - if (empty($another)) |
|
3109 | - fatal_lang_error('at_least_one_admin', 'critical'); |
|
3239 | + if (empty($another)) { |
|
3240 | + fatal_lang_error('at_least_one_admin', 'critical'); |
|
3241 | + } |
|
3110 | 3242 | } |
3111 | 3243 | } |
3112 | 3244 | |
3113 | 3245 | // If we are changing group status, update permission cache as necessary. |
3114 | 3246 | if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups'])) |
3115 | 3247 | { |
3116 | - if ($context['user']['is_owner']) |
|
3117 | - $_SESSION['mc']['time'] = 0; |
|
3118 | - else |
|
3119 | - updateSettings(array('settings_updated' => time())); |
|
3248 | + if ($context['user']['is_owner']) { |
|
3249 | + $_SESSION['mc']['time'] = 0; |
|
3250 | + } else { |
|
3251 | + updateSettings(array('settings_updated' => time())); |
|
3252 | + } |
|
3120 | 3253 | } |
3121 | 3254 | |
3122 | 3255 | // Announce to any hooks that we have changed groups, but don't allow them to change it. |
@@ -3137,8 +3270,9 @@ discard block |
||
3137 | 3270 | global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context; |
3138 | 3271 | |
3139 | 3272 | $memID = $context['id_member']; |
3140 | - if (empty($memID) && !empty($context['password_auth_failed'])) |
|
3141 | - return false; |
|
3273 | + if (empty($memID) && !empty($context['password_auth_failed'])) { |
|
3274 | + return false; |
|
3275 | + } |
|
3142 | 3276 | |
3143 | 3277 | require_once($sourcedir . '/ManageAttachments.php'); |
3144 | 3278 | |
@@ -3149,8 +3283,9 @@ discard block |
||
3149 | 3283 | $downloadedExternalAvatar = false; |
3150 | 3284 | if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external'])) |
3151 | 3285 | { |
3152 | - if (!is_writable($uploadDir)) |
|
3153 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3286 | + if (!is_writable($uploadDir)) { |
|
3287 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3288 | + } |
|
3154 | 3289 | |
3155 | 3290 | require_once($sourcedir . '/Subs-Package.php'); |
3156 | 3291 | |
@@ -3194,19 +3329,18 @@ discard block |
||
3194 | 3329 | |
3195 | 3330 | // Get rid of their old avatar. (if uploaded.) |
3196 | 3331 | removeAttachments(array('id_member' => $memID)); |
3197 | - } |
|
3198 | - elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3332 | + } elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled'])) |
|
3199 | 3333 | { |
3200 | 3334 | // One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar. |
3201 | - if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) |
|
3202 | - $profile_vars['avatar'] = 'gravatar://'; |
|
3203 | - else |
|
3204 | - $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3335 | + if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) { |
|
3336 | + $profile_vars['avatar'] = 'gravatar://'; |
|
3337 | + } else { |
|
3338 | + $profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : ''); |
|
3339 | + } |
|
3205 | 3340 | |
3206 | 3341 | // Get rid of their old avatar. (if uploaded.) |
3207 | 3342 | removeAttachments(array('id_member' => $memID)); |
3208 | - } |
|
3209 | - elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3343 | + } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external'])) |
|
3210 | 3344 | { |
3211 | 3345 | // We need these clean... |
3212 | 3346 | $cur_profile['id_attach'] = 0; |
@@ -3218,11 +3352,13 @@ discard block |
||
3218 | 3352 | |
3219 | 3353 | $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); |
3220 | 3354 | |
3221 | - if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') |
|
3222 | - $profile_vars['avatar'] = ''; |
|
3355 | + if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { |
|
3356 | + $profile_vars['avatar'] = ''; |
|
3357 | + } |
|
3223 | 3358 | // Trying to make us do something we'll regret? |
3224 | - elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') |
|
3225 | - return 'bad_avatar_invalid_url'; |
|
3359 | + elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') { |
|
3360 | + return 'bad_avatar_invalid_url'; |
|
3361 | + } |
|
3226 | 3362 | // Should we check dimensions? |
3227 | 3363 | elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) |
3228 | 3364 | { |
@@ -3232,9 +3368,9 @@ discard block |
||
3232 | 3368 | if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external'])))) |
3233 | 3369 | { |
3234 | 3370 | // Houston, we have a problem. The avatar is too large!! |
3235 | - if ($modSettings['avatar_action_too_large'] == 'option_refuse') |
|
3236 | - return 'bad_avatar_too_large'; |
|
3237 | - elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3371 | + if ($modSettings['avatar_action_too_large'] == 'option_refuse') { |
|
3372 | + return 'bad_avatar_too_large'; |
|
3373 | + } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') |
|
3238 | 3374 | { |
3239 | 3375 | // @todo remove this if appropriate |
3240 | 3376 | require_once($sourcedir . '/Subs-Graphics.php'); |
@@ -3244,26 +3380,27 @@ discard block |
||
3244 | 3380 | $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; |
3245 | 3381 | $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; |
3246 | 3382 | $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; |
3383 | + } else { |
|
3384 | + return 'bad_avatar'; |
|
3247 | 3385 | } |
3248 | - else |
|
3249 | - return 'bad_avatar'; |
|
3250 | 3386 | } |
3251 | 3387 | } |
3252 | 3388 | } |
3253 | - } |
|
3254 | - elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3389 | + } elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar) |
|
3255 | 3390 | { |
3256 | 3391 | if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar) |
3257 | 3392 | { |
3258 | 3393 | // Get the dimensions of the image. |
3259 | 3394 | if (!$downloadedExternalAvatar) |
3260 | 3395 | { |
3261 | - if (!is_writable($uploadDir)) |
|
3262 | - fatal_lang_error('attachments_no_write', 'critical'); |
|
3396 | + if (!is_writable($uploadDir)) { |
|
3397 | + fatal_lang_error('attachments_no_write', 'critical'); |
|
3398 | + } |
|
3263 | 3399 | |
3264 | 3400 | $new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); |
3265 | - if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) |
|
3266 | - fatal_lang_error('attach_timeout', 'critical'); |
|
3401 | + if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) { |
|
3402 | + fatal_lang_error('attach_timeout', 'critical'); |
|
3403 | + } |
|
3267 | 3404 | |
3268 | 3405 | $_FILES['attachment']['tmp_name'] = $new_filename; |
3269 | 3406 | } |
@@ -3376,17 +3513,19 @@ discard block |
||
3376 | 3513 | $profile_vars['avatar'] = ''; |
3377 | 3514 | |
3378 | 3515 | // Delete any temporary file. |
3379 | - if (file_exists($_FILES['attachment']['tmp_name'])) |
|
3380 | - @unlink($_FILES['attachment']['tmp_name']); |
|
3516 | + if (file_exists($_FILES['attachment']['tmp_name'])) { |
|
3517 | + @unlink($_FILES['attachment']['tmp_name']); |
|
3518 | + } |
|
3381 | 3519 | } |
3382 | 3520 | // Selected the upload avatar option and had one already uploaded before or didn't upload one. |
3383 | - else |
|
3521 | + else { |
|
3522 | + $profile_vars['avatar'] = ''; |
|
3523 | + } |
|
3524 | + } elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) { |
|
3525 | + $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3526 | + } else { |
|
3384 | 3527 | $profile_vars['avatar'] = ''; |
3385 | 3528 | } |
3386 | - elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) |
|
3387 | - $profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address']))); |
|
3388 | - else |
|
3389 | - $profile_vars['avatar'] = ''; |
|
3390 | 3529 | |
3391 | 3530 | // Setup the profile variables so it shows things right on display! |
3392 | 3531 | $cur_profile['avatar'] = $profile_vars['avatar']; |
@@ -3434,9 +3573,9 @@ discard block |
||
3434 | 3573 | $smiley_parsed = $unparsed_signature; |
3435 | 3574 | parsesmileys($smiley_parsed); |
3436 | 3575 | $smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img'); |
3437 | - if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) |
|
3438 | - return 'signature_allow_smileys'; |
|
3439 | - elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3576 | + if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) { |
|
3577 | + return 'signature_allow_smileys'; |
|
3578 | + } elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4]) |
|
3440 | 3579 | { |
3441 | 3580 | $txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]); |
3442 | 3581 | return 'signature_max_smileys'; |
@@ -3449,14 +3588,15 @@ discard block |
||
3449 | 3588 | { |
3450 | 3589 | $limit_broke = 0; |
3451 | 3590 | // Attempt to allow all sizes of abuse, so to speak. |
3452 | - if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) |
|
3453 | - $limit_broke = $sig_limits[7] . 'px'; |
|
3454 | - elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) |
|
3455 | - $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3456 | - elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) |
|
3457 | - $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3458 | - elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) |
|
3459 | - $limit_broke = 'large'; |
|
3591 | + if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) { |
|
3592 | + $limit_broke = $sig_limits[7] . 'px'; |
|
3593 | + } elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) { |
|
3594 | + $limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt'; |
|
3595 | + } elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) { |
|
3596 | + $limit_broke = ((float) $sig_limits[7] / 16) . 'em'; |
|
3597 | + } elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) { |
|
3598 | + $limit_broke = 'large'; |
|
3599 | + } |
|
3460 | 3600 | |
3461 | 3601 | if ($limit_broke) |
3462 | 3602 | { |
@@ -3498,24 +3638,26 @@ discard block |
||
3498 | 3638 | $width = -1; $height = -1; |
3499 | 3639 | |
3500 | 3640 | // Does it have predefined restraints? Width first. |
3501 | - if ($matches[6][$key]) |
|
3502 | - $matches[2][$key] = $matches[6][$key]; |
|
3641 | + if ($matches[6][$key]) { |
|
3642 | + $matches[2][$key] = $matches[6][$key]; |
|
3643 | + } |
|
3503 | 3644 | if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5]) |
3504 | 3645 | { |
3505 | 3646 | $width = $sig_limits[5]; |
3506 | 3647 | $matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]); |
3648 | + } elseif ($matches[2][$key]) { |
|
3649 | + $width = $matches[2][$key]; |
|
3507 | 3650 | } |
3508 | - elseif ($matches[2][$key]) |
|
3509 | - $width = $matches[2][$key]; |
|
3510 | 3651 | // ... and height. |
3511 | 3652 | if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6]) |
3512 | 3653 | { |
3513 | 3654 | $height = $sig_limits[6]; |
3514 | - if ($width != -1) |
|
3515 | - $width = $width * ($height / $matches[4][$key]); |
|
3655 | + if ($width != -1) { |
|
3656 | + $width = $width * ($height / $matches[4][$key]); |
|
3657 | + } |
|
3658 | + } elseif ($matches[4][$key]) { |
|
3659 | + $height = $matches[4][$key]; |
|
3516 | 3660 | } |
3517 | - elseif ($matches[4][$key]) |
|
3518 | - $height = $matches[4][$key]; |
|
3519 | 3661 | |
3520 | 3662 | // If the dimensions are still not fixed - we need to check the actual image. |
3521 | 3663 | if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) |
@@ -3533,21 +3675,24 @@ discard block |
||
3533 | 3675 | if ($sizes[1] > $sig_limits[6] && $sig_limits[6]) |
3534 | 3676 | { |
3535 | 3677 | $height = $sig_limits[6]; |
3536 | - if ($width == -1) |
|
3537 | - $width = $sizes[0]; |
|
3678 | + if ($width == -1) { |
|
3679 | + $width = $sizes[0]; |
|
3680 | + } |
|
3538 | 3681 | $width = $width * ($height / $sizes[1]); |
3682 | + } elseif ($width != -1) { |
|
3683 | + $height = $sizes[1]; |
|
3539 | 3684 | } |
3540 | - elseif ($width != -1) |
|
3541 | - $height = $sizes[1]; |
|
3542 | 3685 | } |
3543 | 3686 | } |
3544 | 3687 | |
3545 | 3688 | // Did we come up with some changes? If so remake the string. |
3546 | - if ($width != -1 || $height != -1) |
|
3547 | - $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3689 | + if ($width != -1 || $height != -1) { |
|
3690 | + $replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]'; |
|
3691 | + } |
|
3692 | + } |
|
3693 | + if (!empty($replaces)) { |
|
3694 | + $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3548 | 3695 | } |
3549 | - if (!empty($replaces)) |
|
3550 | - $value = str_replace(array_keys($replaces), array_values($replaces), $value); |
|
3551 | 3696 | } |
3552 | 3697 | } |
3553 | 3698 | |
@@ -3591,10 +3736,12 @@ discard block |
||
3591 | 3736 | $email = strtr($email, array(''' => '\'')); |
3592 | 3737 | |
3593 | 3738 | // Check the name and email for validity. |
3594 | - if (trim($email) == '') |
|
3595 | - return 'no_email'; |
|
3596 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) |
|
3597 | - return 'bad_email'; |
|
3739 | + if (trim($email) == '') { |
|
3740 | + return 'no_email'; |
|
3741 | + } |
|
3742 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
3743 | + return 'bad_email'; |
|
3744 | + } |
|
3598 | 3745 | |
3599 | 3746 | // Email addresses should be and stay unique. |
3600 | 3747 | $request = $smcFunc['db_query']('', ' |
@@ -3609,8 +3756,9 @@ discard block |
||
3609 | 3756 | ) |
3610 | 3757 | ); |
3611 | 3758 | |
3612 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
3613 | - return 'email_taken'; |
|
3759 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
3760 | + return 'email_taken'; |
|
3761 | + } |
|
3614 | 3762 | $smcFunc['db_free_result']($request); |
3615 | 3763 | |
3616 | 3764 | return true; |
@@ -3623,8 +3771,9 @@ discard block |
||
3623 | 3771 | { |
3624 | 3772 | global $modSettings, $context, $cur_profile; |
3625 | 3773 | |
3626 | - if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') |
|
3627 | - setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3774 | + if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') { |
|
3775 | + setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt'])); |
|
3776 | + } |
|
3628 | 3777 | |
3629 | 3778 | loadUserSettings(); |
3630 | 3779 | writeLog(); |
@@ -3640,8 +3789,9 @@ discard block |
||
3640 | 3789 | require_once($sourcedir . '/Subs-Post.php'); |
3641 | 3790 | |
3642 | 3791 | // Shouldn't happen but just in case. |
3643 | - if (empty($profile_vars['email_address'])) |
|
3644 | - return; |
|
3792 | + if (empty($profile_vars['email_address'])) { |
|
3793 | + return; |
|
3794 | + } |
|
3645 | 3795 | |
3646 | 3796 | $replacements = array( |
3647 | 3797 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'], |
@@ -3664,8 +3814,9 @@ discard block |
||
3664 | 3814 | $_SESSION['log_time'] = 0; |
3665 | 3815 | $_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0)); |
3666 | 3816 | |
3667 | - if (isset($_COOKIE[$cookiename])) |
|
3668 | - $_COOKIE[$cookiename] = ''; |
|
3817 | + if (isset($_COOKIE[$cookiename])) { |
|
3818 | + $_COOKIE[$cookiename] = ''; |
|
3819 | + } |
|
3669 | 3820 | |
3670 | 3821 | loadUserSettings(); |
3671 | 3822 | |
@@ -3698,11 +3849,13 @@ discard block |
||
3698 | 3849 | $groups[] = $curMember['id_group']; |
3699 | 3850 | |
3700 | 3851 | // Ensure the query doesn't croak! |
3701 | - if (empty($groups)) |
|
3702 | - $groups = array(0); |
|
3852 | + if (empty($groups)) { |
|
3853 | + $groups = array(0); |
|
3854 | + } |
|
3703 | 3855 | // Just to be sure... |
3704 | - foreach ($groups as $k => $v) |
|
3705 | - $groups[$k] = (int) $v; |
|
3856 | + foreach ($groups as $k => $v) { |
|
3857 | + $groups[$k] = (int) $v; |
|
3858 | + } |
|
3706 | 3859 | |
3707 | 3860 | // Get all the membergroups they can join. |
3708 | 3861 | $request = $smcFunc['db_query']('', ' |
@@ -3732,12 +3885,14 @@ discard block |
||
3732 | 3885 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3733 | 3886 | { |
3734 | 3887 | // Can they edit their primary group? |
3735 | - if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) |
|
3736 | - $context['can_edit_primary'] = true; |
|
3888 | + if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) { |
|
3889 | + $context['can_edit_primary'] = true; |
|
3890 | + } |
|
3737 | 3891 | |
3738 | 3892 | // If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it. |
3739 | - if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) |
|
3740 | - continue; |
|
3893 | + if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) { |
|
3894 | + continue; |
|
3895 | + } |
|
3741 | 3896 | |
3742 | 3897 | $context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array( |
3743 | 3898 | 'id' => $row['id_group'], |
@@ -3766,13 +3921,15 @@ discard block |
||
3766 | 3921 | ); |
3767 | 3922 | |
3768 | 3923 | // No changing primary one unless you have enough groups! |
3769 | - if (count($context['groups']['member']) < 2) |
|
3770 | - $context['can_edit_primary'] = false; |
|
3924 | + if (count($context['groups']['member']) < 2) { |
|
3925 | + $context['can_edit_primary'] = false; |
|
3926 | + } |
|
3771 | 3927 | |
3772 | 3928 | // In the special case that someone is requesting membership of a group, setup some special context vars. |
3773 | - if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) |
|
3774 | - $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3775 | -} |
|
3929 | + if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) { |
|
3930 | + $context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']]; |
|
3931 | + } |
|
3932 | + } |
|
3776 | 3933 | |
3777 | 3934 | /** |
3778 | 3935 | * This function actually makes all the group changes |
@@ -3787,10 +3944,12 @@ discard block |
||
3787 | 3944 | global $user_info, $context, $user_profile, $modSettings, $smcFunc; |
3788 | 3945 | |
3789 | 3946 | // Let's be extra cautious... |
3790 | - if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) |
|
3791 | - isAllowedTo('manage_membergroups'); |
|
3792 | - if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) |
|
3793 | - fatal_lang_error('no_access', false); |
|
3947 | + if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) { |
|
3948 | + isAllowedTo('manage_membergroups'); |
|
3949 | + } |
|
3950 | + if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) { |
|
3951 | + fatal_lang_error('no_access', false); |
|
3952 | + } |
|
3794 | 3953 | |
3795 | 3954 | checkSession(isset($_GET['gid']) ? 'get' : 'post'); |
3796 | 3955 | |
@@ -3809,8 +3968,9 @@ discard block |
||
3809 | 3968 | $foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false; |
3810 | 3969 | |
3811 | 3970 | // Sanity check!! |
3812 | - if ($group_id == 1) |
|
3813 | - isAllowedTo('admin_forum'); |
|
3971 | + if ($group_id == 1) { |
|
3972 | + isAllowedTo('admin_forum'); |
|
3973 | + } |
|
3814 | 3974 | // Protected groups too! |
3815 | 3975 | else |
3816 | 3976 | { |
@@ -3827,8 +3987,9 @@ discard block |
||
3827 | 3987 | list ($is_protected) = $smcFunc['db_fetch_row']($request); |
3828 | 3988 | $smcFunc['db_free_result']($request); |
3829 | 3989 | |
3830 | - if ($is_protected == 1) |
|
3831 | - isAllowedTo('admin_forum'); |
|
3990 | + if ($is_protected == 1) { |
|
3991 | + isAllowedTo('admin_forum'); |
|
3992 | + } |
|
3832 | 3993 | } |
3833 | 3994 | |
3834 | 3995 | // What ever we are doing, we need to determine if changing primary is possible! |
@@ -3850,36 +4011,43 @@ discard block |
||
3850 | 4011 | $group_name = $row['group_name']; |
3851 | 4012 | |
3852 | 4013 | // Does the group type match what we're doing - are we trying to request a non-requestable group? |
3853 | - if ($changeType == 'request' && $row['group_type'] != 2) |
|
3854 | - fatal_lang_error('no_access', false); |
|
4014 | + if ($changeType == 'request' && $row['group_type'] != 2) { |
|
4015 | + fatal_lang_error('no_access', false); |
|
4016 | + } |
|
3855 | 4017 | // What about leaving a requestable group we are not a member of? |
3856 | - elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) |
|
3857 | - fatal_lang_error('no_access', false); |
|
3858 | - elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) |
|
3859 | - fatal_lang_error('no_access', false); |
|
4018 | + elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) { |
|
4019 | + fatal_lang_error('no_access', false); |
|
4020 | + } elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) { |
|
4021 | + fatal_lang_error('no_access', false); |
|
4022 | + } |
|
3860 | 4023 | |
3861 | 4024 | // We can't change the primary group if this is hidden! |
3862 | - if ($row['hidden'] == 2) |
|
3863 | - $canChangePrimary = false; |
|
4025 | + if ($row['hidden'] == 2) { |
|
4026 | + $canChangePrimary = false; |
|
4027 | + } |
|
3864 | 4028 | } |
3865 | 4029 | |
3866 | 4030 | // If this is their old primary, can we change it? |
3867 | - if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) |
|
3868 | - $canChangePrimary = 1; |
|
4031 | + if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) { |
|
4032 | + $canChangePrimary = 1; |
|
4033 | + } |
|
3869 | 4034 | |
3870 | 4035 | // If we are not doing a force primary move, don't do it automatically if current primary is not 0. |
3871 | - if ($changeType != 'primary' && $old_profile['id_group'] != 0) |
|
3872 | - $canChangePrimary = false; |
|
4036 | + if ($changeType != 'primary' && $old_profile['id_group'] != 0) { |
|
4037 | + $canChangePrimary = false; |
|
4038 | + } |
|
3873 | 4039 | |
3874 | 4040 | // If this is the one we are acting on, can we even act? |
3875 | - if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) |
|
3876 | - $canChangePrimary = false; |
|
4041 | + if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) { |
|
4042 | + $canChangePrimary = false; |
|
4043 | + } |
|
3877 | 4044 | } |
3878 | 4045 | $smcFunc['db_free_result']($request); |
3879 | 4046 | |
3880 | 4047 | // Didn't find the target? |
3881 | - if (!$foundTarget) |
|
3882 | - fatal_lang_error('no_access', false); |
|
4048 | + if (!$foundTarget) { |
|
4049 | + fatal_lang_error('no_access', false); |
|
4050 | + } |
|
3883 | 4051 | |
3884 | 4052 | // Final security check, don't allow users to promote themselves to admin. |
3885 | 4053 | if ($context['can_manage_membergroups'] && !allowedTo('admin_forum')) |
@@ -3899,8 +4067,9 @@ discard block |
||
3899 | 4067 | list ($disallow) = $smcFunc['db_fetch_row']($request); |
3900 | 4068 | $smcFunc['db_free_result']($request); |
3901 | 4069 | |
3902 | - if ($disallow) |
|
3903 | - isAllowedTo('admin_forum'); |
|
4070 | + if ($disallow) { |
|
4071 | + isAllowedTo('admin_forum'); |
|
4072 | + } |
|
3904 | 4073 | } |
3905 | 4074 | |
3906 | 4075 | // If we're requesting, add the note then return. |
@@ -3918,8 +4087,9 @@ discard block |
||
3918 | 4087 | 'status_open' => 0, |
3919 | 4088 | ) |
3920 | 4089 | ); |
3921 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
3922 | - fatal_lang_error('profile_error_already_requested_group'); |
|
4090 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
4091 | + fatal_lang_error('profile_error_already_requested_group'); |
|
4092 | + } |
|
3923 | 4093 | $smcFunc['db_free_result']($request); |
3924 | 4094 | |
3925 | 4095 | // Log the request. |
@@ -3953,10 +4123,11 @@ discard block |
||
3953 | 4123 | // Are we leaving? |
3954 | 4124 | if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id])) |
3955 | 4125 | { |
3956 | - if ($old_profile['id_group'] == $group_id) |
|
3957 | - $newPrimary = 0; |
|
3958 | - else |
|
3959 | - unset($addGroups[$group_id]); |
|
4126 | + if ($old_profile['id_group'] == $group_id) { |
|
4127 | + $newPrimary = 0; |
|
4128 | + } else { |
|
4129 | + unset($addGroups[$group_id]); |
|
4130 | + } |
|
3960 | 4131 | } |
3961 | 4132 | // ... if not, must be joining. |
3962 | 4133 | else |
@@ -3964,36 +4135,42 @@ discard block |
||
3964 | 4135 | // Can we change the primary, and do we want to? |
3965 | 4136 | if ($canChangePrimary) |
3966 | 4137 | { |
3967 | - if ($old_profile['id_group'] != 0) |
|
3968 | - $addGroups[$old_profile['id_group']] = -1; |
|
4138 | + if ($old_profile['id_group'] != 0) { |
|
4139 | + $addGroups[$old_profile['id_group']] = -1; |
|
4140 | + } |
|
3969 | 4141 | $newPrimary = $group_id; |
3970 | 4142 | } |
3971 | 4143 | // Otherwise it's an additional group... |
3972 | - else |
|
3973 | - $addGroups[$group_id] = -1; |
|
4144 | + else { |
|
4145 | + $addGroups[$group_id] = -1; |
|
4146 | + } |
|
3974 | 4147 | } |
3975 | 4148 | } |
3976 | 4149 | // Finally, we must be setting the primary. |
3977 | 4150 | elseif ($canChangePrimary) |
3978 | 4151 | { |
3979 | - if ($old_profile['id_group'] != 0) |
|
3980 | - $addGroups[$old_profile['id_group']] = -1; |
|
3981 | - if (isset($addGroups[$group_id])) |
|
3982 | - unset($addGroups[$group_id]); |
|
4152 | + if ($old_profile['id_group'] != 0) { |
|
4153 | + $addGroups[$old_profile['id_group']] = -1; |
|
4154 | + } |
|
4155 | + if (isset($addGroups[$group_id])) { |
|
4156 | + unset($addGroups[$group_id]); |
|
4157 | + } |
|
3983 | 4158 | $newPrimary = $group_id; |
3984 | 4159 | } |
3985 | 4160 | |
3986 | 4161 | // Finally, we can make the changes! |
3987 | - foreach ($addGroups as $id => $dummy) |
|
3988 | - if (empty($id)) |
|
4162 | + foreach ($addGroups as $id => $dummy) { |
|
4163 | + if (empty($id)) |
|
3989 | 4164 | unset($addGroups[$id]); |
4165 | + } |
|
3990 | 4166 | $addGroups = implode(',', array_flip($addGroups)); |
3991 | 4167 | |
3992 | 4168 | // Ensure that we don't cache permissions if the group is changing. |
3993 | - if ($context['user']['is_owner']) |
|
3994 | - $_SESSION['mc']['time'] = 0; |
|
3995 | - else |
|
3996 | - updateSettings(array('settings_updated' => time())); |
|
4169 | + if ($context['user']['is_owner']) { |
|
4170 | + $_SESSION['mc']['time'] = 0; |
|
4171 | + } else { |
|
4172 | + updateSettings(array('settings_updated' => time())); |
|
4173 | + } |
|
3997 | 4174 | |
3998 | 4175 | updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups)); |
3999 | 4176 | |
@@ -4016,8 +4193,9 @@ discard block |
||
4016 | 4193 | if (empty($user_settings['tfa_secret']) && $context['user']['is_owner']) |
4017 | 4194 | { |
4018 | 4195 | // Check to ensure we're forcing SSL for authentication |
4019 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
4020 | - fatal_lang_error('login_ssl_required'); |
|
4196 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
4197 | + fatal_lang_error('login_ssl_required'); |
|
4198 | + } |
|
4021 | 4199 | |
4022 | 4200 | // In some cases (forced 2FA or backup code) they would be forced to be redirected here, |
4023 | 4201 | // we do not want too much AJAX to confuse them. |
@@ -4054,8 +4232,7 @@ discard block |
||
4054 | 4232 | $context['sub_template'] = 'tfasetup_backup'; |
4055 | 4233 | |
4056 | 4234 | return; |
4057 | - } |
|
4058 | - else |
|
4235 | + } else |
|
4059 | 4236 | { |
4060 | 4237 | $context['tfa_secret'] = $_SESSION['tfa_secret']; |
4061 | 4238 | $context['tfa_error'] = !$valid_code; |
@@ -4063,8 +4240,7 @@ discard block |
||
4063 | 4240 | $context['tfa_pass_value'] = $_POST['passwd']; |
4064 | 4241 | $context['tfa_value'] = $_POST['tfa_code']; |
4065 | 4242 | } |
4066 | - } |
|
4067 | - else |
|
4243 | + } else |
|
4068 | 4244 | { |
4069 | 4245 | $totp = new \TOTP\Auth(); |
4070 | 4246 | $secret = $totp->generateCode(); |
@@ -4074,17 +4250,16 @@ discard block |
||
4074 | 4250 | } |
4075 | 4251 | |
4076 | 4252 | $context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']); |
4077 | - } |
|
4078 | - elseif (isset($_REQUEST['disable'])) |
|
4253 | + } elseif (isset($_REQUEST['disable'])) |
|
4079 | 4254 | { |
4080 | 4255 | updateMemberData($memID, array( |
4081 | 4256 | 'tfa_secret' => '', |
4082 | 4257 | 'tfa_backup' => '', |
4083 | 4258 | )); |
4084 | 4259 | redirectexit('action=profile;area=account;u=' . $memID); |
4260 | + } else { |
|
4261 | + redirectexit('action=profile;area=account;u=' . $memID); |
|
4262 | + } |
|
4085 | 4263 | } |
4086 | - else |
|
4087 | - redirectexit('action=profile;area=account;u=' . $memID); |
|
4088 | -} |
|
4089 | 4264 | |
4090 | 4265 | ?> |
4091 | 4266 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | |
20 | 21 | /** |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
45 | 46 | |
46 | 47 | // Is it elsewhere? |
47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Do the permission check, you might not be allowed her. |
51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
104 | 106 | 'function' => function($rowData) use ($scripturl) |
105 | 107 | { |
106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
107 | - if ($rowData['id_group'] == 3) |
|
108 | - $group_name = $rowData['group_name']; |
|
109 | - else |
|
109 | + if ($rowData['id_group'] == 3) { |
|
110 | + $group_name = $rowData['group_name']; |
|
111 | + } else |
|
110 | 112 | { |
111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
113 | 115 | } |
114 | 116 | |
115 | 117 | // Add a help option for moderator and administrator. |
116 | - if ($rowData['id_group'] == 1) |
|
117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | - elseif ($rowData['id_group'] == 3) |
|
119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | + if ($rowData['id_group'] == 1) { |
|
119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
120 | + } elseif ($rowData['id_group'] == 3) { |
|
121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | return $group_name; |
122 | 125 | }, |
@@ -330,12 +333,14 @@ discard block |
||
330 | 333 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
331 | 334 | |
332 | 335 | // Update the post groups now, if this is a post group! |
333 | - if (isset($_POST['min_posts'])) |
|
334 | - updateStats('postgroups'); |
|
336 | + if (isset($_POST['min_posts'])) { |
|
337 | + updateStats('postgroups'); |
|
338 | + } |
|
335 | 339 | |
336 | 340 | // You cannot set permissions for post groups if they are disabled. |
337 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
338 | - $_POST['perm_type'] = ''; |
|
341 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
342 | + $_POST['perm_type'] = ''; |
|
343 | + } |
|
339 | 344 | |
340 | 345 | if ($_POST['perm_type'] == 'predefined') |
341 | 346 | { |
@@ -365,8 +370,9 @@ discard block |
||
365 | 370 | $smcFunc['db_free_result']($request); |
366 | 371 | |
367 | 372 | // Protected groups are... well, protected! |
368 | - if ($copy_type == 1) |
|
369 | - fatal_lang_error('membergroup_does_not_exist'); |
|
373 | + if ($copy_type == 1) { |
|
374 | + fatal_lang_error('membergroup_does_not_exist'); |
|
375 | + } |
|
370 | 376 | } |
371 | 377 | |
372 | 378 | // Don't allow copying of a real priviledged person! |
@@ -384,18 +390,20 @@ discard block |
||
384 | 390 | $inserts = array(); |
385 | 391 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
386 | 392 | { |
387 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
388 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
393 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
394 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
395 | + } |
|
389 | 396 | } |
390 | 397 | $smcFunc['db_free_result']($request); |
391 | 398 | |
392 | - if (!empty($inserts)) |
|
393 | - $smcFunc['db_insert']('insert', |
|
399 | + if (!empty($inserts)) { |
|
400 | + $smcFunc['db_insert']('insert', |
|
394 | 401 | '{db_prefix}permissions', |
395 | 402 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
396 | 403 | $inserts, |
397 | 404 | array('id_group', 'permission') |
398 | 405 | ); |
406 | + } |
|
399 | 407 | |
400 | 408 | $request = $smcFunc['db_query']('', ' |
401 | 409 | SELECT id_profile, permission, add_deny |
@@ -406,17 +414,19 @@ discard block |
||
406 | 414 | ) |
407 | 415 | ); |
408 | 416 | $inserts = array(); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
410 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
417 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
418 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
419 | + } |
|
411 | 420 | $smcFunc['db_free_result']($request); |
412 | 421 | |
413 | - if (!empty($inserts)) |
|
414 | - $smcFunc['db_insert']('insert', |
|
422 | + if (!empty($inserts)) { |
|
423 | + $smcFunc['db_insert']('insert', |
|
415 | 424 | '{db_prefix}board_permissions', |
416 | 425 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
417 | 426 | $inserts, |
418 | 427 | array('id_group', 'id_profile', 'permission') |
419 | 428 | ); |
429 | + } |
|
420 | 430 | |
421 | 431 | // Also get some membergroup information if we're copying and not copying from guests... |
422 | 432 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -469,14 +479,15 @@ discard block |
||
469 | 479 | $changed_boards['allow'] = array(); |
470 | 480 | $changed_boards['deny'] = array(); |
471 | 481 | $changed_boards['ignore'] = array(); |
472 | - foreach ($accesses as $group_id => $action) |
|
473 | - $changed_boards[$action][] = (int) $group_id; |
|
482 | + foreach ($accesses as $group_id => $action) { |
|
483 | + $changed_boards[$action][] = (int) $group_id; |
|
484 | + } |
|
474 | 485 | |
475 | 486 | foreach (array('allow', 'deny') as $board_action) |
476 | 487 | { |
477 | 488 | // Only do this if they have special access requirements. |
478 | - if (!empty($changed_boards[$board_action])) |
|
479 | - $smcFunc['db_query']('', ' |
|
489 | + if (!empty($changed_boards[$board_action])) { |
|
490 | + $smcFunc['db_query']('', ' |
|
480 | 491 | UPDATE {db_prefix}boards |
481 | 492 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
482 | 493 | WHERE id_board IN ({array_int:board_list})', |
@@ -488,11 +499,13 @@ discard block |
||
488 | 499 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
489 | 500 | ) |
490 | 501 | ); |
502 | + } |
|
491 | 503 | } |
492 | 504 | |
493 | 505 | // If this is joinable then set it to show group membership in people's profiles. |
494 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
495 | - updateSettings(array('show_group_membership' => 1)); |
|
506 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
507 | + updateSettings(array('show_group_membership' => 1)); |
|
508 | + } |
|
496 | 509 | |
497 | 510 | // Rebuild the group cache. |
498 | 511 | updateSettings(array( |
@@ -513,8 +526,9 @@ discard block |
||
513 | 526 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
514 | 527 | $context['allow_protected'] = allowedTo('admin_forum'); |
515 | 528 | |
516 | - if (!empty($modSettings['deny_boards_access'])) |
|
517 | - loadLanguage('ManagePermissions'); |
|
529 | + if (!empty($modSettings['deny_boards_access'])) { |
|
530 | + loadLanguage('ManagePermissions'); |
|
531 | + } |
|
518 | 532 | |
519 | 533 | $result = $smcFunc['db_query']('', ' |
520 | 534 | SELECT id_group, group_name |
@@ -531,11 +545,12 @@ discard block |
||
531 | 545 | ) |
532 | 546 | ); |
533 | 547 | $context['groups'] = array(); |
534 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
535 | - $context['groups'][] = array( |
|
548 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
549 | + $context['groups'][] = array( |
|
536 | 550 | 'id' => $row['id_group'], |
537 | 551 | 'name' => $row['group_name'] |
538 | 552 | ); |
553 | + } |
|
539 | 554 | $smcFunc['db_free_result']($result); |
540 | 555 | |
541 | 556 | $request = $smcFunc['db_query']('', ' |
@@ -552,12 +567,13 @@ discard block |
||
552 | 567 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
553 | 568 | { |
554 | 569 | // This category hasn't been set up yet.. |
555 | - if (!isset($context['categories'][$row['id_cat']])) |
|
556 | - $context['categories'][$row['id_cat']] = array( |
|
570 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
571 | + $context['categories'][$row['id_cat']] = array( |
|
557 | 572 | 'id' => $row['id_cat'], |
558 | 573 | 'name' => $row['cat_name'], |
559 | 574 | 'boards' => array() |
560 | 575 | ); |
576 | + } |
|
561 | 577 | |
562 | 578 | // Set this board up, and let the template know when it's a child. (indent them..) |
563 | 579 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -605,8 +621,9 @@ discard block |
||
605 | 621 | require_once($sourcedir . '/Subs-Membergroups.php'); |
606 | 622 | $result = deleteMembergroups((int) $_REQUEST['group']); |
607 | 623 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
608 | - if ($result === 'group_cannot_delete_sub') |
|
609 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
624 | + if ($result === 'group_cannot_delete_sub') { |
|
625 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
626 | + } |
|
610 | 627 | |
611 | 628 | // Go back to the membergroup index. |
612 | 629 | redirectexit('action=admin;area=membergroups;'); |
@@ -628,8 +645,9 @@ discard block |
||
628 | 645 | |
629 | 646 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
630 | 647 | |
631 | - if (!empty($modSettings['deny_boards_access'])) |
|
632 | - loadLanguage('ManagePermissions'); |
|
648 | + if (!empty($modSettings['deny_boards_access'])) { |
|
649 | + loadLanguage('ManagePermissions'); |
|
650 | + } |
|
633 | 651 | |
634 | 652 | // Make sure this group is editable. |
635 | 653 | if (!empty($_REQUEST['group'])) |
@@ -651,8 +669,9 @@ discard block |
||
651 | 669 | } |
652 | 670 | |
653 | 671 | // Now, do we have a valid id? |
654 | - if (empty($_REQUEST['group'])) |
|
655 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
672 | + if (empty($_REQUEST['group'])) { |
|
673 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
674 | + } |
|
656 | 675 | |
657 | 676 | // People who can manage boards are a bit special. |
658 | 677 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -683,8 +702,9 @@ discard block |
||
683 | 702 | require_once($sourcedir . '/Subs-Membergroups.php'); |
684 | 703 | $result = deleteMembergroups($_REQUEST['group']); |
685 | 704 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
686 | - if ($result === 'group_cannot_delete_sub') |
|
687 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
705 | + if ($result === 'group_cannot_delete_sub') { |
|
706 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
707 | + } |
|
688 | 708 | |
689 | 709 | redirectexit('action=admin;area=membergroups;'); |
690 | 710 | } |
@@ -761,16 +781,18 @@ discard block |
||
761 | 781 | $request = $smcFunc['db_query']('', ' |
762 | 782 | SELECT id_board |
763 | 783 | FROM {db_prefix}boards'); |
764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
765 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
784 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
785 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
786 | + } |
|
766 | 787 | $smcFunc['db_free_result']($request); |
767 | 788 | } |
768 | 789 | |
769 | 790 | $changed_boards['allow'] = array(); |
770 | 791 | $changed_boards['deny'] = array(); |
771 | 792 | $changed_boards['ignore'] = array(); |
772 | - foreach ($accesses as $group_id => $action) |
|
773 | - $changed_boards[$action][] = (int) $group_id; |
|
793 | + foreach ($accesses as $group_id => $action) { |
|
794 | + $changed_boards[$action][] = (int) $group_id; |
|
795 | + } |
|
774 | 796 | |
775 | 797 | foreach (array('allow', 'deny') as $board_action) |
776 | 798 | { |
@@ -786,8 +808,8 @@ discard block |
||
786 | 808 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
787 | 809 | ) |
788 | 810 | ); |
789 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
790 | - $smcFunc['db_query']('', ' |
|
811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
812 | + $smcFunc['db_query']('', ' |
|
791 | 813 | UPDATE {db_prefix}boards |
792 | 814 | SET {raw:column} = {string:member_group_access} |
793 | 815 | WHERE id_board = {int:current_board}', |
@@ -797,11 +819,12 @@ discard block |
||
797 | 819 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
798 | 820 | ) |
799 | 821 | ); |
822 | + } |
|
800 | 823 | $smcFunc['db_free_result']($request); |
801 | 824 | |
802 | 825 | // Add the membergroup to all boards that hadn't been set yet. |
803 | - if (!empty($changed_boards[$board_action])) |
|
804 | - $smcFunc['db_query']('', ' |
|
826 | + if (!empty($changed_boards[$board_action])) { |
|
827 | + $smcFunc['db_query']('', ' |
|
805 | 828 | UPDATE {db_prefix}boards |
806 | 829 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
807 | 830 | WHERE id_board IN ({array_int:board_list}) |
@@ -815,6 +838,7 @@ discard block |
||
815 | 838 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
816 | 839 | ) |
817 | 840 | ); |
841 | + } |
|
818 | 842 | } |
819 | 843 | } |
820 | 844 | |
@@ -840,12 +864,14 @@ discard block |
||
840 | 864 | ) |
841 | 865 | ); |
842 | 866 | $updates = array(); |
843 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
844 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
868 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
869 | + } |
|
845 | 870 | $smcFunc['db_free_result']($request); |
846 | 871 | |
847 | - foreach ($updates as $additional_groups => $memberArray) |
|
848 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
872 | + foreach ($updates as $additional_groups => $memberArray) { |
|
873 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
874 | + } |
|
849 | 875 | |
850 | 876 | // Sorry, but post groups can't moderate boards |
851 | 877 | $smcFunc['db_query']('', ' |
@@ -855,8 +881,7 @@ discard block |
||
855 | 881 | 'current_group' => (int) $_REQUEST['group'], |
856 | 882 | ) |
857 | 883 | ); |
858 | - } |
|
859 | - elseif ($_REQUEST['group'] != 3) |
|
884 | + } elseif ($_REQUEST['group'] != 3) |
|
860 | 885 | { |
861 | 886 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
862 | 887 | if ($_POST['group_hidden'] == 2) |
@@ -871,8 +896,9 @@ discard block |
||
871 | 896 | ) |
872 | 897 | ); |
873 | 898 | $updates = array(); |
874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
875 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
899 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
900 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
901 | + } |
|
876 | 902 | $smcFunc['db_free_result']($request); |
877 | 903 | |
878 | 904 | foreach ($updates as $additional_groups => $memberArray) |
@@ -914,8 +940,9 @@ discard block |
||
914 | 940 | $smcFunc['db_free_result']($request); |
915 | 941 | |
916 | 942 | // Do we need to update the setting? |
917 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
918 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
943 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
944 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
945 | + } |
|
919 | 946 | } |
920 | 947 | |
921 | 948 | // Do we need to set inherited permissions? |
@@ -948,8 +975,9 @@ discard block |
||
948 | 975 | { |
949 | 976 | $moderators[$k] = trim($moderators[$k]); |
950 | 977 | |
951 | - if (strlen($moderators[$k]) == 0) |
|
952 | - unset($moderators[$k]); |
|
978 | + if (strlen($moderators[$k]) == 0) { |
|
979 | + unset($moderators[$k]); |
|
980 | + } |
|
953 | 981 | } |
954 | 982 | |
955 | 983 | // Find all the id_member's for the member_name's in the list. |
@@ -965,8 +993,9 @@ discard block |
||
965 | 993 | 'count' => count($moderators), |
966 | 994 | ) |
967 | 995 | ); |
968 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
969 | - $group_moderators[] = $row['id_member']; |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $group_moderators[] = $row['id_member']; |
|
998 | + } |
|
970 | 999 | $smcFunc['db_free_result']($request); |
971 | 1000 | } |
972 | 1001 | } |
@@ -974,8 +1003,9 @@ discard block |
||
974 | 1003 | if (!empty($_POST['moderator_list'])) |
975 | 1004 | { |
976 | 1005 | $moderators = array(); |
977 | - foreach ($_POST['moderator_list'] as $moderator) |
|
978 | - $moderators[] = (int) $moderator; |
|
1006 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
1007 | + $moderators[] = (int) $moderator; |
|
1008 | + } |
|
979 | 1009 | |
980 | 1010 | if (!empty($moderators)) |
981 | 1011 | { |
@@ -989,8 +1019,9 @@ discard block |
||
989 | 1019 | 'num_moderators' => count($moderators), |
990 | 1020 | ) |
991 | 1021 | ); |
992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
993 | - $group_moderators[] = $row['id_member']; |
|
1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1023 | + $group_moderators[] = $row['id_member']; |
|
1024 | + } |
|
994 | 1025 | $smcFunc['db_free_result']($request); |
995 | 1026 | } |
996 | 1027 | } |
@@ -1002,8 +1033,9 @@ discard block |
||
1002 | 1033 | if (!empty($group_moderators)) |
1003 | 1034 | { |
1004 | 1035 | $mod_insert = array(); |
1005 | - foreach ($group_moderators as $moderator) |
|
1006 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1036 | + foreach ($group_moderators as $moderator) { |
|
1037 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1038 | + } |
|
1007 | 1039 | |
1008 | 1040 | $smcFunc['db_insert']('insert', |
1009 | 1041 | '{db_prefix}group_moderators', |
@@ -1037,8 +1069,9 @@ discard block |
||
1037 | 1069 | 'current_group' => (int) $_REQUEST['group'], |
1038 | 1070 | ) |
1039 | 1071 | ); |
1040 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1041 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
1072 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1073 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
1074 | + } |
|
1042 | 1075 | $row = $smcFunc['db_fetch_assoc']($request); |
1043 | 1076 | $smcFunc['db_free_result']($request); |
1044 | 1077 | |
@@ -1075,14 +1108,16 @@ discard block |
||
1075 | 1108 | ) |
1076 | 1109 | ); |
1077 | 1110 | $context['group']['moderators'] = array(); |
1078 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1079 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1111 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1112 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1113 | + } |
|
1080 | 1114 | $smcFunc['db_free_result']($request); |
1081 | 1115 | |
1082 | 1116 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
1083 | 1117 | |
1084 | - if (!empty($context['group']['moderators'])) |
|
1085 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1118 | + if (!empty($context['group']['moderators'])) { |
|
1119 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1120 | + } |
|
1086 | 1121 | |
1087 | 1122 | // Get a list of boards this membergroup is allowed to see. |
1088 | 1123 | $context['boards'] = array(); |
@@ -1102,12 +1137,13 @@ discard block |
||
1102 | 1137 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1103 | 1138 | { |
1104 | 1139 | // This category hasn't been set up yet.. |
1105 | - if (!isset($context['categories'][$row['id_cat']])) |
|
1106 | - $context['categories'][$row['id_cat']] = array( |
|
1140 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
1141 | + $context['categories'][$row['id_cat']] = array( |
|
1107 | 1142 | 'id' => $row['id_cat'], |
1108 | 1143 | 'name' => $row['cat_name'], |
1109 | 1144 | 'boards' => array() |
1110 | 1145 | ); |
1146 | + } |
|
1111 | 1147 | |
1112 | 1148 | // Set this board up, and let the template know when it's a child. (indent them..) |
1113 | 1149 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1155,19 +1191,22 @@ discard block |
||
1155 | 1191 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
1156 | 1192 | |
1157 | 1193 | // If this is bigger than 128 in width or 32 in height, skip this one. |
1158 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
1159 | - continue; |
|
1194 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
1195 | + continue; |
|
1196 | + } |
|
1160 | 1197 | |
1161 | 1198 | // Else it's valid. Add it in. |
1162 | - else |
|
1163 | - $context['possible_icons'][] = $value; |
|
1199 | + else { |
|
1200 | + $context['possible_icons'][] = $value; |
|
1201 | + } |
|
1164 | 1202 | } |
1165 | 1203 | } |
1166 | 1204 | } |
1167 | 1205 | |
1168 | 1206 | // Insert our JS, if we have possible icons. |
1169 | - if (!empty($context['possible_icons'])) |
|
1170 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1207 | + if (!empty($context['possible_icons'])) { |
|
1208 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1209 | + } |
|
1171 | 1210 | |
1172 | 1211 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
1173 | 1212 | |
@@ -1189,8 +1228,9 @@ discard block |
||
1189 | 1228 | ) |
1190 | 1229 | ); |
1191 | 1230 | $context['inheritable_groups'] = array(); |
1192 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1193 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1232 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1233 | + } |
|
1194 | 1234 | $smcFunc['db_free_result']($request); |
1195 | 1235 | |
1196 | 1236 | call_integration_hook('integrate_view_membergroup'); |