@@ -43,28 +43,33 @@ discard block |
||
43 | 43 | </div> |
44 | 44 | <div class="list_posts">', $post['message'], '</div>'; |
45 | 45 | |
46 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
47 | - echo ' |
|
46 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
47 | + echo ' |
|
48 | 48 | <ul class="quickbuttons">'; |
49 | + } |
|
49 | 50 | |
50 | 51 | // If they *can* reply? |
51 | - if ($post['can_reply']) |
|
52 | - echo ' |
|
52 | + if ($post['can_reply']) { |
|
53 | + echo ' |
|
53 | 54 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
55 | + } |
|
54 | 56 | |
55 | 57 | // If they *can* quote? |
56 | - if ($post['can_quote']) |
|
57 | - echo ' |
|
58 | + if ($post['can_quote']) { |
|
59 | + echo ' |
|
58 | 60 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // How about... even... remove it entirely?! |
61 | - if ($post['can_delete']) |
|
62 | - echo ' |
|
64 | + if ($post['can_delete']) { |
|
65 | + echo ' |
|
63 | 66 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
67 | + } |
|
64 | 68 | |
65 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
66 | - echo ' |
|
69 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
70 | + echo ' |
|
67 | 71 | </ul>'; |
72 | + } |
|
68 | 73 | |
69 | 74 | echo ' |
70 | 75 | </div>'; |
@@ -86,12 +91,13 @@ discard block |
||
86 | 91 | echo ' |
87 | 92 | <div id="recent" class="main_content">'; |
88 | 93 | |
89 | - if ($context['showCheckboxes']) |
|
90 | - echo ' |
|
94 | + if ($context['showCheckboxes']) { |
|
95 | + echo ' |
|
91 | 96 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
92 | 97 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
93 | 98 | <input type="hidden" name="qaction" value="markread"> |
94 | 99 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
100 | + } |
|
95 | 101 | |
96 | 102 | if (!empty($context['topics'])) |
97 | 103 | { |
@@ -120,11 +126,12 @@ discard block |
||
120 | 126 | </div>'; |
121 | 127 | |
122 | 128 | // Show a "select all" box for quick moderation? |
123 | - if ($context['showCheckboxes']) |
|
124 | - echo ' |
|
129 | + if ($context['showCheckboxes']) { |
|
130 | + echo ' |
|
125 | 131 | <div class="moderation"> |
126 | 132 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
127 | 133 | </div>'; |
134 | + } |
|
128 | 135 | |
129 | 136 | echo ' |
130 | 137 | </div> |
@@ -143,15 +150,18 @@ discard block |
||
143 | 150 | // Now we handle the icons |
144 | 151 | echo ' |
145 | 152 | <div class="icons floatright">'; |
146 | - if ($topic['is_locked']) |
|
147 | - echo ' |
|
153 | + if ($topic['is_locked']) { |
|
154 | + echo ' |
|
148 | 155 | <span class="generic_icons lock"></span>'; |
149 | - if ($topic['is_sticky']) |
|
150 | - echo ' |
|
156 | + } |
|
157 | + if ($topic['is_sticky']) { |
|
158 | + echo ' |
|
151 | 159 | <span class="generic_icons sticky"></span>'; |
152 | - if ($topic['is_poll']) |
|
153 | - echo ' |
|
160 | + } |
|
161 | + if ($topic['is_poll']) { |
|
162 | + echo ' |
|
154 | 163 | <span class="generic_icons poll"></span>'; |
164 | + } |
|
155 | 165 | echo ' |
156 | 166 | </div>'; |
157 | 167 | |
@@ -176,19 +186,21 @@ discard block |
||
176 | 186 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
177 | 187 | </div>'; |
178 | 188 | |
179 | - if ($context['showCheckboxes']) |
|
180 | - echo ' |
|
189 | + if ($context['showCheckboxes']) { |
|
190 | + echo ' |
|
181 | 191 | <div class="moderation"> |
182 | 192 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
183 | 193 | </div>'; |
194 | + } |
|
184 | 195 | |
185 | 196 | echo ' |
186 | 197 | </div>'; |
187 | 198 | } |
188 | 199 | |
189 | - if (empty($context['topics'])) |
|
190 | - echo ' |
|
200 | + if (empty($context['topics'])) { |
|
201 | + echo ' |
|
191 | 202 | <div style="display: none;"></div>'; |
203 | + } |
|
192 | 204 | |
193 | 205 | echo ' |
194 | 206 | </div> |
@@ -203,25 +215,27 @@ discard block |
||
203 | 215 | ', $context['page_index'], ' |
204 | 216 | </div> |
205 | 217 | </div>'; |
206 | - } |
|
207 | - else |
|
208 | - echo ' |
|
218 | + } else { |
|
219 | + echo ' |
|
209 | 220 | <div class="cat_bar"> |
210 | 221 | <h3 class="catbg centertext"> |
211 | 222 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
212 | 223 | </h3> |
213 | 224 | </div>'; |
225 | + } |
|
214 | 226 | |
215 | - if ($context['showCheckboxes']) |
|
216 | - echo ' |
|
227 | + if ($context['showCheckboxes']) { |
|
228 | + echo ' |
|
217 | 229 | </form>'; |
230 | + } |
|
218 | 231 | |
219 | 232 | echo ' |
220 | 233 | </div>'; |
221 | 234 | |
222 | - if (empty($context['no_topic_listing'])) |
|
223 | - template_topic_legend(); |
|
224 | -} |
|
235 | + if (empty($context['no_topic_listing'])) { |
|
236 | + template_topic_legend(); |
|
237 | + } |
|
238 | + } |
|
225 | 239 | |
226 | 240 | /** |
227 | 241 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -233,12 +247,13 @@ discard block |
||
233 | 247 | echo ' |
234 | 248 | <div id="recent">'; |
235 | 249 | |
236 | - if ($context['showCheckboxes']) |
|
237 | - echo ' |
|
250 | + if ($context['showCheckboxes']) { |
|
251 | + echo ' |
|
238 | 252 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
239 | 253 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
240 | 254 | <input type="hidden" name="qaction" value="markread"> |
241 | 255 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
256 | + } |
|
242 | 257 | |
243 | 258 | if (!empty($context['topics'])) |
244 | 259 | { |
@@ -267,11 +282,12 @@ discard block |
||
267 | 282 | </div>'; |
268 | 283 | |
269 | 284 | // Show a "select all" box for quick moderation? |
270 | - if ($context['showCheckboxes']) |
|
271 | - echo ' |
|
285 | + if ($context['showCheckboxes']) { |
|
286 | + echo ' |
|
272 | 287 | <div class="moderation"> |
273 | 288 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
274 | 289 | </div>'; |
290 | + } |
|
275 | 291 | |
276 | 292 | echo ' |
277 | 293 | </div> |
@@ -290,15 +306,18 @@ discard block |
||
290 | 306 | // Now we handle the icons |
291 | 307 | echo ' |
292 | 308 | <div class="icons floatright">'; |
293 | - if ($topic['is_locked']) |
|
294 | - echo ' |
|
309 | + if ($topic['is_locked']) { |
|
310 | + echo ' |
|
295 | 311 | <span class="generic_icons lock"></span>'; |
296 | - if ($topic['is_sticky']) |
|
297 | - echo ' |
|
312 | + } |
|
313 | + if ($topic['is_sticky']) { |
|
314 | + echo ' |
|
298 | 315 | <span class="generic_icons sticky"></span>'; |
299 | - if ($topic['is_poll']) |
|
300 | - echo ' |
|
316 | + } |
|
317 | + if ($topic['is_poll']) { |
|
318 | + echo ' |
|
301 | 319 | <span class="generic_icons poll"></span>'; |
320 | + } |
|
302 | 321 | echo ' |
303 | 322 | </div>'; |
304 | 323 | |
@@ -323,11 +342,12 @@ discard block |
||
323 | 342 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
324 | 343 | </div>'; |
325 | 344 | |
326 | - if ($context['showCheckboxes']) |
|
327 | - echo ' |
|
345 | + if ($context['showCheckboxes']) { |
|
346 | + echo ' |
|
328 | 347 | <div class="moderation"> |
329 | 348 | <input type="checkbox" name="topics[]" value="', $topic['id'], '"> |
330 | 349 | </div>'; |
350 | + } |
|
331 | 351 | echo ' |
332 | 352 | </div>'; |
333 | 353 | } |
@@ -343,24 +363,26 @@ discard block |
||
343 | 363 | ', $context['page_index'], ' |
344 | 364 | </div> |
345 | 365 | </div>'; |
346 | - } |
|
347 | - else |
|
348 | - echo ' |
|
366 | + } else { |
|
367 | + echo ' |
|
349 | 368 | <div class="cat_bar"> |
350 | 369 | <h3 class="catbg centertext"> |
351 | 370 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
352 | 371 | </h3> |
353 | 372 | </div>'; |
373 | + } |
|
354 | 374 | |
355 | - if ($context['showCheckboxes']) |
|
356 | - echo ' |
|
375 | + if ($context['showCheckboxes']) { |
|
376 | + echo ' |
|
357 | 377 | </form>'; |
378 | + } |
|
358 | 379 | |
359 | 380 | echo ' |
360 | 381 | </div>'; |
361 | 382 | |
362 | - if (empty($context['no_topic_listing'])) |
|
363 | - template_topic_legend(); |
|
364 | -} |
|
383 | + if (empty($context['no_topic_listing'])) { |
|
384 | + template_topic_legend(); |
|
385 | + } |
|
386 | + } |
|
365 | 387 | |
366 | 388 | ?> |
367 | 389 | \ No newline at end of file |
@@ -11,8 +11,9 @@ |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * View a summary. |
@@ -23,8 +24,9 @@ discard block |
||
23 | 24 | global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc; |
24 | 25 | |
25 | 26 | // Attempt to load the member's profile data. |
26 | - if (!loadMemberContext($memID) || !isset($memberContext[$memID])) |
|
27 | - fatal_lang_error('not_a_user', false, 404); |
|
27 | + if (!loadMemberContext($memID) || !isset($memberContext[$memID])) { |
|
28 | + fatal_lang_error('not_a_user', false, 404); |
|
29 | + } |
|
28 | 30 | |
29 | 31 | // Set up the stuff and load the user. |
30 | 32 | $context += array( |
@@ -49,19 +51,21 @@ discard block |
||
49 | 51 | |
50 | 52 | // See if they have broken any warning levels... |
51 | 53 | list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']); |
52 | - if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) |
|
53 | - $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
54 | - elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) |
|
55 | - $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
56 | - elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) |
|
57 | - $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
54 | + if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) { |
|
55 | + $context['warning_status'] = $txt['profile_warning_is_muted']; |
|
56 | + } elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) { |
|
57 | + $context['warning_status'] = $txt['profile_warning_is_moderation']; |
|
58 | + } elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) { |
|
59 | + $context['warning_status'] = $txt['profile_warning_is_watch']; |
|
60 | + } |
|
58 | 61 | |
59 | 62 | // They haven't even been registered for a full day!? |
60 | 63 | $days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24)); |
61 | - if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) |
|
62 | - $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
63 | - else |
|
64 | - $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
64 | + if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) { |
|
65 | + $context['member']['posts_per_day'] = $txt['not_applicable']; |
|
66 | + } else { |
|
67 | + $context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3); |
|
68 | + } |
|
65 | 69 | |
66 | 70 | // Set the age... |
67 | 71 | if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002) |
@@ -70,8 +74,7 @@ discard block |
||
70 | 74 | 'age' => $txt['not_applicable'], |
71 | 75 | 'today_is_birthday' => false |
72 | 76 | ); |
73 | - } |
|
74 | - else |
|
77 | + } else |
|
75 | 78 | { |
76 | 79 | list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d'); |
77 | 80 | $datearray = getdate(forum_time()); |
@@ -84,15 +87,16 @@ discard block |
||
84 | 87 | if (allowedTo('moderate_forum')) |
85 | 88 | { |
86 | 89 | // Make sure it's a valid ip address; otherwise, don't bother... |
87 | - if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) |
|
88 | - $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
89 | - else |
|
90 | - $context['member']['hostname'] = ''; |
|
90 | + if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) { |
|
91 | + $context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']); |
|
92 | + } else { |
|
93 | + $context['member']['hostname'] = ''; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | $context['can_see_ip'] = true; |
97 | + } else { |
|
98 | + $context['can_see_ip'] = false; |
|
93 | 99 | } |
94 | - else |
|
95 | - $context['can_see_ip'] = false; |
|
96 | 100 | |
97 | 101 | // Are they hidden? |
98 | 102 | $context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']); |
@@ -103,8 +107,9 @@ discard block |
||
103 | 107 | include_once($sourcedir . '/Who.php'); |
104 | 108 | $action = determineActions($user_profile[$memID]['url']); |
105 | 109 | |
106 | - if ($action !== false) |
|
107 | - $context['member']['action'] = $action; |
|
110 | + if ($action !== false) { |
|
111 | + $context['member']['action'] = $action; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | // If the user is awaiting activation, and the viewer has permission - setup some activation context messages. |
@@ -167,13 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | // Work out what restrictions we actually have. |
169 | 174 | $ban_restrictions = array(); |
170 | - foreach (array('access', 'login', 'post') as $type) |
|
171 | - if ($row['cannot_' . $type]) |
|
175 | + foreach (array('access', 'login', 'post') as $type) { |
|
176 | + if ($row['cannot_' . $type]) |
|
172 | 177 | $ban_restrictions[] = $txt['ban_type_' . $type]; |
178 | + } |
|
173 | 179 | |
174 | 180 | // No actual ban in place? |
175 | - if (empty($ban_restrictions)) |
|
176 | - continue; |
|
181 | + if (empty($ban_restrictions)) { |
|
182 | + continue; |
|
183 | + } |
|
177 | 184 | |
178 | 185 | // Prepare the link for context. |
179 | 186 | $ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>'); |
@@ -195,9 +202,10 @@ discard block |
||
195 | 202 | $context['print_custom_fields'] = array(); |
196 | 203 | |
197 | 204 | // Any custom profile fields? |
198 | - if (!empty($context['custom_fields'])) |
|
199 | - foreach ($context['custom_fields'] as $custom) |
|
205 | + if (!empty($context['custom_fields'])) { |
|
206 | + foreach ($context['custom_fields'] as $custom) |
|
200 | 207 | $context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
208 | + } |
|
201 | 209 | |
202 | 210 | } |
203 | 211 | |
@@ -241,14 +249,16 @@ discard block |
||
241 | 249 | $row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array(); |
242 | 250 | $alerts[$id_alert] = $row; |
243 | 251 | |
244 | - if (!empty($row['sender_id'])) |
|
245 | - $senders[] = $row['sender_id']; |
|
252 | + if (!empty($row['sender_id'])) { |
|
253 | + $senders[] = $row['sender_id']; |
|
254 | + } |
|
246 | 255 | } |
247 | 256 | $smcFunc['db_free_result']($request); |
248 | 257 | |
249 | 258 | $senders = loadMemberData($senders); |
250 | - foreach ($senders as $member) |
|
251 | - loadMemberContext($member); |
|
259 | + foreach ($senders as $member) { |
|
260 | + loadMemberContext($member); |
|
261 | + } |
|
252 | 262 | |
253 | 263 | // Now go through and actually make with the text. |
254 | 264 | loadLanguage('Alerts'); |
@@ -262,12 +272,15 @@ discard block |
||
262 | 272 | $msgs = array(); |
263 | 273 | foreach ($alerts as $id_alert => $alert) |
264 | 274 | { |
265 | - if (isset($alert['extra']['board'])) |
|
266 | - $boards[$alert['extra']['board']] = $txt['board_na']; |
|
267 | - if (isset($alert['extra']['topic'])) |
|
268 | - $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
269 | - if ($alert['content_type'] == 'msg') |
|
270 | - $msgs[$alert['content_id']] = $txt['topic_na']; |
|
275 | + if (isset($alert['extra']['board'])) { |
|
276 | + $boards[$alert['extra']['board']] = $txt['board_na']; |
|
277 | + } |
|
278 | + if (isset($alert['extra']['topic'])) { |
|
279 | + $topics[$alert['extra']['topic']] = $txt['topic_na']; |
|
280 | + } |
|
281 | + if ($alert['content_type'] == 'msg') { |
|
282 | + $msgs[$alert['content_id']] = $txt['topic_na']; |
|
283 | + } |
|
271 | 284 | } |
272 | 285 | |
273 | 286 | // Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up. |
@@ -282,8 +295,9 @@ discard block |
||
282 | 295 | 'boards' => array_keys($boards), |
283 | 296 | ) |
284 | 297 | ); |
285 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
286 | - $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
298 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
299 | + $boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>'; |
|
300 | + } |
|
287 | 301 | } |
288 | 302 | if (!empty($topics)) |
289 | 303 | { |
@@ -298,8 +312,9 @@ discard block |
||
298 | 312 | 'topics' => array_keys($topics), |
299 | 313 | ) |
300 | 314 | ); |
301 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
302 | - $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
315 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
316 | + $topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'; |
|
317 | + } |
|
303 | 318 | } |
304 | 319 | if (!empty($msgs)) |
305 | 320 | { |
@@ -314,26 +329,33 @@ discard block |
||
314 | 329 | 'msgs' => array_keys($msgs), |
315 | 330 | ) |
316 | 331 | ); |
317 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
318 | - $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
333 | + $msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>'; |
|
334 | + } |
|
319 | 335 | } |
320 | 336 | |
321 | 337 | // Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already) |
322 | 338 | foreach ($alerts as $id_alert => $alert) |
323 | 339 | { |
324 | - if (!empty($alert['text'])) |
|
325 | - continue; |
|
326 | - if (isset($alert['extra']['board'])) |
|
327 | - $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
328 | - if (isset($alert['extra']['topic'])) |
|
329 | - $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
330 | - if ($alert['content_type'] == 'msg') |
|
331 | - $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
332 | - if ($alert['content_type'] == 'profile') |
|
333 | - $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
334 | - |
|
335 | - if (!empty($memberContext[$alert['sender_id']])) |
|
336 | - $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
340 | + if (!empty($alert['text'])) { |
|
341 | + continue; |
|
342 | + } |
|
343 | + if (isset($alert['extra']['board'])) { |
|
344 | + $alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']]; |
|
345 | + } |
|
346 | + if (isset($alert['extra']['topic'])) { |
|
347 | + $alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']]; |
|
348 | + } |
|
349 | + if ($alert['content_type'] == 'msg') { |
|
350 | + $alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']]; |
|
351 | + } |
|
352 | + if ($alert['content_type'] == 'profile') { |
|
353 | + $alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>'; |
|
354 | + } |
|
355 | + |
|
356 | + if (!empty($memberContext[$alert['sender_id']])) { |
|
357 | + $alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']]; |
|
358 | + } |
|
337 | 359 | |
338 | 360 | $string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action']; |
339 | 361 | if (isset($txt[$string])) |
@@ -421,11 +443,11 @@ discard block |
||
421 | 443 | checkSession('request'); |
422 | 444 | |
423 | 445 | // Call it! |
424 | - if ($action == 'remove') |
|
425 | - alert_delete($toMark, $memID); |
|
426 | - |
|
427 | - else |
|
428 | - alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
446 | + if ($action == 'remove') { |
|
447 | + alert_delete($toMark, $memID); |
|
448 | + } else { |
|
449 | + alert_mark($memID, $toMark, $action == 'read' ? 1 : 0); |
|
450 | + } |
|
429 | 451 | |
430 | 452 | // Set a nice update message. |
431 | 453 | $_SESSION['update_message'] = true; |
@@ -475,23 +497,27 @@ discard block |
||
475 | 497 | ); |
476 | 498 | |
477 | 499 | // Set the page title |
478 | - if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) |
|
479 | - $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
480 | - else |
|
481 | - $context['page_title'] = $txt['showPosts']; |
|
500 | + if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) { |
|
501 | + $context['page_title'] = $txt['show' . $title[$_GET['sa']]]; |
|
502 | + } else { |
|
503 | + $context['page_title'] = $txt['showPosts']; |
|
504 | + } |
|
482 | 505 | |
483 | 506 | $context['page_title'] .= ' - ' . $user_profile[$memID]['real_name']; |
484 | 507 | |
485 | 508 | // Is the load average too high to allow searching just now? |
486 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) |
|
487 | - fatal_lang_error('loadavg_show_posts_disabled', false); |
|
509 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) { |
|
510 | + fatal_lang_error('loadavg_show_posts_disabled', false); |
|
511 | + } |
|
488 | 512 | |
489 | 513 | // If we're specifically dealing with attachments use that function! |
490 | - if (isset($_GET['sa']) && $_GET['sa'] == 'attach') |
|
491 | - return showAttachments($memID); |
|
514 | + if (isset($_GET['sa']) && $_GET['sa'] == 'attach') { |
|
515 | + return showAttachments($memID); |
|
516 | + } |
|
492 | 517 | // Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function. |
493 | - elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') |
|
494 | - return showUnwatched($memID); |
|
518 | + elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') { |
|
519 | + return showUnwatched($memID); |
|
520 | + } |
|
495 | 521 | |
496 | 522 | // Are we just viewing topics? |
497 | 523 | $context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false; |
@@ -514,27 +540,30 @@ discard block |
||
514 | 540 | $smcFunc['db_free_result']($request); |
515 | 541 | |
516 | 542 | // Trying to remove a message that doesn't exist. |
517 | - if (empty($info)) |
|
518 | - redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
543 | + if (empty($info)) { |
|
544 | + redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
|
545 | + } |
|
519 | 546 | |
520 | 547 | // We can be lazy, since removeMessage() will check the permissions for us. |
521 | 548 | require_once($sourcedir . '/RemoveTopic.php'); |
522 | 549 | removeMessage((int) $_GET['delete']); |
523 | 550 | |
524 | 551 | // Add it to the mod log. |
525 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
526 | - logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
552 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
553 | + logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3])); |
|
554 | + } |
|
527 | 555 | |
528 | 556 | // Back to... where we are now ;). |
529 | 557 | redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']); |
530 | 558 | } |
531 | 559 | |
532 | 560 | // Default to 10. |
533 | - if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) |
|
534 | - $_REQUEST['viewscount'] = '10'; |
|
561 | + if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) { |
|
562 | + $_REQUEST['viewscount'] = '10'; |
|
563 | + } |
|
535 | 564 | |
536 | - if ($context['is_topics']) |
|
537 | - $request = $smcFunc['db_query']('', ' |
|
565 | + if ($context['is_topics']) { |
|
566 | + $request = $smcFunc['db_query']('', ' |
|
538 | 567 | SELECT COUNT(*) |
539 | 568 | FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
540 | 569 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . ' |
@@ -547,8 +576,8 @@ discard block |
||
547 | 576 | 'board' => $board, |
548 | 577 | ) |
549 | 578 | ); |
550 | - else |
|
551 | - $request = $smcFunc['db_query']('', ' |
|
579 | + } else { |
|
580 | + $request = $smcFunc['db_query']('', ' |
|
552 | 581 | SELECT COUNT(*) |
553 | 582 | FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : ' |
554 | 583 | INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . ' |
@@ -561,6 +590,7 @@ discard block |
||
561 | 590 | 'board' => $board, |
562 | 591 | ) |
563 | 592 | ); |
593 | + } |
|
564 | 594 | list ($msgCount) = $smcFunc['db_fetch_row']($request); |
565 | 595 | $smcFunc['db_free_result']($request); |
566 | 596 | |
@@ -581,10 +611,11 @@ discard block |
||
581 | 611 | |
582 | 612 | $range_limit = ''; |
583 | 613 | |
584 | - if ($context['is_topics']) |
|
585 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
586 | - else |
|
587 | - $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
614 | + if ($context['is_topics']) { |
|
615 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
|
616 | + } else { |
|
617 | + $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
|
618 | + } |
|
588 | 619 | |
589 | 620 | $maxIndex = $maxPerPage; |
590 | 621 | |
@@ -610,9 +641,9 @@ discard block |
||
610 | 641 | { |
611 | 642 | $margin *= 5; |
612 | 643 | $range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin); |
644 | + } else { |
|
645 | + $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
613 | 646 | } |
614 | - else |
|
615 | - $range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin); |
|
616 | 647 | } |
617 | 648 | |
618 | 649 | // Find this user's posts. The left join on categories somehow makes this faster, weird as it looks. |
@@ -644,8 +675,7 @@ discard block |
||
644 | 675 | 'max' => $maxIndex, |
645 | 676 | ) |
646 | 677 | ); |
647 | - } |
|
648 | - else |
|
678 | + } else |
|
649 | 679 | { |
650 | 680 | $request = $smcFunc['db_query']('', ' |
651 | 681 | SELECT |
@@ -674,8 +704,9 @@ discard block |
||
674 | 704 | } |
675 | 705 | |
676 | 706 | // Make sure we quit this loop. |
677 | - if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) |
|
678 | - break; |
|
707 | + if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) { |
|
708 | + break; |
|
709 | + } |
|
679 | 710 | $looped = true; |
680 | 711 | $range_limit = ''; |
681 | 712 | } |
@@ -719,19 +750,21 @@ discard block |
||
719 | 750 | 'css_class' => $row['approved'] ? 'windowbg' : 'approvebg', |
720 | 751 | ); |
721 | 752 | |
722 | - if ($user_info['id'] == $row['id_member_started']) |
|
723 | - $board_ids['own'][$row['id_board']][] = $counter; |
|
753 | + if ($user_info['id'] == $row['id_member_started']) { |
|
754 | + $board_ids['own'][$row['id_board']][] = $counter; |
|
755 | + } |
|
724 | 756 | $board_ids['any'][$row['id_board']][] = $counter; |
725 | 757 | } |
726 | 758 | $smcFunc['db_free_result']($request); |
727 | 759 | |
728 | 760 | // All posts were retrieved in reverse order, get them right again. |
729 | - if ($reverse) |
|
730 | - $context['posts'] = array_reverse($context['posts'], true); |
|
761 | + if ($reverse) { |
|
762 | + $context['posts'] = array_reverse($context['posts'], true); |
|
763 | + } |
|
731 | 764 | |
732 | 765 | // These are all the permissions that are different from board to board.. |
733 | - if ($context['is_topics']) |
|
734 | - $permissions = array( |
|
766 | + if ($context['is_topics']) { |
|
767 | + $permissions = array( |
|
735 | 768 | 'own' => array( |
736 | 769 | 'post_reply_own' => 'can_reply', |
737 | 770 | ), |
@@ -739,8 +772,8 @@ discard block |
||
739 | 772 | 'post_reply_any' => 'can_reply', |
740 | 773 | ) |
741 | 774 | ); |
742 | - else |
|
743 | - $permissions = array( |
|
775 | + } else { |
|
776 | + $permissions = array( |
|
744 | 777 | 'own' => array( |
745 | 778 | 'post_reply_own' => 'can_reply', |
746 | 779 | 'delete_own' => 'can_delete', |
@@ -750,6 +783,7 @@ discard block |
||
750 | 783 | 'delete_any' => 'can_delete', |
751 | 784 | ) |
752 | 785 | ); |
786 | + } |
|
753 | 787 | |
754 | 788 | // For every permission in the own/any lists... |
755 | 789 | foreach ($permissions as $type => $list) |
@@ -760,19 +794,22 @@ discard block |
||
760 | 794 | $boards = boardsAllowedTo($permission); |
761 | 795 | |
762 | 796 | // Hmm, they can do it on all boards, can they? |
763 | - if (!empty($boards) && $boards[0] == 0) |
|
764 | - $boards = array_keys($board_ids[$type]); |
|
797 | + if (!empty($boards) && $boards[0] == 0) { |
|
798 | + $boards = array_keys($board_ids[$type]); |
|
799 | + } |
|
765 | 800 | |
766 | 801 | // Now go through each board they can do the permission on. |
767 | 802 | foreach ($boards as $board_id) |
768 | 803 | { |
769 | 804 | // There aren't any posts displayed from this board. |
770 | - if (!isset($board_ids[$type][$board_id])) |
|
771 | - continue; |
|
805 | + if (!isset($board_ids[$type][$board_id])) { |
|
806 | + continue; |
|
807 | + } |
|
772 | 808 | |
773 | 809 | // Set the permission to true ;). |
774 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
775 | - $context['posts'][$counter][$allowed] = true; |
|
810 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
811 | + $context['posts'][$counter][$allowed] = true; |
|
812 | + } |
|
776 | 813 | } |
777 | 814 | } |
778 | 815 | } |
@@ -803,8 +840,9 @@ discard block |
||
803 | 840 | $boardsAllowed = boardsAllowedTo('view_attachments'); |
804 | 841 | |
805 | 842 | // Make sure we can't actually see anything... |
806 | - if (empty($boardsAllowed)) |
|
807 | - $boardsAllowed = array(-1); |
|
843 | + if (empty($boardsAllowed)) { |
|
844 | + $boardsAllowed = array(-1); |
|
845 | + } |
|
808 | 846 | |
809 | 847 | require_once($sourcedir . '/Subs-List.php'); |
810 | 848 | |
@@ -955,8 +993,8 @@ discard block |
||
955 | 993 | ) |
956 | 994 | ); |
957 | 995 | $attachments = array(); |
958 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
959 | - $attachments[] = array( |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $attachments[] = array( |
|
960 | 998 | 'id' => $row['id_attach'], |
961 | 999 | 'filename' => $row['filename'], |
962 | 1000 | 'downloads' => $row['downloads'], |
@@ -968,6 +1006,7 @@ discard block |
||
968 | 1006 | 'board_name' => $row['name'], |
969 | 1007 | 'approved' => $row['approved'], |
970 | 1008 | ); |
1009 | + } |
|
971 | 1010 | |
972 | 1011 | $smcFunc['db_free_result']($request); |
973 | 1012 | |
@@ -1022,8 +1061,9 @@ discard block |
||
1022 | 1061 | global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir; |
1023 | 1062 | |
1024 | 1063 | // Only the owner can see the list (if the function is enabled of course) |
1025 | - if ($user_info['id'] != $memID) |
|
1026 | - return; |
|
1064 | + if ($user_info['id'] != $memID) { |
|
1065 | + return; |
|
1066 | + } |
|
1027 | 1067 | |
1028 | 1068 | require_once($sourcedir . '/Subs-List.php'); |
1029 | 1069 | |
@@ -1169,8 +1209,9 @@ discard block |
||
1169 | 1209 | ); |
1170 | 1210 | |
1171 | 1211 | $topics = array(); |
1172 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1173 | - $topics[] = $row['id_topic']; |
|
1212 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1213 | + $topics[] = $row['id_topic']; |
|
1214 | + } |
|
1174 | 1215 | |
1175 | 1216 | $smcFunc['db_free_result']($request); |
1176 | 1217 | |
@@ -1190,8 +1231,9 @@ discard block |
||
1190 | 1231 | 'topics' => $topics, |
1191 | 1232 | ) |
1192 | 1233 | ); |
1193 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1194 | - $topicsInfo[] = $row; |
|
1234 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1235 | + $topicsInfo[] = $row; |
|
1236 | + } |
|
1195 | 1237 | $smcFunc['db_free_result']($request); |
1196 | 1238 | } |
1197 | 1239 | |
@@ -1239,8 +1281,9 @@ discard block |
||
1239 | 1281 | $context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name']; |
1240 | 1282 | |
1241 | 1283 | // Is the load average too high to allow searching just now? |
1242 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) |
|
1243 | - fatal_lang_error('loadavg_userstats_disabled', false); |
|
1284 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) { |
|
1285 | + fatal_lang_error('loadavg_userstats_disabled', false); |
|
1286 | + } |
|
1244 | 1287 | |
1245 | 1288 | // General user statistics. |
1246 | 1289 | $timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400); |
@@ -1398,11 +1441,13 @@ discard block |
||
1398 | 1441 | } |
1399 | 1442 | $smcFunc['db_free_result']($result); |
1400 | 1443 | |
1401 | - if ($maxPosts > 0) |
|
1402 | - for ($hour = 0; $hour < 24; $hour++) |
|
1444 | + if ($maxPosts > 0) { |
|
1445 | + for ($hour = 0; |
|
1446 | + } |
|
1447 | + $hour < 24; $hour++) |
|
1403 | 1448 | { |
1404 | - if (!isset($context['posts_by_time'][$hour])) |
|
1405 | - $context['posts_by_time'][$hour] = array( |
|
1449 | + if (!isset($context['posts_by_time'][$hour])) { |
|
1450 | + $context['posts_by_time'][$hour] = array( |
|
1406 | 1451 | 'hour' => $hour, |
1407 | 1452 | 'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)), |
1408 | 1453 | 'posts' => 0, |
@@ -1410,7 +1455,7 @@ discard block |
||
1410 | 1455 | 'relative_percent' => 0, |
1411 | 1456 | 'is_last' => $hour == 23, |
1412 | 1457 | ); |
1413 | - else |
|
1458 | + } else |
|
1414 | 1459 | { |
1415 | 1460 | $context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts); |
1416 | 1461 | $context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts); |
@@ -1443,8 +1488,9 @@ discard block |
||
1443 | 1488 | |
1444 | 1489 | foreach ($subActions as $sa => $action) |
1445 | 1490 | { |
1446 | - if (!allowedTo($action[2])) |
|
1447 | - unset($subActions[$sa]); |
|
1491 | + if (!allowedTo($action[2])) { |
|
1492 | + unset($subActions[$sa]); |
|
1493 | + } |
|
1448 | 1494 | } |
1449 | 1495 | |
1450 | 1496 | // Create the tabs for the template. |
@@ -1462,15 +1508,18 @@ discard block |
||
1462 | 1508 | ); |
1463 | 1509 | |
1464 | 1510 | // Moderation must be on to track edits. |
1465 | - if (empty($modSettings['userlog_enabled'])) |
|
1466 | - unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1511 | + if (empty($modSettings['userlog_enabled'])) { |
|
1512 | + unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']); |
|
1513 | + } |
|
1467 | 1514 | |
1468 | 1515 | // Group requests must be active to show it... |
1469 | - if (empty($modSettings['show_group_membership'])) |
|
1470 | - unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1516 | + if (empty($modSettings['show_group_membership'])) { |
|
1517 | + unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']); |
|
1518 | + } |
|
1471 | 1519 | |
1472 | - if (empty($subActions)) |
|
1473 | - fatal_lang_error('no_access', false); |
|
1520 | + if (empty($subActions)) { |
|
1521 | + fatal_lang_error('no_access', false); |
|
1522 | + } |
|
1474 | 1523 | |
1475 | 1524 | $keys = array_keys($subActions); |
1476 | 1525 | $default = array_shift($keys); |
@@ -1483,9 +1532,10 @@ discard block |
||
1483 | 1532 | $context['sub_template'] = $subActions[$context['tracking_area']][0]; |
1484 | 1533 | $call = call_helper($subActions[$context['tracking_area']][0], true); |
1485 | 1534 | |
1486 | - if (!empty($call)) |
|
1487 | - call_user_func($call, $memID); |
|
1488 | -} |
|
1535 | + if (!empty($call)) { |
|
1536 | + call_user_func($call, $memID); |
|
1537 | + } |
|
1538 | + } |
|
1489 | 1539 | |
1490 | 1540 | /** |
1491 | 1541 | * Handles tracking a user's activity |
@@ -1501,8 +1551,9 @@ discard block |
||
1501 | 1551 | isAllowedTo('moderate_forum'); |
1502 | 1552 | |
1503 | 1553 | $context['last_ip'] = $user_profile[$memID]['member_ip']; |
1504 | - if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) |
|
1505 | - $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1554 | + if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) { |
|
1555 | + $context['last_ip2'] = $user_profile[$memID]['member_ip2']; |
|
1556 | + } |
|
1506 | 1557 | $context['member']['name'] = $user_profile[$memID]['real_name']; |
1507 | 1558 | |
1508 | 1559 | // Set the options for the list component. |
@@ -1668,8 +1719,9 @@ discard block |
||
1668 | 1719 | ) |
1669 | 1720 | ); |
1670 | 1721 | $message_members = array(); |
1671 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1672 | - $message_members[] = $row['id_member']; |
|
1722 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1723 | + $message_members[] = $row['id_member']; |
|
1724 | + } |
|
1673 | 1725 | $smcFunc['db_free_result']($request); |
1674 | 1726 | |
1675 | 1727 | // Fetch their names, cause of the GROUP BY doesn't like giving us that normally. |
@@ -1684,8 +1736,9 @@ discard block |
||
1684 | 1736 | 'ip_list' => $ips, |
1685 | 1737 | ) |
1686 | 1738 | ); |
1687 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1688 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1739 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1740 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1741 | + } |
|
1689 | 1742 | $smcFunc['db_free_result']($request); |
1690 | 1743 | } |
1691 | 1744 | |
@@ -1699,8 +1752,9 @@ discard block |
||
1699 | 1752 | 'ip_list' => $ips, |
1700 | 1753 | ) |
1701 | 1754 | ); |
1702 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1703 | - $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1755 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1756 | + $context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
1757 | + } |
|
1704 | 1758 | $smcFunc['db_free_result']($request); |
1705 | 1759 | } |
1706 | 1760 | } |
@@ -1760,8 +1814,8 @@ discard block |
||
1760 | 1814 | )) |
1761 | 1815 | ); |
1762 | 1816 | $error_messages = array(); |
1763 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1764 | - $error_messages[] = array( |
|
1817 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1818 | + $error_messages[] = array( |
|
1765 | 1819 | 'ip' => inet_dtop($row['ip']), |
1766 | 1820 | 'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'], |
1767 | 1821 | 'message' => strtr($row['message'], array('<span class="remove">' => '', '</span>' => '')), |
@@ -1769,6 +1823,7 @@ discard block |
||
1769 | 1823 | 'time' => timeformat($row['log_time']), |
1770 | 1824 | 'timestamp' => forum_time(true, $row['log_time']), |
1771 | 1825 | ); |
1826 | + } |
|
1772 | 1827 | $smcFunc['db_free_result']($request); |
1773 | 1828 | |
1774 | 1829 | return $error_messages; |
@@ -1831,8 +1886,8 @@ discard block |
||
1831 | 1886 | )) |
1832 | 1887 | ); |
1833 | 1888 | $messages = array(); |
1834 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1835 | - $messages[] = array( |
|
1889 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1890 | + $messages[] = array( |
|
1836 | 1891 | 'ip' => inet_dtop($row['poster_ip']), |
1837 | 1892 | 'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>', |
1838 | 1893 | 'board' => array( |
@@ -1845,6 +1900,7 @@ discard block |
||
1845 | 1900 | 'time' => timeformat($row['poster_time']), |
1846 | 1901 | 'timestamp' => forum_time(true, $row['poster_time']) |
1847 | 1902 | ); |
1903 | + } |
|
1848 | 1904 | $smcFunc['db_free_result']($request); |
1849 | 1905 | |
1850 | 1906 | return $messages; |
@@ -1871,19 +1927,20 @@ discard block |
||
1871 | 1927 | $context['sub_template'] = 'trackIP'; |
1872 | 1928 | $context['page_title'] = $txt['profile']; |
1873 | 1929 | $context['base_url'] = $scripturl . '?action=trackip'; |
1874 | - } |
|
1875 | - else |
|
1930 | + } else |
|
1876 | 1931 | { |
1877 | 1932 | $context['ip'] = $user_profile[$memID]['member_ip']; |
1878 | 1933 | $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
1879 | 1934 | } |
1880 | 1935 | |
1881 | 1936 | // Searching? |
1882 | - if (isset($_REQUEST['searchip'])) |
|
1883 | - $context['ip'] = trim($_REQUEST['searchip']); |
|
1937 | + if (isset($_REQUEST['searchip'])) { |
|
1938 | + $context['ip'] = trim($_REQUEST['searchip']); |
|
1939 | + } |
|
1884 | 1940 | |
1885 | - if (isValidIP($context['ip']) === false) |
|
1886 | - fatal_lang_error('invalid_tracking_ip', false); |
|
1941 | + if (isValidIP($context['ip']) === false) { |
|
1942 | + fatal_lang_error('invalid_tracking_ip', false); |
|
1943 | + } |
|
1887 | 1944 | |
1888 | 1945 | //mysql didn't support like search with varbinary |
1889 | 1946 | //$ip_var = str_replace('*', '%', $context['ip']); |
@@ -1891,8 +1948,9 @@ discard block |
||
1891 | 1948 | $ip_var = $context['ip']; |
1892 | 1949 | $ip_string = '= {inet:ip_address}'; |
1893 | 1950 | |
1894 | - if (empty($context['tracking_area'])) |
|
1895 | - $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1951 | + if (empty($context['tracking_area'])) { |
|
1952 | + $context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip']; |
|
1953 | + } |
|
1896 | 1954 | |
1897 | 1955 | $request = $smcFunc['db_query']('', ' |
1898 | 1956 | SELECT id_member, real_name AS display_name, member_ip |
@@ -1903,8 +1961,9 @@ discard block |
||
1903 | 1961 | ) |
1904 | 1962 | ); |
1905 | 1963 | $context['ips'] = array(); |
1906 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1907 | - $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1964 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1965 | + $context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>'; |
|
1966 | + } |
|
1908 | 1967 | $smcFunc['db_free_result']($request); |
1909 | 1968 | |
1910 | 1969 | ksort($context['ips']); |
@@ -2133,8 +2192,9 @@ discard block |
||
2133 | 2192 | foreach ($context['whois_servers'] as $whois) |
2134 | 2193 | { |
2135 | 2194 | // Strip off the "decimal point" and anything following... |
2136 | - if (in_array((int) $context['ip'], $whois['range'])) |
|
2137 | - $context['auto_whois_server'] = $whois; |
|
2195 | + if (in_array((int) $context['ip'], $whois['range'])) { |
|
2196 | + $context['auto_whois_server'] = $whois; |
|
2197 | + } |
|
2138 | 2198 | } |
2139 | 2199 | } |
2140 | 2200 | } |
@@ -2151,10 +2211,11 @@ discard block |
||
2151 | 2211 | // Gonna want this for the list. |
2152 | 2212 | require_once($sourcedir . '/Subs-List.php'); |
2153 | 2213 | |
2154 | - if ($memID == 0) |
|
2155 | - $context['base_url'] = $scripturl . '?action=trackip'; |
|
2156 | - else |
|
2157 | - $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2214 | + if ($memID == 0) { |
|
2215 | + $context['base_url'] = $scripturl . '?action=trackip'; |
|
2216 | + } else { |
|
2217 | + $context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID; |
|
2218 | + } |
|
2158 | 2219 | |
2159 | 2220 | // Start with the user messages. |
2160 | 2221 | $listOptions = array( |
@@ -2264,12 +2325,13 @@ discard block |
||
2264 | 2325 | ) |
2265 | 2326 | ); |
2266 | 2327 | $logins = array(); |
2267 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2268 | - $logins[] = array( |
|
2328 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2329 | + $logins[] = array( |
|
2269 | 2330 | 'time' => timeformat($row['time']), |
2270 | 2331 | 'ip' => inet_dtop($row['ip']), |
2271 | 2332 | 'ip2' => inet_dtop($row['ip2']), |
2272 | 2333 | ); |
2334 | + } |
|
2273 | 2335 | $smcFunc['db_free_result']($request); |
2274 | 2336 | |
2275 | 2337 | return $logins; |
@@ -2294,11 +2356,12 @@ discard block |
||
2294 | 2356 | ) |
2295 | 2357 | ); |
2296 | 2358 | $context['custom_field_titles'] = array(); |
2297 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2298 | - $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2359 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2360 | + $context['custom_field_titles']['customfield_' . $row['col_name']] = array( |
|
2299 | 2361 | 'title' => $row['field_name'], |
2300 | 2362 | 'parse_bbc' => $row['bbc'], |
2301 | 2363 | ); |
2364 | + } |
|
2302 | 2365 | $smcFunc['db_free_result']($request); |
2303 | 2366 | |
2304 | 2367 | // Set the options for the error lists. |
@@ -2437,19 +2500,22 @@ discard block |
||
2437 | 2500 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2438 | 2501 | { |
2439 | 2502 | $extra = $smcFunc['json_decode']($row['extra'], true); |
2440 | - if (!empty($extra['applicator'])) |
|
2441 | - $members[] = $extra['applicator']; |
|
2503 | + if (!empty($extra['applicator'])) { |
|
2504 | + $members[] = $extra['applicator']; |
|
2505 | + } |
|
2442 | 2506 | |
2443 | 2507 | // Work out what the name of the action is. |
2444 | - if (isset($txt['trackEdit_action_' . $row['action']])) |
|
2445 | - $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2446 | - elseif (isset($txt[$row['action']])) |
|
2447 | - $action_text = $txt[$row['action']]; |
|
2508 | + if (isset($txt['trackEdit_action_' . $row['action']])) { |
|
2509 | + $action_text = $txt['trackEdit_action_' . $row['action']]; |
|
2510 | + } elseif (isset($txt[$row['action']])) { |
|
2511 | + $action_text = $txt[$row['action']]; |
|
2512 | + } |
|
2448 | 2513 | // Custom field? |
2449 | - elseif (isset($context['custom_field_titles'][$row['action']])) |
|
2450 | - $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2451 | - else |
|
2452 | - $action_text = $row['action']; |
|
2514 | + elseif (isset($context['custom_field_titles'][$row['action']])) { |
|
2515 | + $action_text = $context['custom_field_titles'][$row['action']]['title']; |
|
2516 | + } else { |
|
2517 | + $action_text = $row['action']; |
|
2518 | + } |
|
2453 | 2519 | |
2454 | 2520 | // Parse BBC? |
2455 | 2521 | $parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false; |
@@ -2481,13 +2547,15 @@ discard block |
||
2481 | 2547 | ) |
2482 | 2548 | ); |
2483 | 2549 | $members = array(); |
2484 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2485 | - $members[$row['id_member']] = $row['real_name']; |
|
2550 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2551 | + $members[$row['id_member']] = $row['real_name']; |
|
2552 | + } |
|
2486 | 2553 | $smcFunc['db_free_result']($request); |
2487 | 2554 | |
2488 | - foreach ($edits as $key => $value) |
|
2489 | - if (isset($members[$value['id_member']])) |
|
2555 | + foreach ($edits as $key => $value) { |
|
2556 | + if (isset($members[$value['id_member']])) |
|
2490 | 2557 | $edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>'; |
2558 | + } |
|
2491 | 2559 | } |
2492 | 2560 | |
2493 | 2561 | return $edits; |
@@ -2688,10 +2756,11 @@ discard block |
||
2688 | 2756 | $context['board'] = $board; |
2689 | 2757 | |
2690 | 2758 | // Determine which groups this user is in. |
2691 | - if (empty($user_profile[$memID]['additional_groups'])) |
|
2692 | - $curGroups = array(); |
|
2693 | - else |
|
2694 | - $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2759 | + if (empty($user_profile[$memID]['additional_groups'])) { |
|
2760 | + $curGroups = array(); |
|
2761 | + } else { |
|
2762 | + $curGroups = explode(',', $user_profile[$memID]['additional_groups']); |
|
2763 | + } |
|
2695 | 2764 | $curGroups[] = $user_profile[$memID]['id_group']; |
2696 | 2765 | $curGroups[] = $user_profile[$memID]['id_post_group']; |
2697 | 2766 | |
@@ -2711,28 +2780,30 @@ discard block |
||
2711 | 2780 | $context['no_access_boards'] = array(); |
2712 | 2781 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2713 | 2782 | { |
2714 | - if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) |
|
2715 | - $context['no_access_boards'][] = array( |
|
2783 | + if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) { |
|
2784 | + $context['no_access_boards'][] = array( |
|
2716 | 2785 | 'id' => $row['id_board'], |
2717 | 2786 | 'name' => $row['name'], |
2718 | 2787 | 'is_last' => false, |
2719 | 2788 | ); |
2720 | - elseif ($row['id_profile'] != 1 || $row['is_mod']) |
|
2721 | - $context['boards'][$row['id_board']] = array( |
|
2789 | + } elseif ($row['id_profile'] != 1 || $row['is_mod']) { |
|
2790 | + $context['boards'][$row['id_board']] = array( |
|
2722 | 2791 | 'id' => $row['id_board'], |
2723 | 2792 | 'name' => $row['name'], |
2724 | 2793 | 'selected' => $board == $row['id_board'], |
2725 | 2794 | 'profile' => $row['id_profile'], |
2726 | 2795 | 'profile_name' => $context['profiles'][$row['id_profile']]['name'], |
2727 | 2796 | ); |
2797 | + } |
|
2728 | 2798 | } |
2729 | 2799 | $smcFunc['db_free_result']($request); |
2730 | 2800 | |
2731 | 2801 | require_once($sourcedir . '/Subs-Boards.php'); |
2732 | 2802 | sortBoards($context['boards']); |
2733 | 2803 | |
2734 | - if (!empty($context['no_access_boards'])) |
|
2735 | - $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2804 | + if (!empty($context['no_access_boards'])) { |
|
2805 | + $context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true; |
|
2806 | + } |
|
2736 | 2807 | |
2737 | 2808 | $context['member']['permissions'] = array( |
2738 | 2809 | 'general' => array(), |
@@ -2741,8 +2812,9 @@ discard block |
||
2741 | 2812 | |
2742 | 2813 | // If you're an admin we know you can do everything, we might as well leave. |
2743 | 2814 | $context['member']['has_all_permissions'] = in_array(1, $curGroups); |
2744 | - if ($context['member']['has_all_permissions']) |
|
2745 | - return; |
|
2815 | + if ($context['member']['has_all_permissions']) { |
|
2816 | + return; |
|
2817 | + } |
|
2746 | 2818 | |
2747 | 2819 | $denied = array(); |
2748 | 2820 | |
@@ -2761,21 +2833,24 @@ discard block |
||
2761 | 2833 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
2762 | 2834 | { |
2763 | 2835 | // We don't know about this permission, it doesn't exist :P. |
2764 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2765 | - continue; |
|
2836 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2837 | + continue; |
|
2838 | + } |
|
2766 | 2839 | |
2767 | - if (empty($row['add_deny'])) |
|
2768 | - $denied[] = $row['permission']; |
|
2840 | + if (empty($row['add_deny'])) { |
|
2841 | + $denied[] = $row['permission']; |
|
2842 | + } |
|
2769 | 2843 | |
2770 | 2844 | // Permissions that end with _own or _any consist of two parts. |
2771 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2772 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2773 | - else |
|
2774 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2845 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2846 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2847 | + } else { |
|
2848 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2849 | + } |
|
2775 | 2850 | |
2776 | 2851 | // Add this permission if it doesn't exist yet. |
2777 | - if (!isset($context['member']['permissions']['general'][$row['permission']])) |
|
2778 | - $context['member']['permissions']['general'][$row['permission']] = array( |
|
2852 | + if (!isset($context['member']['permissions']['general'][$row['permission']])) { |
|
2853 | + $context['member']['permissions']['general'][$row['permission']] = array( |
|
2779 | 2854 | 'id' => $row['permission'], |
2780 | 2855 | 'groups' => array( |
2781 | 2856 | 'allowed' => array(), |
@@ -2785,6 +2860,7 @@ discard block |
||
2785 | 2860 | 'is_denied' => false, |
2786 | 2861 | 'is_global' => true, |
2787 | 2862 | ); |
2863 | + } |
|
2788 | 2864 | |
2789 | 2865 | // Add the membergroup to either the denied or the allowed groups. |
2790 | 2866 | $context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
@@ -2818,18 +2894,20 @@ discard block |
||
2818 | 2894 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2819 | 2895 | { |
2820 | 2896 | // We don't know about this permission, it doesn't exist :P. |
2821 | - if (!isset($txt['permissionname_' . $row['permission']])) |
|
2822 | - continue; |
|
2897 | + if (!isset($txt['permissionname_' . $row['permission']])) { |
|
2898 | + continue; |
|
2899 | + } |
|
2823 | 2900 | |
2824 | 2901 | // The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'. |
2825 | - if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) |
|
2826 | - $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2827 | - else |
|
2828 | - $name = $txt['permissionname_' . $row['permission']]; |
|
2902 | + if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) { |
|
2903 | + $name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']]; |
|
2904 | + } else { |
|
2905 | + $name = $txt['permissionname_' . $row['permission']]; |
|
2906 | + } |
|
2829 | 2907 | |
2830 | 2908 | // Create the structure for this permission. |
2831 | - if (!isset($context['member']['permissions']['board'][$row['permission']])) |
|
2832 | - $context['member']['permissions']['board'][$row['permission']] = array( |
|
2909 | + if (!isset($context['member']['permissions']['board'][$row['permission']])) { |
|
2910 | + $context['member']['permissions']['board'][$row['permission']] = array( |
|
2833 | 2911 | 'id' => $row['permission'], |
2834 | 2912 | 'groups' => array( |
2835 | 2913 | 'allowed' => array(), |
@@ -2839,6 +2917,7 @@ discard block |
||
2839 | 2917 | 'is_denied' => false, |
2840 | 2918 | 'is_global' => empty($board), |
2841 | 2919 | ); |
2920 | + } |
|
2842 | 2921 | |
2843 | 2922 | $context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name']; |
2844 | 2923 | |
@@ -2857,8 +2936,9 @@ discard block |
||
2857 | 2936 | global $modSettings, $context, $sourcedir, $txt, $scripturl; |
2858 | 2937 | |
2859 | 2938 | // Firstly, can we actually even be here? |
2860 | - if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) |
|
2861 | - fatal_lang_error('no_access', false); |
|
2939 | + if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) { |
|
2940 | + fatal_lang_error('no_access', false); |
|
2941 | + } |
|
2862 | 2942 | |
2863 | 2943 | // Make sure things which are disabled stay disabled. |
2864 | 2944 | $modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110; |
@@ -2945,9 +3025,10 @@ discard block |
||
2945 | 3025 | $modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'], |
2946 | 3026 | ); |
2947 | 3027 | $context['current_level'] = 0; |
2948 | - foreach ($context['level_effects'] as $limit => $dummy) |
|
2949 | - if ($context['member']['warning'] >= $limit) |
|
3028 | + foreach ($context['level_effects'] as $limit => $dummy) { |
|
3029 | + if ($context['member']['warning'] >= $limit) |
|
2950 | 3030 | $context['current_level'] = $limit; |
2951 | -} |
|
3031 | + } |
|
3032 | + } |
|
2952 | 3033 | |
2953 | 3034 | ?> |
2954 | 3035 | \ No newline at end of file |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
30 | 31 | |
31 | 32 | // Don't reload this as we may have processed error strings. |
32 | - if (empty($post_errors)) |
|
33 | - loadLanguage('Profile+Drafts'); |
|
33 | + if (empty($post_errors)) { |
|
34 | + loadLanguage('Profile+Drafts'); |
|
35 | + } |
|
34 | 36 | loadTemplate('Profile'); |
35 | 37 | |
36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
37 | 39 | |
38 | 40 | // Did we get the user by name... |
39 | - if (isset($_REQUEST['user'])) |
|
40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
41 | + if (isset($_REQUEST['user'])) { |
|
42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
43 | + } |
|
41 | 44 | // ... or by id_member? |
42 | - elseif (!empty($_REQUEST['u'])) |
|
43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
45 | + elseif (!empty($_REQUEST['u'])) { |
|
46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
47 | + } |
|
44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
45 | 49 | else |
46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
50 | 54 | } |
51 | 55 | |
52 | 56 | // Check if loadMemberData() has returned a valid result. |
53 | - if (!$memberResult) |
|
54 | - fatal_lang_error('not_a_user', false, 404); |
|
57 | + if (!$memberResult) { |
|
58 | + fatal_lang_error('not_a_user', false, 404); |
|
59 | + } |
|
55 | 60 | |
56 | 61 | // If all went well, we have a valid member ID! |
57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
67 | 72 | |
68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
77 | + } |
|
72 | 78 | |
73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
436 | 442 | foreach ($section['areas'] as $area_id => $area) |
437 | 443 | { |
438 | 444 | // If it said no permissions that meant it wasn't valid! |
439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
447 | + } |
|
441 | 448 | // Otherwise pick the right set. |
442 | - else |
|
443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
449 | + else { |
|
450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
451 | + } |
|
444 | 452 | |
445 | 453 | // Password required in most cases |
446 | - if (!empty($area['password'])) |
|
447 | - $context['password_areas'][] = $area_id; |
|
454 | + if (!empty($area['password'])) { |
|
455 | + $context['password_areas'][] = $area_id; |
|
456 | + } |
|
448 | 457 | } |
449 | 458 | } |
450 | 459 | |
451 | 460 | // Is there an updated message to show? |
452 | - if (isset($_GET['updated'])) |
|
453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
461 | + if (isset($_GET['updated'])) { |
|
462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
463 | + } |
|
454 | 464 | |
455 | 465 | // Set a few options for the menu. |
456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
466 | 476 | |
467 | 477 | // No menu means no access. |
468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
469 | - fatal_lang_error('no_access', false); |
|
478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
479 | + fatal_lang_error('no_access', false); |
|
480 | + } |
|
470 | 481 | |
471 | 482 | // Make a note of the Unique ID for this menu. |
472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
492 | 503 | if ($current_area == $area_id) |
493 | 504 | { |
494 | 505 | // This can't happen - but is a security check. |
495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
496 | - fatal_lang_error('no_access', false); |
|
506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
507 | + fatal_lang_error('no_access', false); |
|
508 | + } |
|
497 | 509 | |
498 | 510 | // Are we saving data in a valid area? |
499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
512 | 524 | } |
513 | 525 | |
514 | 526 | // Does this require session validating? |
515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
516 | - $security_checks['validate'] = true; |
|
527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
528 | + $security_checks['validate'] = true; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | // Permissions for good measure. |
519 | - if (!empty($profile_include_data['permission'])) |
|
520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
532 | + if (!empty($profile_include_data['permission'])) { |
|
533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
534 | + } |
|
521 | 535 | |
522 | 536 | // Either way got something. |
523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
526 | 540 | } |
527 | 541 | |
528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
529 | - if (!$found_area) |
|
530 | - fatal_lang_error('no_access', false); |
|
543 | + if (!$found_area) { |
|
544 | + fatal_lang_error('no_access', false); |
|
545 | + } |
|
531 | 546 | |
532 | 547 | // Release this now. |
533 | 548 | unset($profile_areas); |
534 | 549 | |
535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
536 | - if (isset($security_checks['session'])) |
|
537 | - checkSession($security_checks['session']); |
|
538 | - if (isset($security_checks['validate'])) |
|
539 | - validateSession(); |
|
540 | - if (isset($security_checks['validateToken'])) |
|
541 | - validateToken($token_name, $token_type); |
|
542 | - if (isset($security_checks['permission'])) |
|
543 | - isAllowedTo($security_checks['permission']); |
|
551 | + if (isset($security_checks['session'])) { |
|
552 | + checkSession($security_checks['session']); |
|
553 | + } |
|
554 | + if (isset($security_checks['validate'])) { |
|
555 | + validateSession(); |
|
556 | + } |
|
557 | + if (isset($security_checks['validateToken'])) { |
|
558 | + validateToken($token_name, $token_type); |
|
559 | + } |
|
560 | + if (isset($security_checks['permission'])) { |
|
561 | + isAllowedTo($security_checks['permission']); |
|
562 | + } |
|
544 | 563 | |
545 | 564 | // Create a token if needed. |
546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
550 | 569 | } |
551 | 570 | |
552 | 571 | // File to include? |
553 | - if (isset($profile_include_data['file'])) |
|
554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
572 | + if (isset($profile_include_data['file'])) { |
|
573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
574 | + } |
|
555 | 575 | |
556 | 576 | // Build the link tree. |
557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
560 | 580 | ); |
561 | 581 | |
562 | - if (!empty($profile_include_data['label'])) |
|
563 | - $context['linktree'][] = array( |
|
582 | + if (!empty($profile_include_data['label'])) { |
|
583 | + $context['linktree'][] = array( |
|
564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
565 | 585 | 'name' => $profile_include_data['label'], |
566 | 586 | ); |
587 | + } |
|
567 | 588 | |
568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
569 | - $context['linktree'][] = array( |
|
589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
590 | + $context['linktree'][] = array( |
|
570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
572 | 593 | ); |
594 | + } |
|
573 | 595 | |
574 | 596 | // Set the template for this area and add the profile layer. |
575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
595 | 617 | if ($check_password) |
596 | 618 | { |
597 | 619 | // Check to ensure we're forcing SSL for authentication |
598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
599 | - fatal_lang_error('login_ssl_required'); |
|
620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
621 | + fatal_lang_error('login_ssl_required'); |
|
622 | + } |
|
600 | 623 | |
601 | 624 | // You didn't even enter a password! |
602 | - if (trim($_POST['oldpasswrd']) == '') |
|
603 | - $post_errors[] = 'no_password'; |
|
625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
626 | + $post_errors[] = 'no_password'; |
|
627 | + } |
|
604 | 628 | |
605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
610 | 634 | |
611 | 635 | // Bad password!!! |
612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
613 | - $post_errors[] = 'bad_password'; |
|
636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
637 | + $post_errors[] = 'bad_password'; |
|
638 | + } |
|
614 | 639 | |
615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
616 | - if (in_array('bad_password', $post_errors)) |
|
617 | - $context['password_auth_failed'] = true; |
|
641 | + if (in_array('bad_password', $post_errors)) { |
|
642 | + $context['password_auth_failed'] = true; |
|
643 | + } |
|
618 | 644 | } |
619 | 645 | |
620 | 646 | // Change the IP address in the database. |
621 | - if ($context['user']['is_owner']) |
|
622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
647 | + if ($context['user']['is_owner']) { |
|
648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
649 | + } |
|
623 | 650 | |
624 | 651 | // Now call the sub-action function... |
625 | 652 | if ($current_area == 'activateaccount') |
626 | 653 | { |
627 | - if (empty($post_errors)) |
|
628 | - activateAccount($memID); |
|
629 | - } |
|
630 | - elseif ($current_area == 'deleteaccount') |
|
654 | + if (empty($post_errors)) { |
|
655 | + activateAccount($memID); |
|
656 | + } |
|
657 | + } elseif ($current_area == 'deleteaccount') |
|
631 | 658 | { |
632 | 659 | if (empty($post_errors)) |
633 | 660 | { |
634 | 661 | deleteAccount2($memID); |
635 | 662 | redirectexit(); |
636 | 663 | } |
637 | - } |
|
638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
639 | 665 | { |
640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
641 | 667 | |
642 | 668 | // Whatever we've done, we have nothing else to do here... |
643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
644 | - } |
|
645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
646 | - saveProfileFields(); |
|
647 | - else |
|
670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
671 | + saveProfileFields(); |
|
672 | + } else |
|
648 | 673 | { |
649 | 674 | $force_redirect = true; |
650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
661 | 686 | loadLanguage('Errors'); |
662 | 687 | $context['post_errors'] = $post_errors; |
663 | - } |
|
664 | - elseif (!empty($profile_vars)) |
|
688 | + } elseif (!empty($profile_vars)) |
|
665 | 689 | { |
666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
667 | - if (isset($profile_vars['passwd'])) |
|
668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
691 | + if (isset($profile_vars['passwd'])) { |
|
692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
693 | + } |
|
669 | 694 | |
670 | 695 | updateMemberData($memID, $profile_vars); |
671 | 696 | |
672 | 697 | // What if this is the newest member? |
673 | - if ($modSettings['latestMember'] == $memID) |
|
674 | - updateStats('member'); |
|
675 | - elseif (isset($profile_vars['real_name'])) |
|
676 | - updateSettings(array('memberlist_updated' => time())); |
|
698 | + if ($modSettings['latestMember'] == $memID) { |
|
699 | + updateStats('member'); |
|
700 | + } elseif (isset($profile_vars['real_name'])) { |
|
701 | + updateSettings(array('memberlist_updated' => time())); |
|
702 | + } |
|
677 | 703 | |
678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
680 | - updateSettings(array( |
|
705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
706 | + updateSettings(array( |
|
681 | 707 | 'calendar_updated' => time(), |
682 | 708 | )); |
709 | + } |
|
683 | 710 | |
684 | 711 | // Anything worth logging? |
685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
686 | 713 | { |
687 | 714 | $log_changes = array(); |
688 | 715 | require_once($sourcedir . '/Logging.php'); |
689 | - foreach ($context['log_changes'] as $k => $v) |
|
690 | - $log_changes[] = array( |
|
716 | + foreach ($context['log_changes'] as $k => $v) { |
|
717 | + $log_changes[] = array( |
|
691 | 718 | 'action' => $k, |
692 | 719 | 'log_type' => 'user', |
693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
695 | 722 | 'member_affected' => $memID, |
696 | 723 | )), |
697 | 724 | ); |
725 | + } |
|
698 | 726 | |
699 | 727 | logActions($log_changes); |
700 | 728 | } |
701 | 729 | |
702 | 730 | // Have we got any post save functions to execute? |
703 | - if (!empty($context['profile_execute_on_save'])) |
|
704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
731 | + if (!empty($context['profile_execute_on_save'])) { |
|
732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
705 | 733 | $saveFunc(); |
734 | + } |
|
706 | 735 | |
707 | 736 | // Let them know it worked! |
708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
716 | 745 | if (!empty($post_errors)) |
717 | 746 | { |
718 | 747 | // Set all the errors so the template knows what went wrong. |
719 | - foreach ($post_errors as $error_type) |
|
720 | - $context['modify_error'][$error_type] = true; |
|
748 | + foreach ($post_errors as $error_type) { |
|
749 | + $context['modify_error'][$error_type] = true; |
|
750 | + } |
|
721 | 751 | } |
722 | 752 | // If it's you then we should redirect upon save. |
723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
725 | - elseif (!empty($force_redirect)) |
|
726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
755 | + } elseif (!empty($force_redirect)) { |
|
756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
757 | + } |
|
727 | 758 | |
728 | 759 | |
729 | 760 | // Get the right callable. |
730 | 761 | $call = call_helper($profile_include_data['function'], true); |
731 | 762 | |
732 | 763 | // Is it valid? |
733 | - if (!empty($call)) |
|
734 | - call_user_func($call, $memID); |
|
764 | + if (!empty($call)) { |
|
765 | + call_user_func($call, $memID); |
|
766 | + } |
|
735 | 767 | |
736 | 768 | // Set the page title if it's not already set... |
737 | - if (!isset($context['page_title'])) |
|
738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
739 | -} |
|
769 | + if (!isset($context['page_title'])) { |
|
770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
771 | + } |
|
772 | + } |
|
740 | 773 | |
741 | 774 | /** |
742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
860 | 893 | { |
861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
862 | - if ($memID == $user_info['id']) |
|
863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
864 | - else |
|
865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
895 | + if ($memID == $user_info['id']) { |
|
896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
897 | + } else { |
|
898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
899 | + } |
|
866 | 900 | } |
867 | 901 | |
868 | - if ($area == 'register') |
|
869 | - $where .= ' AND show_reg != 0'; |
|
870 | - elseif ($area != 'summary') |
|
871 | - $where .= ' AND show_profile = {string:area}'; |
|
902 | + if ($area == 'register') { |
|
903 | + $where .= ' AND show_reg != 0'; |
|
904 | + } elseif ($area != 'summary') { |
|
905 | + $where .= ' AND show_profile = {string:area}'; |
|
906 | + } |
|
872 | 907 | |
873 | 908 | // Load all the relevant fields - and data. |
874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -894,13 +929,15 @@ discard block |
||
894 | 929 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
895 | 930 | { |
896 | 931 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
897 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
898 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
932 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
933 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
934 | + } |
|
899 | 935 | } |
900 | 936 | |
901 | 937 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
902 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') |
|
903 | - continue; |
|
938 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'Disabled') { |
|
939 | + continue; |
|
940 | + } |
|
904 | 941 | |
905 | 942 | // HTML for the input form. |
906 | 943 | $output_html = $value; |
@@ -909,8 +946,7 @@ discard block |
||
909 | 946 | $true = (!$exists && $row['default_value']) || $value; |
910 | 947 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
911 | 948 | $output_html = $true ? $txt['yes'] : $txt['no']; |
912 | - } |
|
913 | - elseif ($row['field_type'] == 'select') |
|
949 | + } elseif ($row['field_type'] == 'select') |
|
914 | 950 | { |
915 | 951 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
916 | 952 | $options = explode(',', $row['field_options']); |
@@ -918,13 +954,13 @@ discard block |
||
918 | 954 | { |
919 | 955 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
920 | 956 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
921 | - if ($true) |
|
922 | - $output_html = $v; |
|
957 | + if ($true) { |
|
958 | + $output_html = $v; |
|
959 | + } |
|
923 | 960 | } |
924 | 961 | |
925 | 962 | $input_html .= '</select>'; |
926 | - } |
|
927 | - elseif ($row['field_type'] == 'radio') |
|
963 | + } elseif ($row['field_type'] == 'radio') |
|
928 | 964 | { |
929 | 965 | $input_html = '<fieldset>'; |
930 | 966 | $options = explode(',', $row['field_options']); |
@@ -932,36 +968,37 @@ discard block |
||
932 | 968 | { |
933 | 969 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
934 | 970 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
935 | - if ($true) |
|
936 | - $output_html = $v; |
|
971 | + if ($true) { |
|
972 | + $output_html = $v; |
|
973 | + } |
|
937 | 974 | } |
938 | 975 | $input_html .= '</fieldset>'; |
939 | - } |
|
940 | - elseif ($row['field_type'] == 'text') |
|
976 | + } elseif ($row['field_type'] == 'text') |
|
941 | 977 | { |
942 | 978 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
943 | - } |
|
944 | - else |
|
979 | + } else |
|
945 | 980 | { |
946 | 981 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
947 | 982 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
948 | 983 | } |
949 | 984 | |
950 | 985 | // Parse BBCode |
951 | - if ($row['bbc']) |
|
952 | - $output_html = parse_bbc($output_html); |
|
953 | - elseif ($row['field_type'] == 'textarea') |
|
954 | - // Allow for newlines at least |
|
986 | + if ($row['bbc']) { |
|
987 | + $output_html = parse_bbc($output_html); |
|
988 | + } elseif ($row['field_type'] == 'textarea') { |
|
989 | + // Allow for newlines at least |
|
955 | 990 | $output_html = strtr($output_html, array("\n" => '<br>')); |
991 | + } |
|
956 | 992 | |
957 | 993 | // Enclosing the user input within some other text? |
958 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
959 | - $output_html = strtr($row['enclose'], array( |
|
994 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
995 | + $output_html = strtr($row['enclose'], array( |
|
960 | 996 | '{SCRIPTURL}' => $scripturl, |
961 | 997 | '{IMAGES_URL}' => $settings['images_url'], |
962 | 998 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
963 | 999 | '{INPUT}' => un_htmlspecialchars($output_html), |
964 | 1000 | )); |
1001 | + } |
|
965 | 1002 | |
966 | 1003 | $context['custom_fields'][] = array( |
967 | 1004 | 'name' => $row['field_name'], |
@@ -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 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -133,8 +135,9 @@ discard block |
||
133 | 135 | static $timezone_array = array(); |
134 | 136 | require_once($sourcedir . '/Subs.php'); |
135 | 137 | |
136 | - if (empty($timezone_array['default'])) |
|
137 | - $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
138 | + if (empty($timezone_array['default'])) { |
|
139 | + $timezone_array['default'] = timezone_open(date_default_timezone_get()); |
|
140 | + } |
|
138 | 141 | |
139 | 142 | $low_object = date_create($low_date); |
140 | 143 | $high_object = date_create($high_date); |
@@ -161,8 +164,9 @@ discard block |
||
161 | 164 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
162 | 165 | { |
163 | 166 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
164 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
165 | - continue; |
|
167 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
168 | + continue; |
|
169 | + } |
|
166 | 170 | |
167 | 171 | // Force a censor of the title - as often these are used by others. |
168 | 172 | censorText($row['title'], $use_permissions ? false : true); |
@@ -170,12 +174,14 @@ discard block |
||
170 | 174 | // Get the various time and date properties for this event |
171 | 175 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
172 | 176 | |
173 | - if (empty($timezone_array[$tz])) |
|
174 | - $timezone_array[$tz] = timezone_open($tz); |
|
177 | + if (empty($timezone_array[$tz])) { |
|
178 | + $timezone_array[$tz] = timezone_open($tz); |
|
179 | + } |
|
175 | 180 | |
176 | 181 | // Sanity check |
177 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
178 | - continue; |
|
182 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
183 | + continue; |
|
184 | + } |
|
179 | 185 | |
180 | 186 | // Get set up for the loop |
181 | 187 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), $timezone_array[$tz]); |
@@ -239,8 +245,8 @@ discard block |
||
239 | 245 | ); |
240 | 246 | |
241 | 247 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
242 | - if ($use_permissions) |
|
243 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
248 | + if ($use_permissions) { |
|
249 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
244 | 250 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
245 | 251 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
246 | 252 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -248,9 +254,10 @@ discard block |
||
248 | 254 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
249 | 255 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
250 | 256 | )); |
257 | + } |
|
251 | 258 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
252 | - else |
|
253 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
259 | + else { |
|
260 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
254 | 261 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
255 | 262 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
256 | 263 | 'can_edit' => false, |
@@ -260,6 +267,7 @@ discard block |
||
260 | 267 | 'poster' => $row['id_member'], |
261 | 268 | 'allowed_groups' => explode(',', $row['member_groups']), |
262 | 269 | )); |
270 | + } |
|
263 | 271 | |
264 | 272 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
265 | 273 | } |
@@ -269,8 +277,9 @@ discard block |
||
269 | 277 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
270 | 278 | if ($use_permissions) |
271 | 279 | { |
272 | - foreach ($events as $mday => $array) |
|
273 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
280 | + foreach ($events as $mday => $array) { |
|
281 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
282 | + } |
|
274 | 283 | } |
275 | 284 | |
276 | 285 | ksort($events); |
@@ -290,11 +299,12 @@ discard block |
||
290 | 299 | global $smcFunc; |
291 | 300 | |
292 | 301 | // Get the lowest and highest dates for "all years". |
293 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
294 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
302 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
303 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
295 | 304 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
296 | - else |
|
297 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
305 | + } else { |
|
306 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
307 | + } |
|
298 | 308 | |
299 | 309 | // Find some holidays... ;). |
300 | 310 | $result = $smcFunc['db_query']('', ' |
@@ -314,10 +324,11 @@ discard block |
||
314 | 324 | $holidays = array(); |
315 | 325 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
316 | 326 | { |
317 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
318 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
319 | - else |
|
320 | - $event_year = substr($low_date, 0, 4); |
|
327 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
328 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
329 | + } else { |
|
330 | + $event_year = substr($low_date, 0, 4); |
|
331 | + } |
|
321 | 332 | |
322 | 333 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
323 | 334 | } |
@@ -343,10 +354,12 @@ discard block |
||
343 | 354 | isAllowedTo('calendar_post'); |
344 | 355 | |
345 | 356 | // No board? No topic?!? |
346 | - if (empty($board)) |
|
347 | - fatal_lang_error('missing_board_id', false); |
|
348 | - if (empty($topic)) |
|
349 | - fatal_lang_error('missing_topic_id', false); |
|
357 | + if (empty($board)) { |
|
358 | + fatal_lang_error('missing_board_id', false); |
|
359 | + } |
|
360 | + if (empty($topic)) { |
|
361 | + fatal_lang_error('missing_topic_id', false); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Administrator, Moderator, or owner. Period. |
352 | 365 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -364,12 +377,14 @@ discard block |
||
364 | 377 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 378 | { |
366 | 379 | // Not the owner of the topic. |
367 | - if ($row['id_member_started'] != $user_info['id']) |
|
368 | - fatal_lang_error('not_your_topic', 'user'); |
|
380 | + if ($row['id_member_started'] != $user_info['id']) { |
|
381 | + fatal_lang_error('not_your_topic', 'user'); |
|
382 | + } |
|
369 | 383 | } |
370 | 384 | // Topic/Board doesn't exist..... |
371 | - else |
|
372 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
385 | + else { |
|
386 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
387 | + } |
|
373 | 388 | $smcFunc['db_free_result']($result); |
374 | 389 | } |
375 | 390 | } |
@@ -457,14 +472,16 @@ discard block |
||
457 | 472 | if (!empty($calendarOptions['start_day'])) |
458 | 473 | { |
459 | 474 | $nShift -= $calendarOptions['start_day']; |
460 | - if ($nShift < 0) |
|
461 | - $nShift = 7 + $nShift; |
|
475 | + if ($nShift < 0) { |
|
476 | + $nShift = 7 + $nShift; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Number of rows required to fit the month. |
465 | 481 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
466 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
467 | - $nRows++; |
|
482 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
483 | + $nRows++; |
|
484 | + } |
|
468 | 485 | |
469 | 486 | // Fetch the arrays for birthdays, posted events, and holidays. |
470 | 487 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -477,8 +494,9 @@ discard block |
||
477 | 494 | { |
478 | 495 | $calendarGrid['week_days'][] = $count; |
479 | 496 | $count++; |
480 | - if ($count == 7) |
|
481 | - $count = 0; |
|
497 | + if ($count == 7) { |
|
498 | + $count = 0; |
|
499 | + } |
|
482 | 500 | } |
483 | 501 | |
484 | 502 | // Iterate through each week. |
@@ -495,8 +513,9 @@ discard block |
||
495 | 513 | { |
496 | 514 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
497 | 515 | |
498 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
499 | - $nDay = 0; |
|
516 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
517 | + $nDay = 0; |
|
518 | + } |
|
500 | 519 | |
501 | 520 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
502 | 521 | |
@@ -514,8 +533,9 @@ discard block |
||
514 | 533 | } |
515 | 534 | |
516 | 535 | // What is the last day of the month? |
517 | - if ($is_previous === true) |
|
518 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
536 | + if ($is_previous === true) { |
|
537 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
538 | + } |
|
519 | 539 | |
520 | 540 | // We'll use the shift in the template. |
521 | 541 | $calendarGrid['shift'] = $nShift; |
@@ -549,8 +569,9 @@ discard block |
||
549 | 569 | { |
550 | 570 | // Here we offset accordingly to get things to the real start of a week. |
551 | 571 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
552 | - if ($date_diff < 0) |
|
553 | - $date_diff += 7; |
|
572 | + if ($date_diff < 0) { |
|
573 | + $date_diff += 7; |
|
574 | + } |
|
554 | 575 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
555 | 576 | $day = (int) strftime('%d', $new_timestamp); |
556 | 577 | $month = (int) strftime('%m', $new_timestamp); |
@@ -680,18 +701,20 @@ discard block |
||
680 | 701 | { |
681 | 702 | foreach ($date_events as $event_key => $event_val) |
682 | 703 | { |
683 | - if (in_array($event_val['id'], $temp)) |
|
684 | - unset($calendarGrid['events'][$date][$event_key]); |
|
685 | - else |
|
686 | - $temp[] = $event_val['id']; |
|
704 | + if (in_array($event_val['id'], $temp)) { |
|
705 | + unset($calendarGrid['events'][$date][$event_key]); |
|
706 | + } else { |
|
707 | + $temp[] = $event_val['id']; |
|
708 | + } |
|
687 | 709 | } |
688 | 710 | } |
689 | 711 | |
690 | 712 | // Give birthdays and holidays a friendly format, without the year |
691 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
692 | - $date_format = '%b %d'; |
|
693 | - else |
|
694 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
713 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
714 | + $date_format = '%b %d'; |
|
715 | + } else { |
|
716 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
717 | + } |
|
695 | 718 | |
696 | 719 | foreach (array('birthdays', 'holidays') as $type) |
697 | 720 | { |
@@ -790,8 +813,9 @@ discard block |
||
790 | 813 | // Holidays between now and now + days. |
791 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
792 | 815 | { |
793 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
794 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
816 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
817 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
818 | + } |
|
795 | 819 | } |
796 | 820 | } |
797 | 821 | |
@@ -803,8 +827,9 @@ discard block |
||
803 | 827 | $loop_date = strftime('%Y-%m-%d', $i); |
804 | 828 | if (isset($cached_data['birthdays'][$loop_date])) |
805 | 829 | { |
806 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
807 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
830 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
831 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
832 | + } |
|
808 | 833 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
809 | 834 | } |
810 | 835 | } |
@@ -819,8 +844,9 @@ discard block |
||
819 | 844 | $loop_date = strftime('%Y-%m-%d', $i); |
820 | 845 | |
821 | 846 | // No events today? Check the next day. |
822 | - if (empty($cached_data['events'][$loop_date])) |
|
823 | - continue; |
|
847 | + if (empty($cached_data['events'][$loop_date])) { |
|
848 | + continue; |
|
849 | + } |
|
824 | 850 | |
825 | 851 | // Loop through all events to add a few last-minute values. |
826 | 852 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -833,9 +859,9 @@ discard block |
||
833 | 859 | { |
834 | 860 | unset($cached_data['events'][$loop_date][$ev]); |
835 | 861 | continue; |
862 | + } else { |
|
863 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
836 | 864 | } |
837 | - else |
|
838 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
839 | 865 | |
840 | 866 | // Might be set to true afterwards, depending on the permissions. |
841 | 867 | $this_event['can_edit'] = false; |
@@ -843,16 +869,19 @@ discard block |
||
843 | 869 | $this_event['date'] = $loop_date; |
844 | 870 | } |
845 | 871 | |
846 | - if (!empty($cached_data['events'][$loop_date])) |
|
847 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
872 | + if (!empty($cached_data['events'][$loop_date])) { |
|
873 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
874 | + } |
|
848 | 875 | } |
849 | 876 | } |
850 | 877 | |
851 | 878 | // Mark the last item so that a list separator can be used in the template. |
852 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
853 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
854 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
855 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
879 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
880 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
881 | + } |
|
882 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
883 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
884 | + } |
|
856 | 885 | |
857 | 886 | return array( |
858 | 887 | 'data' => $return_data, |
@@ -900,37 +929,46 @@ discard block |
||
900 | 929 | if (isset($_POST['start_date'])) |
901 | 930 | { |
902 | 931 | $d = date_parse($_POST['start_date']); |
903 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
904 | - fatal_lang_error('invalid_date', false); |
|
905 | - if (empty($d['year'])) |
|
906 | - fatal_lang_error('event_year_missing', false); |
|
907 | - if (empty($d['month'])) |
|
908 | - fatal_lang_error('event_month_missing', false); |
|
909 | - } |
|
910 | - elseif (isset($_POST['start_datetime'])) |
|
932 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
933 | + fatal_lang_error('invalid_date', false); |
|
934 | + } |
|
935 | + if (empty($d['year'])) { |
|
936 | + fatal_lang_error('event_year_missing', false); |
|
937 | + } |
|
938 | + if (empty($d['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + } elseif (isset($_POST['start_datetime'])) |
|
911 | 942 | { |
912 | 943 | $d = date_parse($_POST['start_datetime']); |
913 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
914 | - fatal_lang_error('invalid_date', false); |
|
915 | - if (empty($d['year'])) |
|
916 | - fatal_lang_error('event_year_missing', false); |
|
917 | - if (empty($d['month'])) |
|
918 | - fatal_lang_error('event_month_missing', false); |
|
944 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
945 | + fatal_lang_error('invalid_date', false); |
|
946 | + } |
|
947 | + if (empty($d['year'])) { |
|
948 | + fatal_lang_error('event_year_missing', false); |
|
949 | + } |
|
950 | + if (empty($d['month'])) { |
|
951 | + fatal_lang_error('event_month_missing', false); |
|
952 | + } |
|
919 | 953 | } |
920 | 954 | // The 2.0 way |
921 | 955 | else |
922 | 956 | { |
923 | 957 | // No month? No year? |
924 | - if (!isset($_POST['month'])) |
|
925 | - fatal_lang_error('event_month_missing', false); |
|
926 | - if (!isset($_POST['year'])) |
|
927 | - fatal_lang_error('event_year_missing', false); |
|
958 | + if (!isset($_POST['month'])) { |
|
959 | + fatal_lang_error('event_month_missing', false); |
|
960 | + } |
|
961 | + if (!isset($_POST['year'])) { |
|
962 | + fatal_lang_error('event_year_missing', false); |
|
963 | + } |
|
928 | 964 | |
929 | 965 | // Check the month and year... |
930 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
931 | - fatal_lang_error('invalid_month', false); |
|
932 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
933 | - fatal_lang_error('invalid_year', false); |
|
966 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
967 | + fatal_lang_error('invalid_month', false); |
|
968 | + } |
|
969 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
970 | + fatal_lang_error('invalid_year', false); |
|
971 | + } |
|
934 | 972 | } |
935 | 973 | } |
936 | 974 | |
@@ -940,8 +978,9 @@ discard block |
||
940 | 978 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
941 | 979 | if (isset($_POST['span'])) |
942 | 980 | { |
943 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
944 | - fatal_lang_error('invalid_days_numb', false); |
|
981 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
982 | + fatal_lang_error('invalid_days_numb', false); |
|
983 | + } |
|
945 | 984 | } |
946 | 985 | |
947 | 986 | // There is no need to validate the following values if we are just deleting the event. |
@@ -951,24 +990,29 @@ discard block |
||
951 | 990 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
952 | 991 | { |
953 | 992 | // No day? |
954 | - if (!isset($_POST['day'])) |
|
955 | - fatal_lang_error('event_day_missing', false); |
|
993 | + if (!isset($_POST['day'])) { |
|
994 | + fatal_lang_error('event_day_missing', false); |
|
995 | + } |
|
956 | 996 | |
957 | 997 | // Bad day? |
958 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
959 | - fatal_lang_error('invalid_date', false); |
|
998 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
999 | + fatal_lang_error('invalid_date', false); |
|
1000 | + } |
|
960 | 1001 | } |
961 | 1002 | |
962 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
963 | - fatal_lang_error('event_title_missing', false); |
|
964 | - elseif (!isset($_POST['evtitle'])) |
|
965 | - $_POST['evtitle'] = $_POST['subject']; |
|
1003 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
1004 | + fatal_lang_error('event_title_missing', false); |
|
1005 | + } elseif (!isset($_POST['evtitle'])) { |
|
1006 | + $_POST['evtitle'] = $_POST['subject']; |
|
1007 | + } |
|
966 | 1008 | |
967 | 1009 | // No title? |
968 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
969 | - fatal_lang_error('no_event_title', false); |
|
970 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
971 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1010 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1011 | + fatal_lang_error('no_event_title', false); |
|
1012 | + } |
|
1013 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1014 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1015 | + } |
|
972 | 1016 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
973 | 1017 | } |
974 | 1018 | } |
@@ -995,8 +1039,9 @@ discard block |
||
995 | 1039 | ); |
996 | 1040 | |
997 | 1041 | // No results, return false. |
998 | - if ($smcFunc['db_num_rows'] === 0) |
|
999 | - return false; |
|
1042 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1043 | + return false; |
|
1044 | + } |
|
1000 | 1045 | |
1001 | 1046 | // Grab the results and return. |
1002 | 1047 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1130,8 +1175,9 @@ discard block |
||
1130 | 1175 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1131 | 1176 | |
1132 | 1177 | $column_clauses = array(); |
1133 | - foreach ($event_columns as $col => $crit) |
|
1134 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1178 | + foreach ($event_columns as $col => $crit) { |
|
1179 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1180 | + } |
|
1135 | 1181 | |
1136 | 1182 | $smcFunc['db_query']('', ' |
1137 | 1183 | UPDATE {db_prefix}calendar |
@@ -1216,8 +1262,9 @@ discard block |
||
1216 | 1262 | ); |
1217 | 1263 | |
1218 | 1264 | // If nothing returned, we are in poo, poo. |
1219 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1220 | - return false; |
|
1265 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1266 | + return false; |
|
1267 | + } |
|
1221 | 1268 | |
1222 | 1269 | $row = $smcFunc['db_fetch_assoc']($request); |
1223 | 1270 | $smcFunc['db_free_result']($request); |
@@ -1225,8 +1272,9 @@ discard block |
||
1225 | 1272 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1226 | 1273 | |
1227 | 1274 | // Sanity check |
1228 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1229 | - return false; |
|
1275 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1276 | + return false; |
|
1277 | + } |
|
1230 | 1278 | |
1231 | 1279 | $return_value = array( |
1232 | 1280 | 'boards' => array(), |
@@ -1363,24 +1411,27 @@ discard block |
||
1363 | 1411 | |
1364 | 1412 | // Set $span, in case we need it |
1365 | 1413 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1366 | - if ($span > 0) |
|
1367 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1414 | + if ($span > 0) { |
|
1415 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1416 | + } |
|
1368 | 1417 | |
1369 | 1418 | // Define the timezone for this event, falling back to the default if not provided |
1370 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1371 | - $tz = $eventOptions['tz']; |
|
1372 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1373 | - $tz = $_POST['tz']; |
|
1374 | - else |
|
1375 | - $tz = getUserTimezone(); |
|
1419 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1420 | + $tz = $eventOptions['tz']; |
|
1421 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1422 | + $tz = $_POST['tz']; |
|
1423 | + } else { |
|
1424 | + $tz = getUserTimezone(); |
|
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1378 | - if (isset($eventOptions['allday'])) |
|
1379 | - $allday = $eventOptions['allday']; |
|
1380 | - elseif (empty($_POST['allday'])) |
|
1381 | - $allday = false; |
|
1382 | - else |
|
1383 | - $allday = true; |
|
1428 | + if (isset($eventOptions['allday'])) { |
|
1429 | + $allday = $eventOptions['allday']; |
|
1430 | + } elseif (empty($_POST['allday'])) { |
|
1431 | + $allday = false; |
|
1432 | + } else { |
|
1433 | + $allday = true; |
|
1434 | + } |
|
1384 | 1435 | |
1385 | 1436 | // Input might come as individual parameters... |
1386 | 1437 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1407,10 +1458,12 @@ discard block |
||
1407 | 1458 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1408 | 1459 | |
1409 | 1460 | // If the date and time were given in separate strings, combine them |
1410 | - if (empty($start_string) && isset($start_date_string)) |
|
1411 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1412 | - if (empty($end_string) && isset($end_date_string)) |
|
1413 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1461 | + if (empty($start_string) && isset($start_date_string)) { |
|
1462 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1463 | + } |
|
1464 | + if (empty($end_string) && isset($end_date_string)) { |
|
1465 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1466 | + } |
|
1414 | 1467 | |
1415 | 1468 | // If some form of string input was given, override individually defined options with it |
1416 | 1469 | if (isset($start_string)) |
@@ -1501,10 +1554,11 @@ discard block |
||
1501 | 1554 | if ($start_object >= $end_object) |
1502 | 1555 | { |
1503 | 1556 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1504 | - if ($span > 0) |
|
1505 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1506 | - else |
|
1507 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1557 | + if ($span > 0) { |
|
1558 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1559 | + } else { |
|
1560 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1561 | + } |
|
1508 | 1562 | } |
1509 | 1563 | |
1510 | 1564 | // Is $end_object too late? |
@@ -1517,9 +1571,9 @@ discard block |
||
1517 | 1571 | { |
1518 | 1572 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1519 | 1573 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1574 | + } else { |
|
1575 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1520 | 1576 | } |
1521 | - else |
|
1522 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1523 | 1577 | } |
1524 | 1578 | } |
1525 | 1579 | |
@@ -1532,8 +1586,7 @@ discard block |
||
1532 | 1586 | $start_time = null; |
1533 | 1587 | $end_time = null; |
1534 | 1588 | $tz = null; |
1535 | - } |
|
1536 | - else |
|
1589 | + } else |
|
1537 | 1590 | { |
1538 | 1591 | $start_time = date_format($start_object, 'H:i:s'); |
1539 | 1592 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1559,19 +1612,21 @@ discard block |
||
1559 | 1612 | // First, try to create a better date format, ignoring the "time" elements. |
1560 | 1613 | if (empty($date_format)) |
1561 | 1614 | { |
1562 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1563 | - $date_format = '%F'; |
|
1564 | - else |
|
1565 | - $date_format = $matches[0]; |
|
1615 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1616 | + $date_format = '%F'; |
|
1617 | + } else { |
|
1618 | + $date_format = $matches[0]; |
|
1619 | + } |
|
1566 | 1620 | } |
1567 | 1621 | |
1568 | 1622 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1569 | 1623 | if (empty($time_format)) |
1570 | 1624 | { |
1571 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1572 | - $time_format = '%k:%M'; |
|
1573 | - else |
|
1574 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1625 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1626 | + $time_format = '%k:%M'; |
|
1627 | + } else { |
|
1628 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1629 | + } |
|
1575 | 1630 | } |
1576 | 1631 | |
1577 | 1632 | // Should this be an all day event? |
@@ -1581,11 +1636,13 @@ discard block |
||
1581 | 1636 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1582 | 1637 | |
1583 | 1638 | // We need to have a defined timezone in the steps below |
1584 | - if (empty($row['timezone'])) |
|
1585 | - $row['timezone'] = getUserTimezone(); |
|
1639 | + if (empty($row['timezone'])) { |
|
1640 | + $row['timezone'] = getUserTimezone(); |
|
1641 | + } |
|
1586 | 1642 | |
1587 | - if (empty($timezone_array[$row['timezone']])) |
|
1588 | - $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1643 | + if (empty($timezone_array[$row['timezone']])) { |
|
1644 | + $timezone_array[$row['timezone']] = timezone_open($row['timezone']); |
|
1645 | + } |
|
1589 | 1646 | |
1590 | 1647 | // Get most of the standard date information for the start and end datetimes |
1591 | 1648 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1633,8 +1690,9 @@ discard block |
||
1633 | 1690 | global $smcFunc, $context, $user_info, $modSettings, $user_settings; |
1634 | 1691 | static $member_cache = array(); |
1635 | 1692 | |
1636 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1637 | - $id_member = $context['user']['id']; |
|
1693 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1694 | + $id_member = $context['user']['id']; |
|
1695 | + } |
|
1638 | 1696 | |
1639 | 1697 | //check if the cache got the data |
1640 | 1698 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1663,11 +1721,13 @@ discard block |
||
1663 | 1721 | $smcFunc['db_free_result']($request); |
1664 | 1722 | } |
1665 | 1723 | |
1666 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1667 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1724 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1725 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1726 | + } |
|
1668 | 1727 | |
1669 | - if (isset($id_member)) |
|
1670 | - $member_cache[$id_member] = $timezone; |
|
1728 | + if (isset($id_member)) { |
|
1729 | + $member_cache[$id_member] = $timezone; |
|
1730 | + } |
|
1671 | 1731 | |
1672 | 1732 | return $timezone; |
1673 | 1733 | } |
@@ -1696,8 +1756,9 @@ discard block |
||
1696 | 1756 | ) |
1697 | 1757 | ); |
1698 | 1758 | $holidays = array(); |
1699 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1700 | - $holidays[] = $row; |
|
1759 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1760 | + $holidays[] = $row; |
|
1761 | + } |
|
1701 | 1762 | $smcFunc['db_free_result']($request); |
1702 | 1763 | |
1703 | 1764 | return $holidays; |
@@ -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'], '"> |
@@ -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 | * Create a menu. |
@@ -64,22 +65,26 @@ discard block |
||
64 | 65 | $menu_context['current_action'] = isset($menuOptions['action']) ? $menuOptions['action'] : $context['current_action']; |
65 | 66 | |
66 | 67 | // Allow extend *any* menu with a single hook |
67 | - if (!empty($menu_context['current_action'])) |
|
68 | - call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
68 | + if (!empty($menu_context['current_action'])) { |
|
69 | + call_integration_hook('integrate_' . $menu_context['current_action'] . '_areas', array(&$menuData)); |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // What is the current area selected? |
71 | - if (isset($menuOptions['current_area']) || isset($_GET['area'])) |
|
72 | - $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
73 | + if (isset($menuOptions['current_area']) || isset($_GET['area'])) { |
|
74 | + $menu_context['current_area'] = isset($menuOptions['current_area']) ? $menuOptions['current_area'] : $_GET['area']; |
|
75 | + } |
|
73 | 76 | |
74 | 77 | // Build a list of additional parameters that should go in the URL. |
75 | 78 | $menu_context['extra_parameters'] = ''; |
76 | - if (!empty($menuOptions['extra_url_parameters'])) |
|
77 | - foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
79 | + if (!empty($menuOptions['extra_url_parameters'])) { |
|
80 | + foreach ($menuOptions['extra_url_parameters'] as $key => $value) |
|
78 | 81 | $menu_context['extra_parameters'] .= ';' . $key . '=' . $value; |
82 | + } |
|
79 | 83 | |
80 | 84 | // Only include the session ID in the URL if it's strictly necessary. |
81 | - if (empty($menuOptions['disable_url_session_check'])) |
|
82 | - $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
85 | + if (empty($menuOptions['disable_url_session_check'])) { |
|
86 | + $menu_context['extra_parameters'] .= ';' . $context['session_var'] . '=' . $context['session_id']; |
|
87 | + } |
|
83 | 88 | |
84 | 89 | $include_data = array(); |
85 | 90 | |
@@ -87,8 +92,9 @@ discard block |
||
87 | 92 | foreach ($menuData as $section_id => $section) |
88 | 93 | { |
89 | 94 | // Is this enabled - or has as permission check - which fails? |
90 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) |
|
91 | - continue; |
|
95 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($section['permission']) && !allowedTo($section['permission']))) { |
|
96 | + continue; |
|
97 | + } |
|
92 | 98 | |
93 | 99 | // Now we cycle through the sections to pick the right area. |
94 | 100 | foreach ($section['areas'] as $area_id => $area) |
@@ -110,59 +116,57 @@ discard block |
||
110 | 116 | if (empty($area['hidden'])) |
111 | 117 | { |
112 | 118 | // First time this section? |
113 | - if (!isset($menu_context['sections'][$section_id])) |
|
114 | - $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
119 | + if (!isset($menu_context['sections'][$section_id])) { |
|
120 | + $menu_context['sections'][$section_id]['title'] = $section['title']; |
|
121 | + } |
|
115 | 122 | |
116 | 123 | $menu_context['sections'][$section_id]['areas'][$area_id] = array('label' => isset($area['label']) ? $area['label'] : $txt[$area_id]); |
117 | 124 | // We'll need the ID as well... |
118 | 125 | $menu_context['sections'][$section_id]['id'] = $section_id; |
119 | 126 | // Does it have a custom URL? |
120 | - if (isset($area['custom_url'])) |
|
121 | - $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
127 | + if (isset($area['custom_url'])) { |
|
128 | + $menu_context['sections'][$section_id]['areas'][$area_id]['url'] = $area['custom_url']; |
|
129 | + } |
|
122 | 130 | |
123 | 131 | // Does this area have its own icon? |
124 | 132 | if (!isset($area['force_menu_into_arms_of_another_menu']) && $user_info['name'] == 'iamanoompaloompa') |
125 | 133 | { |
126 | 134 | $menu_context['sections'][$section_id]['areas'][$area_id] = $smcFunc['json_decode'](base64_decode('eyJsYWJlbCI6Ik9vbXBhIExvb21wYSIsInVybCI6Imh0dHBzOlwvXC9lbi53aWtpcGVkaWEub3JnXC93aWtpXC9Pb21wYV9Mb29tcGFzPyIsImljb24iOiI8aW1nIHNyYz1cImh0dHBzOlwvXC93d3cuc2ltcGxlbWFjaGluZXMub3JnXC9pbWFnZXNcL29vbXBhLmdpZlwiIGFsdD1cIkknbSBhbiBPb21wYSBMb29tcGFcIiBcLz4ifQ=='), true); |
127 | - } |
|
128 | - elseif (isset($area['icon'])) |
|
135 | + } elseif (isset($area['icon'])) |
|
129 | 136 | { |
130 | 137 | if (file_exists($settings['theme_dir'] . '/images/admin/' . $area['icon'])) |
131 | 138 | { |
132 | 139 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
133 | - } |
|
134 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
140 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/' . $area['icon'])) |
|
135 | 141 | { |
136 | 142 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<img src="' . $settings['default_images_url'] . '/admin/' . $area['icon'] . '" alt="">'; |
143 | + } else { |
|
144 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
137 | 145 | } |
138 | - else |
|
139 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area['icon'] . '"></span>'; |
|
146 | + } else { |
|
147 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
140 | 148 | } |
141 | - else |
|
142 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon'] = '<span class="generic_icons ' . $area_id . '"></span>'; |
|
143 | 149 | |
144 | 150 | if (isset($area['icon_class']) && empty($menu_context['sections'][$section_id]['areas'][$area_id]['icon'])) |
145 | 151 | { |
146 | 152 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . $area['icon_class']; |
147 | - } |
|
148 | - elseif (isset($area['icon'])) |
|
153 | + } elseif (isset($area['icon'])) |
|
149 | 154 | { |
150 | 155 | if (substr($area['icon'], -4) === '.png' || substr($area['icon'], -4) === '.gif') |
151 | 156 | { |
152 | 157 | if (file_exists($settings['theme_dir'] . '/images/admin/big/' . $area['icon'])) |
153 | 158 | { |
154 | 159 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['theme_url'] . '/images/admin/big/' . $area['icon']; |
155 | - } |
|
156 | - elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
160 | + } elseif (file_exists($settings['default_theme_dir'] . '/images/admin/big/' . $area['icon'])) |
|
157 | 161 | { |
158 | 162 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_file'] = $settings['default_theme_url'] . '/images/admin/big/' . $area['icon']; |
159 | 163 | } |
160 | 164 | } |
161 | 165 | |
162 | 166 | $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area['icon']); |
167 | + } else { |
|
168 | + $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
163 | 169 | } |
164 | - else |
|
165 | - $menu_context['sections'][$section_id]['areas'][$area_id]['icon_class'] = $menu_context['current_action'] . '_menu_icon ' . str_replace(array('.png', '.gif'), '', $area_id); |
|
166 | 170 | |
167 | 171 | // This is a shortcut for Font-Icon users so they don't have to re-do whole CSS. |
168 | 172 | $menu_context['sections'][$section_id]['areas'][$area_id]['plain_class'] = !empty($area['icon']) ? $area['icon'] : ''; |
@@ -179,35 +183,41 @@ discard block |
||
179 | 183 | { |
180 | 184 | if ((empty($sub[1]) || allowedTo($sub[1])) && (!isset($sub['enabled']) || !empty($sub['enabled']))) |
181 | 185 | { |
182 | - if ($first_sa == null) |
|
183 | - $first_sa = $sa; |
|
186 | + if ($first_sa == null) { |
|
187 | + $first_sa = $sa; |
|
188 | + } |
|
184 | 189 | |
185 | 190 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa] = array('label' => $sub[0]); |
186 | 191 | // Custom URL? |
187 | - if (isset($sub['url'])) |
|
188 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
192 | + if (isset($sub['url'])) { |
|
193 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['url'] = $sub['url']; |
|
194 | + } |
|
189 | 195 | |
190 | 196 | // A bit complicated - but is this set? |
191 | 197 | if ($menu_context['current_area'] == $area_id) |
192 | 198 | { |
193 | 199 | // Save which is the first... |
194 | - if (empty($first_sa)) |
|
195 | - $first_sa = $sa; |
|
200 | + if (empty($first_sa)) { |
|
201 | + $first_sa = $sa; |
|
202 | + } |
|
196 | 203 | |
197 | 204 | // Is this the current subsection? |
198 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) |
|
199 | - $menu_context['current_subsection'] = $sa; |
|
205 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == $sa) { |
|
206 | + $menu_context['current_subsection'] = $sa; |
|
207 | + } |
|
200 | 208 | // Otherwise is it the default? |
201 | - elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) |
|
202 | - $menu_context['current_subsection'] = $sa; |
|
209 | + elseif (!isset($menu_context['current_subsection']) && !empty($sub[2])) { |
|
210 | + $menu_context['current_subsection'] = $sa; |
|
211 | + } |
|
203 | 212 | } |
204 | 213 | |
205 | 214 | // Let's assume this is the last, for now. |
206 | 215 | $last_sa = $sa; |
207 | 216 | } |
208 | 217 | // Mark it as disabled... |
209 | - else |
|
210 | - $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
218 | + else { |
|
219 | + $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$sa]['disabled'] = true; |
|
220 | + } |
|
211 | 221 | } |
212 | 222 | |
213 | 223 | // Set which one is first, last and selected in the group. |
@@ -216,8 +226,9 @@ discard block |
||
216 | 226 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $last_sa : $first_sa]['is_first'] = true; |
217 | 227 | $menu_context['sections'][$section_id]['areas'][$area_id]['subsections'][$context['right_to_left'] ? $first_sa : $last_sa]['is_last'] = true; |
218 | 228 | |
219 | - if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) |
|
220 | - $menu_context['current_subsection'] = $first_sa; |
|
229 | + if ($menu_context['current_area'] == $area_id && !isset($menu_context['current_subsection'])) { |
|
230 | + $menu_context['current_subsection'] = $first_sa; |
|
231 | + } |
|
221 | 232 | } |
222 | 233 | } |
223 | 234 | } |
@@ -251,23 +262,26 @@ discard block |
||
251 | 262 | $menu_context['base_url'] = isset($menuOptions['base_url']) ? $menuOptions['base_url'] : $scripturl . '?action=' . $menu_context['current_action']; |
252 | 263 | |
253 | 264 | // If we didn't find the area we were looking for go to a default one. |
254 | - if (isset($backup_area) && empty($found_section)) |
|
255 | - $menu_context['current_area'] = $backup_area; |
|
265 | + if (isset($backup_area) && empty($found_section)) { |
|
266 | + $menu_context['current_area'] = $backup_area; |
|
267 | + } |
|
256 | 268 | |
257 | 269 | // If there are sections quickly goes through all the sections to check if the base menu has an url |
258 | 270 | if (!empty($menu_context['current_section'])) |
259 | 271 | { |
260 | 272 | $menu_context['sections'][$menu_context['current_section']]['selected'] = true; |
261 | 273 | $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['selected'] = true; |
262 | - if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) |
|
263 | - $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
274 | + if (!empty($menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']])) { |
|
275 | + $menu_context['sections'][$menu_context['current_section']]['areas'][$menu_context['current_area']]['subsections'][$context['current_subaction']]['selected'] = true; |
|
276 | + } |
|
264 | 277 | |
265 | - foreach ($menu_context['sections'] as $section_id => $section) |
|
266 | - foreach ($section['areas'] as $area_id => $area) |
|
278 | + foreach ($menu_context['sections'] as $section_id => $section) { |
|
279 | + foreach ($section['areas'] as $area_id => $area) |
|
267 | 280 | { |
268 | 281 | if (!isset($menu_context['sections'][$section_id]['url'])) |
269 | 282 | { |
270 | 283 | $menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id; |
284 | + } |
|
271 | 285 | break; |
272 | 286 | } |
273 | 287 | } |
@@ -278,8 +292,9 @@ discard block |
||
278 | 292 | { |
279 | 293 | // Never happened! |
280 | 294 | $context['max_menu_id']--; |
281 | - if ($context['max_menu_id'] == 0) |
|
282 | - unset($context['max_menu_id']); |
|
295 | + if ($context['max_menu_id'] == 0) { |
|
296 | + unset($context['max_menu_id']); |
|
297 | + } |
|
283 | 298 | |
284 | 299 | return false; |
285 | 300 | } |
@@ -290,8 +305,9 @@ discard block |
||
290 | 305 | $context['template_layers'][] = $menu_context['layer_name']; |
291 | 306 | |
292 | 307 | // Check we had something - for sanity sake. |
293 | - if (empty($include_data)) |
|
294 | - return false; |
|
308 | + if (empty($include_data)) { |
|
309 | + return false; |
|
310 | + } |
|
295 | 311 | |
296 | 312 | // Finally - return information on the selected item. |
297 | 313 | $include_data += array( |
@@ -314,12 +330,14 @@ discard block |
||
314 | 330 | global $context; |
315 | 331 | |
316 | 332 | $menu_name = $menu_id == 'last' && isset($context['max_menu_id']) && isset($context['menu_data_' . $context['max_menu_id']]) ? 'menu_data_' . $context['max_menu_id'] : 'menu_data_' . $menu_id; |
317 | - if (!isset($context[$menu_name])) |
|
318 | - return false; |
|
333 | + if (!isset($context[$menu_name])) { |
|
334 | + return false; |
|
335 | + } |
|
319 | 336 | |
320 | 337 | $layer_index = array_search($context[$menu_name]['layer_name'], $context['template_layers']); |
321 | - if ($layer_index !== false) |
|
322 | - unset($context['template_layers'][$layer_index]); |
|
338 | + if ($layer_index !== false) { |
|
339 | + unset($context['template_layers'][$layer_index]); |
|
340 | + } |
|
323 | 341 | |
324 | 342 | unset($context[$menu_name]); |
325 | 343 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -565,8 +580,9 @@ discard block |
||
565 | 580 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
566 | 581 | |
567 | 582 | // Sanity check |
568 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
569 | - continue; |
|
583 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
584 | + continue; |
|
585 | + } |
|
570 | 586 | |
571 | 587 | $linked_calendar_event = array( |
572 | 588 | 'id' => $row['id_event'], |
@@ -615,8 +631,9 @@ discard block |
||
615 | 631 | } |
616 | 632 | $smcFunc['db_free_result']($request); |
617 | 633 | |
618 | - if (!empty($context['linked_calendar_events'])) |
|
619 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
634 | + if (!empty($context['linked_calendar_events'])) { |
|
635 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
636 | + } |
|
620 | 637 | } |
621 | 638 | |
622 | 639 | // Create the poll info if it exists. |
@@ -679,8 +696,9 @@ discard block |
||
679 | 696 | $smcFunc['db_free_result']($request); |
680 | 697 | |
681 | 698 | // Got we multi choice? |
682 | - if ($pollinfo['max_votes'] > 1) |
|
683 | - $realtotal = $pollinfo['total']; |
|
699 | + if ($pollinfo['max_votes'] > 1) { |
|
700 | + $realtotal = $pollinfo['total']; |
|
701 | + } |
|
684 | 702 | |
685 | 703 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
686 | 704 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -693,20 +711,21 @@ discard block |
||
693 | 711 | foreach ($guestinfo as $i => $guestvoted) |
694 | 712 | { |
695 | 713 | $guestvoted = explode(',', $guestvoted); |
696 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
697 | - break; |
|
714 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
715 | + break; |
|
716 | + } |
|
698 | 717 | } |
699 | 718 | // Has the poll been reset since guest voted? |
700 | 719 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
701 | 720 | { |
702 | 721 | // Remove the poll info from the cookie to allow guest to vote again |
703 | 722 | unset($guestinfo[$i]); |
704 | - if (!empty($guestinfo)) |
|
705 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
706 | - else |
|
707 | - unset($_COOKIE['guest_poll_vote']); |
|
708 | - } |
|
709 | - else |
|
723 | + if (!empty($guestinfo)) { |
|
724 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
725 | + } else { |
|
726 | + unset($_COOKIE['guest_poll_vote']); |
|
727 | + } |
|
728 | + } else |
|
710 | 729 | { |
711 | 730 | // What did they vote for? |
712 | 731 | unset($guestvoted[0], $guestvoted[1]); |
@@ -820,23 +839,29 @@ discard block |
||
820 | 839 | // Build the poll moderation button array. |
821 | 840 | $context['poll_buttons'] = array(); |
822 | 841 | |
823 | - if ($context['allow_return_vote']) |
|
824 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
842 | + if ($context['allow_return_vote']) { |
|
843 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
844 | + } |
|
825 | 845 | |
826 | - if ($context['show_view_results_button']) |
|
827 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
846 | + if ($context['show_view_results_button']) { |
|
847 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
848 | + } |
|
828 | 849 | |
829 | - if ($context['allow_change_vote']) |
|
830 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
850 | + if ($context['allow_change_vote']) { |
|
851 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
852 | + } |
|
831 | 853 | |
832 | - if ($context['allow_lock_poll']) |
|
833 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
854 | + if ($context['allow_lock_poll']) { |
|
855 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
856 | + } |
|
834 | 857 | |
835 | - if ($context['allow_edit_poll']) |
|
836 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
858 | + if ($context['allow_edit_poll']) { |
|
859 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
860 | + } |
|
837 | 861 | |
838 | - if ($context['can_remove_poll']) |
|
839 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
862 | + if ($context['can_remove_poll']) { |
|
863 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
864 | + } |
|
840 | 865 | |
841 | 866 | // Allow mods to add additional buttons here |
842 | 867 | call_integration_hook('integrate_poll_buttons'); |
@@ -871,9 +896,9 @@ discard block |
||
871 | 896 | { |
872 | 897 | $start_char = 'C'; |
873 | 898 | $page_id = $context['topicinfo']['id_first_msg']; |
899 | + } else { |
|
900 | + $start_char = null; |
|
874 | 901 | } |
875 | - else |
|
876 | - $start_char = null; |
|
877 | 902 | |
878 | 903 | $limit = $context['messages_per_page']; |
879 | 904 | |
@@ -888,17 +913,17 @@ discard block |
||
888 | 913 | { |
889 | 914 | $ascending = true; |
890 | 915 | $page_operator = '>='; |
891 | - } |
|
892 | - else |
|
916 | + } else |
|
893 | 917 | { |
894 | 918 | $ascending = false; |
895 | 919 | $page_operator = '<='; |
896 | 920 | } |
897 | 921 | |
898 | - if ($start_char === 'C') |
|
899 | - $limit_seek = $limit; |
|
900 | - else |
|
901 | - $limit_seek = $limit + 1; |
|
922 | + if ($start_char === 'C') { |
|
923 | + $limit_seek = $limit; |
|
924 | + } else { |
|
925 | + $limit_seek = $limit + 1; |
|
926 | + } |
|
902 | 927 | |
903 | 928 | $request = $smcFunc['db_query']('', ' |
904 | 929 | SELECT id_msg, id_member, approved |
@@ -921,21 +946,23 @@ discard block |
||
921 | 946 | $found_msg = false; |
922 | 947 | |
923 | 948 | // Fallback |
924 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
925 | - unset($start_char); |
|
926 | - else |
|
949 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
950 | + unset($start_char); |
|
951 | + } else |
|
927 | 952 | { |
928 | 953 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
929 | 954 | { |
930 | 955 | // Check if the start msg is in our result |
931 | - if ($row['id_msg'] == $page_id) |
|
932 | - $found_msg = true; |
|
956 | + if ($row['id_msg'] == $page_id) { |
|
957 | + $found_msg = true; |
|
958 | + } |
|
933 | 959 | |
934 | 960 | // Skip the the start msg if we not in mode C |
935 | 961 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
936 | 962 | { |
937 | - if (!empty($row['id_member'])) |
|
938 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
963 | + if (!empty($row['id_member'])) { |
|
964 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
965 | + } |
|
939 | 966 | |
940 | 967 | $messages[] = $row['id_msg']; |
941 | 968 | } |
@@ -951,8 +978,9 @@ discard block |
||
951 | 978 | } |
952 | 979 | |
953 | 980 | // Before Page bring in the right order |
954 | - if (!empty($start_char) && $start_char === 'L') |
|
955 | - krsort($messages); |
|
981 | + if (!empty($start_char) && $start_char === 'L') { |
|
982 | + krsort($messages); |
|
983 | + } |
|
956 | 984 | } |
957 | 985 | |
958 | 986 | // Jump to page |
@@ -989,14 +1017,16 @@ discard block |
||
989 | 1017 | |
990 | 1018 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
991 | 1019 | { |
992 | - if (!empty($row['id_member'])) |
|
993 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
1020 | + if (!empty($row['id_member'])) { |
|
1021 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
1022 | + } |
|
994 | 1023 | $messages[] = $row['id_msg']; |
995 | 1024 | } |
996 | 1025 | |
997 | 1026 | // Sort the messages into the correct display order |
998 | - if (!$ascending) |
|
999 | - sort($messages); |
|
1027 | + if (!$ascending) { |
|
1028 | + sort($messages); |
|
1029 | + } |
|
1000 | 1030 | } |
1001 | 1031 | |
1002 | 1032 | // Remember the paging data for next time |
@@ -1016,8 +1046,9 @@ discard block |
||
1016 | 1046 | if (!$user_info['is_guest'] && !empty($messages)) |
1017 | 1047 | { |
1018 | 1048 | $mark_at_msg = max($messages); |
1019 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
1020 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
1049 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
1050 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
1051 | + } |
|
1021 | 1052 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
1022 | 1053 | { |
1023 | 1054 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1049,8 +1080,9 @@ discard block |
||
1049 | 1080 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1050 | 1081 | { |
1051 | 1082 | // Find if this topic is marked for notification... |
1052 | - if (!empty($row['id_topic'])) |
|
1053 | - $context['is_marked_notify'] = true; |
|
1083 | + if (!empty($row['id_topic'])) { |
|
1084 | + $context['is_marked_notify'] = true; |
|
1085 | + } |
|
1054 | 1086 | |
1055 | 1087 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
1056 | 1088 | if (!empty($row['sent']) && $do_once) |
@@ -1072,8 +1104,9 @@ discard block |
||
1072 | 1104 | } |
1073 | 1105 | |
1074 | 1106 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
1075 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
1076 | - $_SESSION['topicseen_cache'][$board]--; |
|
1107 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
1108 | + $_SESSION['topicseen_cache'][$board]--; |
|
1109 | + } |
|
1077 | 1110 | // Mark board as seen if this is the only new topic. |
1078 | 1111 | elseif (isset($_REQUEST['topicseen'])) |
1079 | 1112 | { |
@@ -1097,14 +1130,16 @@ discard block |
||
1097 | 1130 | $smcFunc['db_free_result']($request); |
1098 | 1131 | |
1099 | 1132 | // If there're no real new topics in this board, mark the board as seen. |
1100 | - if (empty($numNewTopics)) |
|
1101 | - $_REQUEST['boardseen'] = true; |
|
1102 | - else |
|
1103 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1133 | + if (empty($numNewTopics)) { |
|
1134 | + $_REQUEST['boardseen'] = true; |
|
1135 | + } else { |
|
1136 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1137 | + } |
|
1104 | 1138 | } |
1105 | 1139 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
1106 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
1107 | - $_SESSION['topicseen_cache'][$board]--; |
|
1140 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1141 | + $_SESSION['topicseen_cache'][$board]--; |
|
1142 | + } |
|
1108 | 1143 | |
1109 | 1144 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
1110 | 1145 | if (isset($_REQUEST['boardseen'])) |
@@ -1161,23 +1196,26 @@ discard block |
||
1161 | 1196 | $temp = array(); |
1162 | 1197 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1163 | 1198 | { |
1164 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1165 | - continue; |
|
1199 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1200 | + continue; |
|
1201 | + } |
|
1166 | 1202 | |
1167 | 1203 | $temp[$row['id_attach']] = $row; |
1168 | 1204 | $temp[$row['id_attach']]['topic'] = $topic; |
1169 | 1205 | $temp[$row['id_attach']]['board'] = $board; |
1170 | 1206 | |
1171 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1172 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1207 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1208 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1209 | + } |
|
1173 | 1210 | } |
1174 | 1211 | $smcFunc['db_free_result']($request); |
1175 | 1212 | |
1176 | 1213 | // This is better than sorting it with the query... |
1177 | 1214 | ksort($temp); |
1178 | 1215 | |
1179 | - foreach ($temp as $row) |
|
1180 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1216 | + foreach ($temp as $row) { |
|
1217 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1218 | + } |
|
1181 | 1219 | } |
1182 | 1220 | |
1183 | 1221 | $msg_parameters = array( |
@@ -1204,21 +1242,23 @@ discard block |
||
1204 | 1242 | ); |
1205 | 1243 | |
1206 | 1244 | // And the likes |
1207 | - if (!empty($modSettings['enable_likes'])) |
|
1208 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1245 | + if (!empty($modSettings['enable_likes'])) { |
|
1246 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1247 | + } |
|
1209 | 1248 | |
1210 | 1249 | // Go to the last message if the given time is beyond the time of the last message. |
1211 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1212 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1250 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1251 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1252 | + } |
|
1213 | 1253 | |
1214 | 1254 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1215 | 1255 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1216 | - if (empty($options['view_newest_first'])) |
|
1217 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1218 | - else |
|
1219 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1220 | - } |
|
1221 | - else |
|
1256 | + if (empty($options['view_newest_first'])) { |
|
1257 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1258 | + } else { |
|
1259 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1260 | + } |
|
1261 | + } else |
|
1222 | 1262 | { |
1223 | 1263 | $messages_request = false; |
1224 | 1264 | $context['first_message'] = 0; |
@@ -1254,8 +1294,9 @@ discard block |
||
1254 | 1294 | 'can_see_likes' => 'likes_view', |
1255 | 1295 | 'can_like' => 'likes_like', |
1256 | 1296 | ); |
1257 | - foreach ($common_permissions as $contextual => $perm) |
|
1258 | - $context[$contextual] = allowedTo($perm); |
|
1297 | + foreach ($common_permissions as $contextual => $perm) { |
|
1298 | + $context[$contextual] = allowedTo($perm); |
|
1299 | + } |
|
1259 | 1300 | |
1260 | 1301 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1261 | 1302 | $anyown_permissions = array( |
@@ -1268,8 +1309,9 @@ discard block |
||
1268 | 1309 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1269 | 1310 | 'can_view_warning' => 'profile_warning', |
1270 | 1311 | ); |
1271 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1272 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1312 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1313 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1314 | + } |
|
1273 | 1315 | |
1274 | 1316 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
1275 | 1317 | { |
@@ -1315,8 +1357,9 @@ discard block |
||
1315 | 1357 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1316 | 1358 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1317 | 1359 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1318 | - if (!empty($context['drafts_save'])) |
|
1319 | - loadLanguage('Drafts'); |
|
1360 | + if (!empty($context['drafts_save'])) { |
|
1361 | + loadLanguage('Drafts'); |
|
1362 | + } |
|
1320 | 1363 | |
1321 | 1364 | // When was the last time this topic was replied to? Should we warn them about it? |
1322 | 1365 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1377,26 +1420,31 @@ discard block |
||
1377 | 1420 | // Message icons - customized icons are off? |
1378 | 1421 | $context['icons'] = getMessageIcons($board); |
1379 | 1422 | |
1380 | - if (!empty($context['icons'])) |
|
1381 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1423 | + if (!empty($context['icons'])) { |
|
1424 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1425 | + } |
|
1382 | 1426 | |
1383 | 1427 | // Build the normal button array. |
1384 | 1428 | $context['normal_buttons'] = array(); |
1385 | 1429 | |
1386 | - if ($context['can_reply']) |
|
1387 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1430 | + if ($context['can_reply']) { |
|
1431 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1432 | + } |
|
1388 | 1433 | |
1389 | - if ($context['can_add_poll']) |
|
1390 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1434 | + if ($context['can_add_poll']) { |
|
1435 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1436 | + } |
|
1391 | 1437 | |
1392 | - if ($context['can_mark_unread']) |
|
1393 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1438 | + if ($context['can_mark_unread']) { |
|
1439 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1440 | + } |
|
1394 | 1441 | |
1395 | - if ($context['can_print']) |
|
1396 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1442 | + if ($context['can_print']) { |
|
1443 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1444 | + } |
|
1397 | 1445 | |
1398 | - if ($context['can_set_notify']) |
|
1399 | - $context['normal_buttons']['notify'] = array( |
|
1446 | + if ($context['can_set_notify']) { |
|
1447 | + $context['normal_buttons']['notify'] = array( |
|
1400 | 1448 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1401 | 1449 | 'sub_buttons' => array( |
1402 | 1450 | array( |
@@ -1418,38 +1466,47 @@ discard block |
||
1418 | 1466 | ), |
1419 | 1467 | ), |
1420 | 1468 | ); |
1469 | + } |
|
1421 | 1470 | |
1422 | 1471 | // Build the mod button array |
1423 | 1472 | $context['mod_buttons'] = array(); |
1424 | 1473 | |
1425 | - if ($context['can_move']) |
|
1426 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1474 | + if ($context['can_move']) { |
|
1475 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1476 | + } |
|
1427 | 1477 | |
1428 | - if ($context['can_delete']) |
|
1429 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1478 | + if ($context['can_delete']) { |
|
1479 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1480 | + } |
|
1430 | 1481 | |
1431 | - if ($context['can_lock']) |
|
1432 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1482 | + if ($context['can_lock']) { |
|
1483 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1484 | + } |
|
1433 | 1485 | |
1434 | - if ($context['can_sticky']) |
|
1435 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1486 | + if ($context['can_sticky']) { |
|
1487 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1488 | + } |
|
1436 | 1489 | |
1437 | - if ($context['can_merge']) |
|
1438 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1490 | + if ($context['can_merge']) { |
|
1491 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1492 | + } |
|
1439 | 1493 | |
1440 | - if ($context['calendar_post']) |
|
1441 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1494 | + if ($context['calendar_post']) { |
|
1495 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1496 | + } |
|
1442 | 1497 | |
1443 | 1498 | // Restore topic. eh? No monkey business. |
1444 | - if ($context['can_restore_topic']) |
|
1445 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1499 | + if ($context['can_restore_topic']) { |
|
1500 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1501 | + } |
|
1446 | 1502 | |
1447 | 1503 | // Show a message in case a recently posted message became unapproved. |
1448 | 1504 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1449 | 1505 | |
1450 | 1506 | // Don't want to show this forever... |
1451 | - if ($context['becomesUnapproved']) |
|
1452 | - unset($_SESSION['becomesUnapproved']); |
|
1507 | + if ($context['becomesUnapproved']) { |
|
1508 | + unset($_SESSION['becomesUnapproved']); |
|
1509 | + } |
|
1453 | 1510 | |
1454 | 1511 | // Allow adding new mod buttons easily. |
1455 | 1512 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1458,12 +1515,14 @@ discard block |
||
1458 | 1515 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1459 | 1516 | |
1460 | 1517 | // Load the drafts js file |
1461 | - if ($context['drafts_autosave']) |
|
1462 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1518 | + if ($context['drafts_autosave']) { |
|
1519 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1520 | + } |
|
1463 | 1521 | |
1464 | 1522 | // Spellcheck |
1465 | - if ($context['show_spellchecking']) |
|
1466 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1523 | + if ($context['show_spellchecking']) { |
|
1524 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1525 | + } |
|
1467 | 1526 | |
1468 | 1527 | // topic.js |
1469 | 1528 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1497,16 +1556,19 @@ discard block |
||
1497 | 1556 | static $counter = null; |
1498 | 1557 | |
1499 | 1558 | // If the query returned false, bail. |
1500 | - if ($messages_request == false) |
|
1501 | - return false; |
|
1559 | + if ($messages_request == false) { |
|
1560 | + return false; |
|
1561 | + } |
|
1502 | 1562 | |
1503 | 1563 | // Remember which message this is. (ie. reply #83) |
1504 | - if ($counter === null || $reset) |
|
1505 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1564 | + if ($counter === null || $reset) { |
|
1565 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1566 | + } |
|
1506 | 1567 | |
1507 | 1568 | // Start from the beginning... |
1508 | - if ($reset) |
|
1509 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1569 | + if ($reset) { |
|
1570 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1571 | + } |
|
1510 | 1572 | |
1511 | 1573 | // Attempt to get the next message. |
1512 | 1574 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1520,19 +1582,21 @@ discard block |
||
1520 | 1582 | if (empty($context['icon_sources'])) |
1521 | 1583 | { |
1522 | 1584 | $context['icon_sources'] = array(); |
1523 | - foreach ($context['stable_icons'] as $icon) |
|
1524 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1585 | + foreach ($context['stable_icons'] as $icon) { |
|
1586 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1587 | + } |
|
1525 | 1588 | } |
1526 | 1589 | |
1527 | 1590 | // Message Icon Management... check the images exist. |
1528 | 1591 | if (empty($modSettings['messageIconChecks_disable'])) |
1529 | 1592 | { |
1530 | 1593 | // If the current icon isn't known, then we need to do something... |
1531 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1532 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1594 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1595 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1596 | + } |
|
1597 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1598 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1533 | 1599 | } |
1534 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1535 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1536 | 1600 | |
1537 | 1601 | // If you're a lazy bum, you probably didn't give a subject... |
1538 | 1602 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1557,8 +1621,7 @@ discard block |
||
1557 | 1621 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1558 | 1622 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1559 | 1623 | $memberContext[$message['id_member']]['is_guest'] = true; |
1560 | - } |
|
1561 | - else |
|
1624 | + } else |
|
1562 | 1625 | { |
1563 | 1626 | // Define this here to make things a bit more readable |
1564 | 1627 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1581,8 +1644,9 @@ discard block |
||
1581 | 1644 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1582 | 1645 | |
1583 | 1646 | // If it's in the recycle bin we need to override whatever icon we did have. |
1584 | - if (!empty($board_info['recycle'])) |
|
1585 | - $message['icon'] = 'recycled'; |
|
1647 | + if (!empty($board_info['recycle'])) { |
|
1648 | + $message['icon'] = 'recycled'; |
|
1649 | + } |
|
1586 | 1650 | |
1587 | 1651 | require_once($sourcedir . '/Subs-Attachments.php'); |
1588 | 1652 | |
@@ -1626,32 +1690,36 @@ discard block |
||
1626 | 1690 | } |
1627 | 1691 | |
1628 | 1692 | // Are likes enable? |
1629 | - if (!empty($modSettings['enable_likes'])) |
|
1630 | - $output['likes'] = array( |
|
1693 | + if (!empty($modSettings['enable_likes'])) { |
|
1694 | + $output['likes'] = array( |
|
1631 | 1695 | 'count' => $message['likes'], |
1632 | 1696 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1633 | 1697 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1634 | 1698 | ); |
1699 | + } |
|
1635 | 1700 | |
1636 | 1701 | // Is this user the message author? |
1637 | 1702 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1638 | - if (!empty($output['modified']['name'])) |
|
1639 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1703 | + if (!empty($output['modified']['name'])) { |
|
1704 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1705 | + } |
|
1640 | 1706 | |
1641 | 1707 | // Did they give a reason for editing? |
1642 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1643 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1708 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1709 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1710 | + } |
|
1644 | 1711 | |
1645 | 1712 | // Any custom profile fields? |
1646 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1647 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1713 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1714 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1648 | 1715 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1716 | + } |
|
1649 | 1717 | |
1650 | - if (empty($options['view_newest_first'])) |
|
1651 | - $counter++; |
|
1652 | - |
|
1653 | - else |
|
1654 | - $counter--; |
|
1718 | + if (empty($options['view_newest_first'])) { |
|
1719 | + $counter++; |
|
1720 | + } else { |
|
1721 | + $counter--; |
|
1722 | + } |
|
1655 | 1723 | |
1656 | 1724 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1657 | 1725 | |
@@ -1677,21 +1745,23 @@ discard block |
||
1677 | 1745 | $context['no_last_modified'] = true; |
1678 | 1746 | |
1679 | 1747 | // Prevent a preview image from being displayed twice. |
1680 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
1681 | - return; |
|
1748 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
1749 | + return; |
|
1750 | + } |
|
1682 | 1751 | |
1683 | 1752 | // Make sure some attachment was requested! |
1684 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
1685 | - fatal_lang_error('no_access', false); |
|
1753 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
1754 | + fatal_lang_error('no_access', false); |
|
1755 | + } |
|
1686 | 1756 | |
1687 | 1757 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
1688 | 1758 | |
1689 | 1759 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
1690 | 1760 | $attachRequest = null; |
1691 | 1761 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
1692 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
1693 | - $request = $attachRequest; |
|
1694 | - else |
|
1762 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
1763 | + $request = $attachRequest; |
|
1764 | + } else |
|
1695 | 1765 | { |
1696 | 1766 | // This checks only the current board for $board/$topic's permissions. |
1697 | 1767 | isAllowedTo('view_attachments'); |
@@ -1712,19 +1782,21 @@ discard block |
||
1712 | 1782 | ); |
1713 | 1783 | } |
1714 | 1784 | |
1715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1716 | - fatal_lang_error('no_access', false); |
|
1785 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1786 | + fatal_lang_error('no_access', false); |
|
1787 | + } |
|
1717 | 1788 | |
1718 | 1789 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
1719 | 1790 | $smcFunc['db_free_result']($request); |
1720 | 1791 | |
1721 | 1792 | // If it isn't yet approved, do they have permission to view it? |
1722 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
1723 | - isAllowedTo('approve_posts'); |
|
1793 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
1794 | + isAllowedTo('approve_posts'); |
|
1795 | + } |
|
1724 | 1796 | |
1725 | 1797 | // Update the download counter (unless it's a thumbnail). |
1726 | - if ($attachment_type != 3) |
|
1727 | - $smcFunc['db_query']('attach_download_increase', ' |
|
1798 | + if ($attachment_type != 3) { |
|
1799 | + $smcFunc['db_query']('attach_download_increase', ' |
|
1728 | 1800 | UPDATE LOW_PRIORITY {db_prefix}attachments |
1729 | 1801 | SET downloads = downloads + 1 |
1730 | 1802 | WHERE id_attach = {int:id_attach}', |
@@ -1732,15 +1804,15 @@ discard block |
||
1732 | 1804 | 'id_attach' => $id_attach, |
1733 | 1805 | ) |
1734 | 1806 | ); |
1807 | + } |
|
1735 | 1808 | |
1736 | 1809 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
1737 | 1810 | |
1738 | 1811 | // This is done to clear any output that was made before now. |
1739 | 1812 | ob_end_clean(); |
1740 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
1741 | - @ob_start('ob_gzhandler'); |
|
1742 | - |
|
1743 | - else |
|
1813 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
1814 | + @ob_start('ob_gzhandler'); |
|
1815 | + } else |
|
1744 | 1816 | { |
1745 | 1817 | ob_start(); |
1746 | 1818 | header('Content-Encoding: none'); |
@@ -1783,8 +1855,9 @@ discard block |
||
1783 | 1855 | // Send the attachment headers. |
1784 | 1856 | header('Pragma: '); |
1785 | 1857 | |
1786 | - if (!isBrowser('gecko')) |
|
1787 | - header('Content-Transfer-Encoding: binary'); |
|
1858 | + if (!isBrowser('gecko')) { |
|
1859 | + header('Content-Transfer-Encoding: binary'); |
|
1860 | + } |
|
1788 | 1861 | |
1789 | 1862 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
1790 | 1863 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1793,18 +1866,19 @@ discard block |
||
1793 | 1866 | header('ETag: ' . $eTag); |
1794 | 1867 | |
1795 | 1868 | // Make sure the mime type warrants an inline display. |
1796 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
1797 | - unset($_REQUEST['image']); |
|
1869 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
1870 | + unset($_REQUEST['image']); |
|
1871 | + } |
|
1798 | 1872 | |
1799 | 1873 | // Does this have a mime type? |
1800 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
1801 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1802 | - |
|
1803 | - else |
|
1874 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
1875 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1876 | + } else |
|
1804 | 1877 | { |
1805 | 1878 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
1806 | - if (isset($_REQUEST['image'])) |
|
1807 | - unset($_REQUEST['image']); |
|
1879 | + if (isset($_REQUEST['image'])) { |
|
1880 | + unset($_REQUEST['image']); |
|
1881 | + } |
|
1808 | 1882 | } |
1809 | 1883 | |
1810 | 1884 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1812,23 +1886,22 @@ discard block |
||
1812 | 1886 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
1813 | 1887 | |
1814 | 1888 | // Different browsers like different standards... |
1815 | - if (isBrowser('firefox')) |
|
1816 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1817 | - |
|
1818 | - elseif (isBrowser('opera')) |
|
1819 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1820 | - |
|
1821 | - elseif (isBrowser('ie')) |
|
1822 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1823 | - |
|
1824 | - else |
|
1825 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1889 | + if (isBrowser('firefox')) { |
|
1890 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1891 | + } elseif (isBrowser('opera')) { |
|
1892 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1893 | + } elseif (isBrowser('ie')) { |
|
1894 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1895 | + } else { |
|
1896 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1897 | + } |
|
1826 | 1898 | |
1827 | 1899 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
1828 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
1829 | - header('Cache-Control: no-cache'); |
|
1830 | - else |
|
1831 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1900 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
1901 | + header('Cache-Control: no-cache'); |
|
1902 | + } else { |
|
1903 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1904 | + } |
|
1832 | 1905 | |
1833 | 1906 | header('Content-Length: ' . filesize($filename)); |
1834 | 1907 | |
@@ -1838,20 +1911,23 @@ discard block |
||
1838 | 1911 | // Recode line endings for text files, if enabled. |
1839 | 1912 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
1840 | 1913 | { |
1841 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
1842 | - $callback = function($buffer) |
|
1914 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
1915 | + $callback = function($buffer) |
|
1843 | 1916 | { |
1844 | 1917 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
1918 | + } |
|
1845 | 1919 | }; |
1846 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
1847 | - $callback = function($buffer) |
|
1920 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
1921 | + $callback = function($buffer) |
|
1848 | 1922 | { |
1849 | 1923 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
1924 | + } |
|
1850 | 1925 | }; |
1851 | - else |
|
1852 | - $callback = function($buffer) |
|
1926 | + else { |
|
1927 | + $callback = function($buffer) |
|
1853 | 1928 | { |
1854 | 1929 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
1930 | + } |
|
1855 | 1931 | }; |
1856 | 1932 | } |
1857 | 1933 | |
@@ -1859,23 +1935,26 @@ discard block |
||
1859 | 1935 | if (filesize($filename) > 4194304) |
1860 | 1936 | { |
1861 | 1937 | // Forcibly end any output buffering going on. |
1862 | - while (@ob_get_level() > 0) |
|
1863 | - @ob_end_clean(); |
|
1938 | + while (@ob_get_level() > 0) { |
|
1939 | + @ob_end_clean(); |
|
1940 | + } |
|
1864 | 1941 | |
1865 | 1942 | $fp = fopen($filename, 'rb'); |
1866 | 1943 | while (!feof($fp)) |
1867 | 1944 | { |
1868 | - if (isset($callback)) |
|
1869 | - echo $callback(fread($fp, 8192)); |
|
1870 | - else |
|
1871 | - echo fread($fp, 8192); |
|
1945 | + if (isset($callback)) { |
|
1946 | + echo $callback(fread($fp, 8192)); |
|
1947 | + } else { |
|
1948 | + echo fread($fp, 8192); |
|
1949 | + } |
|
1872 | 1950 | flush(); |
1873 | 1951 | } |
1874 | 1952 | fclose($fp); |
1875 | 1953 | } |
1876 | 1954 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
1877 | - elseif (isset($callback) || @readfile($filename) === null) |
|
1878 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1955 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
1956 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1957 | + } |
|
1879 | 1958 | |
1880 | 1959 | obExit(false); |
1881 | 1960 | } |
@@ -1888,8 +1967,9 @@ discard block |
||
1888 | 1967 | */ |
1889 | 1968 | function approved_attach_sort($a, $b) |
1890 | 1969 | { |
1891 | - if ($a['is_approved'] == $b['is_approved']) |
|
1892 | - return 0; |
|
1970 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1971 | + return 0; |
|
1972 | + } |
|
1893 | 1973 | |
1894 | 1974 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1895 | 1975 | } |
@@ -1906,16 +1986,19 @@ discard block |
||
1906 | 1986 | |
1907 | 1987 | require_once($sourcedir . '/RemoveTopic.php'); |
1908 | 1988 | |
1909 | - if (empty($_REQUEST['msgs'])) |
|
1910 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1989 | + if (empty($_REQUEST['msgs'])) { |
|
1990 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1991 | + } |
|
1911 | 1992 | |
1912 | 1993 | $messages = array(); |
1913 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1914 | - $messages[] = (int) $dummy; |
|
1994 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1995 | + $messages[] = (int) $dummy; |
|
1996 | + } |
|
1915 | 1997 | |
1916 | 1998 | // We are restoring messages. We handle this in another place. |
1917 | - if (isset($_REQUEST['restore_selected'])) |
|
1918 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1999 | + if (isset($_REQUEST['restore_selected'])) { |
|
2000 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
2001 | + } |
|
1919 | 2002 | if (isset($_REQUEST['split_selection'])) |
1920 | 2003 | { |
1921 | 2004 | $request = $smcFunc['db_query']('', ' |
@@ -1934,8 +2017,9 @@ discard block |
||
1934 | 2017 | } |
1935 | 2018 | |
1936 | 2019 | // Allowed to delete any message? |
1937 | - if (allowedTo('delete_any')) |
|
1938 | - $allowed_all = true; |
|
2020 | + if (allowedTo('delete_any')) { |
|
2021 | + $allowed_all = true; |
|
2022 | + } |
|
1939 | 2023 | // Allowed to delete replies to their messages? |
1940 | 2024 | elseif (allowedTo('delete_replies')) |
1941 | 2025 | { |
@@ -1952,13 +2036,14 @@ discard block |
||
1952 | 2036 | $smcFunc['db_free_result']($request); |
1953 | 2037 | |
1954 | 2038 | $allowed_all = $starter == $user_info['id']; |
2039 | + } else { |
|
2040 | + $allowed_all = false; |
|
1955 | 2041 | } |
1956 | - else |
|
1957 | - $allowed_all = false; |
|
1958 | 2042 | |
1959 | 2043 | // Make sure they're allowed to delete their own messages, if not any. |
1960 | - if (!$allowed_all) |
|
1961 | - isAllowedTo('delete_own'); |
|
2044 | + if (!$allowed_all) { |
|
2045 | + isAllowedTo('delete_own'); |
|
2046 | + } |
|
1962 | 2047 | |
1963 | 2048 | // Allowed to remove which messages? |
1964 | 2049 | $request = $smcFunc['db_query']('', ' |
@@ -1978,8 +2063,9 @@ discard block |
||
1978 | 2063 | $messages = array(); |
1979 | 2064 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1980 | 2065 | { |
1981 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1982 | - continue; |
|
2066 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
2067 | + continue; |
|
2068 | + } |
|
1983 | 2069 | |
1984 | 2070 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1985 | 2071 | } |
@@ -2002,17 +2088,20 @@ discard block |
||
2002 | 2088 | foreach ($messages as $message => $info) |
2003 | 2089 | { |
2004 | 2090 | // Just skip the first message - if it's not the last. |
2005 | - if ($message == $first_message && $message != $last_message) |
|
2006 | - continue; |
|
2091 | + if ($message == $first_message && $message != $last_message) { |
|
2092 | + continue; |
|
2093 | + } |
|
2007 | 2094 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
2008 | - elseif ($message == $first_message) |
|
2009 | - $topicGone = true; |
|
2095 | + elseif ($message == $first_message) { |
|
2096 | + $topicGone = true; |
|
2097 | + } |
|
2010 | 2098 | |
2011 | 2099 | removeMessage($message); |
2012 | 2100 | |
2013 | 2101 | // Log this moderation action ;). |
2014 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
2015 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
2102 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
2103 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
2104 | + } |
|
2016 | 2105 | } |
2017 | 2106 | |
2018 | 2107 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = $smcFunc['json_decode']($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = $smcFunc['json_decode']($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -127,10 +132,11 @@ discard block |
||
127 | 132 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
128 | 133 | |
129 | 134 | // If we're preserving the cookie, reset it with updated salt |
130 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
131 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
132 | - else |
|
133 | - setTFACookie(-3600, 0, ''); |
|
135 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
136 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
137 | + } else { |
|
138 | + setTFACookie(-3600, 0, ''); |
|
139 | + } |
|
134 | 140 | } |
135 | 141 | |
136 | 142 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -141,20 +147,20 @@ discard block |
||
141 | 147 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
142 | 148 | { |
143 | 149 | // Strike! You're outta there! |
144 | - if ($_GET['member'] != $user_info['id']) |
|
145 | - fatal_lang_error('login_cookie_error', false); |
|
150 | + if ($_GET['member'] != $user_info['id']) { |
|
151 | + fatal_lang_error('login_cookie_error', false); |
|
152 | + } |
|
146 | 153 | |
147 | 154 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
148 | 155 | |
149 | 156 | // Some whitelisting for login_url... |
150 | - if (empty($_SESSION['login_url'])) |
|
151 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
152 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | + if (empty($_SESSION['login_url'])) { |
|
158 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
159 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
153 | 160 | { |
154 | 161 | unset ($_SESSION['login_url']); |
155 | 162 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
156 | - } |
|
157 | - else |
|
163 | + } else |
|
158 | 164 | { |
159 | 165 | // Best not to clutter the session data too much... |
160 | 166 | $temp = $_SESSION['login_url']; |
@@ -165,8 +171,9 @@ discard block |
||
165 | 171 | } |
166 | 172 | |
167 | 173 | // Beyond this point you are assumed to be a guest trying to login. |
168 | - if (!$user_info['is_guest']) |
|
169 | - redirectexit(); |
|
174 | + if (!$user_info['is_guest']) { |
|
175 | + redirectexit(); |
|
176 | + } |
|
170 | 177 | |
171 | 178 | // Are you guessing with a script? |
172 | 179 | checkSession(); |
@@ -174,18 +181,21 @@ discard block |
||
174 | 181 | spamProtection('login'); |
175 | 182 | |
176 | 183 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
177 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
178 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
184 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
185 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
186 | + } |
|
179 | 187 | |
180 | 188 | // Been guessing a lot, haven't we? |
181 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
182 | - fatal_lang_error('login_threshold_fail', 'login'); |
|
189 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
190 | + fatal_lang_error('login_threshold_fail', 'login'); |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
185 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
186 | - $modSettings['cookieTime'] = 3153600; |
|
187 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
188 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
194 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
195 | + $modSettings['cookieTime'] = 3153600; |
|
196 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
197 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
198 | + } |
|
189 | 199 | |
190 | 200 | loadLanguage('Login'); |
191 | 201 | // Load the template stuff. |
@@ -305,8 +315,9 @@ discard block |
||
305 | 315 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
306 | 316 | |
307 | 317 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
308 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
309 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
318 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
319 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
320 | + } |
|
310 | 321 | |
311 | 322 | // phpBB3 users new hashing. We now support it as well ;). |
312 | 323 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -326,27 +337,29 @@ discard block |
||
326 | 337 | // Some common md5 ones. |
327 | 338 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
328 | 339 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
329 | - } |
|
330 | - elseif (strlen($user_settings['passwd']) == 40) |
|
340 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
331 | 341 | { |
332 | 342 | // Maybe they are using a hash from before the password fix. |
333 | 343 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
334 | 344 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
335 | 345 | |
336 | 346 | // BurningBoard3 style of hashing. |
337 | - if (!empty($modSettings['enable_password_conversion'])) |
|
338 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
347 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
348 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
349 | + } |
|
339 | 350 | |
340 | 351 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
341 | 352 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
342 | 353 | { |
343 | 354 | // Try iconv first, for no particular reason. |
344 | - if (function_exists('iconv')) |
|
345 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
355 | + if (function_exists('iconv')) { |
|
356 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
357 | + } |
|
346 | 358 | |
347 | 359 | // Say it aint so, iconv failed! |
348 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
349 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
360 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
361 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
362 | + } |
|
350 | 363 | } |
351 | 364 | } |
352 | 365 | |
@@ -376,8 +389,9 @@ discard block |
||
376 | 389 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
377 | 390 | |
378 | 391 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
379 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
380 | - redirectexit('action=reminder'); |
|
392 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
393 | + redirectexit('action=reminder'); |
|
394 | + } |
|
381 | 395 | // We'll give you another chance... |
382 | 396 | else |
383 | 397 | { |
@@ -388,8 +402,7 @@ discard block |
||
388 | 402 | return; |
389 | 403 | } |
390 | 404 | } |
391 | - } |
|
392 | - elseif (!empty($user_settings['passwd_flood'])) |
|
405 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
393 | 406 | { |
394 | 407 | // Let's be sure they weren't a little hacker. |
395 | 408 | validatePasswordFlood($user_settings['id_member'], $user_settings['member_name'], $user_settings['passwd_flood'], true); |
@@ -406,8 +419,9 @@ discard block |
||
406 | 419 | } |
407 | 420 | |
408 | 421 | // Check their activation status. |
409 | - if (!checkActivation()) |
|
410 | - return; |
|
422 | + if (!checkActivation()) { |
|
423 | + return; |
|
424 | + } |
|
411 | 425 | |
412 | 426 | DoLogin(); |
413 | 427 | } |
@@ -419,8 +433,9 @@ discard block |
||
419 | 433 | { |
420 | 434 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
421 | 435 | |
422 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
423 | - fatal_lang_error('no_access', false); |
|
436 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
437 | + fatal_lang_error('no_access', false); |
|
438 | + } |
|
424 | 439 | |
425 | 440 | loadLanguage('Profile'); |
426 | 441 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -428,8 +443,9 @@ discard block |
||
428 | 443 | $member = $context['tfa_member']; |
429 | 444 | |
430 | 445 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
431 | - if (time() - $member['last_login'] < 120) |
|
432 | - fatal_lang_error('tfa_wait', false); |
|
446 | + if (time() - $member['last_login'] < 120) { |
|
447 | + fatal_lang_error('tfa_wait', false); |
|
448 | + } |
|
433 | 449 | |
434 | 450 | $totp = new \TOTP\Auth($member['tfa_secret']); |
435 | 451 | $totp->setRange(1); |
@@ -443,8 +459,9 @@ discard block |
||
443 | 459 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
444 | 460 | { |
445 | 461 | // Check to ensure we're forcing SSL for authentication |
446 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
447 | - fatal_lang_error('login_ssl_required'); |
|
462 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
463 | + fatal_lang_error('login_ssl_required'); |
|
464 | + } |
|
448 | 465 | |
449 | 466 | $code = $_POST['tfa_code']; |
450 | 467 | |
@@ -454,20 +471,19 @@ discard block |
||
454 | 471 | |
455 | 472 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
456 | 473 | redirectexit(); |
457 | - } |
|
458 | - else |
|
474 | + } else |
|
459 | 475 | { |
460 | 476 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
461 | 477 | |
462 | 478 | $context['tfa_error'] = true; |
463 | 479 | $context['tfa_value'] = $_POST['tfa_code']; |
464 | 480 | } |
465 | - } |
|
466 | - elseif (!empty($_POST['tfa_backup'])) |
|
481 | + } elseif (!empty($_POST['tfa_backup'])) |
|
467 | 482 | { |
468 | 483 | // Check to ensure we're forcing SSL for authentication |
469 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
470 | - fatal_lang_error('login_ssl_required'); |
|
484 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
485 | + fatal_lang_error('login_ssl_required'); |
|
486 | + } |
|
471 | 487 | |
472 | 488 | $backup = $_POST['tfa_backup']; |
473 | 489 | |
@@ -481,8 +497,7 @@ discard block |
||
481 | 497 | )); |
482 | 498 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
483 | 499 | redirectexit('action=profile;area=tfasetup;backup'); |
484 | - } |
|
485 | - else |
|
500 | + } else |
|
486 | 501 | { |
487 | 502 | validatePasswordFlood($member['id_member'], $member['member_name'], $member['passwd_flood'], false, true); |
488 | 503 | |
@@ -505,8 +520,9 @@ discard block |
||
505 | 520 | { |
506 | 521 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
507 | 522 | |
508 | - if (!isset($context['login_errors'])) |
|
509 | - $context['login_errors'] = array(); |
|
523 | + if (!isset($context['login_errors'])) { |
|
524 | + $context['login_errors'] = array(); |
|
525 | + } |
|
510 | 526 | |
511 | 527 | // What is the true activation status of this account? |
512 | 528 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -518,8 +534,9 @@ discard block |
||
518 | 534 | return false; |
519 | 535 | } |
520 | 536 | // Awaiting approval still? |
521 | - elseif ($activation_status == 3) |
|
522 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
537 | + elseif ($activation_status == 3) { |
|
538 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
539 | + } |
|
523 | 540 | // Awaiting deletion, changed their mind? |
524 | 541 | elseif ($activation_status == 4) |
525 | 542 | { |
@@ -527,8 +544,7 @@ discard block |
||
527 | 544 | { |
528 | 545 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
529 | 546 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
530 | - } |
|
531 | - else |
|
547 | + } else |
|
532 | 548 | { |
533 | 549 | $context['disable_login_hashing'] = true; |
534 | 550 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -568,8 +584,9 @@ discard block |
||
568 | 584 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
569 | 585 | |
570 | 586 | // Reset the login threshold. |
571 | - if (isset($_SESSION['failed_login'])) |
|
572 | - unset($_SESSION['failed_login']); |
|
587 | + if (isset($_SESSION['failed_login'])) { |
|
588 | + unset($_SESSION['failed_login']); |
|
589 | + } |
|
573 | 590 | |
574 | 591 | $user_info['is_guest'] = false; |
575 | 592 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -591,16 +608,18 @@ discard block |
||
591 | 608 | 'id_member' => $user_info['id'], |
592 | 609 | ) |
593 | 610 | ); |
594 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
595 | - $_SESSION['first_login'] = true; |
|
596 | - else |
|
597 | - unset($_SESSION['first_login']); |
|
611 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
612 | + $_SESSION['first_login'] = true; |
|
613 | + } else { |
|
614 | + unset($_SESSION['first_login']); |
|
615 | + } |
|
598 | 616 | $smcFunc['db_free_result']($request); |
599 | 617 | |
600 | 618 | // You've logged in, haven't you? |
601 | 619 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
602 | - if (empty($user_settings['tfa_secret'])) |
|
603 | - $update['last_login'] = time(); |
|
620 | + if (empty($user_settings['tfa_secret'])) { |
|
621 | + $update['last_login'] = time(); |
|
622 | + } |
|
604 | 623 | updateMemberData($user_info['id'], $update); |
605 | 624 | |
606 | 625 | // Get rid of the online entry for that old guest.... |
@@ -614,8 +633,8 @@ discard block |
||
614 | 633 | $_SESSION['log_time'] = 0; |
615 | 634 | |
616 | 635 | // Log this entry, only if we have it enabled. |
617 | - if (!empty($modSettings['loginHistoryDays'])) |
|
618 | - $smcFunc['db_insert']('insert', |
|
636 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
637 | + $smcFunc['db_insert']('insert', |
|
619 | 638 | '{db_prefix}member_logins', |
620 | 639 | array( |
621 | 640 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -627,13 +646,15 @@ discard block |
||
627 | 646 | 'id_member', 'time' |
628 | 647 | ) |
629 | 648 | ); |
649 | + } |
|
630 | 650 | |
631 | 651 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
632 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
633 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
634 | - else |
|
635 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
636 | -} |
|
652 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
653 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
654 | + } else { |
|
655 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
656 | + } |
|
657 | + } |
|
637 | 658 | |
638 | 659 | /** |
639 | 660 | * Logs the current user out of their account. |
@@ -649,13 +670,15 @@ discard block |
||
649 | 670 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
650 | 671 | |
651 | 672 | // Make sure they aren't being auto-logged out. |
652 | - if (!$internal) |
|
653 | - checkSession('get'); |
|
673 | + if (!$internal) { |
|
674 | + checkSession('get'); |
|
675 | + } |
|
654 | 676 | |
655 | 677 | require_once($sourcedir . '/Subs-Auth.php'); |
656 | 678 | |
657 | - if (isset($_SESSION['pack_ftp'])) |
|
658 | - $_SESSION['pack_ftp'] = null; |
|
679 | + if (isset($_SESSION['pack_ftp'])) { |
|
680 | + $_SESSION['pack_ftp'] = null; |
|
681 | + } |
|
659 | 682 | |
660 | 683 | // It won't be first login anymore. |
661 | 684 | unset($_SESSION['first_login']); |
@@ -683,8 +706,9 @@ discard block |
||
683 | 706 | |
684 | 707 | // And some other housekeeping while we're at it. |
685 | 708 | $salt = substr(md5(mt_rand()), 0, 4); |
686 | - if (!empty($user_info['id'])) |
|
687 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
709 | + if (!empty($user_info['id'])) { |
|
710 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
711 | + } |
|
688 | 712 | |
689 | 713 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
690 | 714 | { |
@@ -693,10 +717,11 @@ discard block |
||
693 | 717 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
694 | 718 | |
695 | 719 | // If we're preserving the cookie, reset it with updated salt |
696 | - if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) |
|
697 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
698 | - else |
|
699 | - setTFACookie(-3600, 0, ''); |
|
720 | + if (isset($tfamember, $tfasecret, $exp, $state, $preserve) && $preserve && time() < $exp) { |
|
721 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
722 | + } else { |
|
723 | + setTFACookie(-3600, 0, ''); |
|
724 | + } |
|
700 | 725 | } |
701 | 726 | |
702 | 727 | session_destroy(); |
@@ -704,14 +729,13 @@ discard block |
||
704 | 729 | // Off to the merry board index we go! |
705 | 730 | if ($redirect) |
706 | 731 | { |
707 | - if (empty($_SESSION['logout_url'])) |
|
708 | - redirectexit('', $context['server']['needs_login_fix']); |
|
709 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
732 | + if (empty($_SESSION['logout_url'])) { |
|
733 | + redirectexit('', $context['server']['needs_login_fix']); |
|
734 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
710 | 735 | { |
711 | 736 | unset ($_SESSION['logout_url']); |
712 | 737 | redirectexit(); |
713 | - } |
|
714 | - else |
|
738 | + } else |
|
715 | 739 | { |
716 | 740 | $temp = $_SESSION['logout_url']; |
717 | 741 | unset($_SESSION['logout_url']); |
@@ -744,8 +768,9 @@ discard block |
||
744 | 768 | function phpBB3_password_check($passwd, $passwd_hash) |
745 | 769 | { |
746 | 770 | // Too long or too short? |
747 | - if (strlen($passwd_hash) != 34) |
|
748 | - return; |
|
771 | + if (strlen($passwd_hash) != 34) { |
|
772 | + return; |
|
773 | + } |
|
749 | 774 | |
750 | 775 | // Range of characters allowed. |
751 | 776 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -756,8 +781,9 @@ discard block |
||
756 | 781 | $salt = substr($passwd_hash, 4, 8); |
757 | 782 | |
758 | 783 | $hash = md5($salt . $passwd, true); |
759 | - for (; $count != 0; --$count) |
|
760 | - $hash = md5($hash . $passwd, true); |
|
784 | + for (; $count != 0; --$count) { |
|
785 | + $hash = md5($hash . $passwd, true); |
|
786 | + } |
|
761 | 787 | |
762 | 788 | $output = substr($passwd_hash, 0, 12); |
763 | 789 | $i = 0; |
@@ -766,21 +792,25 @@ discard block |
||
766 | 792 | $value = ord($hash[$i++]); |
767 | 793 | $output .= $range[$value & 0x3f]; |
768 | 794 | |
769 | - if ($i < 16) |
|
770 | - $value |= ord($hash[$i]) << 8; |
|
795 | + if ($i < 16) { |
|
796 | + $value |= ord($hash[$i]) << 8; |
|
797 | + } |
|
771 | 798 | |
772 | 799 | $output .= $range[($value >> 6) & 0x3f]; |
773 | 800 | |
774 | - if ($i++ >= 16) |
|
775 | - break; |
|
801 | + if ($i++ >= 16) { |
|
802 | + break; |
|
803 | + } |
|
776 | 804 | |
777 | - if ($i < 16) |
|
778 | - $value |= ord($hash[$i]) << 16; |
|
805 | + if ($i < 16) { |
|
806 | + $value |= ord($hash[$i]) << 16; |
|
807 | + } |
|
779 | 808 | |
780 | 809 | $output .= $range[($value >> 12) & 0x3f]; |
781 | 810 | |
782 | - if ($i++ >= 16) |
|
783 | - break; |
|
811 | + if ($i++ >= 16) { |
|
812 | + break; |
|
813 | + } |
|
784 | 814 | |
785 | 815 | $output .= $range[($value >> 18) & 0x3f]; |
786 | 816 | } |
@@ -812,8 +842,9 @@ discard block |
||
812 | 842 | require_once($sourcedir . '/Subs-Auth.php'); |
813 | 843 | setLoginCookie(-3600, 0); |
814 | 844 | |
815 | - if (isset($_SESSION['login_' . $cookiename])) |
|
816 | - unset($_SESSION['login_' . $cookiename]); |
|
845 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
846 | + unset($_SESSION['login_' . $cookiename]); |
|
847 | + } |
|
817 | 848 | } |
818 | 849 | |
819 | 850 | // We need a member! |
@@ -827,8 +858,9 @@ discard block |
||
827 | 858 | } |
828 | 859 | |
829 | 860 | // Right, have we got a flood value? |
830 | - if ($password_flood_value !== false) |
|
831 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
861 | + if ($password_flood_value !== false) { |
|
862 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
863 | + } |
|
832 | 864 | |
833 | 865 | // Timestamp or number of tries invalid? |
834 | 866 | if (empty($number_tries) || empty($time_stamp)) |
@@ -844,15 +876,17 @@ discard block |
||
844 | 876 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
845 | 877 | |
846 | 878 | // They are trying too fast, make them wait longer |
847 | - if ($time_stamp < time() - 10) |
|
848 | - $time_stamp = time(); |
|
879 | + if ($time_stamp < time() - 10) { |
|
880 | + $time_stamp = time(); |
|
881 | + } |
|
849 | 882 | } |
850 | 883 | |
851 | 884 | $number_tries++; |
852 | 885 | |
853 | 886 | // Broken the law? |
854 | - if ($number_tries > 5) |
|
855 | - fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
887 | + if ($number_tries > 5) { |
|
888 | + fatal_lang_error('login_threshold_brute_fail', 'login', [$member_name]); |
|
889 | + } |
|
856 | 890 | |
857 | 891 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
858 | 892 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |