@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | foreach ($context['categories'] as $category) |
68 | 68 | { |
69 | 69 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
70 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
71 | - continue; |
|
70 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
71 | + continue; |
|
72 | + } |
|
72 | 73 | |
73 | 74 | echo ' |
74 | 75 | <div class="main_container"> |
@@ -76,9 +77,10 @@ discard block |
||
76 | 77 | <h3 class="catbg">'; |
77 | 78 | |
78 | 79 | // If this category even can collapse, show a link to collapse it. |
79 | - if ($category['can_collapse']) |
|
80 | - echo ' |
|
80 | + if ($category['can_collapse']) { |
|
81 | + echo ' |
|
81 | 82 | <span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>'; |
83 | + } |
|
82 | 84 | |
83 | 85 | echo ' |
84 | 86 | ', $category['link'], ' |
@@ -105,17 +107,19 @@ discard block |
||
105 | 107 | </a>'; |
106 | 108 | |
107 | 109 | // Has it outstanding posts for approval? |
108 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
109 | - echo ' |
|
110 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
111 | + echo ' |
|
110 | 112 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
113 | + } |
|
111 | 114 | |
112 | 115 | echo ' |
113 | 116 | <p class="board_description">', $board['description'], '</p>'; |
114 | 117 | |
115 | 118 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
116 | - if (!empty($board['link_moderators'])) |
|
117 | - echo ' |
|
119 | + if (!empty($board['link_moderators'])) { |
|
120 | + echo ' |
|
118 | 121 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
122 | + } |
|
119 | 123 | |
120 | 124 | // Show some basic information about the number of posts, etc. |
121 | 125 | echo ' |
@@ -127,9 +131,10 @@ discard block |
||
127 | 131 | </div> |
128 | 132 | <div class="lastpost ',!empty($board['last_post']['id']) ? 'lpr_border' : 'hidden', '">'; |
129 | 133 | |
130 | - if (!empty($board['last_post']['id'])) |
|
131 | - echo ' |
|
134 | + if (!empty($board['last_post']['id'])) { |
|
135 | + echo ' |
|
132 | 136 | <p>', $board['last_post']['last_post_message'], '</p>'; |
137 | + } |
|
133 | 138 | echo ' |
134 | 139 | </div>'; |
135 | 140 | // Show the "Child Boards: ". (there's a link_children but we're going to bold the new ones...) |
@@ -141,14 +146,16 @@ discard block |
||
141 | 146 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
142 | 147 | foreach ($board['children'] as $child) |
143 | 148 | { |
144 | - if (!$child['is_redirect']) |
|
145 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
146 | - else |
|
147 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
149 | + if (!$child['is_redirect']) { |
|
150 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
151 | + } else { |
|
152 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
153 | + } |
|
148 | 154 | |
149 | 155 | // Has it posts awaiting approval? |
150 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
151 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
156 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
157 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
158 | + } |
|
152 | 159 | |
153 | 160 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
154 | 161 | } |
@@ -172,10 +179,11 @@ discard block |
||
172 | 179 | </div>'; |
173 | 180 | |
174 | 181 | // Show the mark all as read button? |
175 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
176 | - echo ' |
|
182 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
183 | + echo ' |
|
177 | 184 | <div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>'; |
178 | -} |
|
185 | + } |
|
186 | + } |
|
179 | 187 | |
180 | 188 | /** |
181 | 189 | * The lower part of the outer layer of the board index |
@@ -192,8 +200,9 @@ discard block |
||
192 | 200 | { |
193 | 201 | global $context, $options, $txt; |
194 | 202 | |
195 | - if (empty($context['info_center'])) |
|
196 | - return; |
|
203 | + if (empty($context['info_center'])) { |
|
204 | + return; |
|
205 | + } |
|
197 | 206 | |
198 | 207 | // Here's where the "Info Center" starts... |
199 | 208 | echo ' |
@@ -293,14 +302,15 @@ discard block |
||
293 | 302 | /* Each post in latest_posts has: |
294 | 303 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
295 | 304 | subject, short_subject (shortened with...), time, link, and href. */ |
296 | - foreach ($context['latest_posts'] as $post) |
|
297 | - echo ' |
|
305 | + foreach ($context['latest_posts'] as $post) { |
|
306 | + echo ' |
|
298 | 307 | <tr class="windowbg"> |
299 | 308 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
300 | 309 | <td class="recentposter">', $post['poster']['link'], '</td> |
301 | 310 | <td class="recentboard">', $post['board']['link'], '</td> |
302 | 311 | <td class="recenttime">', $post['time'], '</td> |
303 | 312 | </tr>'; |
313 | + } |
|
304 | 314 | echo ' |
305 | 315 | </table>'; |
306 | 316 | } |
@@ -324,9 +334,10 @@ discard block |
||
324 | 334 | </div>'; |
325 | 335 | |
326 | 336 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P. |
327 | - if (!empty($context['calendar_holidays'])) |
|
328 | - echo ' |
|
337 | + if (!empty($context['calendar_holidays'])) { |
|
338 | + echo ' |
|
329 | 339 | <p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>'; |
340 | + } |
|
330 | 341 | |
331 | 342 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
332 | 343 | if (!empty($context['calendar_birthdays'])) |
@@ -335,9 +346,10 @@ discard block |
||
335 | 346 | <p class="inline"> |
336 | 347 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
337 | 348 | // Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?) |
338 | - foreach ($context['calendar_birthdays'] as $member) |
|
339 | - echo ' |
|
349 | + foreach ($context['calendar_birthdays'] as $member) { |
|
350 | + echo ' |
|
340 | 351 | <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', '; |
352 | + } |
|
341 | 353 | echo ' |
342 | 354 | </p>'; |
343 | 355 | } |
@@ -351,9 +363,10 @@ discard block |
||
351 | 363 | |
352 | 364 | // Each event in calendar_events should have: |
353 | 365 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
354 | - foreach ($context['calendar_events'] as $event) |
|
355 | - echo ' |
|
366 | + foreach ($context['calendar_events'] as $event) { |
|
367 | + echo ' |
|
356 | 368 | ', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', '; |
369 | + } |
|
357 | 370 | echo ' |
358 | 371 | </p>'; |
359 | 372 | } |
@@ -398,15 +411,19 @@ discard block |
||
398 | 411 | |
399 | 412 | // Handle hidden users and buddies. |
400 | 413 | $bracketList = array(); |
401 | - if ($context['show_buddies']) |
|
402 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
403 | - if (!empty($context['num_spiders'])) |
|
404 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
405 | - if (!empty($context['num_users_hidden'])) |
|
406 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
414 | + if ($context['show_buddies']) { |
|
415 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
416 | + } |
|
417 | + if (!empty($context['num_spiders'])) { |
|
418 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
419 | + } |
|
420 | + if (!empty($context['num_users_hidden'])) { |
|
421 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
422 | + } |
|
407 | 423 | |
408 | - if (!empty($bracketList)) |
|
409 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
424 | + if (!empty($bracketList)) { |
|
425 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
426 | + } |
|
410 | 427 | |
411 | 428 | echo $context['show_who'] ? '</a>' : '', ' |
412 | 429 | |
@@ -420,9 +437,10 @@ discard block |
||
420 | 437 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
421 | 438 | |
422 | 439 | // Showing membergroups? |
423 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
424 | - echo ' |
|
440 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
441 | + echo ' |
|
425 | 442 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
443 | + } |
|
426 | 444 | } |
427 | 445 | |
428 | 446 | echo ' |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | echo ' |
74 | 74 | <div class="main_container"> |
75 | - <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '','" id="category_', $category['id'], '"> |
|
75 | + <div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '', '" id="category_', $category['id'], '"> |
|
76 | 76 | <h3 class="catbg">'; |
77 | 77 | |
78 | 78 | // If this category even can collapse, show a link to collapse it. |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | foreach ($board['children'] as $child) |
143 | 143 | { |
144 | 144 | if (!$child['is_redirect']) |
145 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
145 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
146 | 146 | else |
147 | 147 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
148 | 148 |
@@ -86,7 +86,7 @@ |
||
86 | 86 | foreach ($board['children'] as $child) |
87 | 87 | { |
88 | 88 | if (!$child['is_redirect']) |
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
89 | + $child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | 90 | else |
91 | 91 | $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
92 | 92 |
@@ -48,17 +48,19 @@ discard block |
||
48 | 48 | </a>'; |
49 | 49 | |
50 | 50 | // Has it outstanding posts for approval? |
51 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
52 | - echo ' |
|
51 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
52 | + echo ' |
|
53 | 53 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>'; |
54 | + } |
|
54 | 55 | |
55 | 56 | echo ' |
56 | 57 | <p class="board_description">', $board['description'], '</p>'; |
57 | 58 | |
58 | 59 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
59 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
60 | - echo ' |
|
60 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
61 | + echo ' |
|
61 | 62 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
63 | + } |
|
62 | 64 | |
63 | 65 | // Show some basic information about the number of posts, etc. |
64 | 66 | echo ' |
@@ -70,9 +72,10 @@ discard block |
||
70 | 72 | </div> |
71 | 73 | <div class="lastpost lpr_border">'; |
72 | 74 | |
73 | - if (!empty($board['last_post']['id'])) |
|
74 | - echo ' |
|
75 | + if (!empty($board['last_post']['id'])) { |
|
76 | + echo ' |
|
75 | 77 | <p>', $board['last_post']['last_post_message'], '</p>'; |
78 | + } |
|
76 | 79 | echo ' |
77 | 80 | </div>'; |
78 | 81 | |
@@ -85,14 +88,16 @@ discard block |
||
85 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
86 | 89 | foreach ($board['children'] as $child) |
87 | 90 | { |
88 | - if (!$child['is_redirect']) |
|
89 | - $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
90 | - else |
|
91 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
92 | 96 | |
93 | 97 | // Has it posts awaiting approval? |
94 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
95 | - $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>'; |
|
100 | + } |
|
96 | 101 | |
97 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
98 | 103 | } |
@@ -111,8 +116,9 @@ discard block |
||
111 | 116 | } |
112 | 117 | |
113 | 118 | // They can only mark read if they are logged in and it's enabled! |
114 | - if (!$context['user']['is_logged']) |
|
115 | - unset($context['normal_buttons']['markread']); |
|
119 | + if (!$context['user']['is_logged']) { |
|
120 | + unset($context['normal_buttons']['markread']); |
|
121 | + } |
|
116 | 122 | |
117 | 123 | if (!$context['no_topic_listing']) |
118 | 124 | { |
@@ -138,13 +144,15 @@ discard block |
||
138 | 144 | <div id="description_board" class="generic_list_wrapper"> |
139 | 145 | <h3>', $context['name'], '</h3> |
140 | 146 | <p>'; |
141 | - if ($context['description'] != '') |
|
142 | - echo ' |
|
147 | + if ($context['description'] != '') { |
|
148 | + echo ' |
|
143 | 149 | ', $context['description'], ' '; |
150 | + } |
|
144 | 151 | |
145 | - if (!empty($context['moderators'])) |
|
146 | - echo ' |
|
152 | + if (!empty($context['moderators'])) { |
|
153 | + echo ' |
|
147 | 154 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
155 | + } |
|
148 | 156 | |
149 | 157 | echo ' |
150 | 158 | </p> |
@@ -152,9 +160,10 @@ discard block |
||
152 | 160 | } |
153 | 161 | |
154 | 162 | // If Quick Moderation is enabled start the form. |
155 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
156 | - echo ' |
|
163 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
164 | + echo ' |
|
157 | 165 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
166 | + } |
|
158 | 167 | |
159 | 168 | echo ' |
160 | 169 | <div id="messageindex">'; |
@@ -162,10 +171,11 @@ discard block |
||
162 | 171 | { |
163 | 172 | echo ' |
164 | 173 | <div class="information">'; |
165 | - if ($settings['display_who_viewing'] == 1) |
|
166 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
167 | - else |
|
168 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
174 | + if ($settings['display_who_viewing'] == 1) { |
|
175 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
176 | + } else { |
|
177 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
178 | + } |
|
169 | 179 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
170 | 180 | |
171 | 181 | echo ' |
@@ -184,19 +194,22 @@ discard block |
||
184 | 194 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
185 | 195 | |
186 | 196 | // Show a "select all" box for quick moderation? |
187 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
188 | - echo ' |
|
197 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
198 | + echo ' |
|
189 | 199 | <div class="moderation"><input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"></div>'; |
200 | + } |
|
190 | 201 | |
191 | 202 | // If it's on in "image" mode, don't show anything but the column. |
192 | - elseif (!empty($context['can_quick_mod'])) |
|
193 | - echo ' |
|
203 | + elseif (!empty($context['can_quick_mod'])) { |
|
204 | + echo ' |
|
194 | 205 | <div class="moderation"> </div>'; |
206 | + } |
|
195 | 207 | } |
196 | 208 | // No topics.... just say, "sorry bub". |
197 | - else |
|
198 | - echo ' |
|
209 | + else { |
|
210 | + echo ' |
|
199 | 211 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
212 | + } |
|
200 | 213 | |
201 | 214 | echo ' |
202 | 215 | </div>'; |
@@ -228,21 +241,26 @@ discard block |
||
228 | 241 | // Now we handle the icons |
229 | 242 | echo ' |
230 | 243 | <div class="icons floatright">'; |
231 | - if ($topic['is_watched']) |
|
232 | - echo ' |
|
244 | + if ($topic['is_watched']) { |
|
245 | + echo ' |
|
233 | 246 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
234 | - if ($topic['is_locked']) |
|
235 | - echo ' |
|
247 | + } |
|
248 | + if ($topic['is_locked']) { |
|
249 | + echo ' |
|
236 | 250 | <span class="generic_icons lock"></span>'; |
237 | - if ($topic['is_sticky']) |
|
238 | - echo ' |
|
251 | + } |
|
252 | + if ($topic['is_sticky']) { |
|
253 | + echo ' |
|
239 | 254 | <span class="generic_icons sticky"></span>'; |
240 | - if ($topic['is_redirect']) |
|
241 | - echo ' |
|
255 | + } |
|
256 | + if ($topic['is_redirect']) { |
|
257 | + echo ' |
|
242 | 258 | <span class="generic_icons move"></span>'; |
243 | - if ($topic['is_poll']) |
|
244 | - echo ' |
|
259 | + } |
|
260 | + if ($topic['is_poll']) { |
|
261 | + echo ' |
|
245 | 262 | <span class="generic_icons poll"></span>'; |
263 | + } |
|
246 | 264 | echo ' |
247 | 265 | </div>'; |
248 | 266 | |
@@ -268,26 +286,31 @@ discard block |
||
268 | 286 | { |
269 | 287 | echo ' |
270 | 288 | <div class="moderation">'; |
271 | - if ($options['display_quick_mod'] == 1) |
|
272 | - echo ' |
|
289 | + if ($options['display_quick_mod'] == 1) { |
|
290 | + echo ' |
|
273 | 291 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
274 | - else |
|
292 | + } else |
|
275 | 293 | { |
276 | 294 | // Check permissions on each and show only the ones they are allowed to use. |
277 | - if ($topic['quick_mod']['remove']) |
|
278 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
295 | + if ($topic['quick_mod']['remove']) { |
|
296 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
297 | + } |
|
279 | 298 | |
280 | - if ($topic['quick_mod']['lock']) |
|
281 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
299 | + if ($topic['quick_mod']['lock']) { |
|
300 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
301 | + } |
|
282 | 302 | |
283 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
284 | - echo '<br>'; |
|
303 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
304 | + echo '<br>'; |
|
305 | + } |
|
285 | 306 | |
286 | - if ($topic['quick_mod']['sticky']) |
|
287 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
307 | + if ($topic['quick_mod']['sticky']) { |
|
308 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
309 | + } |
|
288 | 310 | |
289 | - if ($topic['quick_mod']['move']) |
|
290 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
311 | + if ($topic['quick_mod']['move']) { |
|
312 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
313 | + } |
|
291 | 314 | } |
292 | 315 | echo ' |
293 | 316 | </div>'; |
@@ -305,18 +328,20 @@ discard block |
||
305 | 328 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
306 | 329 | <option value="">--------</option>'; |
307 | 330 | |
308 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
309 | - if ($context['can_' . $qmod_action]) |
|
331 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
332 | + if ($context['can_' . $qmod_action]) |
|
310 | 333 | echo ' |
311 | 334 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
335 | + } |
|
312 | 336 | |
313 | 337 | echo ' |
314 | 338 | </select>'; |
315 | 339 | |
316 | 340 | // Show a list of boards they can move the topic to. |
317 | - if ($context['can_move']) |
|
318 | - echo ' |
|
341 | + if ($context['can_move']) { |
|
342 | + echo ' |
|
319 | 343 | <span id="quick_mod_jump_to"> </span>'; |
344 | + } |
|
320 | 345 | |
321 | 346 | echo ' |
322 | 347 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -327,10 +352,11 @@ discard block |
||
327 | 352 | </div>'; |
328 | 353 | |
329 | 354 | // Finish off the form - again. |
330 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
331 | - echo ' |
|
355 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
356 | + echo ' |
|
332 | 357 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
333 | 358 | </form>'; |
359 | + } |
|
334 | 360 | |
335 | 361 | // Mobile action buttons (bottom) |
336 | 362 | echo ' |
@@ -352,8 +378,8 @@ discard block |
||
352 | 378 | // Show breadcrumbs at the bottom too. |
353 | 379 | theme_linktree(); |
354 | 380 | |
355 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
356 | - echo ' |
|
381 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
382 | + echo ' |
|
357 | 383 | <script> |
358 | 384 | if (typeof(window.XMLHttpRequest) != "undefined") |
359 | 385 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -372,6 +398,7 @@ discard block |
||
372 | 398 | sCustomName: "move_to" |
373 | 399 | }); |
374 | 400 | </script>'; |
401 | + } |
|
375 | 402 | |
376 | 403 | // Javascript for inline editing. |
377 | 404 | echo ' |
@@ -407,8 +434,8 @@ discard block |
||
407 | 434 | <div class="information"> |
408 | 435 | <p class="floatright" id="message_index_jump_to"> </p>'; |
409 | 436 | |
410 | - if (empty($context['no_topic_listing'])) |
|
411 | - echo ' |
|
437 | + if (empty($context['no_topic_listing'])) { |
|
438 | + echo ' |
|
412 | 439 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
413 | 440 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
414 | 441 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -418,9 +445,10 @@ discard block |
||
418 | 445 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
419 | 446 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
420 | 447 | </p>'; |
448 | + } |
|
421 | 449 | |
422 | - if (!empty($context['jump_to'])) |
|
423 | - echo ' |
|
450 | + if (!empty($context['jump_to'])) { |
|
451 | + echo ' |
|
424 | 452 | <script> |
425 | 453 | if (typeof(window.XMLHttpRequest) != "undefined") |
426 | 454 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -436,6 +464,7 @@ discard block |
||
436 | 464 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
437 | 465 | }); |
438 | 466 | </script>'; |
467 | + } |
|
439 | 468 | |
440 | 469 | echo ' |
441 | 470 | <br class="clear"> |
@@ -2259,9 +2259,9 @@ discard block |
||
2259 | 2259 | * |
2260 | 2260 | * @uses the template_include() function to include the file. |
2261 | 2261 | * @param string $template_name The name of the template to load |
2262 | - * @param array|string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2262 | + * @param string $style_sheets The name of a single stylesheet or an array of names of stylesheets to load |
|
2263 | 2263 | * @param bool $fatal If true, dies with an error message if the template cannot be found |
2264 | - * @return boolean Whether or not the template was loaded |
|
2264 | + * @return boolean|null Whether or not the template was loaded |
|
2265 | 2265 | */ |
2266 | 2266 | function loadTemplate($template_name, $style_sheets = array(), $fatal = true) |
2267 | 2267 | { |
@@ -2444,7 +2444,7 @@ discard block |
||
2444 | 2444 | * - all code added with this function is added to the same <style> tag so do make sure your css is valid! |
2445 | 2445 | * |
2446 | 2446 | * @param string $css Some css code |
2447 | - * @return void|bool Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2447 | + * @return false|null Adds the CSS to the $context['css_header'] array or returns if no CSS is specified |
|
2448 | 2448 | */ |
2449 | 2449 | function addInlineCss($css) |
2450 | 2450 | { |
@@ -2558,7 +2558,7 @@ discard block |
||
2558 | 2558 | * |
2559 | 2559 | * @param string $javascript Some JS code |
2560 | 2560 | * @param bool $defer Whether the script should load in <head> or before the closing <html> tag |
2561 | - * @return void|bool Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2561 | + * @return false|null Adds the code to one of the $context['javascript_inline'] arrays or returns if no JS was specified |
|
2562 | 2562 | */ |
2563 | 2563 | function addInlineJavaScript($javascript, $defer = false) |
2564 | 2564 | { |
@@ -2791,7 +2791,7 @@ discard block |
||
2791 | 2791 | * It will try to choose only utf8 or non-utf8 languages. |
2792 | 2792 | * |
2793 | 2793 | * @param bool $use_cache Whether or not to use the cache |
2794 | - * @return array An array of information about available languages |
|
2794 | + * @return string An array of information about available languages |
|
2795 | 2795 | */ |
2796 | 2796 | function getLanguages($use_cache = true) |
2797 | 2797 | { |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * 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,28 +48,36 @@ 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 | 73 | // We excpiclity do not use $smcFunc['json_decode'] here yet, as $smcFunc is not fully loaded. |
66 | - if (!is_array($modSettings['attachmentUploadDir'])) |
|
67 | - $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
74 | + if (!is_array($modSettings['attachmentUploadDir'])) { |
|
75 | + $modSettings['attachmentUploadDir'] = smf_json_decode($modSettings['attachmentUploadDir'], true); |
|
76 | + } |
|
68 | 77 | |
69 | - if (!empty($cache_enable)) |
|
70 | - cache_put_data('modSettings', $modSettings, 90); |
|
78 | + if (!empty($cache_enable)) { |
|
79 | + cache_put_data('modSettings', $modSettings, 90); |
|
80 | + } |
|
71 | 81 | } |
72 | 82 | |
73 | 83 | $modSettings['cache_enable'] = $cache_enable; |
@@ -87,8 +97,9 @@ discard block |
||
87 | 97 | }; |
88 | 98 | $fix_utf8mb4 = function($string) use ($utf8, $smcFunc) |
89 | 99 | { |
90 | - if (!$utf8 || $smcFunc['db_mb4']) |
|
91 | - return $string; |
|
100 | + if (!$utf8 || $smcFunc['db_mb4']) { |
|
101 | + return $string; |
|
102 | + } |
|
92 | 103 | |
93 | 104 | $i = 0; |
94 | 105 | $len = strlen($string); |
@@ -100,18 +111,15 @@ discard block |
||
100 | 111 | { |
101 | 112 | $new_string .= $string[$i]; |
102 | 113 | $i++; |
103 | - } |
|
104 | - elseif ($ord < 224) |
|
114 | + } elseif ($ord < 224) |
|
105 | 115 | { |
106 | 116 | $new_string .= $string[$i] . $string[$i + 1]; |
107 | 117 | $i += 2; |
108 | - } |
|
109 | - elseif ($ord < 240) |
|
118 | + } elseif ($ord < 240) |
|
110 | 119 | { |
111 | 120 | $new_string .= $string[$i] . $string[$i + 1] . $string[$i + 2]; |
112 | 121 | $i += 3; |
113 | - } |
|
114 | - elseif ($ord < 248) |
|
122 | + } elseif ($ord < 248) |
|
115 | 123 | { |
116 | 124 | // Magic happens. |
117 | 125 | $val = (ord($string[$i]) & 0x07) << 18; |
@@ -155,8 +163,7 @@ discard block |
||
155 | 163 | { |
156 | 164 | $result = array_search($needle, array_slice($haystack_arr, $offset)); |
157 | 165 | return is_int($result) ? $result + $offset : false; |
158 | - } |
|
159 | - else |
|
166 | + } else |
|
160 | 167 | { |
161 | 168 | $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); |
162 | 169 | $needle_size = count($needle_arr); |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | while ((int) $result === $result) |
166 | 173 | { |
167 | 174 | $offset += $result; |
168 | - if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) |
|
169 | - return $offset; |
|
175 | + if (array_slice($haystack_arr, $offset, $needle_size) === $needle_arr) { |
|
176 | + return $offset; |
|
177 | + } |
|
170 | 178 | $result = array_search($needle_arr[0], array_slice($haystack_arr, ++$offset)); |
171 | 179 | } |
172 | 180 | return false; |
@@ -204,8 +212,9 @@ discard block |
||
204 | 212 | $string = $ent_check($string); |
205 | 213 | preg_match('~^(' . $ent_list . '|.){' . $smcFunc['strlen'](substr($string, 0, $length)) . '}~' . ($utf8 ? 'u' : ''), $string, $matches); |
206 | 214 | $string = $matches[0]; |
207 | - while (strlen($string) > $length) |
|
208 | - $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
215 | + while (strlen($string) > $length) { |
|
216 | + $string = preg_replace('~(?:' . $ent_list . '|.)$~' . ($utf8 ? 'u' : ''), '', $string); |
|
217 | + } |
|
209 | 218 | return $string; |
210 | 219 | }, |
211 | 220 | 'ucfirst' => $utf8 ? function($string) use (&$smcFunc) |
@@ -215,8 +224,9 @@ discard block |
||
215 | 224 | 'ucwords' => $utf8 ? function($string) use (&$smcFunc) |
216 | 225 | { |
217 | 226 | $words = preg_split('~([\s\r\n\t]+)~', $string, -1, PREG_SPLIT_DELIM_CAPTURE); |
218 | - for ($i = 0, $n = count($words); $i < $n; $i += 2) |
|
219 | - $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
227 | + for ($i = 0, $n = count($words); $i < $n; $i += 2) { |
|
228 | + $words[$i] = $smcFunc['ucfirst']($words[$i]); |
|
229 | + } |
|
220 | 230 | return implode('', $words); |
221 | 231 | } : 'ucwords', |
222 | 232 | 'json_decode' => 'smf_json_decode', |
@@ -224,16 +234,17 @@ discard block |
||
224 | 234 | ); |
225 | 235 | |
226 | 236 | // Setting the timezone is a requirement for some functions. |
227 | - if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
|
228 | - date_default_timezone_set($modSettings['default_timezone']); |
|
229 | - else |
|
237 | + if (isset($modSettings['default_timezone']) && in_array($modSettings['default_timezone'], timezone_identifiers_list())) { |
|
238 | + date_default_timezone_set($modSettings['default_timezone']); |
|
239 | + } else |
|
230 | 240 | { |
231 | 241 | // Get PHP's default timezone, if set |
232 | 242 | $ini_tz = ini_get('date.timezone'); |
233 | - if (!empty($ini_tz)) |
|
234 | - $modSettings['default_timezone'] = $ini_tz; |
|
235 | - else |
|
236 | - $modSettings['default_timezone'] = ''; |
|
243 | + if (!empty($ini_tz)) { |
|
244 | + $modSettings['default_timezone'] = $ini_tz; |
|
245 | + } else { |
|
246 | + $modSettings['default_timezone'] = ''; |
|
247 | + } |
|
237 | 248 | |
238 | 249 | // If date.timezone is unset, invalid, or just plain weird, make a best guess |
239 | 250 | if (!in_array($modSettings['default_timezone'], timezone_identifiers_list())) |
@@ -251,22 +262,26 @@ discard block |
||
251 | 262 | if (($modSettings['load_average'] = cache_get_data('loadavg', 90)) == null) |
252 | 263 | { |
253 | 264 | $modSettings['load_average'] = @file_get_contents('/proc/loadavg'); |
254 | - if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) |
|
255 | - $modSettings['load_average'] = (float) $matches[1]; |
|
256 | - elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) |
|
257 | - $modSettings['load_average'] = (float) $matches[1]; |
|
258 | - else |
|
259 | - unset($modSettings['load_average']); |
|
265 | + if (!empty($modSettings['load_average']) && preg_match('~^([^ ]+?) ([^ ]+?) ([^ ]+)~', $modSettings['load_average'], $matches) != 0) { |
|
266 | + $modSettings['load_average'] = (float) $matches[1]; |
|
267 | + } elseif (($modSettings['load_average'] = @`uptime`) != null && preg_match('~load average[s]?: (\d+\.\d+), (\d+\.\d+), (\d+\.\d+)~i', $modSettings['load_average'], $matches) != 0) { |
|
268 | + $modSettings['load_average'] = (float) $matches[1]; |
|
269 | + } else { |
|
270 | + unset($modSettings['load_average']); |
|
271 | + } |
|
260 | 272 | |
261 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
262 | - cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
273 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
274 | + cache_put_data('loadavg', $modSettings['load_average'], 90); |
|
275 | + } |
|
263 | 276 | } |
264 | 277 | |
265 | - if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) |
|
266 | - call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
278 | + if (!empty($modSettings['load_average']) || $modSettings['load_average'] === 0.0) { |
|
279 | + call_integration_hook('integrate_load_average', array($modSettings['load_average'])); |
|
280 | + } |
|
267 | 281 | |
268 | - if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) |
|
269 | - display_loadavg_error(); |
|
282 | + if (!empty($modSettings['loadavg_forum']) && !empty($modSettings['load_average']) && $modSettings['load_average'] >= $modSettings['loadavg_forum']) { |
|
283 | + display_loadavg_error(); |
|
284 | + } |
|
270 | 285 | } |
271 | 286 | |
272 | 287 | // Is post moderation alive and well? Everywhere else assumes this has been defined, so let's make sure it is. |
@@ -287,8 +302,9 @@ discard block |
||
287 | 302 | if (defined('SMF_INTEGRATION_SETTINGS')) |
288 | 303 | { |
289 | 304 | $integration_settings = $smcFunc['json_decode'](SMF_INTEGRATION_SETTINGS, true); |
290 | - foreach ($integration_settings as $hook => $function) |
|
291 | - add_integration_function($hook, $function, '', false); |
|
305 | + foreach ($integration_settings as $hook => $function) { |
|
306 | + add_integration_function($hook, $function, '', false); |
|
307 | + } |
|
292 | 308 | } |
293 | 309 | |
294 | 310 | // Any files to pre include? |
@@ -298,8 +314,9 @@ discard block |
||
298 | 314 | foreach ($pre_includes as $include) |
299 | 315 | { |
300 | 316 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir)); |
301 | - if (file_exists($include)) |
|
302 | - require_once($include); |
|
317 | + if (file_exists($include)) { |
|
318 | + require_once($include); |
|
319 | + } |
|
303 | 320 | } |
304 | 321 | } |
305 | 322 | |
@@ -403,27 +420,28 @@ discard block |
||
403 | 420 | break; |
404 | 421 | } |
405 | 422 | } |
423 | + } else { |
|
424 | + $id_member = 0; |
|
406 | 425 | } |
407 | - else |
|
408 | - $id_member = 0; |
|
409 | 426 | |
410 | 427 | if (empty($id_member) && isset($_COOKIE[$cookiename])) |
411 | 428 | { |
412 | 429 | $cookie_data = $smcFunc['json_decode']($_COOKIE[$cookiename], true, false); |
413 | 430 | |
414 | - if (empty($cookie_data)) |
|
415 | - $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
431 | + if (empty($cookie_data)) { |
|
432 | + $cookie_data = safe_unserialize($_COOKIE[$cookiename]); |
|
433 | + } |
|
416 | 434 | |
417 | 435 | list ($id_member, $password) = $cookie_data; |
418 | 436 | $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0; |
419 | - } |
|
420 | - elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
437 | + } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) |
|
421 | 438 | { |
422 | 439 | // @todo Perhaps we can do some more checking on this, such as on the first octet of the IP? |
423 | 440 | $cookie_data = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
424 | 441 | |
425 | - if (empty($cookie_data)) |
|
426 | - $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
442 | + if (empty($cookie_data)) { |
|
443 | + $cookie_data = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
444 | + } |
|
427 | 445 | |
428 | 446 | list ($id_member, $password, $login_span) = $cookie_data; |
429 | 447 | $id_member = !empty($id_member) && strlen($password) == 128 && $login_span > time() ? (int) $id_member : 0; |
@@ -448,30 +466,34 @@ discard block |
||
448 | 466 | $user_settings = $smcFunc['db_fetch_assoc']($request); |
449 | 467 | $smcFunc['db_free_result']($request); |
450 | 468 | |
451 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) |
|
452 | - $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
469 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($user_settings['avatar'], 'http://') !== false) { |
|
470 | + $user_settings['avatar'] = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($user_settings['avatar']) . '&hash=' . md5($user_settings['avatar'] . $image_proxy_secret); |
|
471 | + } |
|
453 | 472 | |
454 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
455 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
473 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
474 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
475 | + } |
|
456 | 476 | } |
457 | 477 | |
458 | 478 | // Did we find 'im? If not, junk it. |
459 | 479 | if (!empty($user_settings)) |
460 | 480 | { |
461 | 481 | // As much as the password should be right, we can assume the integration set things up. |
462 | - if (!empty($already_verified) && $already_verified === true) |
|
463 | - $check = true; |
|
482 | + if (!empty($already_verified) && $already_verified === true) { |
|
483 | + $check = true; |
|
484 | + } |
|
464 | 485 | // SHA-512 hash should be 128 characters long. |
465 | - elseif (strlen($password) == 128) |
|
466 | - $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
467 | - else |
|
468 | - $check = false; |
|
486 | + elseif (strlen($password) == 128) { |
|
487 | + $check = hash_salt($user_settings['passwd'], $user_settings['password_salt']) == $password; |
|
488 | + } else { |
|
489 | + $check = false; |
|
490 | + } |
|
469 | 491 | |
470 | 492 | // Wrong password or not activated - either way, you're going nowhere. |
471 | 493 | $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? (int) $user_settings['id_member'] : 0; |
494 | + } else { |
|
495 | + $id_member = 0; |
|
472 | 496 | } |
473 | - else |
|
474 | - $id_member = 0; |
|
475 | 497 | |
476 | 498 | // If we no longer have the member maybe they're being all hackey, stop brute force! |
477 | 499 | if (!$id_member) |
@@ -500,8 +522,9 @@ discard block |
||
500 | 522 | |
501 | 523 | list ($tfamember, $tfasecret) = $tfa_data; |
502 | 524 | |
503 | - if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) |
|
504 | - $tfasecret = null; |
|
525 | + if (!isset($tfamember, $tfasecret) || (int) $tfamember != $id_member) { |
|
526 | + $tfasecret = null; |
|
527 | + } |
|
505 | 528 | } |
506 | 529 | |
507 | 530 | if (empty($tfasecret) || hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']) != $tfasecret) |
@@ -521,10 +544,12 @@ discard block |
||
521 | 544 | // Are we forcing 2FA? Need to check if the user groups actually require 2FA |
522 | 545 | elseif (!empty($modSettings['tfa_mode']) && $modSettings['tfa_mode'] >= 2 && $id_member && empty($user_settings['tfa_secret'])) |
523 | 546 | { |
524 | - if ($modSettings['tfa_mode'] == 2) //only do this if we are just forcing SOME membergroups |
|
547 | + if ($modSettings['tfa_mode'] == 2) { |
|
548 | + //only do this if we are just forcing SOME membergroups |
|
525 | 549 | { |
526 | 550 | //Build an array of ALL user membergroups. |
527 | 551 | $full_groups = array($user_settings['id_group']); |
552 | + } |
|
528 | 553 | if (!empty($user_settings['additional_groups'])) |
529 | 554 | { |
530 | 555 | $full_groups = array_merge($full_groups, explode(',', $user_settings['additional_groups'])); |
@@ -544,15 +569,17 @@ discard block |
||
544 | 569 | ); |
545 | 570 | $row = $smcFunc['db_fetch_assoc']($request); |
546 | 571 | $smcFunc['db_free_result']($request); |
572 | + } else { |
|
573 | + $row['total'] = 1; |
|
547 | 574 | } |
548 | - else |
|
549 | - $row['total'] = 1; //simplifies logics in the next "if" |
|
575 | + //simplifies logics in the next "if" |
|
550 | 576 | |
551 | 577 | $area = !empty($_REQUEST['area']) ? $_REQUEST['area'] : ''; |
552 | 578 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
553 | 579 | |
554 | - if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) |
|
555 | - redirectexit('action=profile;area=tfasetup;forced'); |
|
580 | + if ($row['total'] > 0 && !in_array($action, array('profile', 'logout')) || ($action == 'profile' && $area != 'tfasetup')) { |
|
581 | + redirectexit('action=profile;area=tfasetup;forced'); |
|
582 | + } |
|
556 | 583 | } |
557 | 584 | } |
558 | 585 | |
@@ -589,33 +616,37 @@ discard block |
||
589 | 616 | 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'])); |
590 | 617 | $user_settings['last_login'] = time(); |
591 | 618 | |
592 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
593 | - cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
619 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
620 | + cache_put_data('user_settings-' . $id_member, $user_settings, 60); |
|
621 | + } |
|
594 | 622 | |
595 | - if (!empty($modSettings['cache_enable'])) |
|
596 | - cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
623 | + if (!empty($modSettings['cache_enable'])) { |
|
624 | + cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600); |
|
625 | + } |
|
597 | 626 | } |
627 | + } elseif (empty($_SESSION['id_msg_last_visit'])) { |
|
628 | + $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
598 | 629 | } |
599 | - elseif (empty($_SESSION['id_msg_last_visit'])) |
|
600 | - $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit']; |
|
601 | 630 | |
602 | 631 | $username = $user_settings['member_name']; |
603 | 632 | |
604 | - if (empty($user_settings['additional_groups'])) |
|
605 | - $user_info = array( |
|
633 | + if (empty($user_settings['additional_groups'])) { |
|
634 | + $user_info = array( |
|
606 | 635 | 'groups' => array($user_settings['id_group'], $user_settings['id_post_group']) |
607 | 636 | ); |
608 | - else |
|
609 | - $user_info = array( |
|
637 | + } else { |
|
638 | + $user_info = array( |
|
610 | 639 | 'groups' => array_merge( |
611 | 640 | array($user_settings['id_group'], $user_settings['id_post_group']), |
612 | 641 | explode(',', $user_settings['additional_groups']) |
613 | 642 | ) |
614 | 643 | ); |
644 | + } |
|
615 | 645 | |
616 | 646 | // Because history has proven that it is possible for groups to go bad - clean up in case. |
617 | - foreach ($user_info['groups'] as $k => $v) |
|
618 | - $user_info['groups'][$k] = (int) $v; |
|
647 | + foreach ($user_info['groups'] as $k => $v) { |
|
648 | + $user_info['groups'][$k] = (int) $v; |
|
649 | + } |
|
619 | 650 | |
620 | 651 | // This is a logged in user, so definitely not a spider. |
621 | 652 | $user_info['possibly_robot'] = false; |
@@ -629,8 +660,7 @@ discard block |
||
629 | 660 | $time_system = new DateTime('now', $tz_system); |
630 | 661 | $time_user = new DateTime('now', $tz_user); |
631 | 662 | $user_info['time_offset'] = ($tz_user->getOffset($time_user) - $tz_system->getOffset($time_system)) / 3600; |
632 | - } |
|
633 | - else |
|
663 | + } else |
|
634 | 664 | { |
635 | 665 | // !!! Compatibility. |
636 | 666 | $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset']; |
@@ -644,8 +674,9 @@ discard block |
||
644 | 674 | $user_info = array('groups' => array(-1)); |
645 | 675 | $user_settings = array(); |
646 | 676 | |
647 | - if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) |
|
648 | - $_COOKIE[$cookiename] = ''; |
|
677 | + if (isset($_COOKIE[$cookiename]) && empty($context['tfa_member'])) { |
|
678 | + $_COOKIE[$cookiename] = ''; |
|
679 | + } |
|
649 | 680 | |
650 | 681 | // Expire the 2FA cookie |
651 | 682 | if (isset($_COOKIE[$cookiename . '_tfa']) && empty($context['tfa_member'])) |
@@ -662,19 +693,20 @@ discard block |
||
662 | 693 | } |
663 | 694 | |
664 | 695 | // Create a login token if it doesn't exist yet. |
665 | - if (!isset($_SESSION['token']['post-login'])) |
|
666 | - createToken('login'); |
|
667 | - else |
|
668 | - 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 | + } |
|
669 | 701 | |
670 | 702 | // Do we perhaps think this is a search robot? Check every five minutes just in case... |
671 | 703 | if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) |
672 | 704 | { |
673 | 705 | require_once($sourcedir . '/ManageSearchEngines.php'); |
674 | 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; |
|
675 | 709 | } |
676 | - elseif (!empty($modSettings['spider_mode'])) |
|
677 | - $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0; |
|
678 | 710 | // If we haven't turned on proper spider hunts then have a guess! |
679 | 711 | else |
680 | 712 | { |
@@ -722,8 +754,9 @@ discard block |
||
722 | 754 | $user_info['groups'] = array_unique($user_info['groups']); |
723 | 755 | |
724 | 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. |
725 | - if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) |
|
726 | - 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 | + } |
|
727 | 760 | |
728 | 761 | // Allow the user to change their language. |
729 | 762 | if (!empty($modSettings['userLanguage'])) |
@@ -736,31 +769,36 @@ discard block |
||
736 | 769 | $user_info['language'] = strtr($_GET['language'], './\\:', '____'); |
737 | 770 | |
738 | 771 | // Make it permanent for members. |
739 | - if (!empty($user_info['id'])) |
|
740 | - updateMemberData($user_info['id'], array('lngfile' => $user_info['language'])); |
|
741 | - else |
|
742 | - $_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'], './\\:', '____'); |
|
743 | 779 | } |
744 | - elseif (!empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) |
|
745 | - $user_info['language'] = strtr($_SESSION['language'], './\\:', '____'); |
|
746 | 780 | } |
747 | 781 | |
748 | 782 | // Just build this here, it makes it easier to change/use - administrators can see all boards. |
749 | - if ($user_info['is_admin']) |
|
750 | - $user_info['query_see_board'] = '1=1'; |
|
783 | + if ($user_info['is_admin']) { |
|
784 | + $user_info['query_see_board'] = '1=1'; |
|
785 | + } |
|
751 | 786 | // Otherwise just the groups in $user_info['groups']. |
752 | - else |
|
753 | - $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 | + } |
|
754 | 790 | |
755 | 791 | // Build the list of boards they WANT to see. |
756 | 792 | // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also |
757 | 793 | |
758 | 794 | // If they aren't ignoring any boards then they want to see all the boards they can see |
759 | - if (empty($user_info['ignoreboards'])) |
|
760 | - $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 | + } |
|
761 | 798 | // Ok I guess they don't want to see all the boards |
762 | - else |
|
763 | - $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 | + } |
|
764 | 802 | |
765 | 803 | call_integration_hook('integrate_user_info'); |
766 | 804 | } |
@@ -818,9 +856,9 @@ discard block |
||
818 | 856 | } |
819 | 857 | |
820 | 858 | // Remember redirection is the key to avoiding fallout from your bosses. |
821 | - if (!empty($topic)) |
|
822 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
823 | - else |
|
859 | + if (!empty($topic)) { |
|
860 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg']); |
|
861 | + } else |
|
824 | 862 | { |
825 | 863 | loadPermissions(); |
826 | 864 | loadTheme(); |
@@ -838,10 +876,11 @@ discard block |
||
838 | 876 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
839 | 877 | { |
840 | 878 | // @todo SLOW? |
841 | - if (!empty($topic)) |
|
842 | - $temp = cache_get_data('topic_board-' . $topic, 120); |
|
843 | - else |
|
844 | - $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 | + } |
|
845 | 884 | |
846 | 885 | if (!empty($temp)) |
847 | 886 | { |
@@ -879,8 +918,9 @@ discard block |
||
879 | 918 | $row = $smcFunc['db_fetch_assoc']($request); |
880 | 919 | |
881 | 920 | // Set the current board. |
882 | - if (!empty($row['id_board'])) |
|
883 | - $board = $row['id_board']; |
|
921 | + if (!empty($row['id_board'])) { |
|
922 | + $board = $row['id_board']; |
|
923 | + } |
|
884 | 924 | |
885 | 925 | // Basic operating information. (globals... :/) |
886 | 926 | $board_info = array( |
@@ -916,21 +956,23 @@ discard block |
||
916 | 956 | |
917 | 957 | do |
918 | 958 | { |
919 | - if (!empty($row['id_moderator'])) |
|
920 | - $board_info['moderators'][$row['id_moderator']] = array( |
|
959 | + if (!empty($row['id_moderator'])) { |
|
960 | + $board_info['moderators'][$row['id_moderator']] = array( |
|
921 | 961 | 'id' => $row['id_moderator'], |
922 | 962 | 'name' => $row['real_name'], |
923 | 963 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
924 | 964 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
925 | 965 | ); |
966 | + } |
|
926 | 967 | |
927 | - if (!empty($row['id_moderator_group'])) |
|
928 | - $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( |
|
929 | 970 | 'id' => $row['id_moderator_group'], |
930 | 971 | 'name' => $row['group_name'], |
931 | 972 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
932 | 973 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
933 | 974 | ); |
975 | + } |
|
934 | 976 | } |
935 | 977 | while ($row = $smcFunc['db_fetch_assoc']($request)); |
936 | 978 | |
@@ -962,12 +1004,12 @@ discard block |
||
962 | 1004 | if (!empty($modSettings['cache_enable']) && (empty($topic) || $modSettings['cache_enable'] >= 3)) |
963 | 1005 | { |
964 | 1006 | // @todo SLOW? |
965 | - if (!empty($topic)) |
|
966 | - cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1007 | + if (!empty($topic)) { |
|
1008 | + cache_put_data('topic_board-' . $topic, $board_info, 120); |
|
1009 | + } |
|
967 | 1010 | cache_put_data('board-' . $board, $board_info, 120); |
968 | 1011 | } |
969 | - } |
|
970 | - else |
|
1012 | + } else |
|
971 | 1013 | { |
972 | 1014 | // Otherwise the topic is invalid, there are no moderators, etc. |
973 | 1015 | $board_info = array( |
@@ -981,8 +1023,9 @@ discard block |
||
981 | 1023 | $smcFunc['db_free_result']($request); |
982 | 1024 | } |
983 | 1025 | |
984 | - if (!empty($topic)) |
|
985 | - $_GET['board'] = (int) $board; |
|
1026 | + if (!empty($topic)) { |
|
1027 | + $_GET['board'] = (int) $board; |
|
1028 | + } |
|
986 | 1029 | |
987 | 1030 | if (!empty($board)) |
988 | 1031 | { |
@@ -992,10 +1035,12 @@ discard block |
||
992 | 1035 | // Now check if the user is a moderator. |
993 | 1036 | $user_info['is_mod'] = isset($board_info['moderators'][$user_info['id']]) || count(array_intersect($user_info['groups'], $moderator_groups)) != 0; |
994 | 1037 | |
995 | - if (count(array_intersect($user_info['groups'], $board_info['groups'])) == 0 && !$user_info['is_admin']) |
|
996 | - $board_info['error'] = 'access'; |
|
997 | - if (!empty($modSettings['deny_boards_access']) && count(array_intersect($user_info['groups'], $board_info['deny_groups'])) != 0 && !$user_info['is_admin']) |
|
998 | - $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 | + } |
|
999 | 1044 | |
1000 | 1045 | // Build up the linktree. |
1001 | 1046 | $context['linktree'] = array_merge( |
@@ -1018,8 +1063,9 @@ discard block |
||
1018 | 1063 | $context['current_board'] = $board; |
1019 | 1064 | |
1020 | 1065 | // No posting in redirection boards! |
1021 | - if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'post' && !empty($board_info['redirect'])) |
|
1022 | - $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 | + } |
|
1023 | 1069 | |
1024 | 1070 | // Hacker... you can't see this topic, I'll tell you that. (but moderators can!) |
1025 | 1071 | if (!empty($board_info['error']) && (!empty($modSettings['deny_boards_access']) || $board_info['error'] != 'access' || !$user_info['is_mod'])) |
@@ -1045,24 +1091,23 @@ discard block |
||
1045 | 1091 | ob_end_clean(); |
1046 | 1092 | header('HTTP/1.1 403 Forbidden'); |
1047 | 1093 | die; |
1048 | - } |
|
1049 | - elseif ($board_info['error'] == 'post_in_redirect') |
|
1094 | + } elseif ($board_info['error'] == 'post_in_redirect') |
|
1050 | 1095 | { |
1051 | 1096 | // Slightly different error message here... |
1052 | 1097 | fatal_lang_error('cannot_post_redirect', false); |
1053 | - } |
|
1054 | - elseif ($user_info['is_guest']) |
|
1098 | + } elseif ($user_info['is_guest']) |
|
1055 | 1099 | { |
1056 | 1100 | loadLanguage('Errors'); |
1057 | 1101 | is_not_guest($txt['topic_gone']); |
1102 | + } else { |
|
1103 | + fatal_lang_error('topic_gone', false); |
|
1058 | 1104 | } |
1059 | - else |
|
1060 | - fatal_lang_error('topic_gone', false); |
|
1061 | 1105 | } |
1062 | 1106 | |
1063 | - if ($user_info['is_mod']) |
|
1064 | - $user_info['groups'][] = 3; |
|
1065 | -} |
|
1107 | + if ($user_info['is_mod']) { |
|
1108 | + $user_info['groups'][] = 3; |
|
1109 | + } |
|
1110 | + } |
|
1066 | 1111 | |
1067 | 1112 | /** |
1068 | 1113 | * Load this user's permissions. |
@@ -1083,8 +1128,9 @@ discard block |
||
1083 | 1128 | asort($cache_groups); |
1084 | 1129 | $cache_groups = implode(',', $cache_groups); |
1085 | 1130 | // If it's a spider then cache it different. |
1086 | - if ($user_info['possibly_robot']) |
|
1087 | - $cache_groups .= '-spider'; |
|
1131 | + if ($user_info['possibly_robot']) { |
|
1132 | + $cache_groups .= '-spider'; |
|
1133 | + } |
|
1088 | 1134 | |
1089 | 1135 | if ($modSettings['cache_enable'] >= 2 && !empty($board) && ($temp = cache_get_data('permissions:' . $cache_groups . ':' . $board, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
1090 | 1136 | { |
@@ -1092,9 +1138,9 @@ discard block |
||
1092 | 1138 | banPermissions(); |
1093 | 1139 | |
1094 | 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; |
|
1095 | 1143 | } |
1096 | - elseif (($temp = cache_get_data('permissions:' . $cache_groups, 240)) != null && time() - 240 > $modSettings['settings_updated']) |
|
1097 | - list ($user_info['permissions'], $removals) = $temp; |
|
1098 | 1144 | } |
1099 | 1145 | |
1100 | 1146 | // If it is detected as a robot, and we are restricting permissions as a special group - then implement this. |
@@ -1116,23 +1162,26 @@ discard block |
||
1116 | 1162 | $removals = array(); |
1117 | 1163 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1118 | 1164 | { |
1119 | - if (empty($row['add_deny'])) |
|
1120 | - $removals[] = $row['permission']; |
|
1121 | - else |
|
1122 | - $user_info['permissions'][] = $row['permission']; |
|
1165 | + if (empty($row['add_deny'])) { |
|
1166 | + $removals[] = $row['permission']; |
|
1167 | + } else { |
|
1168 | + $user_info['permissions'][] = $row['permission']; |
|
1169 | + } |
|
1123 | 1170 | } |
1124 | 1171 | $smcFunc['db_free_result']($request); |
1125 | 1172 | |
1126 | - if (isset($cache_groups)) |
|
1127 | - 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 | + } |
|
1128 | 1176 | } |
1129 | 1177 | |
1130 | 1178 | // Get the board permissions. |
1131 | 1179 | if (!empty($board)) |
1132 | 1180 | { |
1133 | 1181 | // Make sure the board (if any) has been loaded by loadBoard(). |
1134 | - if (!isset($board_info['profile'])) |
|
1135 | - fatal_lang_error('no_board'); |
|
1182 | + if (!isset($board_info['profile'])) { |
|
1183 | + fatal_lang_error('no_board'); |
|
1184 | + } |
|
1136 | 1185 | |
1137 | 1186 | $request = $smcFunc['db_query']('', ' |
1138 | 1187 | SELECT permission, add_deny |
@@ -1148,20 +1197,23 @@ discard block |
||
1148 | 1197 | ); |
1149 | 1198 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1150 | 1199 | { |
1151 | - if (empty($row['add_deny'])) |
|
1152 | - $removals[] = $row['permission']; |
|
1153 | - else |
|
1154 | - $user_info['permissions'][] = $row['permission']; |
|
1200 | + if (empty($row['add_deny'])) { |
|
1201 | + $removals[] = $row['permission']; |
|
1202 | + } else { |
|
1203 | + $user_info['permissions'][] = $row['permission']; |
|
1204 | + } |
|
1155 | 1205 | } |
1156 | 1206 | $smcFunc['db_free_result']($request); |
1157 | 1207 | } |
1158 | 1208 | |
1159 | 1209 | // Remove all the permissions they shouldn't have ;). |
1160 | - if (!empty($modSettings['permission_enable_deny'])) |
|
1161 | - $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 | + } |
|
1162 | 1213 | |
1163 | - if (isset($cache_groups) && !empty($board) && $modSettings['cache_enable'] >= 2) |
|
1164 | - 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 | + } |
|
1165 | 1217 | |
1166 | 1218 | // Banned? Watch, don't touch.. |
1167 | 1219 | banPermissions(); |
@@ -1173,17 +1225,18 @@ discard block |
||
1173 | 1225 | { |
1174 | 1226 | require_once($sourcedir . '/Subs-Auth.php'); |
1175 | 1227 | rebuildModCache(); |
1228 | + } else { |
|
1229 | + $user_info['mod_cache'] = $_SESSION['mc']; |
|
1176 | 1230 | } |
1177 | - else |
|
1178 | - $user_info['mod_cache'] = $_SESSION['mc']; |
|
1179 | 1231 | |
1180 | 1232 | // This is a useful phantom permission added to the current user, and only the current user while they are logged in. |
1181 | 1233 | // For example this drastically simplifies certain changes to the profile area. |
1182 | 1234 | $user_info['permissions'][] = 'is_not_guest'; |
1183 | 1235 | // And now some backwards compatibility stuff for mods and whatnot that aren't expecting the new permissions. |
1184 | 1236 | $user_info['permissions'][] = 'profile_view_own'; |
1185 | - if (in_array('profile_view', $user_info['permissions'])) |
|
1186 | - $user_info['permissions'][] = 'profile_view_any'; |
|
1237 | + if (in_array('profile_view', $user_info['permissions'])) { |
|
1238 | + $user_info['permissions'][] = 'profile_view_any'; |
|
1239 | + } |
|
1187 | 1240 | } |
1188 | 1241 | } |
1189 | 1242 | |
@@ -1201,8 +1254,9 @@ discard block |
||
1201 | 1254 | global $image_proxy_enabled, $image_proxy_secret, $boardurl; |
1202 | 1255 | |
1203 | 1256 | // Can't just look for no users :P. |
1204 | - if (empty($users)) |
|
1205 | - return array(); |
|
1257 | + if (empty($users)) { |
|
1258 | + return array(); |
|
1259 | + } |
|
1206 | 1260 | |
1207 | 1261 | // Pass the set value |
1208 | 1262 | $context['loadMemberContext_set'] = $set; |
@@ -1217,8 +1271,9 @@ discard block |
||
1217 | 1271 | for ($i = 0, $n = count($users); $i < $n; $i++) |
1218 | 1272 | { |
1219 | 1273 | $data = cache_get_data('member_data-' . $set . '-' . $users[$i], 240); |
1220 | - if ($data == null) |
|
1221 | - continue; |
|
1274 | + if ($data == null) { |
|
1275 | + continue; |
|
1276 | + } |
|
1222 | 1277 | |
1223 | 1278 | $loaded_ids[] = $data['id_member']; |
1224 | 1279 | $user_profile[$data['id_member']] = $data; |
@@ -1285,16 +1340,19 @@ discard block |
||
1285 | 1340 | $row['avatar_original'] = !empty($row['avatar']) ? $row['avatar'] : ''; |
1286 | 1341 | |
1287 | 1342 | // Take care of proxying avatar if required, do this here for maximum reach |
1288 | - if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) |
|
1289 | - $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1343 | + if ($image_proxy_enabled && !empty($row['avatar']) && stripos($row['avatar'], 'http://') !== false) { |
|
1344 | + $row['avatar'] = $boardurl . '/proxy.php?request=' . urlencode($row['avatar']) . '&hash=' . md5($row['avatar'] . $image_proxy_secret); |
|
1345 | + } |
|
1290 | 1346 | |
1291 | 1347 | // Keep track of the member's normal member group |
1292 | 1348 | $row['primary_group'] = $row['member_group']; |
1293 | 1349 | |
1294 | - if (isset($row['member_ip'])) |
|
1295 | - $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1296 | - if (isset($row['member_ip2'])) |
|
1297 | - $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1350 | + if (isset($row['member_ip'])) { |
|
1351 | + $row['member_ip'] = inet_dtop($row['member_ip']); |
|
1352 | + } |
|
1353 | + if (isset($row['member_ip2'])) { |
|
1354 | + $row['member_ip2'] = inet_dtop($row['member_ip2']); |
|
1355 | + } |
|
1298 | 1356 | $new_loaded_ids[] = $row['id_member']; |
1299 | 1357 | $loaded_ids[] = $row['id_member']; |
1300 | 1358 | $row['options'] = array(); |
@@ -1313,8 +1371,9 @@ discard block |
||
1313 | 1371 | 'loaded_ids' => $new_loaded_ids, |
1314 | 1372 | ) |
1315 | 1373 | ); |
1316 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1317 | - $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1374 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1375 | + $user_profile[$row['id_member']]['options'][$row['variable']] = $row['value']; |
|
1376 | + } |
|
1318 | 1377 | $smcFunc['db_free_result']($request); |
1319 | 1378 | } |
1320 | 1379 | |
@@ -1325,10 +1384,11 @@ discard block |
||
1325 | 1384 | { |
1326 | 1385 | foreach ($loaded_ids as $a_member) |
1327 | 1386 | { |
1328 | - if (!empty($user_profile[$a_member]['additional_groups'])) |
|
1329 | - $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1330 | - else |
|
1331 | - $groups = array($user_profile[$a_member]['id_group']); |
|
1387 | + if (!empty($user_profile[$a_member]['additional_groups'])) { |
|
1388 | + $groups = array_merge(array($user_profile[$a_member]['id_group']), explode(',', $user_profile[$a_member]['additional_groups'])); |
|
1389 | + } else { |
|
1390 | + $groups = array($user_profile[$a_member]['id_group']); |
|
1391 | + } |
|
1332 | 1392 | |
1333 | 1393 | $temp = array_intersect($groups, array_keys($board_info['moderator_groups'])); |
1334 | 1394 | |
@@ -1341,8 +1401,9 @@ discard block |
||
1341 | 1401 | |
1342 | 1402 | if (!empty($new_loaded_ids) && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
1343 | 1403 | { |
1344 | - for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) |
|
1345 | - cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1404 | + for ($i = 0, $n = count($new_loaded_ids); $i < $n; $i++) { |
|
1405 | + cache_put_data('member_data-' . $set . '-' . $new_loaded_ids[$i], $user_profile[$new_loaded_ids[$i]], 240); |
|
1406 | + } |
|
1346 | 1407 | } |
1347 | 1408 | |
1348 | 1409 | // Are we loading any moderators? If so, fix their group data... |
@@ -1368,14 +1429,17 @@ discard block |
||
1368 | 1429 | foreach ($temp_mods as $id) |
1369 | 1430 | { |
1370 | 1431 | // By popular demand, don't show admins or global moderators as moderators. |
1371 | - if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) |
|
1372 | - $user_profile[$id]['member_group'] = $row['member_group']; |
|
1432 | + if ($user_profile[$id]['id_group'] != 1 && $user_profile[$id]['id_group'] != 2) { |
|
1433 | + $user_profile[$id]['member_group'] = $row['member_group']; |
|
1434 | + } |
|
1373 | 1435 | |
1374 | 1436 | // If the Moderator group has no color or icons, but their group does... don't overwrite. |
1375 | - if (!empty($row['icons'])) |
|
1376 | - $user_profile[$id]['icons'] = $row['icons']; |
|
1377 | - if (!empty($row['member_group_color'])) |
|
1378 | - $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1437 | + if (!empty($row['icons'])) { |
|
1438 | + $user_profile[$id]['icons'] = $row['icons']; |
|
1439 | + } |
|
1440 | + if (!empty($row['member_group_color'])) { |
|
1441 | + $user_profile[$id]['member_group_color'] = $row['member_group_color']; |
|
1442 | + } |
|
1379 | 1443 | } |
1380 | 1444 | } |
1381 | 1445 | |
@@ -1397,12 +1461,14 @@ discard block |
||
1397 | 1461 | static $loadedLanguages = array(); |
1398 | 1462 | |
1399 | 1463 | // If this person's data is already loaded, skip it. |
1400 | - if (isset($dataLoaded[$user])) |
|
1401 | - return true; |
|
1464 | + if (isset($dataLoaded[$user])) { |
|
1465 | + return true; |
|
1466 | + } |
|
1402 | 1467 | |
1403 | 1468 | // We can't load guests or members not loaded by loadMemberData()! |
1404 | - if ($user == 0) |
|
1405 | - return false; |
|
1469 | + if ($user == 0) { |
|
1470 | + return false; |
|
1471 | + } |
|
1406 | 1472 | if (!isset($user_profile[$user])) |
1407 | 1473 | { |
1408 | 1474 | trigger_error('loadMemberContext(): member id ' . $user . ' not previously loaded by loadMemberData()', E_USER_WARNING); |
@@ -1428,12 +1494,16 @@ discard block |
||
1428 | 1494 | $buddy_list = !empty($profile['buddy_list']) ? explode(',', $profile['buddy_list']) : array(); |
1429 | 1495 | |
1430 | 1496 | //We need a little fallback for the membergroup icons. If it doesn't exist in the current theme, fallback to default theme |
1431 | - if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) //icon is set and exists |
|
1497 | + if (isset($profile['icons'][1]) && file_exists($settings['actual_theme_dir'] . '/images/membericons/' . $profile['icons'][1])) { |
|
1498 | + //icon is set and exists |
|
1432 | 1499 | $group_icon_url = $settings['images_url'] . '/membericons/' . $profile['icons'][1]; |
1433 | - elseif (isset($profile['icons'][1])) //icon is set and doesn't exist, fallback to default |
|
1500 | + } elseif (isset($profile['icons'][1])) { |
|
1501 | + //icon is set and doesn't exist, fallback to default |
|
1434 | 1502 | $group_icon_url = $settings['default_images_url'] . '/membericons/' . $profile['icons'][1]; |
1435 | - else //not set, bye bye |
|
1503 | + } else { |
|
1504 | + //not set, bye bye |
|
1436 | 1505 | $group_icon_url = ''; |
1506 | + } |
|
1437 | 1507 | |
1438 | 1508 | // These minimal values are always loaded |
1439 | 1509 | $memberContext[$user] = array( |
@@ -1452,8 +1522,9 @@ discard block |
||
1452 | 1522 | if ($context['loadMemberContext_set'] != 'minimal') |
1453 | 1523 | { |
1454 | 1524 | // Go the extra mile and load the user's native language name. |
1455 | - if (empty($loadedLanguages)) |
|
1456 | - $loadedLanguages = getLanguages(); |
|
1525 | + if (empty($loadedLanguages)) { |
|
1526 | + $loadedLanguages = getLanguages(); |
|
1527 | + } |
|
1457 | 1528 | |
1458 | 1529 | $memberContext[$user] += array( |
1459 | 1530 | 'username_color' => '<span ' . (!empty($profile['member_group_color']) ? 'style="color:' . $profile['member_group_color'] . ';"' : '') . '>' . $profile['member_name'] . '</span>', |
@@ -1508,31 +1579,33 @@ discard block |
||
1508 | 1579 | { |
1509 | 1580 | if (!empty($modSettings['gravatarOverride']) || (!empty($modSettings['gravatarEnabled']) && stristr($profile['avatar'], 'gravatar://'))) |
1510 | 1581 | { |
1511 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) |
|
1512 | - $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1513 | - else |
|
1514 | - $image = get_gravatar_url($profile['email_address']); |
|
1515 | - } |
|
1516 | - else |
|
1582 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && stristr($profile['avatar'], 'gravatar://') && strlen($profile['avatar']) > 11) { |
|
1583 | + $image = get_gravatar_url($smcFunc['substr']($profile['avatar'], 11)); |
|
1584 | + } else { |
|
1585 | + $image = get_gravatar_url($profile['email_address']); |
|
1586 | + } |
|
1587 | + } else |
|
1517 | 1588 | { |
1518 | 1589 | // So it's stored in the member table? |
1519 | 1590 | if (!empty($profile['avatar'])) |
1520 | 1591 | { |
1521 | 1592 | $image = (stristr($profile['avatar'], 'http://') || stristr($profile['avatar'], 'https://')) ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']; |
1593 | + } elseif (!empty($profile['filename'])) { |
|
1594 | + $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1522 | 1595 | } |
1523 | - elseif (!empty($profile['filename'])) |
|
1524 | - $image = $modSettings['custom_avatar_url'] . '/' . $profile['filename']; |
|
1525 | 1596 | // Right... no avatar...use the default one |
1526 | - else |
|
1527 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
1597 | + else { |
|
1598 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
1599 | + } |
|
1528 | 1600 | } |
1529 | - if (!empty($image)) |
|
1530 | - $memberContext[$user]['avatar'] = array( |
|
1601 | + if (!empty($image)) { |
|
1602 | + $memberContext[$user]['avatar'] = array( |
|
1531 | 1603 | 'name' => $profile['avatar'], |
1532 | 1604 | 'image' => '<img class="avatar" src="' . $image . '" alt="avatar_' . $profile['member_name'] . '">', |
1533 | 1605 | 'href' => $image, |
1534 | 1606 | 'url' => $image, |
1535 | 1607 | ); |
1608 | + } |
|
1536 | 1609 | } |
1537 | 1610 | |
1538 | 1611 | // Are we also loading the members custom fields into context? |
@@ -1540,35 +1613,41 @@ discard block |
||
1540 | 1613 | { |
1541 | 1614 | $memberContext[$user]['custom_fields'] = array(); |
1542 | 1615 | |
1543 | - if (!isset($context['display_fields'])) |
|
1544 | - $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1616 | + if (!isset($context['display_fields'])) { |
|
1617 | + $context['display_fields'] = $smcFunc['json_decode']($modSettings['displayFields'], true); |
|
1618 | + } |
|
1545 | 1619 | |
1546 | 1620 | foreach ($context['display_fields'] as $custom) |
1547 | 1621 | { |
1548 | - if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) |
|
1549 | - continue; |
|
1622 | + if (!isset($custom['col_name']) || trim($custom['col_name']) == '' || empty($profile['options'][$custom['col_name']])) { |
|
1623 | + continue; |
|
1624 | + } |
|
1550 | 1625 | |
1551 | 1626 | $value = $profile['options'][$custom['col_name']]; |
1552 | 1627 | |
1553 | 1628 | // Don't show the "disabled" option for the "gender" field. |
1554 | - if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
1555 | - continue; |
|
1629 | + if ($custom['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
1630 | + continue; |
|
1631 | + } |
|
1556 | 1632 | |
1557 | 1633 | // BBC? |
1558 | - if ($custom['bbc']) |
|
1559 | - $value = parse_bbc($value); |
|
1634 | + if ($custom['bbc']) { |
|
1635 | + $value = parse_bbc($value); |
|
1636 | + } |
|
1560 | 1637 | // ... or checkbox? |
1561 | - elseif (isset($custom['type']) && $custom['type'] == 'check') |
|
1562 | - $value = $value ? $txt['yes'] : $txt['no']; |
|
1638 | + elseif (isset($custom['type']) && $custom['type'] == 'check') { |
|
1639 | + $value = $value ? $txt['yes'] : $txt['no']; |
|
1640 | + } |
|
1563 | 1641 | |
1564 | 1642 | // Enclosing the user input within some other text? |
1565 | - if (!empty($custom['enclose'])) |
|
1566 | - $value = strtr($custom['enclose'], array( |
|
1643 | + if (!empty($custom['enclose'])) { |
|
1644 | + $value = strtr($custom['enclose'], array( |
|
1567 | 1645 | '{SCRIPTURL}' => $scripturl, |
1568 | 1646 | '{IMAGES_URL}' => $settings['images_url'], |
1569 | 1647 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1570 | 1648 | '{INPUT}' => $value, |
1571 | 1649 | )); |
1650 | + } |
|
1572 | 1651 | |
1573 | 1652 | $memberContext[$user]['custom_fields'][] = array( |
1574 | 1653 | 'title' => !empty($custom['title']) ? $custom['title'] : $custom['col_name'], |
@@ -1595,8 +1674,9 @@ discard block |
||
1595 | 1674 | global $smcFunc, $txt, $scripturl, $settings; |
1596 | 1675 | |
1597 | 1676 | // Do not waste my time... |
1598 | - if (empty($users) || empty($params)) |
|
1599 | - return false; |
|
1677 | + if (empty($users) || empty($params)) { |
|
1678 | + return false; |
|
1679 | + } |
|
1600 | 1680 | |
1601 | 1681 | // Make sure it's an array. |
1602 | 1682 | $users = !is_array($users) ? array($users) : array_unique($users); |
@@ -1620,31 +1700,36 @@ discard block |
||
1620 | 1700 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1621 | 1701 | { |
1622 | 1702 | // BBC? |
1623 | - if (!empty($row['bbc'])) |
|
1624 | - $row['value'] = parse_bbc($row['value']); |
|
1703 | + if (!empty($row['bbc'])) { |
|
1704 | + $row['value'] = parse_bbc($row['value']); |
|
1705 | + } |
|
1625 | 1706 | |
1626 | 1707 | // ... or checkbox? |
1627 | - elseif (isset($row['type']) && $row['type'] == 'check') |
|
1628 | - $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1708 | + elseif (isset($row['type']) && $row['type'] == 'check') { |
|
1709 | + $row['value'] = !empty($row['value']) ? $txt['yes'] : $txt['no']; |
|
1710 | + } |
|
1629 | 1711 | |
1630 | 1712 | // Enclosing the user input within some other text? |
1631 | - if (!empty($row['enclose'])) |
|
1632 | - $row['value'] = strtr($row['enclose'], array( |
|
1713 | + if (!empty($row['enclose'])) { |
|
1714 | + $row['value'] = strtr($row['enclose'], array( |
|
1633 | 1715 | '{SCRIPTURL}' => $scripturl, |
1634 | 1716 | '{IMAGES_URL}' => $settings['images_url'], |
1635 | 1717 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
1636 | 1718 | '{INPUT}' => un_htmlspecialchars($row['value']), |
1637 | 1719 | )); |
1720 | + } |
|
1638 | 1721 | |
1639 | 1722 | // Send a simple array if there is just 1 param |
1640 | - if (count($params) == 1) |
|
1641 | - $return[$row['id_member']] = $row; |
|
1723 | + if (count($params) == 1) { |
|
1724 | + $return[$row['id_member']] = $row; |
|
1725 | + } |
|
1642 | 1726 | |
1643 | 1727 | // More than 1? knock yourself out... |
1644 | 1728 | else |
1645 | 1729 | { |
1646 | - if (!isset($return[$row['id_member']])) |
|
1647 | - $return[$row['id_member']] = array(); |
|
1730 | + if (!isset($return[$row['id_member']])) { |
|
1731 | + $return[$row['id_member']] = array(); |
|
1732 | + } |
|
1648 | 1733 | |
1649 | 1734 | $return[$row['id_member']][$row['variable']] = $row; |
1650 | 1735 | } |
@@ -1678,8 +1763,9 @@ discard block |
||
1678 | 1763 | global $context; |
1679 | 1764 | |
1680 | 1765 | // Don't know any browser! |
1681 | - if (empty($context['browser'])) |
|
1682 | - detectBrowser(); |
|
1766 | + if (empty($context['browser'])) { |
|
1767 | + detectBrowser(); |
|
1768 | + } |
|
1683 | 1769 | |
1684 | 1770 | return !empty($context['browser'][$browser]) || !empty($context['browser']['is_' . $browser]) ? true : false; |
1685 | 1771 | } |
@@ -1697,8 +1783,9 @@ discard block |
||
1697 | 1783 | global $context, $settings, $options, $sourcedir, $ssi_theme, $smcFunc, $language, $board, $image_proxy_enabled; |
1698 | 1784 | |
1699 | 1785 | // The theme was specified by parameter. |
1700 | - if (!empty($id_theme)) |
|
1701 | - $id_theme = (int) $id_theme; |
|
1786 | + if (!empty($id_theme)) { |
|
1787 | + $id_theme = (int) $id_theme; |
|
1788 | + } |
|
1702 | 1789 | // The theme was specified by REQUEST. |
1703 | 1790 | elseif (!empty($_REQUEST['theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
1704 | 1791 | { |
@@ -1706,51 +1793,58 @@ discard block |
||
1706 | 1793 | $_SESSION['id_theme'] = $id_theme; |
1707 | 1794 | } |
1708 | 1795 | // The theme was specified by REQUEST... previously. |
1709 | - elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) |
|
1710 | - $id_theme = (int) $_SESSION['id_theme']; |
|
1796 | + elseif (!empty($_SESSION['id_theme']) && (!empty($modSettings['theme_allow']) || allowedTo('admin_forum'))) { |
|
1797 | + $id_theme = (int) $_SESSION['id_theme']; |
|
1798 | + } |
|
1711 | 1799 | // The theme is just the user's choice. (might use ?board=1;theme=0 to force board theme.) |
1712 | - elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) |
|
1713 | - $id_theme = $user_info['theme']; |
|
1800 | + elseif (!empty($user_info['theme']) && !isset($_REQUEST['theme'])) { |
|
1801 | + $id_theme = $user_info['theme']; |
|
1802 | + } |
|
1714 | 1803 | // The theme was specified by the board. |
1715 | - elseif (!empty($board_info['theme'])) |
|
1716 | - $id_theme = $board_info['theme']; |
|
1804 | + elseif (!empty($board_info['theme'])) { |
|
1805 | + $id_theme = $board_info['theme']; |
|
1806 | + } |
|
1717 | 1807 | // The theme is the forum's default. |
1718 | - else |
|
1719 | - $id_theme = $modSettings['theme_guests']; |
|
1808 | + else { |
|
1809 | + $id_theme = $modSettings['theme_guests']; |
|
1810 | + } |
|
1720 | 1811 | |
1721 | 1812 | // Verify the id_theme... no foul play. |
1722 | 1813 | // Always allow the board specific theme, if they are overriding. |
1723 | - if (!empty($board_info['theme']) && $board_info['override_theme']) |
|
1724 | - $id_theme = $board_info['theme']; |
|
1814 | + if (!empty($board_info['theme']) && $board_info['override_theme']) { |
|
1815 | + $id_theme = $board_info['theme']; |
|
1816 | + } |
|
1725 | 1817 | // If they have specified a particular theme to use with SSI allow it to be used. |
1726 | - elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) |
|
1727 | - $id_theme = (int) $id_theme; |
|
1728 | - elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1818 | + elseif (!empty($ssi_theme) && $id_theme == $ssi_theme) { |
|
1819 | + $id_theme = (int) $id_theme; |
|
1820 | + } elseif (!empty($modSettings['enableThemes']) && !allowedTo('admin_forum')) |
|
1729 | 1821 | { |
1730 | 1822 | $themes = explode(',', $modSettings['enableThemes']); |
1731 | - if (!in_array($id_theme, $themes)) |
|
1732 | - $id_theme = $modSettings['theme_guests']; |
|
1733 | - else |
|
1823 | + if (!in_array($id_theme, $themes)) { |
|
1824 | + $id_theme = $modSettings['theme_guests']; |
|
1825 | + } else { |
|
1826 | + $id_theme = (int) $id_theme; |
|
1827 | + } |
|
1828 | + } else { |
|
1734 | 1829 | $id_theme = (int) $id_theme; |
1735 | 1830 | } |
1736 | - else |
|
1737 | - $id_theme = (int) $id_theme; |
|
1738 | 1831 | |
1739 | 1832 | $member = empty($user_info['id']) ? -1 : $user_info['id']; |
1740 | 1833 | |
1741 | 1834 | // Disable image proxy if we don't have SSL enabled |
1742 | - if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) |
|
1743 | - $image_proxy_enabled = false; |
|
1835 | + if (empty($modSettings['force_ssl']) || $modSettings['force_ssl'] < 2) { |
|
1836 | + $image_proxy_enabled = false; |
|
1837 | + } |
|
1744 | 1838 | |
1745 | 1839 | 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']) |
1746 | 1840 | { |
1747 | 1841 | $themeData = $temp; |
1748 | 1842 | $flag = true; |
1843 | + } elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) { |
|
1844 | + $themeData = $temp + array($member => array()); |
|
1845 | + } else { |
|
1846 | + $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1749 | 1847 | } |
1750 | - elseif (($temp = cache_get_data('theme_settings-' . $id_theme, 90)) != null && time() - 60 > $modSettings['settings_updated']) |
|
1751 | - $themeData = $temp + array($member => array()); |
|
1752 | - else |
|
1753 | - $themeData = array(-1 => array(), 0 => array(), $member => array()); |
|
1754 | 1848 | |
1755 | 1849 | if (empty($flag)) |
1756 | 1850 | { |
@@ -1769,31 +1863,37 @@ discard block |
||
1769 | 1863 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1770 | 1864 | { |
1771 | 1865 | // There are just things we shouldn't be able to change as members. |
1772 | - 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'))) |
|
1773 | - continue; |
|
1866 | + 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'))) { |
|
1867 | + continue; |
|
1868 | + } |
|
1774 | 1869 | |
1775 | 1870 | // If this is the theme_dir of the default theme, store it. |
1776 | - if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) |
|
1777 | - $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1871 | + if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1' && empty($row['id_member'])) { |
|
1872 | + $themeData[0]['default_' . $row['variable']] = $row['value']; |
|
1873 | + } |
|
1778 | 1874 | |
1779 | 1875 | // If this isn't set yet, is a theme option, or is not the default theme.. |
1780 | - if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') |
|
1781 | - $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1876 | + if (!isset($themeData[$row['id_member']][$row['variable']]) || $row['id_theme'] != '1') { |
|
1877 | + $themeData[$row['id_member']][$row['variable']] = substr($row['variable'], 0, 5) == 'show_' ? $row['value'] == '1' : $row['value']; |
|
1878 | + } |
|
1782 | 1879 | } |
1783 | 1880 | $smcFunc['db_free_result']($result); |
1784 | 1881 | |
1785 | - if (!empty($themeData[-1])) |
|
1786 | - foreach ($themeData[-1] as $k => $v) |
|
1882 | + if (!empty($themeData[-1])) { |
|
1883 | + foreach ($themeData[-1] as $k => $v) |
|
1787 | 1884 | { |
1788 | 1885 | if (!isset($themeData[$member][$k])) |
1789 | 1886 | $themeData[$member][$k] = $v; |
1887 | + } |
|
1790 | 1888 | } |
1791 | 1889 | |
1792 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1793 | - cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1890 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1891 | + cache_put_data('theme_settings-' . $id_theme . ':' . $member, $themeData, 60); |
|
1892 | + } |
|
1794 | 1893 | // Only if we didn't already load that part of the cache... |
1795 | - elseif (!isset($temp)) |
|
1796 | - cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1894 | + elseif (!isset($temp)) { |
|
1895 | + cache_put_data('theme_settings-' . $id_theme, array(-1 => $themeData[-1], 0 => $themeData[0]), 90); |
|
1896 | + } |
|
1797 | 1897 | } |
1798 | 1898 | |
1799 | 1899 | $settings = $themeData[0]; |
@@ -1810,20 +1910,24 @@ discard block |
||
1810 | 1910 | $settings['template_dirs'][] = $settings['theme_dir']; |
1811 | 1911 | |
1812 | 1912 | // Based on theme (if there is one). |
1813 | - if (!empty($settings['base_theme_dir'])) |
|
1814 | - $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1913 | + if (!empty($settings['base_theme_dir'])) { |
|
1914 | + $settings['template_dirs'][] = $settings['base_theme_dir']; |
|
1915 | + } |
|
1815 | 1916 | |
1816 | 1917 | // Lastly the default theme. |
1817 | - if ($settings['theme_dir'] != $settings['default_theme_dir']) |
|
1818 | - $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1918 | + if ($settings['theme_dir'] != $settings['default_theme_dir']) { |
|
1919 | + $settings['template_dirs'][] = $settings['default_theme_dir']; |
|
1920 | + } |
|
1819 | 1921 | |
1820 | - if (!$initialize) |
|
1821 | - return; |
|
1922 | + if (!$initialize) { |
|
1923 | + return; |
|
1924 | + } |
|
1822 | 1925 | |
1823 | 1926 | // Check to see if we're forcing SSL |
1824 | 1927 | if (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] == 2 && empty($maintenance) && |
1825 | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') |
|
1826 | - redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1928 | + (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && SMF != 'SSI') { |
|
1929 | + redirectexit(strtr($_SERVER['REQUEST_URL'], array('http://' => 'https://'))); |
|
1930 | + } |
|
1827 | 1931 | |
1828 | 1932 | // Check to see if they're accessing it from the wrong place. |
1829 | 1933 | if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME'])) |
@@ -1831,8 +1935,9 @@ discard block |
||
1831 | 1935 | $detected_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https://' : 'http://'; |
1832 | 1936 | $detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST']; |
1833 | 1937 | $temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/')); |
1834 | - if ($temp != '/') |
|
1835 | - $detected_url .= $temp; |
|
1938 | + if ($temp != '/') { |
|
1939 | + $detected_url .= $temp; |
|
1940 | + } |
|
1836 | 1941 | } |
1837 | 1942 | if (isset($detected_url) && $detected_url != $boardurl) |
1838 | 1943 | { |
@@ -1844,8 +1949,9 @@ discard block |
||
1844 | 1949 | foreach ($aliases as $alias) |
1845 | 1950 | { |
1846 | 1951 | // Rip off all the boring parts, spaces, etc. |
1847 | - if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) |
|
1848 | - $do_fix = true; |
|
1952 | + if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias)) { |
|
1953 | + $do_fix = true; |
|
1954 | + } |
|
1849 | 1955 | } |
1850 | 1956 | } |
1851 | 1957 | |
@@ -1853,20 +1959,22 @@ discard block |
||
1853 | 1959 | if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && SMF != 'SSI') |
1854 | 1960 | { |
1855 | 1961 | // Okay, this seems weird, but we don't want an endless loop - this will make $_GET not empty ;). |
1856 | - if (empty($_GET)) |
|
1857 | - redirectexit('wwwRedirect'); |
|
1858 | - else |
|
1962 | + if (empty($_GET)) { |
|
1963 | + redirectexit('wwwRedirect'); |
|
1964 | + } else |
|
1859 | 1965 | { |
1860 | 1966 | list ($k, $v) = each($_GET); |
1861 | 1967 | |
1862 | - if ($k != 'wwwRedirect') |
|
1863 | - redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1968 | + if ($k != 'wwwRedirect') { |
|
1969 | + redirectexit('wwwRedirect;' . $k . '=' . $v); |
|
1970 | + } |
|
1864 | 1971 | } |
1865 | 1972 | } |
1866 | 1973 | |
1867 | 1974 | // #3 is just a check for SSL... |
1868 | - if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) |
|
1869 | - $do_fix = true; |
|
1975 | + if (strtr($detected_url, array('https://' => 'http://')) == $boardurl) { |
|
1976 | + $do_fix = true; |
|
1977 | + } |
|
1870 | 1978 | |
1871 | 1979 | // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...) |
1872 | 1980 | if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d\.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1) |
@@ -1900,8 +2008,9 @@ discard block |
||
1900 | 2008 | $board_info['moderators'][$k]['link'] = strtr($dummy['link'], array('"' . $oldurl => '"' . $boardurl)); |
1901 | 2009 | } |
1902 | 2010 | } |
1903 | - foreach ($context['linktree'] as $k => $dummy) |
|
1904 | - $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2011 | + foreach ($context['linktree'] as $k => $dummy) { |
|
2012 | + $context['linktree'][$k]['url'] = strtr($dummy['url'], array($oldurl => $boardurl)); |
|
2013 | + } |
|
1905 | 2014 | } |
1906 | 2015 | } |
1907 | 2016 | // Set up the contextual user array. |
@@ -1920,16 +2029,16 @@ discard block |
||
1920 | 2029 | 'email' => $user_info['email'], |
1921 | 2030 | 'ignoreusers' => $user_info['ignoreusers'], |
1922 | 2031 | ); |
1923 | - if (!$context['user']['is_guest']) |
|
1924 | - $context['user']['name'] = $user_info['name']; |
|
1925 | - elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) |
|
1926 | - $context['user']['name'] = $txt['guest_title']; |
|
2032 | + if (!$context['user']['is_guest']) { |
|
2033 | + $context['user']['name'] = $user_info['name']; |
|
2034 | + } elseif ($context['user']['is_guest'] && !empty($txt['guest_title'])) { |
|
2035 | + $context['user']['name'] = $txt['guest_title']; |
|
2036 | + } |
|
1927 | 2037 | |
1928 | 2038 | // Determine the current smiley set. |
1929 | 2039 | $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']; |
1930 | 2040 | $context['user']['smiley_set'] = $user_info['smiley_set']; |
1931 | - } |
|
1932 | - else |
|
2041 | + } else |
|
1933 | 2042 | { |
1934 | 2043 | $context['user'] = array( |
1935 | 2044 | 'id' => -1, |
@@ -1945,18 +2054,24 @@ discard block |
||
1945 | 2054 | } |
1946 | 2055 | |
1947 | 2056 | // Some basic information... |
1948 | - if (!isset($context['html_headers'])) |
|
1949 | - $context['html_headers'] = ''; |
|
1950 | - if (!isset($context['javascript_files'])) |
|
1951 | - $context['javascript_files'] = array(); |
|
1952 | - if (!isset($context['css_files'])) |
|
1953 | - $context['css_files'] = array(); |
|
1954 | - if (!isset($context['css_header'])) |
|
1955 | - $context['css_header'] = array(); |
|
1956 | - if (!isset($context['javascript_inline'])) |
|
1957 | - $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
1958 | - if (!isset($context['javascript_vars'])) |
|
1959 | - $context['javascript_vars'] = array(); |
|
2057 | + if (!isset($context['html_headers'])) { |
|
2058 | + $context['html_headers'] = ''; |
|
2059 | + } |
|
2060 | + if (!isset($context['javascript_files'])) { |
|
2061 | + $context['javascript_files'] = array(); |
|
2062 | + } |
|
2063 | + if (!isset($context['css_files'])) { |
|
2064 | + $context['css_files'] = array(); |
|
2065 | + } |
|
2066 | + if (!isset($context['css_header'])) { |
|
2067 | + $context['css_header'] = array(); |
|
2068 | + } |
|
2069 | + if (!isset($context['javascript_inline'])) { |
|
2070 | + $context['javascript_inline'] = array('standard' => array(), 'defer' => array()); |
|
2071 | + } |
|
2072 | + if (!isset($context['javascript_vars'])) { |
|
2073 | + $context['javascript_vars'] = array(); |
|
2074 | + } |
|
1960 | 2075 | |
1961 | 2076 | $context['login_url'] = (!empty($modSettings['force_ssl']) && $modSettings['force_ssl'] < 2 ? strtr($scripturl, array('http://' => 'https://')) : $scripturl) . '?action=login2'; |
1962 | 2077 | $context['menu_separator'] = !empty($settings['use_image_buttons']) ? ' ' : ' | '; |
@@ -1968,8 +2083,9 @@ discard block |
||
1968 | 2083 | $context['current_action'] = isset($_REQUEST['action']) ? $smcFunc['htmlspecialchars']($_REQUEST['action']) : null; |
1969 | 2084 | $context['current_subaction'] = isset($_REQUEST['sa']) ? $_REQUEST['sa'] : null; |
1970 | 2085 | $context['can_register'] = empty($modSettings['registration_method']) || $modSettings['registration_method'] != 3; |
1971 | - if (isset($modSettings['load_average'])) |
|
1972 | - $context['load_average'] = $modSettings['load_average']; |
|
2086 | + if (isset($modSettings['load_average'])) { |
|
2087 | + $context['load_average'] = $modSettings['load_average']; |
|
2088 | + } |
|
1973 | 2089 | |
1974 | 2090 | // Detect the browser. This is separated out because it's also used in attachment downloads |
1975 | 2091 | detectBrowser(); |
@@ -1983,8 +2099,9 @@ discard block |
||
1983 | 2099 | // This allows sticking some HTML on the page output - useful for controls. |
1984 | 2100 | $context['insert_after_template'] = ''; |
1985 | 2101 | |
1986 | - if (!isset($txt)) |
|
1987 | - $txt = array(); |
|
2102 | + if (!isset($txt)) { |
|
2103 | + $txt = array(); |
|
2104 | + } |
|
1988 | 2105 | |
1989 | 2106 | $simpleActions = array( |
1990 | 2107 | 'findmember', |
@@ -2030,9 +2147,10 @@ discard block |
||
2030 | 2147 | |
2031 | 2148 | // See if theres any extra param to check. |
2032 | 2149 | $requiresXML = false; |
2033 | - foreach ($extraParams as $key => $extra) |
|
2034 | - if (isset($_REQUEST[$extra])) |
|
2150 | + foreach ($extraParams as $key => $extra) { |
|
2151 | + if (isset($_REQUEST[$extra])) |
|
2035 | 2152 | $requiresXML = true; |
2153 | + } |
|
2036 | 2154 | |
2037 | 2155 | // Output is fully XML, so no need for the index template. |
2038 | 2156 | if (isset($_REQUEST['xml']) && (in_array($context['current_action'], $xmlActions) || $requiresXML)) |
@@ -2047,37 +2165,39 @@ discard block |
||
2047 | 2165 | { |
2048 | 2166 | loadLanguage('index+Modifications'); |
2049 | 2167 | $context['template_layers'] = array(); |
2050 | - } |
|
2051 | - |
|
2052 | - else |
|
2168 | + } else |
|
2053 | 2169 | { |
2054 | 2170 | // Custom templates to load, or just default? |
2055 | - if (isset($settings['theme_templates'])) |
|
2056 | - $templates = explode(',', $settings['theme_templates']); |
|
2057 | - else |
|
2058 | - $templates = array('index'); |
|
2171 | + if (isset($settings['theme_templates'])) { |
|
2172 | + $templates = explode(',', $settings['theme_templates']); |
|
2173 | + } else { |
|
2174 | + $templates = array('index'); |
|
2175 | + } |
|
2059 | 2176 | |
2060 | 2177 | // Load each template... |
2061 | - foreach ($templates as $template) |
|
2062 | - loadTemplate($template); |
|
2178 | + foreach ($templates as $template) { |
|
2179 | + loadTemplate($template); |
|
2180 | + } |
|
2063 | 2181 | |
2064 | 2182 | // ...and attempt to load their associated language files. |
2065 | 2183 | $required_files = implode('+', array_merge($templates, array('Modifications'))); |
2066 | 2184 | loadLanguage($required_files, '', false); |
2067 | 2185 | |
2068 | 2186 | // Custom template layers? |
2069 | - if (isset($settings['theme_layers'])) |
|
2070 | - $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2071 | - else |
|
2072 | - $context['template_layers'] = array('html', 'body'); |
|
2187 | + if (isset($settings['theme_layers'])) { |
|
2188 | + $context['template_layers'] = explode(',', $settings['theme_layers']); |
|
2189 | + } else { |
|
2190 | + $context['template_layers'] = array('html', 'body'); |
|
2191 | + } |
|
2073 | 2192 | } |
2074 | 2193 | |
2075 | 2194 | // Initialize the theme. |
2076 | 2195 | loadSubTemplate('init', 'ignore'); |
2077 | 2196 | |
2078 | 2197 | // Allow overriding the board wide time/number formats. |
2079 | - if (empty($user_settings['time_format']) && !empty($txt['time_format'])) |
|
2080 | - $user_info['time_format'] = $txt['time_format']; |
|
2198 | + if (empty($user_settings['time_format']) && !empty($txt['time_format'])) { |
|
2199 | + $user_info['time_format'] = $txt['time_format']; |
|
2200 | + } |
|
2081 | 2201 | |
2082 | 2202 | // Set the character set from the template. |
2083 | 2203 | $context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set']; |
@@ -2085,12 +2205,14 @@ discard block |
||
2085 | 2205 | $context['right_to_left'] = !empty($txt['lang_rtl']); |
2086 | 2206 | |
2087 | 2207 | // Guests may still need a name. |
2088 | - if ($context['user']['is_guest'] && empty($context['user']['name'])) |
|
2089 | - $context['user']['name'] = $txt['guest_title']; |
|
2208 | + if ($context['user']['is_guest'] && empty($context['user']['name'])) { |
|
2209 | + $context['user']['name'] = $txt['guest_title']; |
|
2210 | + } |
|
2090 | 2211 | |
2091 | 2212 | // Any theme-related strings that need to be loaded? |
2092 | - if (!empty($settings['require_theme_strings'])) |
|
2093 | - loadLanguage('ThemeStrings', '', false); |
|
2213 | + if (!empty($settings['require_theme_strings'])) { |
|
2214 | + loadLanguage('ThemeStrings', '', false); |
|
2215 | + } |
|
2094 | 2216 | |
2095 | 2217 | // Make a special URL for the language. |
2096 | 2218 | $settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']); |
@@ -2101,8 +2223,9 @@ discard block |
||
2101 | 2223 | // Here is my luvly Responsive CSS |
2102 | 2224 | loadCSSFile('responsive.css', array('force_current' => false, 'validate' => true, 'minimize' => true), 'smf_responsive'); |
2103 | 2225 | |
2104 | - if ($context['right_to_left']) |
|
2105 | - loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2226 | + if ($context['right_to_left']) { |
|
2227 | + loadCSSFile('rtl.css', array(), 'smf_rtl'); |
|
2228 | + } |
|
2106 | 2229 | |
2107 | 2230 | // We allow theme variants, because we're cool. |
2108 | 2231 | $context['theme_variant'] = ''; |
@@ -2110,14 +2233,17 @@ discard block |
||
2110 | 2233 | if (!empty($settings['theme_variants'])) |
2111 | 2234 | { |
2112 | 2235 | // Overriding - for previews and that ilk. |
2113 | - if (!empty($_REQUEST['variant'])) |
|
2114 | - $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2236 | + if (!empty($_REQUEST['variant'])) { |
|
2237 | + $_SESSION['id_variant'] = $_REQUEST['variant']; |
|
2238 | + } |
|
2115 | 2239 | // User selection? |
2116 | - if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) |
|
2117 | - $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2240 | + if (empty($settings['disable_user_variant']) || allowedTo('admin_forum')) { |
|
2241 | + $context['theme_variant'] = !empty($_SESSION['id_variant']) ? $_SESSION['id_variant'] : (!empty($options['theme_variant']) ? $options['theme_variant'] : ''); |
|
2242 | + } |
|
2118 | 2243 | // If not a user variant, select the default. |
2119 | - if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) |
|
2120 | - $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2244 | + if ($context['theme_variant'] == '' || !in_array($context['theme_variant'], $settings['theme_variants'])) { |
|
2245 | + $context['theme_variant'] = !empty($settings['default_variant']) && in_array($settings['default_variant'], $settings['theme_variants']) ? $settings['default_variant'] : $settings['theme_variants'][0]; |
|
2246 | + } |
|
2121 | 2247 | |
2122 | 2248 | // Do this to keep things easier in the templates. |
2123 | 2249 | $context['theme_variant'] = '_' . $context['theme_variant']; |
@@ -2126,20 +2252,23 @@ discard block |
||
2126 | 2252 | if (!empty($context['theme_variant'])) |
2127 | 2253 | { |
2128 | 2254 | loadCSSFile('index' . $context['theme_variant'] . '.css', array(), 'smf_index' . $context['theme_variant']); |
2129 | - if ($context['right_to_left']) |
|
2130 | - loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2255 | + if ($context['right_to_left']) { |
|
2256 | + loadCSSFile('rtl' . $context['theme_variant'] . '.css', array(), 'smf_rtl' . $context['theme_variant']); |
|
2257 | + } |
|
2131 | 2258 | } |
2132 | 2259 | } |
2133 | 2260 | |
2134 | 2261 | // Let's be compatible with old themes! |
2135 | - if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) |
|
2136 | - $context['template_layers'] = array('main'); |
|
2262 | + if (!function_exists('template_html_above') && in_array('html', $context['template_layers'])) { |
|
2263 | + $context['template_layers'] = array('main'); |
|
2264 | + } |
|
2137 | 2265 | |
2138 | 2266 | $context['tabindex'] = 1; |
2139 | 2267 | |
2140 | 2268 | // Compatibility. |
2141 | - if (!isset($settings['theme_version'])) |
|
2142 | - $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2269 | + if (!isset($settings['theme_version'])) { |
|
2270 | + $modSettings['memberCount'] = $modSettings['totalMembers']; |
|
2271 | + } |
|
2143 | 2272 | |
2144 | 2273 | // Default JS variables for use in every theme |
2145 | 2274 | $context['javascript_vars'] = array( |
@@ -2158,18 +2287,18 @@ discard block |
||
2158 | 2287 | ); |
2159 | 2288 | |
2160 | 2289 | // Add the JQuery library to the list of files to load. |
2161 | - if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') |
|
2162 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2163 | - |
|
2164 | - elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') |
|
2165 | - loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2166 | - |
|
2167 | - elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') |
|
2168 | - loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2290 | + if (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'cdn') { |
|
2291 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2292 | + } elseif (isset($modSettings['jquery_source']) && $modSettings['jquery_source'] == 'local') { |
|
2293 | + loadJavaScriptFile('jquery-3.1.1.min.js', array('seed' => false), 'smf_jquery'); |
|
2294 | + } elseif (isset($modSettings['jquery_source'], $modSettings['jquery_custom']) && $modSettings['jquery_source'] == 'custom') { |
|
2295 | + loadJavaScriptFile($modSettings['jquery_custom'], array('external' => true), 'smf_jquery'); |
|
2296 | + } |
|
2169 | 2297 | |
2170 | 2298 | // Auto loading? template_javascript() will take care of the local half of this. |
2171 | - else |
|
2172 | - loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2299 | + else { |
|
2300 | + loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js', array('external' => true), 'smf_jquery'); |
|
2301 | + } |
|
2173 | 2302 | |
2174 | 2303 | // Queue our JQuery plugins! |
2175 | 2304 | loadJavaScriptFile('smf_jquery_plugins.js', array('minimize' => true), 'smf_jquery_plugins'); |
@@ -2192,12 +2321,12 @@ discard block |
||
2192 | 2321 | require_once($sourcedir . '/ScheduledTasks.php'); |
2193 | 2322 | |
2194 | 2323 | // What to do, what to do?! |
2195 | - if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) |
|
2196 | - AutoTask(); |
|
2197 | - else |
|
2198 | - ReduceMailQueue(); |
|
2199 | - } |
|
2200 | - else |
|
2324 | + if (empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time()) { |
|
2325 | + AutoTask(); |
|
2326 | + } else { |
|
2327 | + ReduceMailQueue(); |
|
2328 | + } |
|
2329 | + } else |
|
2201 | 2330 | { |
2202 | 2331 | $type = empty($modSettings['next_task_time']) || $modSettings['next_task_time'] < time() ? 'task' : 'mailq'; |
2203 | 2332 | $ts = $type == 'mailq' ? $modSettings['mail_next_send'] : $modSettings['next_task_time']; |
@@ -2248,8 +2377,9 @@ discard block |
||
2248 | 2377 | foreach ($theme_includes as $include) |
2249 | 2378 | { |
2250 | 2379 | $include = strtr(trim($include), array('$boarddir' => $boarddir, '$sourcedir' => $sourcedir, '$themedir' => $settings['theme_dir'])); |
2251 | - if (file_exists($include)) |
|
2252 | - require_once($include); |
|
2380 | + if (file_exists($include)) { |
|
2381 | + require_once($include); |
|
2382 | + } |
|
2253 | 2383 | } |
2254 | 2384 | } |
2255 | 2385 | |
@@ -2279,16 +2409,19 @@ discard block |
||
2279 | 2409 | // Do any style sheets first, cause we're easy with those. |
2280 | 2410 | if (!empty($style_sheets)) |
2281 | 2411 | { |
2282 | - if (!is_array($style_sheets)) |
|
2283 | - $style_sheets = array($style_sheets); |
|
2412 | + if (!is_array($style_sheets)) { |
|
2413 | + $style_sheets = array($style_sheets); |
|
2414 | + } |
|
2284 | 2415 | |
2285 | - foreach ($style_sheets as $sheet) |
|
2286 | - loadCSSFile($sheet . '.css', array(), $sheet); |
|
2416 | + foreach ($style_sheets as $sheet) { |
|
2417 | + loadCSSFile($sheet . '.css', array(), $sheet); |
|
2418 | + } |
|
2287 | 2419 | } |
2288 | 2420 | |
2289 | 2421 | // No template to load? |
2290 | - if ($template_name === false) |
|
2291 | - return true; |
|
2422 | + if ($template_name === false) { |
|
2423 | + return true; |
|
2424 | + } |
|
2292 | 2425 | |
2293 | 2426 | $loaded = false; |
2294 | 2427 | foreach ($settings['template_dirs'] as $template_dir) |
@@ -2303,12 +2436,14 @@ discard block |
||
2303 | 2436 | |
2304 | 2437 | if ($loaded) |
2305 | 2438 | { |
2306 | - if ($db_show_debug === true) |
|
2307 | - $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2439 | + if ($db_show_debug === true) { |
|
2440 | + $context['debug']['templates'][] = $template_name . ' (' . basename($template_dir) . ')'; |
|
2441 | + } |
|
2308 | 2442 | |
2309 | 2443 | // If they have specified an initialization function for this template, go ahead and call it now. |
2310 | - if (function_exists('template_' . $template_name . '_init')) |
|
2311 | - call_user_func('template_' . $template_name . '_init'); |
|
2444 | + if (function_exists('template_' . $template_name . '_init')) { |
|
2445 | + call_user_func('template_' . $template_name . '_init'); |
|
2446 | + } |
|
2312 | 2447 | } |
2313 | 2448 | // Hmmm... doesn't exist?! I don't suppose the directory is wrong, is it? |
2314 | 2449 | elseif (!file_exists($settings['default_theme_dir']) && file_exists($boarddir . '/Themes/default')) |
@@ -2328,13 +2463,14 @@ discard block |
||
2328 | 2463 | loadTemplate($template_name); |
2329 | 2464 | } |
2330 | 2465 | // Cause an error otherwise. |
2331 | - elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) |
|
2332 | - fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2333 | - elseif ($fatal) |
|
2334 | - 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')); |
|
2335 | - else |
|
2336 | - return false; |
|
2337 | -} |
|
2466 | + elseif ($template_name != 'Errors' && $template_name != 'index' && $fatal) { |
|
2467 | + fatal_lang_error('theme_template_error', 'template', array((string) $template_name)); |
|
2468 | + } elseif ($fatal) { |
|
2469 | + 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')); |
|
2470 | + } else { |
|
2471 | + return false; |
|
2472 | + } |
|
2473 | + } |
|
2338 | 2474 | |
2339 | 2475 | /** |
2340 | 2476 | * Load a sub-template. |
@@ -2352,17 +2488,19 @@ discard block |
||
2352 | 2488 | { |
2353 | 2489 | global $context, $txt, $db_show_debug; |
2354 | 2490 | |
2355 | - if ($db_show_debug === true) |
|
2356 | - $context['debug']['sub_templates'][] = $sub_template_name; |
|
2491 | + if ($db_show_debug === true) { |
|
2492 | + $context['debug']['sub_templates'][] = $sub_template_name; |
|
2493 | + } |
|
2357 | 2494 | |
2358 | 2495 | // Figure out what the template function is named. |
2359 | 2496 | $theme_function = 'template_' . $sub_template_name; |
2360 | - if (function_exists($theme_function)) |
|
2361 | - $theme_function(); |
|
2362 | - elseif ($fatal === false) |
|
2363 | - fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2364 | - elseif ($fatal !== 'ignore') |
|
2365 | - 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')); |
|
2497 | + if (function_exists($theme_function)) { |
|
2498 | + $theme_function(); |
|
2499 | + } elseif ($fatal === false) { |
|
2500 | + fatal_lang_error('theme_template_error', 'template', array((string) $sub_template_name)); |
|
2501 | + } elseif ($fatal !== 'ignore') { |
|
2502 | + 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')); |
|
2503 | + } |
|
2366 | 2504 | |
2367 | 2505 | // Are we showing debugging for templates? Just make sure not to do it before the doctype... |
2368 | 2506 | if (allowedTo('admin_forum') && isset($_REQUEST['debug']) && !in_array($sub_template_name, array('init', 'main_below')) && ob_get_length() > 0 && !isset($_REQUEST['xml'])) |
@@ -2399,8 +2537,9 @@ discard block |
||
2399 | 2537 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2400 | 2538 | |
2401 | 2539 | // If this is an external file, automatically set this to false. |
2402 | - if (!empty($params['external'])) |
|
2403 | - $params['minimize'] = false; |
|
2540 | + if (!empty($params['external'])) { |
|
2541 | + $params['minimize'] = false; |
|
2542 | + } |
|
2404 | 2543 | |
2405 | 2544 | // Account for shorthand like admin.css?alp21 filenames |
2406 | 2545 | $has_seed = strpos($fileName, '.css?'); |
@@ -2417,13 +2556,10 @@ discard block |
||
2417 | 2556 | { |
2418 | 2557 | $fileUrl = $settings['default_theme_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2419 | 2558 | $filePath = $settings['default_theme_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2559 | + } else { |
|
2560 | + $fileUrl = false; |
|
2420 | 2561 | } |
2421 | - |
|
2422 | - else |
|
2423 | - $fileUrl = false; |
|
2424 | - } |
|
2425 | - |
|
2426 | - else |
|
2562 | + } else |
|
2427 | 2563 | { |
2428 | 2564 | $fileUrl = $settings[$themeRef . '_url'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
2429 | 2565 | $filePath = $settings[$themeRef . '_dir'] . '/css/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2438,12 +2574,14 @@ discard block |
||
2438 | 2574 | } |
2439 | 2575 | |
2440 | 2576 | // Add it to the array for use in the template |
2441 | - if (!empty($fileName)) |
|
2442 | - $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2577 | + if (!empty($fileName)) { |
|
2578 | + $context['css_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2579 | + } |
|
2443 | 2580 | |
2444 | - if (!empty($context['right_to_left']) && !empty($params['rtl'])) |
|
2445 | - loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2446 | -} |
|
2581 | + if (!empty($context['right_to_left']) && !empty($params['rtl'])) { |
|
2582 | + loadCSSFile($params['rtl'], array_diff_key($params, array('rtl' => 0))); |
|
2583 | + } |
|
2584 | + } |
|
2447 | 2585 | |
2448 | 2586 | /** |
2449 | 2587 | * Add a block of inline css code to be executed later |
@@ -2460,8 +2598,9 @@ discard block |
||
2460 | 2598 | global $context; |
2461 | 2599 | |
2462 | 2600 | // Gotta add something... |
2463 | - if (empty($css)) |
|
2464 | - return false; |
|
2601 | + if (empty($css)) { |
|
2602 | + return false; |
|
2603 | + } |
|
2465 | 2604 | |
2466 | 2605 | $context['css_header'][] = $css; |
2467 | 2606 | } |
@@ -2496,8 +2635,9 @@ discard block |
||
2496 | 2635 | $params['validate'] = isset($params['validate']) ? $params['validate'] : true; |
2497 | 2636 | |
2498 | 2637 | // If this is an external file, automatically set this to false. |
2499 | - if (!empty($params['external'])) |
|
2500 | - $params['minimize'] = false; |
|
2638 | + if (!empty($params['external'])) { |
|
2639 | + $params['minimize'] = false; |
|
2640 | + } |
|
2501 | 2641 | |
2502 | 2642 | // Account for shorthand like admin.js?alp21 filenames |
2503 | 2643 | $has_seed = strpos($fileName, '.js?'); |
@@ -2514,16 +2654,12 @@ discard block |
||
2514 | 2654 | { |
2515 | 2655 | $fileUrl = $settings['default_theme_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2516 | 2656 | $filePath = $settings['default_theme_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2517 | - } |
|
2518 | - |
|
2519 | - else |
|
2657 | + } else |
|
2520 | 2658 | { |
2521 | 2659 | $fileUrl = false; |
2522 | 2660 | $filePath = false; |
2523 | 2661 | } |
2524 | - } |
|
2525 | - |
|
2526 | - else |
|
2662 | + } else |
|
2527 | 2663 | { |
2528 | 2664 | $fileUrl = $settings[$themeRef . '_url'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
2529 | 2665 | $filePath = $settings[$themeRef . '_dir'] . '/scripts/' . $fileName . ($has_seed ? '' : $params['seed']); |
@@ -2538,9 +2674,10 @@ discard block |
||
2538 | 2674 | } |
2539 | 2675 | |
2540 | 2676 | // Add it to the array for use in the template |
2541 | - if (!empty($fileName)) |
|
2542 | - $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2543 | -} |
|
2677 | + if (!empty($fileName)) { |
|
2678 | + $context['javascript_files'][$id] = array('fileUrl' => $fileUrl, 'filePath' => $filePath, 'fileName' => $fileName, 'options' => $params); |
|
2679 | + } |
|
2680 | + } |
|
2544 | 2681 | |
2545 | 2682 | /** |
2546 | 2683 | * Add a Javascript variable for output later (for feeding text strings and similar to JS) |
@@ -2554,9 +2691,10 @@ discard block |
||
2554 | 2691 | { |
2555 | 2692 | global $context; |
2556 | 2693 | |
2557 | - if (!empty($key) && (!empty($value) || $value === '0')) |
|
2558 | - $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2559 | -} |
|
2694 | + if (!empty($key) && (!empty($value) || $value === '0')) { |
|
2695 | + $context['javascript_vars'][$key] = !empty($escape) ? JavaScriptEscape($value) : $value; |
|
2696 | + } |
|
2697 | + } |
|
2560 | 2698 | |
2561 | 2699 | /** |
2562 | 2700 | * Add a block of inline Javascript code to be executed later |
@@ -2573,8 +2711,9 @@ discard block |
||
2573 | 2711 | { |
2574 | 2712 | global $context; |
2575 | 2713 | |
2576 | - if (empty($javascript)) |
|
2577 | - return false; |
|
2714 | + if (empty($javascript)) { |
|
2715 | + return false; |
|
2716 | + } |
|
2578 | 2717 | |
2579 | 2718 | $context['javascript_inline'][($defer === true ? 'defer' : 'standard')][] = $javascript; |
2580 | 2719 | } |
@@ -2595,15 +2734,18 @@ discard block |
||
2595 | 2734 | static $already_loaded = array(); |
2596 | 2735 | |
2597 | 2736 | // Default to the user's language. |
2598 | - if ($lang == '') |
|
2599 | - $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2737 | + if ($lang == '') { |
|
2738 | + $lang = isset($user_info['language']) ? $user_info['language'] : $language; |
|
2739 | + } |
|
2600 | 2740 | |
2601 | 2741 | // Do we want the English version of language file as fallback? |
2602 | - if (empty($modSettings['disable_language_fallback']) && $lang != 'english') |
|
2603 | - loadLanguage($template_name, 'english', false); |
|
2742 | + if (empty($modSettings['disable_language_fallback']) && $lang != 'english') { |
|
2743 | + loadLanguage($template_name, 'english', false); |
|
2744 | + } |
|
2604 | 2745 | |
2605 | - if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) |
|
2606 | - return $lang; |
|
2746 | + if (!$force_reload && isset($already_loaded[$template_name]) && $already_loaded[$template_name] == $lang) { |
|
2747 | + return $lang; |
|
2748 | + } |
|
2607 | 2749 | |
2608 | 2750 | // Make sure we have $settings - if not we're in trouble and need to find it! |
2609 | 2751 | if (empty($settings['default_theme_dir'])) |
@@ -2614,8 +2756,9 @@ discard block |
||
2614 | 2756 | |
2615 | 2757 | // What theme are we in? |
2616 | 2758 | $theme_name = basename($settings['theme_url']); |
2617 | - if (empty($theme_name)) |
|
2618 | - $theme_name = 'unknown'; |
|
2759 | + if (empty($theme_name)) { |
|
2760 | + $theme_name = 'unknown'; |
|
2761 | + } |
|
2619 | 2762 | |
2620 | 2763 | // For each file open it up and write it out! |
2621 | 2764 | foreach (explode('+', $template_name) as $template) |
@@ -2657,8 +2800,9 @@ discard block |
||
2657 | 2800 | $found = true; |
2658 | 2801 | |
2659 | 2802 | // setlocale is required for basename() & pathinfo() to work properly on the selected language |
2660 | - if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) |
|
2661 | - setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2803 | + if (!empty($txt['lang_locale']) && !empty($modSettings['global_character_set'])) { |
|
2804 | + setlocale(LC_CTYPE, $txt['lang_locale'] . '.' . $modSettings['global_character_set']); |
|
2805 | + } |
|
2662 | 2806 | |
2663 | 2807 | break; |
2664 | 2808 | } |
@@ -2698,8 +2842,9 @@ discard block |
||
2698 | 2842 | } |
2699 | 2843 | |
2700 | 2844 | // Keep track of what we're up to soldier. |
2701 | - if ($db_show_debug === true) |
|
2702 | - $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2845 | + if ($db_show_debug === true) { |
|
2846 | + $context['debug']['language_files'][] = $template_name . '.' . $lang . ' (' . $theme_name . ')'; |
|
2847 | + } |
|
2703 | 2848 | |
2704 | 2849 | // Remember what we have loaded, and in which language. |
2705 | 2850 | $already_loaded[$template_name] = $lang; |
@@ -2745,8 +2890,9 @@ discard block |
||
2745 | 2890 | ) |
2746 | 2891 | ); |
2747 | 2892 | // In the EXTREMELY unlikely event this happens, give an error message. |
2748 | - if ($smcFunc['db_num_rows']($result) == 0) |
|
2749 | - fatal_lang_error('parent_not_found', 'critical'); |
|
2893 | + if ($smcFunc['db_num_rows']($result) == 0) { |
|
2894 | + fatal_lang_error('parent_not_found', 'critical'); |
|
2895 | + } |
|
2750 | 2896 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2751 | 2897 | { |
2752 | 2898 | if (!isset($boards[$row['id_board']])) |
@@ -2763,8 +2909,8 @@ discard block |
||
2763 | 2909 | ); |
2764 | 2910 | } |
2765 | 2911 | // If a moderator exists for this board, add that moderator for all children too. |
2766 | - if (!empty($row['id_moderator'])) |
|
2767 | - foreach ($boards as $id => $dummy) |
|
2912 | + if (!empty($row['id_moderator'])) { |
|
2913 | + foreach ($boards as $id => $dummy) |
|
2768 | 2914 | { |
2769 | 2915 | $boards[$id]['moderators'][$row['id_moderator']] = array( |
2770 | 2916 | 'id' => $row['id_moderator'], |
@@ -2772,11 +2918,12 @@ discard block |
||
2772 | 2918 | 'href' => $scripturl . '?action=profile;u=' . $row['id_moderator'], |
2773 | 2919 | 'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_moderator'] . '">' . $row['real_name'] . '</a>' |
2774 | 2920 | ); |
2921 | + } |
|
2775 | 2922 | } |
2776 | 2923 | |
2777 | 2924 | // If a moderator group exists for this board, add that moderator group for all children too |
2778 | - if (!empty($row['id_moderator_group'])) |
|
2779 | - foreach ($boards as $id => $dummy) |
|
2925 | + if (!empty($row['id_moderator_group'])) { |
|
2926 | + foreach ($boards as $id => $dummy) |
|
2780 | 2927 | { |
2781 | 2928 | $boards[$id]['moderator_groups'][$row['id_moderator_group']] = array( |
2782 | 2929 | 'id' => $row['id_moderator_group'], |
@@ -2784,6 +2931,7 @@ discard block |
||
2784 | 2931 | 'href' => $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'], |
2785 | 2932 | 'link' => '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_moderator_group'] . '">' . $row['group_name'] . '</a>' |
2786 | 2933 | ); |
2934 | + } |
|
2787 | 2935 | } |
2788 | 2936 | } |
2789 | 2937 | $smcFunc['db_free_result']($result); |
@@ -2810,23 +2958,27 @@ discard block |
||
2810 | 2958 | if (!$use_cache || ($context['languages'] = cache_get_data('known_languages', !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600)) == null) |
2811 | 2959 | { |
2812 | 2960 | // If we don't have our ucwords function defined yet, let's load the settings data. |
2813 | - if (empty($smcFunc['ucwords'])) |
|
2814 | - reloadSettings(); |
|
2961 | + if (empty($smcFunc['ucwords'])) { |
|
2962 | + reloadSettings(); |
|
2963 | + } |
|
2815 | 2964 | |
2816 | 2965 | // If we don't have our theme information yet, let's get it. |
2817 | - if (empty($settings['default_theme_dir'])) |
|
2818 | - loadTheme(0, false); |
|
2966 | + if (empty($settings['default_theme_dir'])) { |
|
2967 | + loadTheme(0, false); |
|
2968 | + } |
|
2819 | 2969 | |
2820 | 2970 | // Default language directories to try. |
2821 | 2971 | $language_directories = array( |
2822 | 2972 | $settings['default_theme_dir'] . '/languages', |
2823 | 2973 | ); |
2824 | - if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) |
|
2825 | - $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2974 | + if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir']) { |
|
2975 | + $language_directories[] = $settings['actual_theme_dir'] . '/languages'; |
|
2976 | + } |
|
2826 | 2977 | |
2827 | 2978 | // We possibly have a base theme directory. |
2828 | - if (!empty($settings['base_theme_dir'])) |
|
2829 | - $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2979 | + if (!empty($settings['base_theme_dir'])) { |
|
2980 | + $language_directories[] = $settings['base_theme_dir'] . '/languages'; |
|
2981 | + } |
|
2830 | 2982 | |
2831 | 2983 | // Remove any duplicates. |
2832 | 2984 | $language_directories = array_unique($language_directories); |
@@ -2840,20 +2992,21 @@ discard block |
||
2840 | 2992 | foreach ($language_directories as $language_dir) |
2841 | 2993 | { |
2842 | 2994 | // Can't look in here... doesn't exist! |
2843 | - if (!file_exists($language_dir)) |
|
2844 | - continue; |
|
2995 | + if (!file_exists($language_dir)) { |
|
2996 | + continue; |
|
2997 | + } |
|
2845 | 2998 | |
2846 | 2999 | $dir = dir($language_dir); |
2847 | 3000 | while ($entry = $dir->read()) |
2848 | 3001 | { |
2849 | 3002 | // Look for the index language file... For good measure skip any "index.language-utf8.php" files |
2850 | - if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) |
|
2851 | - continue; |
|
2852 | - |
|
2853 | - if (!empty($langList) && !empty($langList[$matches[1]])) |
|
2854 | - $langName = $langList[$matches[1]]; |
|
3003 | + if (!preg_match('~^index\.(.+[^-utf8])\.php$~', $entry, $matches)) { |
|
3004 | + continue; |
|
3005 | + } |
|
2855 | 3006 | |
2856 | - else |
|
3007 | + if (!empty($langList) && !empty($langList[$matches[1]])) { |
|
3008 | + $langName = $langList[$matches[1]]; |
|
3009 | + } else |
|
2857 | 3010 | { |
2858 | 3011 | $langName = $smcFunc['ucwords'](strtr($matches[1], array('_' => ' '))); |
2859 | 3012 | |
@@ -2894,12 +3047,14 @@ discard block |
||
2894 | 3047 | } |
2895 | 3048 | |
2896 | 3049 | // Do we need to store the lang list? |
2897 | - if (empty($langList)) |
|
2898 | - updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3050 | + if (empty($langList)) { |
|
3051 | + updateSettings(array('langList' => $smcFunc['json_encode']($catchLang))); |
|
3052 | + } |
|
2899 | 3053 | |
2900 | 3054 | // Let's cash in on this deal. |
2901 | - if (!empty($modSettings['cache_enable'])) |
|
2902 | - cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3055 | + if (!empty($modSettings['cache_enable'])) { |
|
3056 | + cache_put_data('known_languages', $context['languages'], !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] < 1 ? 86400 : 3600); |
|
3057 | + } |
|
2903 | 3058 | } |
2904 | 3059 | |
2905 | 3060 | return $context['languages']; |
@@ -2922,8 +3077,9 @@ discard block |
||
2922 | 3077 | global $modSettings, $options, $txt; |
2923 | 3078 | static $censor_vulgar = null, $censor_proper; |
2924 | 3079 | |
2925 | - if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') |
|
2926 | - return $text; |
|
3080 | + if ((!empty($options['show_no_censored']) && !empty($modSettings['allow_no_censored']) && !$force) || empty($modSettings['censor_vulgar']) || trim($text) === '') { |
|
3081 | + return $text; |
|
3082 | + } |
|
2927 | 3083 | |
2928 | 3084 | // If they haven't yet been loaded, load them. |
2929 | 3085 | if ($censor_vulgar == null) |
@@ -2951,9 +3107,9 @@ discard block |
||
2951 | 3107 | { |
2952 | 3108 | $func = !empty($modSettings['censorIgnoreCase']) ? 'str_ireplace' : 'str_replace'; |
2953 | 3109 | $text = $func($censor_vulgar, $censor_proper, $text); |
3110 | + } else { |
|
3111 | + $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2954 | 3112 | } |
2955 | - else |
|
2956 | - $text = preg_replace($censor_vulgar, $censor_proper, $text); |
|
2957 | 3113 | |
2958 | 3114 | return $text; |
2959 | 3115 | } |
@@ -2979,38 +3135,42 @@ discard block |
||
2979 | 3135 | @ini_set('track_errors', '1'); |
2980 | 3136 | |
2981 | 3137 | // Don't include the file more than once, if $once is true. |
2982 | - if ($once && in_array($filename, $templates)) |
|
2983 | - return; |
|
3138 | + if ($once && in_array($filename, $templates)) { |
|
3139 | + return; |
|
3140 | + } |
|
2984 | 3141 | // Add this file to the include list, whether $once is true or not. |
2985 | - else |
|
2986 | - $templates[] = $filename; |
|
3142 | + else { |
|
3143 | + $templates[] = $filename; |
|
3144 | + } |
|
2987 | 3145 | |
2988 | 3146 | // Are we going to use eval? |
2989 | 3147 | if (empty($modSettings['disableTemplateEval'])) |
2990 | 3148 | { |
2991 | 3149 | $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false; |
2992 | 3150 | $settings['current_include_filename'] = $filename; |
2993 | - } |
|
2994 | - else |
|
3151 | + } else |
|
2995 | 3152 | { |
2996 | 3153 | $file_found = file_exists($filename); |
2997 | 3154 | |
2998 | - if ($once && $file_found) |
|
2999 | - require_once($filename); |
|
3000 | - elseif ($file_found) |
|
3001 | - require($filename); |
|
3155 | + if ($once && $file_found) { |
|
3156 | + require_once($filename); |
|
3157 | + } elseif ($file_found) { |
|
3158 | + require($filename); |
|
3159 | + } |
|
3002 | 3160 | } |
3003 | 3161 | |
3004 | 3162 | if ($file_found !== true) |
3005 | 3163 | { |
3006 | 3164 | ob_end_clean(); |
3007 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
3008 | - @ob_start('ob_gzhandler'); |
|
3009 | - else |
|
3010 | - ob_start(); |
|
3165 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
3166 | + @ob_start('ob_gzhandler'); |
|
3167 | + } else { |
|
3168 | + ob_start(); |
|
3169 | + } |
|
3011 | 3170 | |
3012 | - if (isset($_GET['debug'])) |
|
3013 | - header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3171 | + if (isset($_GET['debug'])) { |
|
3172 | + header('Content-Type: application/xhtml+xml; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set'])); |
|
3173 | + } |
|
3014 | 3174 | |
3015 | 3175 | // Don't cache error pages!! |
3016 | 3176 | header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); |
@@ -3029,12 +3189,13 @@ discard block |
||
3029 | 3189 | echo '<!DOCTYPE html> |
3030 | 3190 | <html', !empty($context['right_to_left']) ? ' dir="rtl"' : '', '> |
3031 | 3191 | <head>'; |
3032 | - if (isset($context['character_set'])) |
|
3033 | - echo ' |
|
3192 | + if (isset($context['character_set'])) { |
|
3193 | + echo ' |
|
3034 | 3194 | <meta charset="', $context['character_set'], '">'; |
3195 | + } |
|
3035 | 3196 | |
3036 | - if (!empty($maintenance) && !allowedTo('admin_forum')) |
|
3037 | - echo ' |
|
3197 | + if (!empty($maintenance) && !allowedTo('admin_forum')) { |
|
3198 | + echo ' |
|
3038 | 3199 | <title>', $mtitle, '</title> |
3039 | 3200 | </head> |
3040 | 3201 | <body> |
@@ -3042,8 +3203,8 @@ discard block |
||
3042 | 3203 | ', $mmessage, ' |
3043 | 3204 | </body> |
3044 | 3205 | </html>'; |
3045 | - elseif (!allowedTo('admin_forum')) |
|
3046 | - echo ' |
|
3206 | + } elseif (!allowedTo('admin_forum')) { |
|
3207 | + echo ' |
|
3047 | 3208 | <title>', $txt['template_parse_error'], '</title> |
3048 | 3209 | </head> |
3049 | 3210 | <body> |
@@ -3051,16 +3212,18 @@ discard block |
||
3051 | 3212 | ', $txt['template_parse_error_message'], ' |
3052 | 3213 | </body> |
3053 | 3214 | </html>'; |
3054 | - else |
|
3215 | + } else |
|
3055 | 3216 | { |
3056 | 3217 | require_once($sourcedir . '/Subs-Package.php'); |
3057 | 3218 | |
3058 | 3219 | $error = fetch_web_data($boardurl . strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3059 | 3220 | $error_array = error_get_last(); |
3060 | - if (empty($error) && ini_get('track_errors') && !empty($error_array)) |
|
3061 | - $error = $error_array['message']; |
|
3062 | - if (empty($error)) |
|
3063 | - $error = $txt['template_parse_errmsg']; |
|
3221 | + if (empty($error) && ini_get('track_errors') && !empty($error_array)) { |
|
3222 | + $error = $error_array['message']; |
|
3223 | + } |
|
3224 | + if (empty($error)) { |
|
3225 | + $error = $txt['template_parse_errmsg']; |
|
3226 | + } |
|
3064 | 3227 | |
3065 | 3228 | $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>')); |
3066 | 3229 | |
@@ -3071,11 +3234,12 @@ discard block |
||
3071 | 3234 | <h3>', $txt['template_parse_error'], '</h3> |
3072 | 3235 | ', sprintf($txt['template_parse_error_details'], strtr($filename, array($boarddir => '', strtr($boarddir, '\\', '/') => ''))); |
3073 | 3236 | |
3074 | - if (!empty($error)) |
|
3075 | - echo ' |
|
3237 | + if (!empty($error)) { |
|
3238 | + echo ' |
|
3076 | 3239 | <hr> |
3077 | 3240 | |
3078 | 3241 | <div style="margin: 0 20px;"><pre>', strtr(strtr($error, array('<strong>' . $boarddir => '<strong>...', '<strong>' . strtr($boarddir, '\\', '/') => '<strong>...')), '\\', '/'), '</pre></div>'; |
3242 | + } |
|
3079 | 3243 | |
3080 | 3244 | // I know, I know... this is VERY COMPLICATED. Still, it's good. |
3081 | 3245 | if (preg_match('~ <strong>(\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) |
@@ -3085,10 +3249,11 @@ discard block |
||
3085 | 3249 | $data2 = preg_split('~\<br( /)?\>~', $data2); |
3086 | 3250 | |
3087 | 3251 | // Fix the PHP code stuff... |
3088 | - if (!isBrowser('gecko')) |
|
3089 | - $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3090 | - else |
|
3091 | - $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3252 | + if (!isBrowser('gecko')) { |
|
3253 | + $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2); |
|
3254 | + } else { |
|
3255 | + $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2); |
|
3256 | + } |
|
3092 | 3257 | |
3093 | 3258 | // Now we get to work around a bug in PHP where it doesn't escape <br>s! |
3094 | 3259 | $j = -1; |
@@ -3096,8 +3261,9 @@ discard block |
||
3096 | 3261 | { |
3097 | 3262 | $j++; |
3098 | 3263 | |
3099 | - if (substr_count($line, '<br>') == 0) |
|
3100 | - continue; |
|
3264 | + if (substr_count($line, '<br>') == 0) { |
|
3265 | + continue; |
|
3266 | + } |
|
3101 | 3267 | |
3102 | 3268 | $n = substr_count($line, '<br>'); |
3103 | 3269 | for ($i = 0; $i < $n; $i++) |
@@ -3116,38 +3282,42 @@ discard block |
||
3116 | 3282 | // Figure out what the color coding was before... |
3117 | 3283 | $line = max($match[1] - 9, 1); |
3118 | 3284 | $last_line = ''; |
3119 | - for ($line2 = $line - 1; $line2 > 1; $line2--) |
|
3120 | - if (strpos($data2[$line2], '<') !== false) |
|
3285 | + for ($line2 = $line - 1; $line2 > 1; $line2--) { |
|
3286 | + if (strpos($data2[$line2], '<') !== false) |
|
3121 | 3287 | { |
3122 | 3288 | if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) |
3123 | 3289 | $last_line = $color_match[1]; |
3290 | + } |
|
3124 | 3291 | break; |
3125 | 3292 | } |
3126 | 3293 | |
3127 | 3294 | // Show the relevant lines... |
3128 | 3295 | for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) |
3129 | 3296 | { |
3130 | - if ($line == $match[1]) |
|
3131 | - echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3297 | + if ($line == $match[1]) { |
|
3298 | + echo '</pre><div style="background-color: #ffb0b5;"><pre style="margin: 0;">'; |
|
3299 | + } |
|
3132 | 3300 | |
3133 | 3301 | echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> '; |
3134 | - if (isset($data2[$line]) && $data2[$line] != '') |
|
3135 | - echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3302 | + if (isset($data2[$line]) && $data2[$line] != '') { |
|
3303 | + echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line]; |
|
3304 | + } |
|
3136 | 3305 | |
3137 | 3306 | if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) |
3138 | 3307 | { |
3139 | 3308 | $last_line = $color_match[1]; |
3140 | 3309 | echo '</', substr($last_line, 1, 4), '>'; |
3310 | + } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) { |
|
3311 | + $last_line = ''; |
|
3312 | + } elseif ($last_line != '' && $data2[$line] != '') { |
|
3313 | + echo '</', substr($last_line, 1, 4), '>'; |
|
3141 | 3314 | } |
3142 | - elseif ($last_line != '' && strpos($data2[$line], '<') !== false) |
|
3143 | - $last_line = ''; |
|
3144 | - elseif ($last_line != '' && $data2[$line] != '') |
|
3145 | - echo '</', substr($last_line, 1, 4), '>'; |
|
3146 | 3315 | |
3147 | - if ($line == $match[1]) |
|
3148 | - echo '</pre></div><pre style="margin: 0;">'; |
|
3149 | - else |
|
3150 | - echo "\n"; |
|
3316 | + if ($line == $match[1]) { |
|
3317 | + echo '</pre></div><pre style="margin: 0;">'; |
|
3318 | + } else { |
|
3319 | + echo "\n"; |
|
3320 | + } |
|
3151 | 3321 | } |
3152 | 3322 | |
3153 | 3323 | echo '</pre></div>'; |
@@ -3171,8 +3341,9 @@ discard block |
||
3171 | 3341 | global $db_type, $db_name, $ssi_db_user, $ssi_db_passwd, $sourcedir, $db_prefix, $db_port; |
3172 | 3342 | |
3173 | 3343 | // Figure out what type of database we are using. |
3174 | - if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) |
|
3175 | - $db_type = 'mysql'; |
|
3344 | + if (empty($db_type) || !file_exists($sourcedir . '/Subs-Db-' . $db_type . '.php')) { |
|
3345 | + $db_type = 'mysql'; |
|
3346 | + } |
|
3176 | 3347 | |
3177 | 3348 | // Load the file for the database. |
3178 | 3349 | require_once($sourcedir . '/Subs-Db-' . $db_type . '.php'); |
@@ -3180,8 +3351,9 @@ discard block |
||
3180 | 3351 | $db_options = array(); |
3181 | 3352 | |
3182 | 3353 | // Add in the port if needed |
3183 | - if (!empty($db_port)) |
|
3184 | - $db_options['port'] = $db_port; |
|
3354 | + if (!empty($db_port)) { |
|
3355 | + $db_options['port'] = $db_port; |
|
3356 | + } |
|
3185 | 3357 | |
3186 | 3358 | // 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. |
3187 | 3359 | if (SMF == 'SSI' && !empty($ssi_db_user) && !empty($ssi_db_passwd)) |
@@ -3200,13 +3372,15 @@ discard block |
||
3200 | 3372 | } |
3201 | 3373 | |
3202 | 3374 | // Safe guard here, if there isn't a valid connection lets put a stop to it. |
3203 | - if (!$db_connection) |
|
3204 | - display_db_error(); |
|
3375 | + if (!$db_connection) { |
|
3376 | + display_db_error(); |
|
3377 | + } |
|
3205 | 3378 | |
3206 | 3379 | // If in SSI mode fix up the prefix. |
3207 | - if (SMF == 'SSI') |
|
3208 | - db_fix_prefix($db_prefix, $db_name); |
|
3209 | -} |
|
3380 | + if (SMF == 'SSI') { |
|
3381 | + db_fix_prefix($db_prefix, $db_name); |
|
3382 | + } |
|
3383 | + } |
|
3210 | 3384 | |
3211 | 3385 | /** |
3212 | 3386 | * Try to load up a supported caching method. This is saved in $cacheAPI if we are not overriding it. |
@@ -3220,10 +3394,11 @@ discard block |
||
3220 | 3394 | global $sourcedir, $cacheAPI, $cache_accelerator; |
3221 | 3395 | |
3222 | 3396 | // Not overriding this and we have a cacheAPI, send it back. |
3223 | - if (empty($overrideCache) && is_object($cacheAPI)) |
|
3224 | - return $cacheAPI; |
|
3225 | - elseif (is_null($cacheAPI)) |
|
3226 | - $cacheAPI = false; |
|
3397 | + if (empty($overrideCache) && is_object($cacheAPI)) { |
|
3398 | + return $cacheAPI; |
|
3399 | + } elseif (is_null($cacheAPI)) { |
|
3400 | + $cacheAPI = false; |
|
3401 | + } |
|
3227 | 3402 | |
3228 | 3403 | // Make sure our class is in session. |
3229 | 3404 | require_once($sourcedir . '/Class-CacheAPI.php'); |
@@ -3244,8 +3419,9 @@ discard block |
||
3244 | 3419 | if (!$testAPI->isSupported()) |
3245 | 3420 | { |
3246 | 3421 | // Can we save ourselves? |
3247 | - if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') |
|
3248 | - return loadCacheAccelerator(null, false); |
|
3422 | + if (!empty($fallbackSMF) && is_null($overrideCache) && $tryAccelerator != 'smf') { |
|
3423 | + return loadCacheAccelerator(null, false); |
|
3424 | + } |
|
3249 | 3425 | return false; |
3250 | 3426 | } |
3251 | 3427 | |
@@ -3257,9 +3433,9 @@ discard block |
||
3257 | 3433 | { |
3258 | 3434 | $cacheAPI = $testAPI; |
3259 | 3435 | return $cacheAPI; |
3436 | + } else { |
|
3437 | + return $testAPI; |
|
3260 | 3438 | } |
3261 | - else |
|
3262 | - return $testAPI; |
|
3263 | 3439 | } |
3264 | 3440 | } |
3265 | 3441 | |
@@ -3279,8 +3455,9 @@ discard block |
||
3279 | 3455 | |
3280 | 3456 | // @todo Why are we doing this if caching is disabled? |
3281 | 3457 | |
3282 | - if (function_exists('call_integration_hook')) |
|
3283 | - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3458 | + if (function_exists('call_integration_hook')) { |
|
3459 | + call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); |
|
3460 | + } |
|
3284 | 3461 | |
3285 | 3462 | /* Refresh the cache if either: |
3286 | 3463 | 1. Caching is disabled. |
@@ -3294,16 +3471,19 @@ discard block |
||
3294 | 3471 | require_once($sourcedir . '/' . $file); |
3295 | 3472 | $cache_block = call_user_func_array($function, $params); |
3296 | 3473 | |
3297 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) |
|
3298 | - cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3474 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) { |
|
3475 | + cache_put_data($key, $cache_block, $cache_block['expires'] - time()); |
|
3476 | + } |
|
3299 | 3477 | } |
3300 | 3478 | |
3301 | 3479 | // Some cached data may need a freshening up after retrieval. |
3302 | - if (!empty($cache_block['post_retri_eval'])) |
|
3303 | - eval($cache_block['post_retri_eval']); |
|
3480 | + if (!empty($cache_block['post_retri_eval'])) { |
|
3481 | + eval($cache_block['post_retri_eval']); |
|
3482 | + } |
|
3304 | 3483 | |
3305 | - if (function_exists('call_integration_hook')) |
|
3306 | - call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3484 | + if (function_exists('call_integration_hook')) { |
|
3485 | + call_integration_hook('post_cache_quick_get', array(&$cache_block)); |
|
3486 | + } |
|
3307 | 3487 | |
3308 | 3488 | return $cache_block['data']; |
3309 | 3489 | } |
@@ -3330,8 +3510,9 @@ discard block |
||
3330 | 3510 | global $smcFunc, $cache_enable, $cacheAPI; |
3331 | 3511 | global $cache_hits, $cache_count, $db_show_debug; |
3332 | 3512 | |
3333 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3334 | - return; |
|
3513 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3514 | + return; |
|
3515 | + } |
|
3335 | 3516 | |
3336 | 3517 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3337 | 3518 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3344,12 +3525,14 @@ discard block |
||
3344 | 3525 | $value = $value === null ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_encode']($value) : json_encode($value)); |
3345 | 3526 | $cacheAPI->putData($key, $value, $ttl); |
3346 | 3527 | |
3347 | - if (function_exists('call_integration_hook')) |
|
3348 | - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3528 | + if (function_exists('call_integration_hook')) { |
|
3529 | + call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); |
|
3530 | + } |
|
3349 | 3531 | |
3350 | - if (isset($db_show_debug) && $db_show_debug === true) |
|
3351 | - $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3352 | -} |
|
3532 | + if (isset($db_show_debug) && $db_show_debug === true) { |
|
3533 | + $cache_hits[$cache_count]['t'] = array_sum(explode(' ', microtime())) - array_sum(explode(' ', $st)); |
|
3534 | + } |
|
3535 | + } |
|
3353 | 3536 | |
3354 | 3537 | /** |
3355 | 3538 | * Gets the value from the cache specified by key, so long as it is not older than ttl seconds. |
@@ -3365,8 +3548,9 @@ discard block |
||
3365 | 3548 | global $smcFunc, $cache_enable, $cacheAPI; |
3366 | 3549 | global $cache_hits, $cache_count, $cache_misses, $cache_count_misses, $db_show_debug; |
3367 | 3550 | |
3368 | - if (empty($cache_enable) || empty($cacheAPI)) |
|
3369 | - return; |
|
3551 | + if (empty($cache_enable) || empty($cacheAPI)) { |
|
3552 | + return; |
|
3553 | + } |
|
3370 | 3554 | |
3371 | 3555 | $cache_count = isset($cache_count) ? $cache_count + 1 : 1; |
3372 | 3556 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -3386,16 +3570,18 @@ discard block |
||
3386 | 3570 | |
3387 | 3571 | if (empty($value)) |
3388 | 3572 | { |
3389 | - if (!is_array($cache_misses)) |
|
3390 | - $cache_misses = array(); |
|
3573 | + if (!is_array($cache_misses)) { |
|
3574 | + $cache_misses = array(); |
|
3575 | + } |
|
3391 | 3576 | |
3392 | 3577 | $cache_count_misses = isset($cache_count_misses) ? $cache_count_misses + 1 : 1; |
3393 | 3578 | $cache_misses[$cache_count_misses] = array('k' => $original_key, 'd' => 'get'); |
3394 | 3579 | } |
3395 | 3580 | } |
3396 | 3581 | |
3397 | - if (function_exists('call_integration_hook') && isset($value)) |
|
3398 | - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3582 | + if (function_exists('call_integration_hook') && isset($value)) { |
|
3583 | + call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); |
|
3584 | + } |
|
3399 | 3585 | |
3400 | 3586 | return empty($value) ? null : (isset($smcFunc['json_encode']) ? $smcFunc['json_decode']($value, true) : smf_json_decode($value, true)); |
3401 | 3587 | } |
@@ -3417,8 +3603,9 @@ discard block |
||
3417 | 3603 | global $cacheAPI; |
3418 | 3604 | |
3419 | 3605 | // If we can't get to the API, can't do this. |
3420 | - if (empty($cacheAPI)) |
|
3421 | - return; |
|
3606 | + if (empty($cacheAPI)) { |
|
3607 | + return; |
|
3608 | + } |
|
3422 | 3609 | |
3423 | 3610 | // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. |
3424 | 3611 | $cacheAPI->cleanCache($type); |
@@ -3443,8 +3630,9 @@ discard block |
||
3443 | 3630 | global $modSettings, $boardurl, $smcFunc, $image_proxy_enabled, $image_proxy_secret; |
3444 | 3631 | |
3445 | 3632 | // Come on! |
3446 | - if (empty($data)) |
|
3447 | - return array(); |
|
3633 | + if (empty($data)) { |
|
3634 | + return array(); |
|
3635 | + } |
|
3448 | 3636 | |
3449 | 3637 | // Set a nice default var. |
3450 | 3638 | $image = ''; |
@@ -3452,11 +3640,11 @@ discard block |
||
3452 | 3640 | // Gravatar has been set as mandatory! |
3453 | 3641 | if (!empty($modSettings['gravatarOverride'])) |
3454 | 3642 | { |
3455 | - if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) |
|
3456 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3457 | - |
|
3458 | - else if (!empty($data['email'])) |
|
3459 | - $image = get_gravatar_url($data['email']); |
|
3643 | + if (!empty($modSettings['gravatarAllowExtraEmail']) && !empty($data['avatar']) && stristr($data['avatar'], 'gravatar://')) { |
|
3644 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3645 | + } else if (!empty($data['email'])) { |
|
3646 | + $image = get_gravatar_url($data['email']); |
|
3647 | + } |
|
3460 | 3648 | } |
3461 | 3649 | |
3462 | 3650 | // Look if the user has a gravatar field or has set an external url as avatar. |
@@ -3468,54 +3656,60 @@ discard block |
||
3468 | 3656 | // Gravatar. |
3469 | 3657 | if (stristr($data['avatar'], 'gravatar://')) |
3470 | 3658 | { |
3471 | - if ($data['avatar'] == 'gravatar://') |
|
3472 | - $image = get_gravatar_url($data['email']); |
|
3473 | - |
|
3474 | - elseif (!empty($modSettings['gravatarAllowExtraEmail'])) |
|
3475 | - $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3659 | + if ($data['avatar'] == 'gravatar://') { |
|
3660 | + $image = get_gravatar_url($data['email']); |
|
3661 | + } elseif (!empty($modSettings['gravatarAllowExtraEmail'])) { |
|
3662 | + $image = get_gravatar_url($smcFunc['substr']($data['avatar'], 11)); |
|
3663 | + } |
|
3476 | 3664 | } |
3477 | 3665 | |
3478 | 3666 | // External url. |
3479 | 3667 | else |
3480 | 3668 | { |
3481 | 3669 | // Using ssl? |
3482 | - if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) |
|
3483 | - $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3670 | + if (!empty($modSettings['force_ssl']) && $image_proxy_enabled && stripos($data['avatar'], 'http://') !== false) { |
|
3671 | + $image = strtr($boardurl, array('http://' => 'https://')) . '/proxy.php?request=' . urlencode($data['avatar']) . '&hash=' . md5($data['avatar'] . $image_proxy_secret); |
|
3672 | + } |
|
3484 | 3673 | |
3485 | 3674 | // Just a plain external url. |
3486 | - else |
|
3487 | - $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3675 | + else { |
|
3676 | + $image = (stristr($data['avatar'], 'http://') || stristr($data['avatar'], 'https://')) ? $data['avatar'] : $modSettings['avatar_url'] . '/' . $data['avatar']; |
|
3677 | + } |
|
3488 | 3678 | } |
3489 | 3679 | } |
3490 | 3680 | |
3491 | 3681 | // Perhaps this user has an attachment as avatar... |
3492 | - else if (!empty($data['filename'])) |
|
3493 | - $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3682 | + else if (!empty($data['filename'])) { |
|
3683 | + $image = $modSettings['custom_avatar_url'] . '/' . $data['filename']; |
|
3684 | + } |
|
3494 | 3685 | |
3495 | 3686 | // Right... no avatar... use our default image. |
3496 | - else |
|
3497 | - $image = $modSettings['avatar_url'] . '/default.png'; |
|
3687 | + else { |
|
3688 | + $image = $modSettings['avatar_url'] . '/default.png'; |
|
3689 | + } |
|
3498 | 3690 | } |
3499 | 3691 | |
3500 | 3692 | call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); |
3501 | 3693 | |
3502 | 3694 | // 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. |
3503 | - if (!empty($image)) |
|
3504 | - return array( |
|
3695 | + if (!empty($image)) { |
|
3696 | + return array( |
|
3505 | 3697 | 'name' => !empty($data['avatar']) ? $data['avatar'] : '', |
3506 | 3698 | 'image' => '<img class="avatar" src="' . $image . '" />', |
3507 | 3699 | 'href' => $image, |
3508 | 3700 | 'url' => $image, |
3509 | 3701 | ); |
3702 | + } |
|
3510 | 3703 | |
3511 | 3704 | // Fallback to make life easier for everyone... |
3512 | - else |
|
3513 | - return array( |
|
3705 | + else { |
|
3706 | + return array( |
|
3514 | 3707 | 'name' => '', |
3515 | 3708 | 'image' => '', |
3516 | 3709 | 'href' => '', |
3517 | 3710 | 'url' => '', |
3518 | 3711 | ); |
3519 | -} |
|
3712 | + } |
|
3713 | + } |
|
3520 | 3714 | |
3521 | 3715 | ?> |
3522 | 3716 | \ No newline at end of file |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | { |
24 | 24 | global $context, $txt; |
25 | 25 | |
26 | - if (!empty($context['simple_action'])) |
|
27 | - echo ' |
|
26 | + if (!empty($context['simple_action'])) { |
|
27 | + echo ' |
|
28 | 28 | <strong> |
29 | 29 | ', $context['error_title'], ' |
30 | 30 | </strong><br> |
31 | 31 | <div ', $context['error_code'], 'class="padding">', $context['error_message'], '</div>'; |
32 | - else |
|
32 | + } else |
|
33 | 33 | { |
34 | 34 | echo ' |
35 | 35 | <div id="fatal_error"> |
@@ -82,21 +82,23 @@ discard block |
||
82 | 82 | ', $txt['apply_filter_of_type'], ':'; |
83 | 83 | |
84 | 84 | $error_types = array(); |
85 | - foreach ($context['error_types'] as $type => $details) |
|
86 | - $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
85 | + foreach ($context['error_types'] as $type => $details) { |
|
86 | + $error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>'; |
|
87 | + } |
|
87 | 88 | |
88 | 89 | echo ' |
89 | 90 | ', implode(' | ', $error_types), ' |
90 | 91 | </td> |
91 | 92 | </tr>'; |
92 | 93 | |
93 | - if ($context['has_filter']) |
|
94 | - echo ' |
|
94 | + if ($context['has_filter']) { |
|
95 | + echo ' |
|
95 | 96 | <tr> |
96 | 97 | <td colspan="3" class="windowbg"> |
97 | 98 | <strong> ', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>] |
98 | 99 | </td> |
99 | 100 | </tr>'; |
101 | + } |
|
100 | 102 | |
101 | 103 | echo ' |
102 | 104 | <tr> |
@@ -107,11 +109,12 @@ discard block |
||
107 | 109 | </tr>'; |
108 | 110 | |
109 | 111 | // No errors, then show a message |
110 | - if (count($context['errors']) == 0) |
|
111 | - echo ' |
|
112 | + if (count($context['errors']) == 0) { |
|
113 | + echo ' |
|
112 | 114 | <tr class="windowbg"> |
113 | 115 | <td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td> |
114 | 116 | </tr>'; |
117 | + } |
|
115 | 118 | |
116 | 119 | // we have some errors, must be some mods installed :P |
117 | 120 | foreach ($context['errors'] as $error) |
@@ -125,19 +128,21 @@ discard block |
||
125 | 128 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a> |
126 | 129 | ', $error['time'], '<br>'; |
127 | 130 | |
128 | - if (!empty($error['member']['ip'])) |
|
129 | - echo ' |
|
131 | + if (!empty($error['member']['ip'])) { |
|
132 | + echo ' |
|
130 | 133 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a> |
131 | 134 | <strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong> <br>'; |
135 | + } |
|
132 | 136 | |
133 | 137 | echo ' |
134 | 138 | </div> |
135 | 139 | <div style="float: left; width: 50%; line-height: 1.8em; padding: 0 4px;">'; |
136 | 140 | |
137 | - if ($error['member']['session'] != '') |
|
138 | - echo ' |
|
141 | + if ($error['member']['session'] != '') { |
|
142 | + echo ' |
|
139 | 143 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a> |
140 | 144 | ', $error['member']['session'], '<br>'; |
145 | + } |
|
141 | 146 | |
142 | 147 | echo ' |
143 | 148 | <a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=error_type;value=', $error['error_type']['type'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_type'], '"><span class="generic_icons filter centericon"></span></a> |
@@ -151,8 +156,8 @@ discard block |
||
151 | 156 | <a style="display: table-cell;" href="', $error['url']['html'], '">', $error['url']['html'], '</a> |
152 | 157 | </div>'; |
153 | 158 | |
154 | - if (!empty($error['file'])) |
|
155 | - echo ' |
|
159 | + if (!empty($error['file'])) { |
|
160 | + echo ' |
|
156 | 161 | <div style="float: left; width: 100%; padding: 4px 0; line-height: 1.6em; border-top: 1px solid #e3e3e3;"> |
157 | 162 | <a style="display: table-cell; padding: 4px; width: 20px; vertical-align: top;" href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '"><span class="generic_icons filter"></span></a> |
158 | 163 | <div> |
@@ -160,6 +165,7 @@ discard block |
||
160 | 165 | ', $txt['line'], ': ', $error['file']['line'], ' |
161 | 166 | </div> |
162 | 167 | </div>'; |
168 | + } |
|
163 | 169 | |
164 | 170 | echo ' |
165 | 171 | </td> |
@@ -187,9 +193,10 @@ discard block |
||
187 | 193 | </div> |
188 | 194 | </div>'; |
189 | 195 | |
190 | - if ($context['sort_direction'] == 'down') |
|
191 | - echo ' |
|
196 | + if ($context['sort_direction'] == 'down') { |
|
197 | + echo ' |
|
192 | 198 | <input type="hidden" name="desc" value="1">'; |
199 | + } |
|
193 | 200 | |
194 | 201 | echo ' |
195 | 202 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
29 | 29 | // Go through each type of report they can run. |
30 | 30 | foreach ($context['report_types'] as $type) |
31 | 31 | { |
32 | - if (isset($type['description'])) |
|
33 | - echo ' |
|
32 | + if (isset($type['description'])) { |
|
33 | + echo ' |
|
34 | 34 | <dt>', $type['description'], '</dt>'; |
35 | + } |
|
35 | 36 | echo ' |
36 | 37 | <dd> |
37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '> |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | </div> |
62 | 63 | <div id="report_buttons">'; |
63 | 64 | |
64 | - if (!empty($context['report_buttons'])) |
|
65 | - template_button_strip($context['report_buttons'], 'right'); |
|
65 | + if (!empty($context['report_buttons'])) { |
|
66 | + template_button_strip($context['report_buttons'], 'right'); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | echo ' |
68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
73 | 75 | echo ' |
74 | 76 | <table class="table_grid report_results">'; |
75 | 77 | |
76 | - if (!empty($table['title'])) |
|
77 | - echo ' |
|
78 | + if (!empty($table['title'])) { |
|
79 | + echo ' |
|
78 | 80 | <thead> |
79 | 81 | <tr class="title_bar"> |
80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
81 | 83 | </tr> |
82 | 84 | </thead> |
83 | 85 | <tbody>'; |
86 | + } |
|
84 | 87 | |
85 | 88 | // Now do each row! |
86 | 89 | $row_number = 0; |
87 | 90 | foreach ($table['data'] as $row) |
88 | 91 | { |
89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
90 | - echo ' |
|
92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
93 | + echo ' |
|
91 | 94 | <tr class="windowbg table_caption">'; |
92 | - else |
|
93 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
98 | + } |
|
95 | 99 | |
96 | 100 | // Now do each column. |
97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
109 | 113 | } |
110 | 114 | |
111 | 115 | // Shaded? |
112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
113 | - echo ' |
|
116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
117 | + echo ' |
|
114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
116 | 120 | </td>'; |
117 | - else |
|
118 | - echo ' |
|
121 | + } else { |
|
122 | + echo ' |
|
119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
120 | 124 | ', $data['v'], ' |
121 | 125 | </td>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | $column_number++; |
124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
168 | 173 | <table class="bordercolor">'; |
169 | 174 | |
170 | - if (!empty($table['title'])) |
|
171 | - echo ' |
|
175 | + if (!empty($table['title'])) { |
|
176 | + echo ' |
|
172 | 177 | <tr class="title_bar"> |
173 | 178 | <td colspan="', $table['column_count'], '"> |
174 | 179 | ', $table['title'], ' |
175 | 180 | </td> |
176 | 181 | </tr>'; |
182 | + } |
|
177 | 183 | |
178 | 184 | // Now do each row! |
179 | 185 | $row_number = 0; |
180 | 186 | foreach ($table['data'] as $row) |
181 | 187 | { |
182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
183 | - echo ' |
|
188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
189 | + echo ' |
|
184 | 190 | <tr class="titlebg">'; |
185 | - else |
|
186 | - echo ' |
|
191 | + } else { |
|
192 | + echo ' |
|
187 | 193 | <tr class="windowbg">'; |
194 | + } |
|
188 | 195 | |
189 | 196 | // Now do each column!! |
190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
201 | 208 | } |
202 | 209 | |
203 | 210 | // Shaded? |
204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
205 | - echo ' |
|
211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
212 | + echo ' |
|
206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
208 | 215 | </td>'; |
209 | - else |
|
210 | - echo ' |
|
216 | + } else { |
|
217 | + echo ' |
|
211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
212 | 219 | ', $data['v'], ' |
213 | 220 | </td>'; |
221 | + } |
|
214 | 222 | |
215 | 223 | $column_number++; |
216 | 224 | } |
@@ -18,9 +18,10 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl; |
19 | 19 | |
20 | 20 | // Are we done sending the newsletter? |
21 | - if (!empty($context['newsletter_sent'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['newsletter_sent'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox">', $txt['admin_news_newsletter_' . $context['newsletter_sent']], '</div>'; |
24 | + } |
|
24 | 25 | |
25 | 26 | echo ' |
26 | 27 | <div id="admincenter"> |
@@ -39,9 +40,10 @@ discard block |
||
39 | 40 | </dt> |
40 | 41 | <dd>'; |
41 | 42 | |
42 | - foreach ($context['groups'] as $group) |
|
43 | - echo ' |
|
43 | + foreach ($context['groups'] as $group) { |
|
44 | + echo ' |
|
44 | 45 | <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
46 | + } |
|
45 | 47 | |
46 | 48 | echo ' |
47 | 49 | <br> |
@@ -82,9 +84,10 @@ discard block |
||
82 | 84 | </dt> |
83 | 85 | <dd>'; |
84 | 86 | |
85 | - foreach ($context['groups'] as $group) |
|
86 | - echo ' |
|
87 | + foreach ($context['groups'] as $group) { |
|
88 | + echo ' |
|
87 | 89 | <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
90 | + } |
|
88 | 91 | |
89 | 92 | echo ' |
90 | 93 | <br> |
@@ -228,9 +231,10 @@ discard block |
||
228 | 231 | <div id="bbcBox_message"></div>'; |
229 | 232 | |
230 | 233 | // What about smileys? |
231 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
232 | - echo ' |
|
234 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
235 | + echo ' |
|
233 | 236 | <div id="smileyBox_message"></div>'; |
237 | + } |
|
234 | 238 | |
235 | 239 | // Show BBC buttons, smileys and textbox. |
236 | 240 | echo ' |
@@ -251,9 +255,10 @@ discard block |
||
251 | 255 | <input type="hidden" name="email_force" value="', $context['email_force'], '"> |
252 | 256 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '">'; |
253 | 257 | |
254 | - foreach ($context['recipients'] as $key => $values) |
|
255 | - echo ' |
|
258 | + foreach ($context['recipients'] as $key => $values) { |
|
259 | + echo ' |
|
256 | 260 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
261 | + } |
|
257 | 262 | |
258 | 263 | echo ' |
259 | 264 | <script>'; |
@@ -408,9 +413,10 @@ discard block |
||
408 | 413 | <input type="hidden" name="parse_html" value="', $context['parse_html'], '">'; |
409 | 414 | |
410 | 415 | // All the things we must remember! |
411 | - foreach ($context['recipients'] as $key => $values) |
|
412 | - echo ' |
|
416 | + foreach ($context['recipients'] as $key => $values) { |
|
417 | + echo ' |
|
413 | 418 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
419 | + } |
|
414 | 420 | |
415 | 421 | echo ' |
416 | 422 | </div> |
@@ -443,9 +449,10 @@ discard block |
||
443 | 449 | { |
444 | 450 | global $context, $txt; |
445 | 451 | |
446 | - if (!empty($context['saved_successful'])) |
|
447 | - echo ' |
|
452 | + if (!empty($context['saved_successful'])) { |
|
453 | + echo ' |
|
448 | 454 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
455 | + } |
|
449 | 456 | |
450 | 457 | template_show_list('news_lists'); |
451 | 458 | } |
@@ -116,9 +116,10 @@ discard block |
||
116 | 116 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
117 | 117 | </div>'; |
118 | 118 | |
119 | - if (!empty($context['results'])) |
|
120 | - echo ' |
|
119 | + if (!empty($context['results'])) { |
|
120 | + echo ' |
|
121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
122 | + } |
|
122 | 123 | |
123 | 124 | echo ' |
124 | 125 | <div class="windowbg2 noup"> |
@@ -129,9 +130,10 @@ discard block |
||
129 | 130 | <dd><select name="from"> |
130 | 131 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
131 | 132 | |
132 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
133 | - echo ' |
|
133 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
134 | + echo ' |
|
134 | 135 | <option value="', $id, '">', $dir, '</option>'; |
136 | + } |
|
135 | 137 | echo ' |
136 | 138 | </select></dd> |
137 | 139 | <dt>', $txt['attachment_transfer_auto'], '</dt> |
@@ -139,13 +141,14 @@ discard block |
||
139 | 141 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
140 | 142 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
141 | 143 | |
142 | - if (!empty($context['base_dirs'])) |
|
143 | - foreach ($context['base_dirs'] as $id => $dir) |
|
144 | + if (!empty($context['base_dirs'])) { |
|
145 | + foreach ($context['base_dirs'] as $id => $dir) |
|
144 | 146 | echo ' |
145 | 147 | <option value="', $id, '">', $dir, '</option>'; |
146 | - else |
|
147 | - echo ' |
|
148 | + } else { |
|
149 | + echo ' |
|
148 | 150 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
151 | + } |
|
149 | 152 | |
150 | 153 | echo ' |
151 | 154 | </select></dd> |
@@ -153,16 +156,18 @@ discard block |
||
153 | 156 | <dd><select name="to"> |
154 | 157 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
155 | 158 | |
156 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
157 | - echo ' |
|
159 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
160 | + echo ' |
|
158 | 161 | <option value="', $id, '">', $dir, '</option>'; |
162 | + } |
|
159 | 163 | echo ' |
160 | 164 | </select></dd>'; |
161 | 165 | |
162 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
163 | - echo ' |
|
166 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
167 | + echo ' |
|
164 | 168 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
165 | 169 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
170 | + } |
|
166 | 171 | echo ' |
167 | 172 | </dl> |
168 | 173 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -238,10 +243,11 @@ discard block |
||
238 | 243 | // Loop through each error reporting the status |
239 | 244 | foreach ($context['repair_errors'] as $error => $number) |
240 | 245 | { |
241 | - if (!empty($number)) |
|
242 | - echo ' |
|
246 | + if (!empty($number)) { |
|
247 | + echo ' |
|
243 | 248 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
244 | 249 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
250 | + } |
|
245 | 251 | } |
246 | 252 | |
247 | 253 | echo ' <br> |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | |
55 | 55 | // Prepare the comments... |
56 | 56 | $comments = array(); |
57 | - foreach ($report['comments'] as $comment) |
|
58 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
57 | + foreach ($report['comments'] as $comment) { |
|
58 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | echo ' |
61 | 62 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -69,18 +70,21 @@ discard block |
||
69 | 70 | <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
70 | 71 | |
71 | 72 | // Delete message button. |
72 | - if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) |
|
73 | - echo ' |
|
73 | + if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) { |
|
74 | + echo ' |
|
74 | 75 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $report['topic']['id'], '.0;msg=', $report['topic']['id_msg'], ';modcenter;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['mc_reportedp_delete_confirm'], '" class="you_sure">', $delete_button, '</a></li>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | // Ban this user button. |
77 | - if (!$report['closed'] && !empty($context['report_manage_bans'])) |
|
78 | - echo ' |
|
79 | + if (!$report['closed'] && !empty($context['report_manage_bans'])) { |
|
80 | + echo ' |
|
79 | 81 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add', (!empty($report['author']['id']) ? ';u=' . $report['author']['id'] : ';msg=' . $report['topic']['id_msg']), ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
82 | + } |
|
80 | 83 | |
81 | - if (!$context['view_closed']) |
|
82 | - echo ' |
|
84 | + if (!$context['view_closed']) { |
|
85 | + echo ' |
|
83 | 86 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
87 | + } |
|
84 | 88 | |
85 | 89 | echo ' |
86 | 90 | </ul> |
@@ -88,11 +92,12 @@ discard block |
||
88 | 92 | } |
89 | 93 | |
90 | 94 | // Were none found? |
91 | - if (empty($context['reports'])) |
|
92 | - echo ' |
|
95 | + if (empty($context['reports'])) { |
|
96 | + echo ' |
|
93 | 97 | <div class="windowbg2"> |
94 | 98 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
95 | 99 | </div>'; |
100 | + } |
|
96 | 101 | |
97 | 102 | echo ' |
98 | 103 | <div class="pagesection"> |
@@ -125,18 +130,20 @@ discard block |
||
125 | 130 | <div class="modbox"> |
126 | 131 | <ul>'; |
127 | 132 | |
128 | - foreach ($context['reported_posts'] as $report) |
|
129 | - echo ' |
|
133 | + foreach ($context['reported_posts'] as $report) { |
|
134 | + echo ' |
|
130 | 135 | <li class="smalltext"> |
131 | 136 | <a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], ' |
132 | 137 | </li>'; |
138 | + } |
|
133 | 139 | |
134 | 140 | // Don't have any watched users right now? |
135 | - if (empty($context['reported_posts'])) |
|
136 | - echo ' |
|
141 | + if (empty($context['reported_posts'])) { |
|
142 | + echo ' |
|
137 | 143 | <li> |
138 | 144 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
139 | 145 | </li>'; |
146 | + } |
|
140 | 147 | |
141 | 148 | echo ' |
142 | 149 | </ul> |
@@ -226,12 +233,13 @@ discard block |
||
226 | 233 | <h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3> |
227 | 234 | </div>'; |
228 | 235 | |
229 | - foreach ($context['report']['comments'] as $comment) |
|
230 | - echo ' |
|
236 | + foreach ($context['report']['comments'] as $comment) { |
|
237 | + echo ' |
|
231 | 238 | <div class="windowbg"> |
232 | 239 | <p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p> |
233 | 240 | <p>', $comment['message'], '</p> |
234 | 241 | </div>'; |
242 | + } |
|
235 | 243 | |
236 | 244 | echo ' |
237 | 245 | <br> |
@@ -240,11 +248,12 @@ discard block |
||
240 | 248 | </div> |
241 | 249 | <div>'; |
242 | 250 | |
243 | - if (empty($context['report']['mod_comments'])) |
|
244 | - echo ' |
|
251 | + if (empty($context['report']['mod_comments'])) { |
|
252 | + echo ' |
|
245 | 253 | <div class="information"> |
246 | 254 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
247 | 255 | </div>'; |
256 | + } |
|
248 | 257 | |
249 | 258 | foreach ($context['report']['mod_comments'] as $comment) |
250 | 259 | { |
@@ -334,18 +343,20 @@ discard block |
||
334 | 343 | <div class="modbox"> |
335 | 344 | <ul>'; |
336 | 345 | |
337 | - foreach ($context['reported_members'] as $report) |
|
338 | - echo ' |
|
346 | + foreach ($context['reported_members'] as $report) { |
|
347 | + echo ' |
|
339 | 348 | <li class="smalltext"> |
340 | 349 | <a href="', $report['report_href'], '">', $report['user_name'], '</a> |
341 | 350 | </li>'; |
351 | + } |
|
342 | 352 | |
343 | 353 | // Don't have any reported members right now? |
344 | - if (empty($context['reported_members'])) |
|
345 | - echo ' |
|
354 | + if (empty($context['reported_members'])) { |
|
355 | + echo ' |
|
346 | 356 | <li> |
347 | 357 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
348 | 358 | </li>'; |
359 | + } |
|
349 | 360 | |
350 | 361 | echo ' |
351 | 362 | </ul> |
@@ -431,8 +442,9 @@ discard block |
||
431 | 442 | |
432 | 443 | // Prepare the comments... |
433 | 444 | $comments = array(); |
434 | - foreach ($report['comments'] as $comment) |
|
435 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
445 | + foreach ($report['comments'] as $comment) { |
|
446 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
447 | + } |
|
436 | 448 | |
437 | 449 | echo ' |
438 | 450 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -444,13 +456,15 @@ discard block |
||
444 | 456 | <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
445 | 457 | |
446 | 458 | // Ban this user button. |
447 | - if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
|
448 | - echo ' |
|
459 | + if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) { |
|
460 | + echo ' |
|
449 | 461 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
462 | + } |
|
450 | 463 | |
451 | - if (!$context['view_closed']) |
|
452 | - echo ' |
|
464 | + if (!$context['view_closed']) { |
|
465 | + echo ' |
|
453 | 466 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
467 | + } |
|
454 | 468 | |
455 | 469 | echo ' |
456 | 470 | </ul> |
@@ -458,11 +472,12 @@ discard block |
||
458 | 472 | } |
459 | 473 | |
460 | 474 | // Were none found? |
461 | - if (empty($context['reports'])) |
|
462 | - echo ' |
|
475 | + if (empty($context['reports'])) { |
|
476 | + echo ' |
|
463 | 477 | <div class="windowbg2"> |
464 | 478 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
465 | 479 | </div>'; |
480 | + } |
|
466 | 481 | |
467 | 482 | echo ' |
468 | 483 | <div class="pagesection"> |
@@ -522,12 +537,13 @@ discard block |
||
522 | 537 | <h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3> |
523 | 538 | </div>'; |
524 | 539 | |
525 | - foreach ($context['report']['comments'] as $comment) |
|
526 | - echo ' |
|
540 | + foreach ($context['report']['comments'] as $comment) { |
|
541 | + echo ' |
|
527 | 542 | <div class="windowbg"> |
528 | 543 | <p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p> |
529 | 544 | <p>', $comment['message'], '</p> |
530 | 545 | </div>'; |
546 | + } |
|
531 | 547 | |
532 | 548 | echo ' |
533 | 549 | <br> |
@@ -536,11 +552,12 @@ discard block |
||
536 | 552 | </div> |
537 | 553 | <div>'; |
538 | 554 | |
539 | - if (empty($context['report']['mod_comments'])) |
|
540 | - echo ' |
|
555 | + if (empty($context['report']['mod_comments'])) { |
|
556 | + echo ' |
|
541 | 557 | <div class="information"> |
542 | 558 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
543 | 559 | </div>'; |
560 | + } |
|
544 | 561 | |
545 | 562 | foreach ($context['report']['mod_comments'] as $comment) |
546 | 563 | { |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | </thead> |
149 | 149 | <tbody>'; |
150 | 150 | |
151 | - foreach ($context['membergroups'] as $membergroup) |
|
152 | - echo ' |
|
151 | + foreach ($context['membergroups'] as $membergroup) { |
|
152 | + echo ' |
|
153 | 153 | <tr class="windowbg"> |
154 | 154 | <td>', $membergroup['name'], '</td> |
155 | 155 | <td class="centercol"> |
@@ -159,6 +159,7 @@ discard block |
||
159 | 159 | ', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked>' : '', ' |
160 | 160 | </td> |
161 | 161 | </tr>'; |
162 | + } |
|
162 | 163 | |
163 | 164 | echo ' |
164 | 165 | <tr class="windowbg"> |
@@ -185,8 +186,8 @@ discard block |
||
185 | 186 | </thead> |
186 | 187 | <tbody>'; |
187 | 188 | |
188 | - foreach ($context['postgroups'] as $postgroup) |
|
189 | - echo ' |
|
189 | + foreach ($context['postgroups'] as $postgroup) { |
|
190 | + echo ' |
|
190 | 191 | <tr class="windowbg"> |
191 | 192 | <td> |
192 | 193 | ', $postgroup['name'], ' |
@@ -195,6 +196,7 @@ discard block |
||
195 | 196 | <input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked> |
196 | 197 | </td> |
197 | 198 | </tr>'; |
199 | + } |
|
198 | 200 | |
199 | 201 | echo ' |
200 | 202 | <tr class="windowbg"> |