@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
74 | 76 | ); |
75 | 77 | |
76 | 78 | // Start with an empty array. |
77 | - if ($boardIndexOptions['include_categories']) |
|
78 | - $categories = array(); |
|
79 | - else |
|
80 | - $this_category = array(); |
|
79 | + if ($boardIndexOptions['include_categories']) { |
|
80 | + $categories = array(); |
|
81 | + } else { |
|
82 | + $this_category = array(); |
|
83 | + } |
|
81 | 84 | $boards = array(); |
82 | 85 | |
83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
89 | 92 | |
90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
92 | - $boards[] = $row_board['id_board']; |
|
94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
95 | + $boards[] = $row_board['id_board']; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ($boardIndexOptions['include_categories']) |
95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -160,14 +165,12 @@ discard block |
||
160 | 165 | { |
161 | 166 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
162 | 167 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
163 | - } |
|
164 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
168 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
165 | 169 | { |
166 | 170 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
167 | 171 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
168 | 172 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
169 | - } |
|
170 | - else |
|
173 | + } else |
|
171 | 174 | { |
172 | 175 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
173 | 176 | } |
@@ -218,14 +221,16 @@ discard block |
||
218 | 221 | // Child of a child... just add it on... |
219 | 222 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
220 | 223 | { |
221 | - if (!isset($parent_map)) |
|
222 | - $parent_map = array(); |
|
224 | + if (!isset($parent_map)) { |
|
225 | + $parent_map = array(); |
|
226 | + } |
|
223 | 227 | |
224 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
225 | - foreach ($this_category as $id => $board) |
|
228 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
229 | + foreach ($this_category as $id => $board) |
|
226 | 230 | { |
227 | 231 | if (!isset($board['children'][$row_board['id_parent']])) |
228 | 232 | continue; |
233 | + } |
|
229 | 234 | |
230 | 235 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
231 | 236 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -246,8 +251,9 @@ discard block |
||
246 | 251 | continue; |
247 | 252 | } |
248 | 253 | // Found a child of a child - skip. |
249 | - else |
|
250 | - continue; |
|
254 | + else { |
|
255 | + continue; |
|
256 | + } |
|
251 | 257 | |
252 | 258 | // Prepare the subject, and make sure it's not too long. |
253 | 259 | censorText($row_board['subject']); |
@@ -268,12 +274,13 @@ discard block |
||
268 | 274 | 'topic' => $row_board['id_topic'] |
269 | 275 | ); |
270 | 276 | |
271 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
272 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
277 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
278 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
273 | 279 | 'avatar' => $row_board['avatar'], |
274 | 280 | 'email' => $row_board['email_address'], |
275 | 281 | 'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '', |
276 | 282 | )); |
283 | + } |
|
277 | 284 | |
278 | 285 | // Provide the href and link. |
279 | 286 | if ($row_board['subject'] != '') |
@@ -285,8 +292,7 @@ discard block |
||
285 | 292 | link, href, subject, start (where they should go for the first unread post.), |
286 | 293 | and member. (which has id, name, link, href, username in it.) */ |
287 | 294 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
288 | - } |
|
289 | - else |
|
295 | + } else |
|
290 | 296 | { |
291 | 297 | $this_last_post['href'] = ''; |
292 | 298 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -294,8 +300,9 @@ discard block |
||
294 | 300 | } |
295 | 301 | |
296 | 302 | // Set the last post in the parent board. |
297 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
298 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
303 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
304 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
305 | + } |
|
299 | 306 | // Just in the child...? |
300 | 307 | if ($isChild) |
301 | 308 | { |
@@ -305,15 +312,17 @@ discard block |
||
305 | 312 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
306 | 313 | } |
307 | 314 | // No last post for this board? It's not new then, is it..? |
308 | - elseif ($row_board['poster_name'] == '') |
|
309 | - $this_category[$row_board['id_board']]['new'] = false; |
|
315 | + elseif ($row_board['poster_name'] == '') { |
|
316 | + $this_category[$row_board['id_board']]['new'] = false; |
|
317 | + } |
|
310 | 318 | |
311 | 319 | // Determine a global most recent topic. |
312 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
313 | - $latest_post = array( |
|
320 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
321 | + $latest_post = array( |
|
314 | 322 | 'timestamp' => $row_board['poster_time'], |
315 | 323 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
316 | 324 | ); |
325 | + } |
|
317 | 326 | } |
318 | 327 | $smcFunc['db_free_result']($result_boards); |
319 | 328 | |
@@ -330,8 +339,9 @@ discard block |
||
330 | 339 | if (!empty($moderators[$board['id']])) |
331 | 340 | { |
332 | 341 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
333 | - foreach ($moderators[$board['id']] as $moderator) |
|
334 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
342 | + foreach ($moderators[$board['id']] as $moderator) { |
|
343 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
344 | + } |
|
335 | 345 | } |
336 | 346 | if (!empty($groups[$board['id']])) |
337 | 347 | { |
@@ -344,16 +354,16 @@ discard block |
||
344 | 354 | } |
345 | 355 | } |
346 | 356 | } |
347 | - } |
|
348 | - else |
|
357 | + } else |
|
349 | 358 | { |
350 | 359 | foreach ($this_category as $k => $board) |
351 | 360 | { |
352 | 361 | if (!empty($moderators[$board['id']])) |
353 | 362 | { |
354 | 363 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
355 | - foreach ($moderators[$board['id']] as $moderator) |
|
356 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
364 | + foreach ($moderators[$board['id']] as $moderator) { |
|
365 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
366 | + } |
|
357 | 367 | } |
358 | 368 | if (!empty($groups[$board['id']])) |
359 | 369 | { |
@@ -367,20 +377,23 @@ discard block |
||
367 | 377 | } |
368 | 378 | } |
369 | 379 | |
370 | - if ($boardIndexOptions['include_categories']) |
|
371 | - sortCategories($categories); |
|
372 | - else |
|
373 | - sortBoards($this_category); |
|
380 | + if ($boardIndexOptions['include_categories']) { |
|
381 | + sortCategories($categories); |
|
382 | + } else { |
|
383 | + sortBoards($this_category); |
|
384 | + } |
|
374 | 385 | |
375 | 386 | // By now we should know the most recent post...if we wanna know it that is. |
376 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
377 | - $context['latest_post'] = $latest_post['ref']; |
|
387 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
388 | + $context['latest_post'] = $latest_post['ref']; |
|
389 | + } |
|
378 | 390 | |
379 | 391 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
380 | - if ($boardIndexOptions['include_categories']) |
|
381 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
382 | - else |
|
383 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
392 | + if ($boardIndexOptions['include_categories']) { |
|
393 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
394 | + } else { |
|
395 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
396 | + } |
|
384 | 397 | |
385 | 398 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
386 | 399 | } |
@@ -51,30 +51,33 @@ discard block |
||
51 | 51 | $ignored_members = explode(',', $row['pm_ignore_list']); |
52 | 52 | |
53 | 53 | // If the user is in group 1 anywhere, they can see everything anyway. |
54 | - if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) |
|
55 | - $author = $row['id_member']; |
|
54 | + if (in_array(1, $groups) || count(array_intersect($allowed, $groups)) != 0) { |
|
55 | + $author = $row['id_member']; |
|
56 | + } |
|
56 | 57 | } |
57 | 58 | $smcFunc['db_free_result']($request); |
58 | - } |
|
59 | - else |
|
59 | + } else |
|
60 | 60 | { |
61 | 61 | // This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id. |
62 | 62 | $hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id'])); |
63 | - foreach ($hook_results as $result) |
|
64 | - if (!empty($result)) |
|
63 | + foreach ($hook_results as $result) { |
|
64 | + if (!empty($result)) |
|
65 | 65 | { |
66 | 66 | $author = $result; |
67 | + } |
|
67 | 68 | break; |
68 | 69 | } |
69 | 70 | } |
70 | 71 | |
71 | 72 | // If we didn't have a member... leave. |
72 | - if (empty($author)) |
|
73 | - return true; |
|
73 | + if (empty($author)) { |
|
74 | + return true; |
|
75 | + } |
|
74 | 76 | |
75 | 77 | // If the person who sent the notification is the person whose content it is, do nothing. |
76 | - if ($author == $this->_details['sender_id']) |
|
77 | - return true; |
|
78 | + if ($author == $this->_details['sender_id']) { |
|
79 | + return true; |
|
80 | + } |
|
78 | 81 | |
79 | 82 | // If the person who sent the notification is on this person's ignore list, do nothing. |
80 | 83 | if (!empty($ignored_members) && in_array($this->_details['sender_id'], $ignored_members)) { |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | // As a result, the value should really just be non empty. |
89 | 92 | |
90 | 93 | // Check the value. If no value or it's empty, they didn't want alerts, oh well. |
91 | - if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) |
|
92 | - return true; |
|
94 | + if (empty($prefs[$author][$this->_details['content_type'] . '_like'])) { |
|
95 | + return true; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | // Don't spam the alerts: if there is an existing unread alert of the |
95 | 99 | // requested type for the target user from the sender, don't make a new one. |
@@ -109,8 +113,9 @@ discard block |
||
109 | 113 | ) |
110 | 114 | ); |
111 | 115 | |
112 | - if ($smcFunc['db_num_rows']($request) > 0) |
|
113 | - return true; |
|
116 | + if ($smcFunc['db_num_rows']($request) > 0) { |
|
117 | + return true; |
|
118 | + } |
|
114 | 119 | $smcFunc['db_free_result']($request); |
115 | 120 | |
116 | 121 | // Issue, update, move on. |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | if (!empty($modSettings['search_simple_fulltext'])) |
208 | 208 | { |
209 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
209 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
210 | 210 | { |
211 | 211 | $language_ftx = $smcFunc['db_search_language'](); |
212 | 212 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // remove any indexed words that are used in the complex body search terms |
225 | 225 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
226 | 226 | |
227 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
227 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
228 | 228 | $row = 0; |
229 | 229 | foreach ($words['indexed_words'] as $fulltextWord) { |
230 | 230 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | // if we have bool terms to search, add them in |
242 | 242 | if ($query_params['boolean_match']) { |
243 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
243 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
244 | 244 | { |
245 | 245 | $language_ftx = $smcFunc['db_search_language'](); |
246 | 246 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
256 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
257 | 257 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
258 | 258 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
259 | 259 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
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 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,41 +168,50 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if ($query_params['id_search']) |
|
170 | - $query_select['id_search'] = '{int:id_search}'; |
|
171 | + if ($query_params['id_search']) { |
|
172 | + $query_select['id_search'] = '{int:id_search}'; |
|
173 | + } |
|
171 | 174 | |
172 | 175 | $count = 0; |
173 | - if (empty($modSettings['search_simple_fulltext'])) |
|
174 | - foreach ($words['words'] as $regularWord) |
|
176 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
177 | + foreach ($words['words'] as $regularWord) |
|
175 | 178 | { |
176 | 179 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
180 | + } |
|
177 | 181 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
178 | 182 | } |
179 | 183 | |
180 | - if ($query_params['user_query']) |
|
181 | - $query_where[] = '{raw:user_query}'; |
|
182 | - if ($query_params['board_query']) |
|
183 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
184 | + if ($query_params['user_query']) { |
|
185 | + $query_where[] = '{raw:user_query}'; |
|
186 | + } |
|
187 | + if ($query_params['board_query']) { |
|
188 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
189 | + } |
|
184 | 190 | |
185 | - if ($query_params['topic']) |
|
186 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
187 | - if ($query_params['min_msg_id']) |
|
188 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
189 | - if ($query_params['max_msg_id']) |
|
190 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
191 | + if ($query_params['topic']) { |
|
192 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
193 | + } |
|
194 | + if ($query_params['min_msg_id']) { |
|
195 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
196 | + } |
|
197 | + if ($query_params['max_msg_id']) { |
|
198 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
199 | + } |
|
191 | 200 | |
192 | 201 | $count = 0; |
193 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
194 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
202 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
203 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
195 | 204 | { |
196 | 205 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
206 | + } |
|
197 | 207 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
198 | 208 | } |
199 | 209 | $count = 0; |
200 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
201 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
210 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
211 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
202 | 212 | { |
203 | 213 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
214 | + } |
|
204 | 215 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
205 | 216 | } |
206 | 217 | |
@@ -212,12 +223,11 @@ discard block |
||
212 | 223 | |
213 | 224 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})'; |
214 | 225 | $query_params['language_ftx'] = $language_ftx; |
226 | + } else { |
|
227 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
215 | 228 | } |
216 | - else |
|
217 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 229 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
219 | - } |
|
220 | - else |
|
230 | + } else |
|
221 | 231 | { |
222 | 232 | $query_params['boolean_match'] = ''; |
223 | 233 | |
@@ -231,10 +241,10 @@ discard block |
||
231 | 241 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
232 | 242 | $row++; |
233 | 243 | } |
234 | - } |
|
235 | - else |
|
236 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
244 | + } else { |
|
245 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
237 | 246 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
247 | + } |
|
238 | 248 | |
239 | 249 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
240 | 250 | |
@@ -246,9 +256,9 @@ discard block |
||
246 | 256 | |
247 | 257 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})'; |
248 | 258 | $query_params['language_ftx'] = $language_ftx; |
259 | + } else { |
|
260 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
249 | 261 | } |
250 | - else |
|
251 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 262 | } |
253 | 263 | |
254 | 264 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $version = $smcFunc['db_get_version'](); |
39 | 39 | // if we got a Beta Version |
40 | 40 | if (stripos($version, 'beta') !== false) |
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
41 | + $version = substr($version, 0, stripos($version, 'beta')) . '.0'; |
|
42 | 42 | // or RC |
43 | 43 | if (stripos($version, 'rc') !== false) |
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
44 | + $version = substr($version, 0, stripos($version, 'rc')) . '.0'; |
|
45 | 45 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
46 | + if (version_compare($version, '9.5.0', '>=')) |
|
47 | 47 | $smcFunc['db_support_ignore'] = true; |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function smf_db_search_support($search_type) |
57 | 57 | { |
58 | - $supported_types = array('custom','fulltext'); |
|
58 | + $supported_types = array('custom', 'fulltext'); |
|
59 | 59 | |
60 | 60 | return in_array($search_type, $supported_types); |
61 | 61 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 110 | { |
111 | 111 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | - if ($smcFunc['db_support_ignore']){ |
|
112 | + if ($smcFunc['db_support_ignore']) { |
|
113 | 113 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | - $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
|
114 | + $db_string = $db_string . ' ON CONFLICT DO NOTHING'; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $language_ftx = $modSettings['search_language']; |
169 | 169 | else |
170 | 170 | { |
171 | - $request = $smcFunc['db_query']('',' |
|
171 | + $request = $smcFunc['db_query']('', ' |
|
172 | 172 | SHOW default_text_search_config', |
173 | 173 | array() |
174 | 174 | ); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,29 +24,33 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_search_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => false, |
32 | 33 | 'db_search_language' => 'smf_db_search_language', |
33 | 34 | ); |
35 | + } |
|
34 | 36 | |
35 | 37 | db_extend(); |
36 | 38 | |
37 | 39 | //pg 9.5 got ignore support |
38 | 40 | $version = $smcFunc['db_get_version'](); |
39 | 41 | // if we got a Beta Version |
40 | - if (stripos($version, 'beta') !== false) |
|
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
42 | + if (stripos($version, 'beta') !== false) { |
|
43 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
44 | + } |
|
42 | 45 | // or RC |
43 | - if (stripos($version, 'rc') !== false) |
|
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
46 | + if (stripos($version, 'rc') !== false) { |
|
47 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
48 | + } |
|
45 | 49 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
47 | - $smcFunc['db_support_ignore'] = true; |
|
48 | -} |
|
50 | + if (version_compare($version,'9.5.0','>=')) { |
|
51 | + $smcFunc['db_support_ignore'] = true; |
|
52 | + } |
|
53 | + } |
|
49 | 54 | |
50 | 55 | /** |
51 | 56 | * This function will tell you whether this database type supports this search type. |
@@ -104,16 +109,16 @@ discard block |
||
104 | 109 | ), |
105 | 110 | ); |
106 | 111 | |
107 | - if (isset($replacements[$identifier])) |
|
108 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
112 | + if (isset($replacements[$identifier])) { |
|
113 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
114 | + } |
|
109 | 115 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 116 | { |
111 | 117 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | 118 | if ($smcFunc['db_support_ignore']){ |
113 | 119 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | 120 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
115 | - } |
|
116 | - else |
|
121 | + } else |
|
117 | 122 | { |
118 | 123 | // Don't error on multi-insert. |
119 | 124 | $db_values['db_error_skip'] = true; |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | //fix double quotes |
124 | - if ($identifier == 'insert_into_log_messages_fulltext') |
|
125 | - $db_values = str_replace('"', "'", $db_values); |
|
129 | + if ($identifier == 'insert_into_log_messages_fulltext') { |
|
130 | + $db_values = str_replace('"', "'", $db_values); |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $return = $smcFunc['db_query']('', $db_string, |
128 | 134 | $db_values, $connection |
@@ -164,9 +170,9 @@ discard block |
||
164 | 170 | |
165 | 171 | $language_ftx = 'english'; |
166 | 172 | |
167 | - if (!empty($modSettings['search_language'])) |
|
168 | - $language_ftx = $modSettings['search_language']; |
|
169 | - else |
|
173 | + if (!empty($modSettings['search_language'])) { |
|
174 | + $language_ftx = $modSettings['search_language']; |
|
175 | + } else |
|
170 | 176 | { |
171 | 177 | $request = $smcFunc['db_query']('',' |
172 | 178 | SHOW default_text_search_config', |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get 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 | } |
@@ -157,8 +159,9 @@ discard block |
||
157 | 159 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
158 | 160 | { |
159 | 161 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
160 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
161 | - continue; |
|
162 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
163 | + continue; |
|
164 | + } |
|
162 | 165 | |
163 | 166 | // Force a censor of the title - as often these are used by others. |
164 | 167 | censorText($row['title'], $use_permissions ? false : true); |
@@ -167,8 +170,9 @@ discard block |
||
167 | 170 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
168 | 171 | |
169 | 172 | // Sanity check |
170 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
171 | - continue; |
|
173 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
174 | + continue; |
|
175 | + } |
|
172 | 176 | |
173 | 177 | // Get set up for the loop |
174 | 178 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz)); |
@@ -232,8 +236,8 @@ discard block |
||
232 | 236 | ); |
233 | 237 | |
234 | 238 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
235 | - if ($use_permissions) |
|
236 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
239 | + if ($use_permissions) { |
|
240 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
237 | 241 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
238 | 242 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
239 | 243 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -241,9 +245,10 @@ discard block |
||
241 | 245 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
242 | 246 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
243 | 247 | )); |
248 | + } |
|
244 | 249 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
245 | - else |
|
246 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
250 | + else { |
|
251 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
247 | 252 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
248 | 253 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
249 | 254 | 'can_edit' => false, |
@@ -253,6 +258,7 @@ discard block |
||
253 | 258 | 'poster' => $row['id_member'], |
254 | 259 | 'allowed_groups' => explode(',', $row['member_groups']), |
255 | 260 | )); |
261 | + } |
|
256 | 262 | |
257 | 263 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
258 | 264 | } |
@@ -262,8 +268,9 @@ discard block |
||
262 | 268 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
263 | 269 | if ($use_permissions) |
264 | 270 | { |
265 | - foreach ($events as $mday => $array) |
|
266 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
271 | + foreach ($events as $mday => $array) { |
|
272 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
273 | + } |
|
267 | 274 | } |
268 | 275 | |
269 | 276 | ksort($events); |
@@ -283,11 +290,12 @@ discard block |
||
283 | 290 | global $smcFunc; |
284 | 291 | |
285 | 292 | // Get the lowest and highest dates for "all years". |
286 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
287 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
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} |
|
288 | 295 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
289 | - else |
|
290 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
296 | + } else { |
|
297 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
298 | + } |
|
291 | 299 | |
292 | 300 | // Find some holidays... ;). |
293 | 301 | $result = $smcFunc['db_query']('', ' |
@@ -307,10 +315,11 @@ discard block |
||
307 | 315 | $holidays = array(); |
308 | 316 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
309 | 317 | { |
310 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
311 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
312 | - else |
|
313 | - $event_year = substr($low_date, 0, 4); |
|
318 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
319 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
320 | + } else { |
|
321 | + $event_year = substr($low_date, 0, 4); |
|
322 | + } |
|
314 | 323 | |
315 | 324 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
316 | 325 | } |
@@ -336,10 +345,12 @@ discard block |
||
336 | 345 | isAllowedTo('calendar_post'); |
337 | 346 | |
338 | 347 | // No board? No topic?!? |
339 | - if (empty($board)) |
|
340 | - fatal_lang_error('missing_board_id', false); |
|
341 | - if (empty($topic)) |
|
342 | - fatal_lang_error('missing_topic_id', false); |
|
348 | + if (empty($board)) { |
|
349 | + fatal_lang_error('missing_board_id', false); |
|
350 | + } |
|
351 | + if (empty($topic)) { |
|
352 | + fatal_lang_error('missing_topic_id', false); |
|
353 | + } |
|
343 | 354 | |
344 | 355 | // Administrator, Moderator, or owner. Period. |
345 | 356 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -357,12 +368,14 @@ discard block |
||
357 | 368 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
358 | 369 | { |
359 | 370 | // Not the owner of the topic. |
360 | - if ($row['id_member_started'] != $user_info['id']) |
|
361 | - fatal_lang_error('not_your_topic', 'user'); |
|
371 | + if ($row['id_member_started'] != $user_info['id']) { |
|
372 | + fatal_lang_error('not_your_topic', 'user'); |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | // Topic/Board doesn't exist..... |
364 | - else |
|
365 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
376 | + else { |
|
377 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
378 | + } |
|
366 | 379 | $smcFunc['db_free_result']($result); |
367 | 380 | } |
368 | 381 | } |
@@ -450,14 +463,16 @@ discard block |
||
450 | 463 | if (!empty($calendarOptions['start_day'])) |
451 | 464 | { |
452 | 465 | $nShift -= $calendarOptions['start_day']; |
453 | - if ($nShift < 0) |
|
454 | - $nShift = 7 + $nShift; |
|
466 | + if ($nShift < 0) { |
|
467 | + $nShift = 7 + $nShift; |
|
468 | + } |
|
455 | 469 | } |
456 | 470 | |
457 | 471 | // Number of rows required to fit the month. |
458 | 472 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
459 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
460 | - $nRows++; |
|
473 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
474 | + $nRows++; |
|
475 | + } |
|
461 | 476 | |
462 | 477 | // Fetch the arrays for birthdays, posted events, and holidays. |
463 | 478 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -470,8 +485,9 @@ discard block |
||
470 | 485 | { |
471 | 486 | $calendarGrid['week_days'][] = $count; |
472 | 487 | $count++; |
473 | - if ($count == 7) |
|
474 | - $count = 0; |
|
488 | + if ($count == 7) { |
|
489 | + $count = 0; |
|
490 | + } |
|
475 | 491 | } |
476 | 492 | |
477 | 493 | // Iterate through each week. |
@@ -488,8 +504,9 @@ discard block |
||
488 | 504 | { |
489 | 505 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
490 | 506 | |
491 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
492 | - $nDay = 0; |
|
507 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
508 | + $nDay = 0; |
|
509 | + } |
|
493 | 510 | |
494 | 511 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
495 | 512 | |
@@ -507,8 +524,9 @@ discard block |
||
507 | 524 | } |
508 | 525 | |
509 | 526 | // What is the last day of the month? |
510 | - if ($is_previous === true) |
|
511 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
527 | + if ($is_previous === true) { |
|
528 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
529 | + } |
|
512 | 530 | |
513 | 531 | // We'll use the shift in the template. |
514 | 532 | $calendarGrid['shift'] = $nShift; |
@@ -542,8 +560,9 @@ discard block |
||
542 | 560 | { |
543 | 561 | // Here we offset accordingly to get things to the real start of a week. |
544 | 562 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
545 | - if ($date_diff < 0) |
|
546 | - $date_diff += 7; |
|
563 | + if ($date_diff < 0) { |
|
564 | + $date_diff += 7; |
|
565 | + } |
|
547 | 566 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
548 | 567 | $day = (int) strftime('%d', $new_timestamp); |
549 | 568 | $month = (int) strftime('%m', $new_timestamp); |
@@ -673,18 +692,20 @@ discard block |
||
673 | 692 | { |
674 | 693 | foreach ($date_events as $event_key => $event_val) |
675 | 694 | { |
676 | - if (in_array($event_val['id'], $temp)) |
|
677 | - unset($calendarGrid['events'][$date][$event_key]); |
|
678 | - else |
|
679 | - $temp[] = $event_val['id']; |
|
695 | + if (in_array($event_val['id'], $temp)) { |
|
696 | + unset($calendarGrid['events'][$date][$event_key]); |
|
697 | + } else { |
|
698 | + $temp[] = $event_val['id']; |
|
699 | + } |
|
680 | 700 | } |
681 | 701 | } |
682 | 702 | |
683 | 703 | // Give birthdays and holidays a friendly format, without the year |
684 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
685 | - $date_format = '%b %d'; |
|
686 | - else |
|
687 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
704 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
705 | + $date_format = '%b %d'; |
|
706 | + } else { |
|
707 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
708 | + } |
|
688 | 709 | |
689 | 710 | foreach (array('birthdays', 'holidays') as $type) |
690 | 711 | { |
@@ -792,8 +813,9 @@ discard block |
||
792 | 813 | // Holidays between now and now + days. |
793 | 814 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
794 | 815 | { |
795 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
796 | - $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 | + } |
|
797 | 819 | } |
798 | 820 | |
799 | 821 | // Happy Birthday, guys and gals! |
@@ -802,8 +824,9 @@ discard block |
||
802 | 824 | $loop_date = strftime('%Y-%m-%d', $i); |
803 | 825 | if (isset($cached_data['birthdays'][$loop_date])) |
804 | 826 | { |
805 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
806 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
827 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
828 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
829 | + } |
|
807 | 830 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
808 | 831 | } |
809 | 832 | } |
@@ -815,8 +838,9 @@ discard block |
||
815 | 838 | $loop_date = strftime('%Y-%m-%d', $i); |
816 | 839 | |
817 | 840 | // No events today? Check the next day. |
818 | - if (empty($cached_data['events'][$loop_date])) |
|
819 | - continue; |
|
841 | + if (empty($cached_data['events'][$loop_date])) { |
|
842 | + continue; |
|
843 | + } |
|
820 | 844 | |
821 | 845 | // Loop through all events to add a few last-minute values. |
822 | 846 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -829,9 +853,9 @@ discard block |
||
829 | 853 | { |
830 | 854 | unset($cached_data['events'][$loop_date][$ev]); |
831 | 855 | continue; |
856 | + } else { |
|
857 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
832 | 858 | } |
833 | - else |
|
834 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
835 | 859 | |
836 | 860 | // Might be set to true afterwards, depending on the permissions. |
837 | 861 | $this_event['can_edit'] = false; |
@@ -839,15 +863,18 @@ discard block |
||
839 | 863 | $this_event['date'] = $loop_date; |
840 | 864 | } |
841 | 865 | |
842 | - if (!empty($cached_data['events'][$loop_date])) |
|
843 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
866 | + if (!empty($cached_data['events'][$loop_date])) { |
|
867 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
868 | + } |
|
844 | 869 | } |
845 | 870 | |
846 | 871 | // Mark the last item so that a list separator can be used in the template. |
847 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
848 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
849 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
850 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
872 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
873 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
874 | + } |
|
875 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
876 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
877 | + } |
|
851 | 878 | |
852 | 879 | return array( |
853 | 880 | 'data' => $return_data, |
@@ -895,37 +922,46 @@ discard block |
||
895 | 922 | if (isset($_POST['start_date'])) |
896 | 923 | { |
897 | 924 | $d = date_parse($_POST['start_date']); |
898 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
899 | - fatal_lang_error('invalid_date', false); |
|
900 | - if (empty($d['year'])) |
|
901 | - fatal_lang_error('event_year_missing', false); |
|
902 | - if (empty($d['month'])) |
|
903 | - fatal_lang_error('event_month_missing', false); |
|
904 | - } |
|
905 | - elseif (isset($_POST['start_datetime'])) |
|
925 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
926 | + fatal_lang_error('invalid_date', false); |
|
927 | + } |
|
928 | + if (empty($d['year'])) { |
|
929 | + fatal_lang_error('event_year_missing', false); |
|
930 | + } |
|
931 | + if (empty($d['month'])) { |
|
932 | + fatal_lang_error('event_month_missing', false); |
|
933 | + } |
|
934 | + } elseif (isset($_POST['start_datetime'])) |
|
906 | 935 | { |
907 | 936 | $d = date_parse($_POST['start_datetime']); |
908 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
909 | - fatal_lang_error('invalid_date', false); |
|
910 | - if (empty($d['year'])) |
|
911 | - fatal_lang_error('event_year_missing', false); |
|
912 | - if (empty($d['month'])) |
|
913 | - fatal_lang_error('event_month_missing', false); |
|
937 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
938 | + fatal_lang_error('invalid_date', false); |
|
939 | + } |
|
940 | + if (empty($d['year'])) { |
|
941 | + fatal_lang_error('event_year_missing', false); |
|
942 | + } |
|
943 | + if (empty($d['month'])) { |
|
944 | + fatal_lang_error('event_month_missing', false); |
|
945 | + } |
|
914 | 946 | } |
915 | 947 | // The 2.0 way |
916 | 948 | else |
917 | 949 | { |
918 | 950 | // No month? No year? |
919 | - if (!isset($_POST['month'])) |
|
920 | - fatal_lang_error('event_month_missing', false); |
|
921 | - if (!isset($_POST['year'])) |
|
922 | - fatal_lang_error('event_year_missing', false); |
|
951 | + if (!isset($_POST['month'])) { |
|
952 | + fatal_lang_error('event_month_missing', false); |
|
953 | + } |
|
954 | + if (!isset($_POST['year'])) { |
|
955 | + fatal_lang_error('event_year_missing', false); |
|
956 | + } |
|
923 | 957 | |
924 | 958 | // Check the month and year... |
925 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
926 | - fatal_lang_error('invalid_month', false); |
|
927 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
928 | - fatal_lang_error('invalid_year', false); |
|
959 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
960 | + fatal_lang_error('invalid_month', false); |
|
961 | + } |
|
962 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
963 | + fatal_lang_error('invalid_year', false); |
|
964 | + } |
|
929 | 965 | } |
930 | 966 | } |
931 | 967 | |
@@ -935,8 +971,9 @@ discard block |
||
935 | 971 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
936 | 972 | if (isset($_POST['span'])) |
937 | 973 | { |
938 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
939 | - fatal_lang_error('invalid_days_numb', false); |
|
974 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
975 | + fatal_lang_error('invalid_days_numb', false); |
|
976 | + } |
|
940 | 977 | } |
941 | 978 | |
942 | 979 | // There is no need to validate the following values if we are just deleting the event. |
@@ -946,24 +983,29 @@ discard block |
||
946 | 983 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
947 | 984 | { |
948 | 985 | // No day? |
949 | - if (!isset($_POST['day'])) |
|
950 | - fatal_lang_error('event_day_missing', false); |
|
986 | + if (!isset($_POST['day'])) { |
|
987 | + fatal_lang_error('event_day_missing', false); |
|
988 | + } |
|
951 | 989 | |
952 | 990 | // Bad day? |
953 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
954 | - fatal_lang_error('invalid_date', false); |
|
991 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
992 | + fatal_lang_error('invalid_date', false); |
|
993 | + } |
|
955 | 994 | } |
956 | 995 | |
957 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
958 | - fatal_lang_error('event_title_missing', false); |
|
959 | - elseif (!isset($_POST['evtitle'])) |
|
960 | - $_POST['evtitle'] = $_POST['subject']; |
|
996 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
997 | + fatal_lang_error('event_title_missing', false); |
|
998 | + } elseif (!isset($_POST['evtitle'])) { |
|
999 | + $_POST['evtitle'] = $_POST['subject']; |
|
1000 | + } |
|
961 | 1001 | |
962 | 1002 | // No title? |
963 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
964 | - fatal_lang_error('no_event_title', false); |
|
965 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
966 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1003 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1004 | + fatal_lang_error('no_event_title', false); |
|
1005 | + } |
|
1006 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
1007 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
1008 | + } |
|
967 | 1009 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
968 | 1010 | } |
969 | 1011 | } |
@@ -990,8 +1032,9 @@ discard block |
||
990 | 1032 | ); |
991 | 1033 | |
992 | 1034 | // No results, return false. |
993 | - if ($smcFunc['db_num_rows'] === 0) |
|
994 | - return false; |
|
1035 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1036 | + return false; |
|
1037 | + } |
|
995 | 1038 | |
996 | 1039 | // Grab the results and return. |
997 | 1040 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1125,8 +1168,9 @@ discard block |
||
1125 | 1168 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1126 | 1169 | |
1127 | 1170 | $column_clauses = array(); |
1128 | - foreach ($event_columns as $col => $crit) |
|
1129 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1171 | + foreach ($event_columns as $col => $crit) { |
|
1172 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1173 | + } |
|
1130 | 1174 | |
1131 | 1175 | $smcFunc['db_query']('', ' |
1132 | 1176 | UPDATE {db_prefix}calendar |
@@ -1211,8 +1255,9 @@ discard block |
||
1211 | 1255 | ); |
1212 | 1256 | |
1213 | 1257 | // If nothing returned, we are in poo, poo. |
1214 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1215 | - return false; |
|
1258 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1259 | + return false; |
|
1260 | + } |
|
1216 | 1261 | |
1217 | 1262 | $row = $smcFunc['db_fetch_assoc']($request); |
1218 | 1263 | $smcFunc['db_free_result']($request); |
@@ -1220,8 +1265,9 @@ discard block |
||
1220 | 1265 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1221 | 1266 | |
1222 | 1267 | // Sanity check |
1223 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1224 | - return false; |
|
1268 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1269 | + return false; |
|
1270 | + } |
|
1225 | 1271 | |
1226 | 1272 | $return_value = array( |
1227 | 1273 | 'boards' => array(), |
@@ -1358,24 +1404,27 @@ discard block |
||
1358 | 1404 | |
1359 | 1405 | // Set $span, in case we need it |
1360 | 1406 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1361 | - if ($span > 0) |
|
1362 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1407 | + if ($span > 0) { |
|
1408 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1409 | + } |
|
1363 | 1410 | |
1364 | 1411 | // Define the timezone for this event, falling back to the default if not provided |
1365 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1366 | - $tz = $eventOptions['tz']; |
|
1367 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1368 | - $tz = $_POST['tz']; |
|
1369 | - else |
|
1370 | - $tz = getUserTimezone(); |
|
1412 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1413 | + $tz = $eventOptions['tz']; |
|
1414 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1415 | + $tz = $_POST['tz']; |
|
1416 | + } else { |
|
1417 | + $tz = getUserTimezone(); |
|
1418 | + } |
|
1371 | 1419 | |
1372 | 1420 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1373 | - if (isset($eventOptions['allday'])) |
|
1374 | - $allday = $eventOptions['allday']; |
|
1375 | - elseif (empty($_POST['allday'])) |
|
1376 | - $allday = false; |
|
1377 | - else |
|
1378 | - $allday = true; |
|
1421 | + if (isset($eventOptions['allday'])) { |
|
1422 | + $allday = $eventOptions['allday']; |
|
1423 | + } elseif (empty($_POST['allday'])) { |
|
1424 | + $allday = false; |
|
1425 | + } else { |
|
1426 | + $allday = true; |
|
1427 | + } |
|
1379 | 1428 | |
1380 | 1429 | // Input might come as individual parameters... |
1381 | 1430 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1402,10 +1451,12 @@ discard block |
||
1402 | 1451 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1403 | 1452 | |
1404 | 1453 | // If the date and time were given in separate strings, combine them |
1405 | - if (empty($start_string) && isset($start_date_string)) |
|
1406 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1407 | - if (empty($end_string) && isset($end_date_string)) |
|
1408 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1454 | + if (empty($start_string) && isset($start_date_string)) { |
|
1455 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1456 | + } |
|
1457 | + if (empty($end_string) && isset($end_date_string)) { |
|
1458 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1459 | + } |
|
1409 | 1460 | |
1410 | 1461 | // If some form of string input was given, override individually defined options with it |
1411 | 1462 | if (isset($start_string)) |
@@ -1496,10 +1547,11 @@ discard block |
||
1496 | 1547 | if ($start_object >= $end_object) |
1497 | 1548 | { |
1498 | 1549 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1499 | - if ($span > 0) |
|
1500 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1501 | - else |
|
1502 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1550 | + if ($span > 0) { |
|
1551 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1552 | + } else { |
|
1553 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1554 | + } |
|
1503 | 1555 | } |
1504 | 1556 | |
1505 | 1557 | // Is $end_object too late? |
@@ -1512,9 +1564,9 @@ discard block |
||
1512 | 1564 | { |
1513 | 1565 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1514 | 1566 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1567 | + } else { |
|
1568 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1515 | 1569 | } |
1516 | - else |
|
1517 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1518 | 1570 | } |
1519 | 1571 | } |
1520 | 1572 | |
@@ -1527,8 +1579,7 @@ discard block |
||
1527 | 1579 | $start_time = null; |
1528 | 1580 | $end_time = null; |
1529 | 1581 | $tz = null; |
1530 | - } |
|
1531 | - else |
|
1582 | + } else |
|
1532 | 1583 | { |
1533 | 1584 | $start_time = date_format($start_object, 'H:i:s'); |
1534 | 1585 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1549,16 +1600,18 @@ discard block |
||
1549 | 1600 | require_once($sourcedir . '/Subs.php'); |
1550 | 1601 | |
1551 | 1602 | // First, try to create a better date format, ignoring the "time" elements. |
1552 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1553 | - $date_format = '%F'; |
|
1554 | - else |
|
1555 | - $date_format = $matches[0]; |
|
1603 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1604 | + $date_format = '%F'; |
|
1605 | + } else { |
|
1606 | + $date_format = $matches[0]; |
|
1607 | + } |
|
1556 | 1608 | |
1557 | 1609 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1558 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1559 | - $time_format = '%k:%M'; |
|
1560 | - else |
|
1561 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1610 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1611 | + $time_format = '%k:%M'; |
|
1612 | + } else { |
|
1613 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1614 | + } |
|
1562 | 1615 | |
1563 | 1616 | // Should this be an all day event? |
1564 | 1617 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
@@ -1567,8 +1620,9 @@ discard block |
||
1567 | 1620 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1568 | 1621 | |
1569 | 1622 | // We need to have a defined timezone in the steps below |
1570 | - if (empty($row['timezone'])) |
|
1571 | - $row['timezone'] = getUserTimezone(); |
|
1623 | + if (empty($row['timezone'])) { |
|
1624 | + $row['timezone'] = getUserTimezone(); |
|
1625 | + } |
|
1572 | 1626 | |
1573 | 1627 | // Get most of the standard date information for the start and end datetimes |
1574 | 1628 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1620,8 +1674,9 @@ discard block |
||
1620 | 1674 | global $smcFunc, $context, $sourcedir, $user_info, $modSettings; |
1621 | 1675 | static $member_cache = array(); |
1622 | 1676 | |
1623 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1624 | - $id_member = $context['user']['id']; |
|
1677 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1678 | + $id_member = $context['user']['id']; |
|
1679 | + } |
|
1625 | 1680 | |
1626 | 1681 | //check if the cache got the data |
1627 | 1682 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1643,11 +1698,13 @@ discard block |
||
1643 | 1698 | $smcFunc['db_free_result']($request); |
1644 | 1699 | } |
1645 | 1700 | |
1646 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1647 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1701 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1702 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1703 | + } |
|
1648 | 1704 | |
1649 | - if (isset($id_member)) |
|
1650 | - $member_cache[$id_member] = $timezone; |
|
1705 | + if (isset($id_member)) { |
|
1706 | + $member_cache[$id_member] = $timezone; |
|
1707 | + } |
|
1651 | 1708 | |
1652 | 1709 | return $timezone; |
1653 | 1710 | } |
@@ -1676,8 +1733,9 @@ discard block |
||
1676 | 1733 | ) |
1677 | 1734 | ); |
1678 | 1735 | $holidays = array(); |
1679 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1680 | - $holidays[] = $row; |
|
1736 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1737 | + $holidays[] = $row; |
|
1738 | + } |
|
1681 | 1739 | $smcFunc['db_free_result']($request); |
1682 | 1740 | |
1683 | 1741 | return $holidays; |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
257 | 257 | |
258 | 258 | $js_time_string = str_replace( |
259 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
259 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
260 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
261 | 261 | $time_string |
262 | 262 | ); |
263 | 263 | |
@@ -1306,14 +1306,14 @@ discard block |
||
1306 | 1306 | if (isset($context['name']) && isset($context['email'])) |
1307 | 1307 | { |
1308 | 1308 | $context['posting_fields']['guestname'] = array( |
1309 | - 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1309 | + 'dt' => '<span id="caption_guestname"' . (isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '') . '>' . $txt['name'] . '</span>', |
|
1310 | 1310 | 'dd' => '<input type="text" name="guestname" size="25" value="' . $context['name'] . '" class="input_text" required>', |
1311 | 1311 | ); |
1312 | 1312 | |
1313 | 1313 | if (empty($modSettings['guest_post_no_email'])) |
1314 | 1314 | { |
1315 | 1315 | $context['posting_fields']['email'] = array( |
1316 | - 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1316 | + 'dt' => '<span id="caption_email"' . (isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '') . '>' . $txt['email'] . '</span>', |
|
1317 | 1317 | 'dd' => '<input type="email" name="email" size="25" value="' . $context['email'] . '" class="input_text" required>', |
1318 | 1318 | ); |
1319 | 1319 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Handles showing the post screen, loading the post to be modified, and loading any post quoted. |
@@ -35,12 +36,14 @@ discard block |
||
35 | 36 | global $sourcedir, $smcFunc, $language; |
36 | 37 | |
37 | 38 | loadLanguage('Post'); |
38 | - if (!empty($modSettings['drafts_post_enabled'])) |
|
39 | - loadLanguage('Drafts'); |
|
39 | + if (!empty($modSettings['drafts_post_enabled'])) { |
|
40 | + loadLanguage('Drafts'); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | // You can't reply with a poll... hacker. |
42 | - if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) |
|
43 | - unset($_REQUEST['poll']); |
|
44 | + if (isset($_REQUEST['poll']) && !empty($topic) && !isset($_REQUEST['msg'])) { |
|
45 | + unset($_REQUEST['poll']); |
|
46 | + } |
|
44 | 47 | |
45 | 48 | // Posting an event? |
46 | 49 | $context['make_event'] = isset($_REQUEST['calendar']); |
@@ -54,8 +57,9 @@ discard block |
||
54 | 57 | $context['auto_notify'] = !empty($context['notify_prefs']['msg_auto_notify']); |
55 | 58 | |
56 | 59 | // You must be posting to *some* board. |
57 | - if (empty($board) && !$context['make_event']) |
|
58 | - fatal_lang_error('no_board', false); |
|
60 | + if (empty($board) && !$context['make_event']) { |
|
61 | + fatal_lang_error('no_board', false); |
|
62 | + } |
|
59 | 63 | |
60 | 64 | require_once($sourcedir . '/Subs-Post.php'); |
61 | 65 | |
@@ -78,10 +82,11 @@ discard block |
||
78 | 82 | array( |
79 | 83 | 'msg' => (int) $_REQUEST['msg'], |
80 | 84 | )); |
81 | - if ($smcFunc['db_num_rows']($request) != 1) |
|
82 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
83 | - else |
|
84 | - list ($topic) = $smcFunc['db_fetch_row']($request); |
|
85 | + if ($smcFunc['db_num_rows']($request) != 1) { |
|
86 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
87 | + } else { |
|
88 | + list ($topic) = $smcFunc['db_fetch_row']($request); |
|
89 | + } |
|
85 | 90 | $smcFunc['db_free_result']($request); |
86 | 91 | } |
87 | 92 | |
@@ -108,33 +113,36 @@ discard block |
||
108 | 113 | $smcFunc['db_free_result']($request); |
109 | 114 | |
110 | 115 | // If this topic already has a poll, they sure can't add another. |
111 | - if (isset($_REQUEST['poll']) && $pollID > 0) |
|
112 | - unset($_REQUEST['poll']); |
|
116 | + if (isset($_REQUEST['poll']) && $pollID > 0) { |
|
117 | + unset($_REQUEST['poll']); |
|
118 | + } |
|
113 | 119 | |
114 | 120 | if (empty($_REQUEST['msg'])) |
115 | 121 | { |
116 | - if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
|
117 | - is_not_guest(); |
|
122 | + if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) { |
|
123 | + is_not_guest(); |
|
124 | + } |
|
118 | 125 | |
119 | 126 | // By default the reply will be approved... |
120 | 127 | $context['becomes_approved'] = true; |
121 | 128 | if ($id_member_poster != $user_info['id'] || $user_info['is_guest']) |
122 | 129 | { |
123 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
124 | - $context['becomes_approved'] = false; |
|
125 | - else |
|
126 | - isAllowedTo('post_reply_any'); |
|
127 | - } |
|
128 | - elseif (!allowedTo('post_reply_any')) |
|
130 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
131 | + $context['becomes_approved'] = false; |
|
132 | + } else { |
|
133 | + isAllowedTo('post_reply_any'); |
|
134 | + } |
|
135 | + } elseif (!allowedTo('post_reply_any')) |
|
129 | 136 | { |
130 | - if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) |
|
131 | - $context['becomes_approved'] = false; |
|
132 | - else |
|
133 | - isAllowedTo('post_reply_own'); |
|
137 | + if ($modSettings['postmod_active'] && ((allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) || allowedTo('post_unapproved_replies_any'))) { |
|
138 | + $context['becomes_approved'] = false; |
|
139 | + } else { |
|
140 | + isAllowedTo('post_reply_own'); |
|
141 | + } |
|
134 | 142 | } |
143 | + } else { |
|
144 | + $context['becomes_approved'] = true; |
|
135 | 145 | } |
136 | - else |
|
137 | - $context['becomes_approved'] = true; |
|
138 | 146 | |
139 | 147 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $id_member_poster && allowedTo('lock_own')); |
140 | 148 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -146,18 +154,19 @@ discard block |
||
146 | 154 | $context['sticky'] = isset($_REQUEST['sticky']) ? !empty($_REQUEST['sticky']) : $sticky; |
147 | 155 | |
148 | 156 | // Check whether this is a really old post being bumped... |
149 | - if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) |
|
150 | - $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
151 | - } |
|
152 | - else |
|
157 | + if (!empty($modSettings['oldTopicDays']) && $lastPostTime + $modSettings['oldTopicDays'] * 86400 < time() && empty($sticky) && !isset($_REQUEST['subject'])) { |
|
158 | + $post_errors[] = array('old_topic', array($modSettings['oldTopicDays'])); |
|
159 | + } |
|
160 | + } else |
|
153 | 161 | { |
154 | 162 | $context['becomes_approved'] = true; |
155 | 163 | if ((!$context['make_event'] || !empty($board))) |
156 | 164 | { |
157 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
158 | - $context['becomes_approved'] = false; |
|
159 | - else |
|
160 | - isAllowedTo('post_new'); |
|
165 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
166 | + $context['becomes_approved'] = false; |
|
167 | + } else { |
|
168 | + isAllowedTo('post_new'); |
|
169 | + } |
|
161 | 170 | } |
162 | 171 | |
163 | 172 | $locked = 0; |
@@ -193,20 +202,24 @@ discard block |
||
193 | 202 | } |
194 | 203 | |
195 | 204 | // Don't allow a post if it's locked and you aren't all powerful. |
196 | - if ($locked && !allowedTo('moderate_board')) |
|
197 | - fatal_lang_error('topic_locked', false); |
|
205 | + if ($locked && !allowedTo('moderate_board')) { |
|
206 | + fatal_lang_error('topic_locked', false); |
|
207 | + } |
|
198 | 208 | // Check the users permissions - is the user allowed to add or post a poll? |
199 | 209 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
200 | 210 | { |
201 | 211 | // New topic, new poll. |
202 | - if (empty($topic)) |
|
203 | - isAllowedTo('poll_post'); |
|
212 | + if (empty($topic)) { |
|
213 | + isAllowedTo('poll_post'); |
|
214 | + } |
|
204 | 215 | // This is an old topic - but it is yours! Can you add to it? |
205 | - elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) |
|
206 | - isAllowedTo('poll_add_own'); |
|
216 | + elseif ($user_info['id'] == $id_member_poster && !allowedTo('poll_add_any')) { |
|
217 | + isAllowedTo('poll_add_own'); |
|
218 | + } |
|
207 | 219 | // If you're not the owner, can you add to any poll? |
208 | - else |
|
209 | - isAllowedTo('poll_add_any'); |
|
220 | + else { |
|
221 | + isAllowedTo('poll_add_any'); |
|
222 | + } |
|
210 | 223 | |
211 | 224 | require_once($sourcedir . '/Subs-Members.php'); |
212 | 225 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
@@ -235,8 +248,9 @@ discard block |
||
235 | 248 | if ($context['make_event']) |
236 | 249 | { |
237 | 250 | // They might want to pick a board. |
238 | - if (!isset($context['current_board'])) |
|
239 | - $context['current_board'] = 0; |
|
251 | + if (!isset($context['current_board'])) { |
|
252 | + $context['current_board'] = 0; |
|
253 | + } |
|
240 | 254 | |
241 | 255 | // Start loading up the event info. |
242 | 256 | $context['event'] = array(); |
@@ -250,10 +264,11 @@ discard block |
||
250 | 264 | isAllowedTo('calendar_post'); |
251 | 265 | |
252 | 266 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
253 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
254 | - $time_string = '%k:%M'; |
|
255 | - else |
|
256 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
267 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
268 | + $time_string = '%k:%M'; |
|
269 | + } else { |
|
270 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
271 | + } |
|
257 | 272 | |
258 | 273 | $js_time_string = str_replace( |
259 | 274 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -275,8 +290,7 @@ discard block |
||
275 | 290 | require_once($sourcedir . '/Subs-Calendar.php'); |
276 | 291 | $eventProperties = getEventProperties($context['event']['id']); |
277 | 292 | $context['event'] = array_merge($context['event'], $eventProperties); |
278 | - } |
|
279 | - else |
|
293 | + } else |
|
280 | 294 | { |
281 | 295 | // Get the current event information. |
282 | 296 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -284,15 +298,18 @@ discard block |
||
284 | 298 | $context['event'] = array_merge($context['event'], $eventProperties); |
285 | 299 | |
286 | 300 | // Make sure the year and month are in the valid range. |
287 | - if ($context['event']['month'] < 1 || $context['event']['month'] > 12) |
|
288 | - fatal_lang_error('invalid_month', false); |
|
289 | - if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) |
|
290 | - fatal_lang_error('invalid_year', false); |
|
301 | + if ($context['event']['month'] < 1 || $context['event']['month'] > 12) { |
|
302 | + fatal_lang_error('invalid_month', false); |
|
303 | + } |
|
304 | + if ($context['event']['year'] < $modSettings['cal_minyear'] || $context['event']['year'] > $modSettings['cal_maxyear']) { |
|
305 | + fatal_lang_error('invalid_year', false); |
|
306 | + } |
|
291 | 307 | |
292 | 308 | // Get a list of boards they can post in. |
293 | 309 | $boards = boardsAllowedTo('post_new'); |
294 | - if (empty($boards)) |
|
295 | - fatal_lang_error('cannot_post_new', 'user'); |
|
310 | + if (empty($boards)) { |
|
311 | + fatal_lang_error('cannot_post_new', 'user'); |
|
312 | + } |
|
296 | 313 | |
297 | 314 | // Load a list of boards for this event in the context. |
298 | 315 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -411,10 +428,11 @@ discard block |
||
411 | 428 | |
412 | 429 | if (!empty($context['new_replies'])) |
413 | 430 | { |
414 | - if ($context['new_replies'] == 1) |
|
415 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
416 | - else |
|
417 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
431 | + if ($context['new_replies'] == 1) { |
|
432 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
433 | + } else { |
|
434 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
435 | + } |
|
418 | 436 | |
419 | 437 | $post_errors[] = 'new_replies'; |
420 | 438 | |
@@ -426,9 +444,9 @@ discard block |
||
426 | 444 | // Get a response prefix (like 'Re:') in the default forum language. |
427 | 445 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
428 | 446 | { |
429 | - if ($language === $user_info['language']) |
|
430 | - $context['response_prefix'] = $txt['response_prefix']; |
|
431 | - else |
|
447 | + if ($language === $user_info['language']) { |
|
448 | + $context['response_prefix'] = $txt['response_prefix']; |
|
449 | + } else |
|
432 | 450 | { |
433 | 451 | loadLanguage('index', $language, false); |
434 | 452 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -441,8 +459,9 @@ discard block |
||
441 | 459 | // Do we have a body, but an error happened. |
442 | 460 | if (isset($_REQUEST['message']) || isset($_REQUEST['quickReply']) || !empty($context['post_error'])) |
443 | 461 | { |
444 | - if (isset($_REQUEST['quickReply'])) |
|
445 | - $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
462 | + if (isset($_REQUEST['quickReply'])) { |
|
463 | + $_REQUEST['message'] = $_REQUEST['quickReply']; |
|
464 | + } |
|
446 | 465 | |
447 | 466 | // Validate inputs. |
448 | 467 | if (empty($context['post_error'])) |
@@ -450,15 +469,17 @@ discard block |
||
450 | 469 | // This means they didn't click Post and get an error. |
451 | 470 | $really_previewing = true; |
452 | 471 | |
453 | - } |
|
454 | - else |
|
472 | + } else |
|
455 | 473 | { |
456 | - if (!isset($_REQUEST['subject'])) |
|
457 | - $_REQUEST['subject'] = ''; |
|
458 | - if (!isset($_REQUEST['message'])) |
|
459 | - $_REQUEST['message'] = ''; |
|
460 | - if (!isset($_REQUEST['icon'])) |
|
461 | - $_REQUEST['icon'] = 'xx'; |
|
474 | + if (!isset($_REQUEST['subject'])) { |
|
475 | + $_REQUEST['subject'] = ''; |
|
476 | + } |
|
477 | + if (!isset($_REQUEST['message'])) { |
|
478 | + $_REQUEST['message'] = ''; |
|
479 | + } |
|
480 | + if (!isset($_REQUEST['icon'])) { |
|
481 | + $_REQUEST['icon'] = 'xx'; |
|
482 | + } |
|
462 | 483 | |
463 | 484 | // They are previewing if they asked to preview (i.e. came from quick reply). |
464 | 485 | $really_previewing = !empty($_POST['preview']); |
@@ -474,8 +495,9 @@ discard block |
||
474 | 495 | $form_message = $smcFunc['htmlspecialchars']($_REQUEST['message'], ENT_QUOTES); |
475 | 496 | |
476 | 497 | // Make sure the subject isn't too long - taking into account special characters. |
477 | - if ($smcFunc['strlen']($form_subject) > 100) |
|
478 | - $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
498 | + if ($smcFunc['strlen']($form_subject) > 100) { |
|
499 | + $form_subject = $smcFunc['substr']($form_subject, 0, 100); |
|
500 | + } |
|
479 | 501 | |
480 | 502 | if (isset($_REQUEST['poll'])) |
481 | 503 | { |
@@ -487,8 +509,9 @@ discard block |
||
487 | 509 | $_POST['options'] = empty($_POST['options']) ? array() : htmlspecialchars__recursive($_POST['options']); |
488 | 510 | foreach ($_POST['options'] as $option) |
489 | 511 | { |
490 | - if (trim($option) == '') |
|
491 | - continue; |
|
512 | + if (trim($option) == '') { |
|
513 | + continue; |
|
514 | + } |
|
492 | 515 | |
493 | 516 | $context['choices'][] = array( |
494 | 517 | 'id' => $choice_id++, |
@@ -550,13 +573,14 @@ discard block |
||
550 | 573 | $context['preview_subject'] = $form_subject; |
551 | 574 | |
552 | 575 | censorText($context['preview_subject']); |
576 | + } else { |
|
577 | + $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
553 | 578 | } |
554 | - else |
|
555 | - $context['preview_subject'] = '<em>' . $txt['no_subject'] . '</em>'; |
|
556 | 579 | |
557 | 580 | // Protect any CDATA blocks. |
558 | - if (isset($_REQUEST['xml'])) |
|
559 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
581 | + if (isset($_REQUEST['xml'])) { |
|
582 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]>< == 0) |
|
599 | - fatal_lang_error('no_board', false); |
|
622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
623 | + fatal_lang_error('no_board', false); |
|
624 | + } |
|
600 | 625 | $row = $smcFunc['db_fetch_assoc']($request); |
601 | 626 | |
602 | 627 | $attachment_stuff = array($row); |
603 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
604 | - $attachment_stuff[] = $row2; |
|
628 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
629 | + $attachment_stuff[] = $row2; |
|
630 | + } |
|
605 | 631 | $smcFunc['db_free_result']($request); |
606 | 632 | |
607 | 633 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
608 | 634 | { |
609 | 635 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
610 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
611 | - fatal_lang_error('modify_post_time_passed', false); |
|
612 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
613 | - isAllowedTo('modify_replies'); |
|
614 | - else |
|
615 | - isAllowedTo('modify_own'); |
|
636 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
637 | + fatal_lang_error('modify_post_time_passed', false); |
|
638 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
639 | + isAllowedTo('modify_replies'); |
|
640 | + } else { |
|
641 | + isAllowedTo('modify_own'); |
|
642 | + } |
|
643 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
644 | + isAllowedTo('modify_replies'); |
|
645 | + } else { |
|
646 | + isAllowedTo('modify_any'); |
|
616 | 647 | } |
617 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
618 | - isAllowedTo('modify_replies'); |
|
619 | - else |
|
620 | - isAllowedTo('modify_any'); |
|
621 | 648 | |
622 | 649 | if ($context['can_announce'] && !empty($row['id_action'])) |
623 | 650 | { |
@@ -641,8 +668,9 @@ discard block |
||
641 | 668 | |
642 | 669 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
643 | 670 | { |
644 | - if ($row['filesize'] <= 0) |
|
645 | - continue; |
|
671 | + if ($row['filesize'] <= 0) { |
|
672 | + continue; |
|
673 | + } |
|
646 | 674 | $context['current_attachments'][$row['id_attach']] = array( |
647 | 675 | 'name' => $smcFunc['htmlspecialchars']($row['filename']), |
648 | 676 | 'size' => $row['filesize'], |
@@ -712,29 +740,32 @@ discard block |
||
712 | 740 | ) |
713 | 741 | ); |
714 | 742 | // The message they were trying to edit was most likely deleted. |
715 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
716 | - fatal_lang_error('no_message', false); |
|
743 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
744 | + fatal_lang_error('no_message', false); |
|
745 | + } |
|
717 | 746 | $row = $smcFunc['db_fetch_assoc']($request); |
718 | 747 | |
719 | 748 | $attachment_stuff = array($row); |
720 | - while ($row2 = $smcFunc['db_fetch_assoc']($request)) |
|
721 | - $attachment_stuff[] = $row2; |
|
749 | + while ($row2 = $smcFunc['db_fetch_assoc']($request)) { |
|
750 | + $attachment_stuff[] = $row2; |
|
751 | + } |
|
722 | 752 | $smcFunc['db_free_result']($request); |
723 | 753 | |
724 | 754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
725 | 755 | { |
726 | 756 | // Give an extra five minutes over the disable time threshold, so they can type - assuming the post is public. |
727 | - if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
728 | - fatal_lang_error('modify_post_time_passed', false); |
|
729 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) |
|
730 | - isAllowedTo('modify_replies'); |
|
731 | - else |
|
732 | - isAllowedTo('modify_own'); |
|
757 | + if ($row['approved'] && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
758 | + fatal_lang_error('modify_post_time_passed', false); |
|
759 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
760 | + isAllowedTo('modify_replies'); |
|
761 | + } else { |
|
762 | + isAllowedTo('modify_own'); |
|
763 | + } |
|
764 | + } elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
765 | + isAllowedTo('modify_replies'); |
|
766 | + } else { |
|
767 | + isAllowedTo('modify_any'); |
|
733 | 768 | } |
734 | - elseif ($row['id_member_poster'] == $user_info['id'] && !allowedTo('modify_any')) |
|
735 | - isAllowedTo('modify_replies'); |
|
736 | - else |
|
737 | - isAllowedTo('modify_any'); |
|
738 | 769 | |
739 | 770 | if ($context['can_announce'] && !empty($row['id_action'])) |
740 | 771 | { |
@@ -761,15 +792,17 @@ discard block |
||
761 | 792 | $context['icon'] = $row['icon']; |
762 | 793 | |
763 | 794 | // Show an "approve" box if the user can approve it, and the message isn't approved. |
764 | - if (!$row['approved'] && !$context['show_approval']) |
|
765 | - $context['show_approval'] = allowedTo('approve_posts'); |
|
795 | + if (!$row['approved'] && !$context['show_approval']) { |
|
796 | + $context['show_approval'] = allowedTo('approve_posts'); |
|
797 | + } |
|
766 | 798 | |
767 | 799 | // Sort the attachments so they are in the order saved |
768 | 800 | $temp = array(); |
769 | 801 | foreach ($attachment_stuff as $attachment) |
770 | 802 | { |
771 | - if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) |
|
772 | - $temp[$attachment['id_attach']] = $attachment; |
|
803 | + if ($attachment['filesize'] >= 0 && !empty($modSettings['attachmentEnable'])) { |
|
804 | + $temp[$attachment['id_attach']] = $attachment; |
|
805 | + } |
|
773 | 806 | |
774 | 807 | } |
775 | 808 | ksort($temp); |
@@ -831,14 +864,16 @@ discard block |
||
831 | 864 | 'is_approved' => 1, |
832 | 865 | ) |
833 | 866 | ); |
834 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
835 | - fatal_lang_error('quoted_post_deleted', false); |
|
867 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
868 | + fatal_lang_error('quoted_post_deleted', false); |
|
869 | + } |
|
836 | 870 | list ($form_subject, $mname, $mdate, $form_message) = $smcFunc['db_fetch_row']($request); |
837 | 871 | $smcFunc['db_free_result']($request); |
838 | 872 | |
839 | 873 | // Add 'Re: ' to the front of the quoted subject. |
840 | - if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
841 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
874 | + if (trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
875 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
876 | + } |
|
842 | 877 | |
843 | 878 | // Censor the message and subject. |
844 | 879 | censorText($form_message); |
@@ -851,10 +886,11 @@ discard block |
||
851 | 886 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
852 | 887 | { |
853 | 888 | // It goes 0 = outside, 1 = begin tag, 2 = inside, 3 = close tag, repeat. |
854 | - if ($i % 4 == 0) |
|
855 | - $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
889 | + if ($i % 4 == 0) { |
|
890 | + $parts[$i] = preg_replace_callback('~\[html\](.+?)\[/html\]~is', function($m) |
|
856 | 891 | { |
857 | 892 | return '[html]' . preg_replace('~<br\s?/?' . '>~i', '<br /><br>', "$m[1]") . '[/html]'; |
893 | + } |
|
858 | 894 | }, $parts[$i]); |
859 | 895 | } |
860 | 896 | $form_message = implode('', $parts); |
@@ -863,8 +899,9 @@ discard block |
||
863 | 899 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $form_message); |
864 | 900 | |
865 | 901 | // Remove any nested quotes, if necessary. |
866 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
867 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
902 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
903 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
904 | + } |
|
868 | 905 | |
869 | 906 | // Add a quote string on the front and end. |
870 | 907 | $form_message = '[quote author=' . $mname . ' link=msg=' . (int) $_REQUEST['quote'] . ' date=' . $mdate . ']' . "\n" . rtrim($form_message) . "\n" . '[/quote]'; |
@@ -876,15 +913,15 @@ discard block |
||
876 | 913 | $form_subject = $first_subject; |
877 | 914 | |
878 | 915 | // Add 'Re: ' to the front of the subject. |
879 | - if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
880 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
916 | + if (trim($context['response_prefix']) != '' && $form_subject != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
917 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
918 | + } |
|
881 | 919 | |
882 | 920 | // Censor the subject. |
883 | 921 | censorText($form_subject); |
884 | 922 | |
885 | 923 | $form_message = ''; |
886 | - } |
|
887 | - else |
|
924 | + } else |
|
888 | 925 | { |
889 | 926 | $form_subject = isset($_GET['subject']) ? $_GET['subject'] : ''; |
890 | 927 | $form_message = ''; |
@@ -902,13 +939,15 @@ discard block |
||
902 | 939 | if (isset($_REQUEST['msg'])) |
903 | 940 | { |
904 | 941 | $context['attachments']['quantity'] = count($context['current_attachments']); |
905 | - foreach ($context['current_attachments'] as $attachment) |
|
906 | - $context['attachments']['total_size'] += $attachment['size']; |
|
942 | + foreach ($context['current_attachments'] as $attachment) { |
|
943 | + $context['attachments']['total_size'] += $attachment['size']; |
|
944 | + } |
|
907 | 945 | } |
908 | 946 | |
909 | 947 | // A bit of house keeping first. |
910 | - if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) |
|
911 | - unset($_SESSION['temp_attachments']); |
|
948 | + if (!empty($_SESSION['temp_attachments']) && count($_SESSION['temp_attachments']) == 1) { |
|
949 | + unset($_SESSION['temp_attachments']); |
|
950 | + } |
|
912 | 951 | |
913 | 952 | if (!empty($_SESSION['temp_attachments'])) |
914 | 953 | { |
@@ -917,9 +956,10 @@ discard block |
||
917 | 956 | { |
918 | 957 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
919 | 958 | { |
920 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
921 | - if (file_exists($attachment['tmp_name'])) |
|
959 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) { |
|
960 | + if (file_exists($attachment['tmp_name'])) |
|
922 | 961 | unlink($attachment['tmp_name']); |
962 | + } |
|
923 | 963 | } |
924 | 964 | $post_errors[] = 'temp_attachments_gone'; |
925 | 965 | $_SESSION['temp_attachments'] = array(); |
@@ -933,8 +973,9 @@ discard block |
||
933 | 973 | // See if any files still exist before showing the warning message and the files attached. |
934 | 974 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
935 | 975 | { |
936 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
937 | - continue; |
|
976 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
977 | + continue; |
|
978 | + } |
|
938 | 979 | |
939 | 980 | if (file_exists($attachment['tmp_name'])) |
940 | 981 | { |
@@ -944,20 +985,21 @@ discard block |
||
944 | 985 | break; |
945 | 986 | } |
946 | 987 | } |
947 | - } |
|
948 | - else |
|
988 | + } else |
|
949 | 989 | { |
950 | 990 | // Since, they don't belong here. Let's inform the user that they exist.. |
951 | - if (!empty($topic)) |
|
952 | - $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
953 | - else |
|
954 | - $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
991 | + if (!empty($topic)) { |
|
992 | + $delete_url = $scripturl . '?action=post' . (!empty($_REQUEST['msg']) ? (';msg=' . $_REQUEST['msg']) : '') . (!empty($_REQUEST['last_msg']) ? (';last_msg=' . $_REQUEST['last_msg']) : '') . ';topic=' . $topic . ';delete_temp'; |
|
993 | + } else { |
|
994 | + $delete_url = $scripturl . '?action=post;board=' . $board . ';delete_temp'; |
|
995 | + } |
|
955 | 996 | |
956 | 997 | // Compile a list of the files to show the user. |
957 | 998 | $file_list = array(); |
958 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
959 | - if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
999 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) { |
|
1000 | + if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false) |
|
960 | 1001 | $file_list[] = $attachment['name']; |
1002 | + } |
|
961 | 1003 | |
962 | 1004 | $_SESSION['temp_attachments']['post']['files'] = $file_list; |
963 | 1005 | $file_list = '<div class="attachments">' . implode('<br>', $file_list) . '</div>'; |
@@ -969,8 +1011,7 @@ discard block |
||
969 | 1011 | |
970 | 1012 | $post_errors[] = array('temp_attachments_found', array($delete_url, $goback_url, $file_list)); |
971 | 1013 | $context['ignore_temp_attachments'] = true; |
972 | - } |
|
973 | - else |
|
1014 | + } else |
|
974 | 1015 | { |
975 | 1016 | $post_errors[] = array('temp_attachments_lost', array($delete_url, $file_list)); |
976 | 1017 | $context['ignore_temp_attachments'] = true; |
@@ -978,16 +1019,19 @@ discard block |
||
978 | 1019 | } |
979 | 1020 | } |
980 | 1021 | |
981 | - if (!empty($context['we_are_history'])) |
|
982 | - $post_errors[] = $context['we_are_history']; |
|
1022 | + if (!empty($context['we_are_history'])) { |
|
1023 | + $post_errors[] = $context['we_are_history']; |
|
1024 | + } |
|
983 | 1025 | |
984 | 1026 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
985 | 1027 | { |
986 | - if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) |
|
987 | - break; |
|
1028 | + if (isset($context['ignore_temp_attachments']) || isset($_SESSION['temp_attachments']['post']['files'])) { |
|
1029 | + break; |
|
1030 | + } |
|
988 | 1031 | |
989 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
990 | - continue; |
|
1032 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
1033 | + continue; |
|
1034 | + } |
|
991 | 1035 | |
992 | 1036 | if ($attachID == 'initial_error') |
993 | 1037 | { |
@@ -1002,15 +1046,17 @@ discard block |
||
1002 | 1046 | { |
1003 | 1047 | $txt['error_attach_errors'] = empty($txt['error_attach_errors']) ? '<br>' : ''; |
1004 | 1048 | $txt['error_attach_errors'] .= vsprintf($txt['attach_warning'], $attachment['name']) . '<div style="padding: 0 1em;">'; |
1005 | - foreach ($attachment['errors'] as $error) |
|
1006 | - $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1049 | + foreach ($attachment['errors'] as $error) { |
|
1050 | + $txt['error_attach_errors'] .= (is_array($error) ? vsprintf($txt[$error[0]], $error[1]) : $txt[$error]) . '<br >'; |
|
1051 | + } |
|
1007 | 1052 | $txt['error_attach_errors'] .= '</div>'; |
1008 | 1053 | $post_errors[] = 'attach_errors'; |
1009 | 1054 | |
1010 | 1055 | // Take out the trash. |
1011 | 1056 | unset($_SESSION['temp_attachments'][$attachID]); |
1012 | - if (file_exists($attachment['tmp_name'])) |
|
1013 | - unlink($attachment['tmp_name']); |
|
1057 | + if (file_exists($attachment['tmp_name'])) { |
|
1058 | + unlink($attachment['tmp_name']); |
|
1059 | + } |
|
1014 | 1060 | continue; |
1015 | 1061 | } |
1016 | 1062 | |
@@ -1023,8 +1069,9 @@ discard block |
||
1023 | 1069 | |
1024 | 1070 | $context['attachments']['quantity']++; |
1025 | 1071 | $context['attachments']['total_size'] += $attachment['size']; |
1026 | - if (!isset($context['files_in_session_warning'])) |
|
1027 | - $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1072 | + if (!isset($context['files_in_session_warning'])) { |
|
1073 | + $context['files_in_session_warning'] = $txt['attached_files_in_session']; |
|
1074 | + } |
|
1028 | 1075 | |
1029 | 1076 | $context['current_attachments'][$attachID] = array( |
1030 | 1077 | 'name' => '<u>' . $smcFunc['htmlspecialchars']($attachment['name']) . '</u>', |
@@ -1052,8 +1099,9 @@ discard block |
||
1052 | 1099 | } |
1053 | 1100 | |
1054 | 1101 | // If they came from quick reply, and have to enter verification details, give them some notice. |
1055 | - if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) |
|
1056 | - $post_errors[] = 'need_qr_verification'; |
|
1102 | + if (!empty($_REQUEST['from_qr']) && !empty($context['require_verification'])) { |
|
1103 | + $post_errors[] = 'need_qr_verification'; |
|
1104 | + } |
|
1057 | 1105 | |
1058 | 1106 | /* |
1059 | 1107 | * There are two error types: serious and minor. Serious errors |
@@ -1070,52 +1118,56 @@ discard block |
||
1070 | 1118 | { |
1071 | 1119 | loadLanguage('Errors'); |
1072 | 1120 | $context['error_type'] = 'minor'; |
1073 | - foreach ($post_errors as $post_error) |
|
1074 | - if (is_array($post_error)) |
|
1121 | + foreach ($post_errors as $post_error) { |
|
1122 | + if (is_array($post_error)) |
|
1075 | 1123 | { |
1076 | 1124 | $post_error_id = $post_error[0]; |
1125 | + } |
|
1077 | 1126 | $context['post_error'][$post_error_id] = vsprintf($txt['error_' . $post_error_id], $post_error[1]); |
1078 | 1127 | |
1079 | 1128 | // If it's not a minor error flag it as such. |
1080 | - if (!in_array($post_error_id, $minor_errors)) |
|
1081 | - $context['error_type'] = 'serious'; |
|
1082 | - } |
|
1083 | - else |
|
1129 | + if (!in_array($post_error_id, $minor_errors)) { |
|
1130 | + $context['error_type'] = 'serious'; |
|
1131 | + } |
|
1132 | + } else |
|
1084 | 1133 | { |
1085 | 1134 | $context['post_error'][$post_error] = $txt['error_' . $post_error]; |
1086 | 1135 | |
1087 | 1136 | // If it's not a minor error flag it as such. |
1088 | - if (!in_array($post_error, $minor_errors)) |
|
1089 | - $context['error_type'] = 'serious'; |
|
1137 | + if (!in_array($post_error, $minor_errors)) { |
|
1138 | + $context['error_type'] = 'serious'; |
|
1139 | + } |
|
1090 | 1140 | } |
1091 | 1141 | } |
1092 | 1142 | |
1093 | 1143 | // What are you doing? Posting a poll, modifying, previewing, new post, or reply... |
1094 | - if (isset($_REQUEST['poll'])) |
|
1095 | - $context['page_title'] = $txt['new_poll']; |
|
1096 | - elseif ($context['make_event']) |
|
1097 | - $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1098 | - elseif (isset($_REQUEST['msg'])) |
|
1099 | - $context['page_title'] = $txt['modify_msg']; |
|
1100 | - elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
|
1101 | - $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1102 | - elseif (empty($topic)) |
|
1103 | - $context['page_title'] = $txt['start_new_topic']; |
|
1104 | - else |
|
1105 | - $context['page_title'] = $txt['post_reply']; |
|
1144 | + if (isset($_REQUEST['poll'])) { |
|
1145 | + $context['page_title'] = $txt['new_poll']; |
|
1146 | + } elseif ($context['make_event']) { |
|
1147 | + $context['page_title'] = $context['event']['id'] == -1 ? $txt['calendar_post_event'] : $txt['calendar_edit']; |
|
1148 | + } elseif (isset($_REQUEST['msg'])) { |
|
1149 | + $context['page_title'] = $txt['modify_msg']; |
|
1150 | + } elseif (isset($_REQUEST['subject'], $context['preview_subject'])) { |
|
1151 | + $context['page_title'] = $txt['preview'] . ' - ' . strip_tags($context['preview_subject']); |
|
1152 | + } elseif (empty($topic)) { |
|
1153 | + $context['page_title'] = $txt['start_new_topic']; |
|
1154 | + } else { |
|
1155 | + $context['page_title'] = $txt['post_reply']; |
|
1156 | + } |
|
1106 | 1157 | |
1107 | 1158 | // Build the link tree. |
1108 | - if (empty($topic)) |
|
1109 | - $context['linktree'][] = array( |
|
1159 | + if (empty($topic)) { |
|
1160 | + $context['linktree'][] = array( |
|
1110 | 1161 | 'name' => '<em>' . $txt['start_new_topic'] . '</em>' |
1111 | 1162 | ); |
1112 | - else |
|
1113 | - $context['linktree'][] = array( |
|
1163 | + } else { |
|
1164 | + $context['linktree'][] = array( |
|
1114 | 1165 | 'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'], |
1115 | 1166 | 'name' => $form_subject, |
1116 | 1167 | 'extra_before' => '<span><strong class="nav">' . $context['page_title'] . ' (</strong></span>', |
1117 | 1168 | 'extra_after' => '<span><strong class="nav">)</strong></span>' |
1118 | 1169 | ); |
1170 | + } |
|
1119 | 1171 | |
1120 | 1172 | $context['subject'] = addcslashes($form_subject, '"'); |
1121 | 1173 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $form_message); |
@@ -1159,8 +1211,9 @@ discard block |
||
1159 | 1211 | // Message icons - customized icons are off? |
1160 | 1212 | $context['icons'] = getMessageIcons($board); |
1161 | 1213 | |
1162 | - if (!empty($context['icons'])) |
|
1163 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1214 | + if (!empty($context['icons'])) { |
|
1215 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1216 | + } |
|
1164 | 1217 | |
1165 | 1218 | // Are we starting a poll? if set the poll icon as selected if its available |
1166 | 1219 | if (isset($_REQUEST['poll'])) |
@@ -1180,8 +1233,9 @@ discard block |
||
1180 | 1233 | for ($i = 0, $n = count($context['icons']); $i < $n; $i++) |
1181 | 1234 | { |
1182 | 1235 | $context['icons'][$i]['selected'] = $context['icon'] == $context['icons'][$i]['value']; |
1183 | - if ($context['icons'][$i]['selected']) |
|
1184 | - $context['icon_url'] = $context['icons'][$i]['url']; |
|
1236 | + if ($context['icons'][$i]['selected']) { |
|
1237 | + $context['icon_url'] = $context['icons'][$i]['url']; |
|
1238 | + } |
|
1185 | 1239 | } |
1186 | 1240 | if (empty($context['icon_url'])) |
1187 | 1241 | { |
@@ -1195,8 +1249,9 @@ discard block |
||
1195 | 1249 | )); |
1196 | 1250 | } |
1197 | 1251 | |
1198 | - if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) |
|
1199 | - getTopic(); |
|
1252 | + if (!empty($topic) && !empty($modSettings['topicSummaryPosts'])) { |
|
1253 | + getTopic(); |
|
1254 | + } |
|
1200 | 1255 | |
1201 | 1256 | // If the user can post attachments prepare the warning labels. |
1202 | 1257 | if ($context['can_post_attachment']) |
@@ -1207,12 +1262,13 @@ discard block |
||
1207 | 1262 | $context['attachment_restrictions'] = array(); |
1208 | 1263 | $context['allowed_extensions'] = strtr(strtolower($modSettings['attachmentExtensions']), array(',' => ', ')); |
1209 | 1264 | $attachmentRestrictionTypes = array('attachmentNumPerPostLimit', 'attachmentPostLimit', 'attachmentSizeLimit'); |
1210 | - foreach ($attachmentRestrictionTypes as $type) |
|
1211 | - if (!empty($modSettings[$type])) |
|
1265 | + foreach ($attachmentRestrictionTypes as $type) { |
|
1266 | + if (!empty($modSettings[$type])) |
|
1212 | 1267 | { |
1213 | 1268 | // Show the max number of attachments if not 0. |
1214 | 1269 | if ($type == 'attachmentNumPerPostLimit') |
1215 | 1270 | $context['attachment_restrictions'][] = sprintf($txt['attach_remaining'], $modSettings['attachmentNumPerPostLimit'] - $context['attachments']['quantity']); |
1271 | + } |
|
1216 | 1272 | } |
1217 | 1273 | } |
1218 | 1274 | |
@@ -1246,8 +1302,8 @@ discard block |
||
1246 | 1302 | |
1247 | 1303 | if (!empty($context['current_attachments'])) |
1248 | 1304 | { |
1249 | - foreach ($context['current_attachments'] as $key => $mock) |
|
1250 | - addInlineJavaScript(' |
|
1305 | + foreach ($context['current_attachments'] as $key => $mock) { |
|
1306 | + addInlineJavaScript(' |
|
1251 | 1307 | current_attachments.push({ |
1252 | 1308 | name: '. JavaScriptEscape($mock['name']) . ', |
1253 | 1309 | size: '. $mock['size'] . ', |
@@ -1256,6 +1312,7 @@ discard block |
||
1256 | 1312 | type: '. JavaScriptEscape(!empty($mock['mime_type']) ? $mock['mime_type'] : '') . ', |
1257 | 1313 | thumbID: '. (!empty($mock['thumb']) ? $mock['thumb'] : 0) . ' |
1258 | 1314 | });', true); |
1315 | + } |
|
1259 | 1316 | } |
1260 | 1317 | |
1261 | 1318 | // File Upload. |
@@ -1341,8 +1398,9 @@ discard block |
||
1341 | 1398 | |
1342 | 1399 | |
1343 | 1400 | // Finally, load the template. |
1344 | - if (!isset($_REQUEST['xml'])) |
|
1345 | - loadTemplate('Post'); |
|
1401 | + if (!isset($_REQUEST['xml'])) { |
|
1402 | + loadTemplate('Post'); |
|
1403 | + } |
|
1346 | 1404 | |
1347 | 1405 | call_integration_hook('integrate_post_end'); |
1348 | 1406 | } |
@@ -1363,13 +1421,14 @@ discard block |
||
1363 | 1421 | // Sneaking off, are we? |
1364 | 1422 | if (empty($_POST) && empty($topic)) |
1365 | 1423 | { |
1366 | - if (empty($_SERVER['CONTENT_LENGTH'])) |
|
1367 | - redirectexit('action=post;board=' . $board . '.0'); |
|
1368 | - else |
|
1369 | - fatal_lang_error('post_upload_error', false); |
|
1424 | + if (empty($_SERVER['CONTENT_LENGTH'])) { |
|
1425 | + redirectexit('action=post;board=' . $board . '.0'); |
|
1426 | + } else { |
|
1427 | + fatal_lang_error('post_upload_error', false); |
|
1428 | + } |
|
1429 | + } elseif (empty($_POST) && !empty($topic)) { |
|
1430 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
1370 | 1431 | } |
1371 | - elseif (empty($_POST) && !empty($topic)) |
|
1372 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
1373 | 1432 | |
1374 | 1433 | // No need! |
1375 | 1434 | $context['robot_no_index'] = true; |
@@ -1381,8 +1440,9 @@ discard block |
||
1381 | 1440 | $post_errors = array(); |
1382 | 1441 | |
1383 | 1442 | // If the session has timed out, let the user re-submit their form. |
1384 | - if (checkSession('post', '', false) != '') |
|
1385 | - $post_errors[] = 'session_timeout'; |
|
1443 | + if (checkSession('post', '', false) != '') { |
|
1444 | + $post_errors[] = 'session_timeout'; |
|
1445 | + } |
|
1386 | 1446 | |
1387 | 1447 | // Wrong verification code? |
1388 | 1448 | if (!$user_info['is_admin'] && !$user_info['is_mod'] && !empty($modSettings['posts_require_captcha']) && ($user_info['posts'] < $modSettings['posts_require_captcha'] || ($user_info['is_guest'] && $modSettings['posts_require_captcha'] == -1))) |
@@ -1392,33 +1452,38 @@ discard block |
||
1392 | 1452 | 'id' => 'post', |
1393 | 1453 | ); |
1394 | 1454 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
1395 | - if (is_array($context['require_verification'])) |
|
1396 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1455 | + if (is_array($context['require_verification'])) { |
|
1456 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
1457 | + } |
|
1397 | 1458 | } |
1398 | 1459 | |
1399 | 1460 | require_once($sourcedir . '/Subs-Post.php'); |
1400 | 1461 | loadLanguage('Post'); |
1401 | 1462 | |
1402 | 1463 | // Drafts enabled and needed? |
1403 | - if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) |
|
1404 | - require_once($sourcedir . '/Drafts.php'); |
|
1464 | + if (!empty($modSettings['drafts_post_enabled']) && (isset($_POST['save_draft']) || isset($_POST['id_draft']))) { |
|
1465 | + require_once($sourcedir . '/Drafts.php'); |
|
1466 | + } |
|
1405 | 1467 | |
1406 | 1468 | // First check to see if they are trying to delete any current attachments. |
1407 | 1469 | if (isset($_POST['attach_del'])) |
1408 | 1470 | { |
1409 | 1471 | $keep_temp = array(); |
1410 | 1472 | $keep_ids = array(); |
1411 | - foreach ($_POST['attach_del'] as $dummy) |
|
1412 | - if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1473 | + foreach ($_POST['attach_del'] as $dummy) { |
|
1474 | + if (strpos($dummy, 'post_tmp_' . $user_info['id']) !== false) |
|
1413 | 1475 | $keep_temp[] = $dummy; |
1414 | - else |
|
1415 | - $keep_ids[] = (int) $dummy; |
|
1476 | + } |
|
1477 | + else { |
|
1478 | + $keep_ids[] = (int) $dummy; |
|
1479 | + } |
|
1416 | 1480 | |
1417 | - if (isset($_SESSION['temp_attachments'])) |
|
1418 | - foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1481 | + if (isset($_SESSION['temp_attachments'])) { |
|
1482 | + foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
|
1419 | 1483 | { |
1420 | 1484 | if ((isset($_SESSION['temp_attachments']['post']['files'], $attachment['name']) && in_array($attachment['name'], $_SESSION['temp_attachments']['post']['files'])) || in_array($attachID, $keep_temp) || strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
1421 | 1485 | continue; |
1486 | + } |
|
1422 | 1487 | |
1423 | 1488 | unset($_SESSION['temp_attachments'][$attachID]); |
1424 | 1489 | unlink($attachment['tmp_name']); |
@@ -1460,24 +1525,28 @@ discard block |
||
1460 | 1525 | $smcFunc['db_free_result']($request); |
1461 | 1526 | |
1462 | 1527 | // Though the topic should be there, it might have vanished. |
1463 | - if (!is_array($topic_info)) |
|
1464 | - fatal_lang_error('topic_doesnt_exist', 404); |
|
1528 | + if (!is_array($topic_info)) { |
|
1529 | + fatal_lang_error('topic_doesnt_exist', 404); |
|
1530 | + } |
|
1465 | 1531 | |
1466 | 1532 | // Did this topic suddenly move? Just checking... |
1467 | - if ($topic_info['id_board'] != $board) |
|
1468 | - fatal_lang_error('not_a_topic'); |
|
1533 | + if ($topic_info['id_board'] != $board) { |
|
1534 | + fatal_lang_error('not_a_topic'); |
|
1535 | + } |
|
1469 | 1536 | } |
1470 | 1537 | |
1471 | 1538 | // Replying to a topic? |
1472 | 1539 | if (!empty($topic) && !isset($_REQUEST['msg'])) |
1473 | 1540 | { |
1474 | 1541 | // Don't allow a post if it's locked. |
1475 | - if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
|
1476 | - fatal_lang_error('topic_locked', false); |
|
1542 | + if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) { |
|
1543 | + fatal_lang_error('topic_locked', false); |
|
1544 | + } |
|
1477 | 1545 | |
1478 | 1546 | // Sorry, multiple polls aren't allowed... yet. You should stop giving me ideas :P. |
1479 | - if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) |
|
1480 | - unset($_REQUEST['poll']); |
|
1547 | + if (isset($_REQUEST['poll']) && $topic_info['id_poll'] > 0) { |
|
1548 | + unset($_REQUEST['poll']); |
|
1549 | + } |
|
1481 | 1550 | |
1482 | 1551 | // Do the permissions and approval stuff... |
1483 | 1552 | $becomesApproved = true; |
@@ -1493,44 +1562,43 @@ discard block |
||
1493 | 1562 | |
1494 | 1563 | // Set a nice session var... |
1495 | 1564 | $_SESSION['becomesUnapproved'] = true; |
1496 | - } |
|
1497 | - |
|
1498 | - elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1565 | + } elseif ($topic_info['id_member_started'] != $user_info['id']) |
|
1499 | 1566 | { |
1500 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
|
1501 | - $becomesApproved = false; |
|
1502 | - |
|
1503 | - else |
|
1504 | - isAllowedTo('post_reply_any'); |
|
1505 | - } |
|
1506 | - elseif (!allowedTo('post_reply_any')) |
|
1567 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) { |
|
1568 | + $becomesApproved = false; |
|
1569 | + } else { |
|
1570 | + isAllowedTo('post_reply_any'); |
|
1571 | + } |
|
1572 | + } elseif (!allowedTo('post_reply_any')) |
|
1507 | 1573 | { |
1508 | - if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
|
1509 | - $becomesApproved = false; |
|
1510 | - |
|
1511 | - else |
|
1512 | - isAllowedTo('post_reply_own'); |
|
1574 | + if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) { |
|
1575 | + $becomesApproved = false; |
|
1576 | + } else { |
|
1577 | + isAllowedTo('post_reply_own'); |
|
1578 | + } |
|
1513 | 1579 | } |
1514 | 1580 | |
1515 | 1581 | if (isset($_POST['lock'])) |
1516 | 1582 | { |
1517 | 1583 | // Nothing is changed to the lock. |
1518 | - if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1519 | - unset($_POST['lock']); |
|
1584 | + if ((empty($topic_info['locked']) && empty($_POST['lock'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1585 | + unset($_POST['lock']); |
|
1586 | + } |
|
1520 | 1587 | |
1521 | 1588 | // You're have no permission to lock this topic. |
1522 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1523 | - unset($_POST['lock']); |
|
1589 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1590 | + unset($_POST['lock']); |
|
1591 | + } |
|
1524 | 1592 | |
1525 | 1593 | // You are allowed to (un)lock your own topic only. |
1526 | 1594 | elseif (!allowedTo('lock_any')) |
1527 | 1595 | { |
1528 | 1596 | // You cannot override a moderator lock. |
1529 | - if ($topic_info['locked'] == 1) |
|
1530 | - unset($_POST['lock']); |
|
1531 | - |
|
1532 | - else |
|
1533 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1597 | + if ($topic_info['locked'] == 1) { |
|
1598 | + unset($_POST['lock']); |
|
1599 | + } else { |
|
1600 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1601 | + } |
|
1534 | 1602 | } |
1535 | 1603 | // Hail mighty moderator, (un)lock this topic immediately. |
1536 | 1604 | else |
@@ -1538,19 +1606,21 @@ discard block |
||
1538 | 1606 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1539 | 1607 | |
1540 | 1608 | // Did someone (un)lock this while you were posting? |
1541 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1542 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1609 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1610 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1611 | + } |
|
1543 | 1612 | } |
1544 | 1613 | } |
1545 | 1614 | |
1546 | 1615 | // So you wanna (un)sticky this...let's see. |
1547 | - if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
|
1548 | - unset($_POST['sticky']); |
|
1549 | - elseif (isset($_POST['sticky'])) |
|
1616 | + if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) { |
|
1617 | + unset($_POST['sticky']); |
|
1618 | + } elseif (isset($_POST['sticky'])) |
|
1550 | 1619 | { |
1551 | 1620 | // Did someone (un)sticky this while you were posting? |
1552 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1553 | - $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1621 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1622 | + $post_errors[] = 'topic_' . (empty($topic_info['is_sticky']) ? 'un' : '') . 'sticky'; |
|
1623 | + } |
|
1554 | 1624 | } |
1555 | 1625 | |
1556 | 1626 | // If drafts are enabled, then pass this off |
@@ -1577,26 +1647,31 @@ discard block |
||
1577 | 1647 | |
1578 | 1648 | // Do like, the permissions, for safety and stuff... |
1579 | 1649 | $becomesApproved = true; |
1580 | - if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
|
1581 | - $becomesApproved = false; |
|
1582 | - else |
|
1583 | - isAllowedTo('post_new'); |
|
1650 | + if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) { |
|
1651 | + $becomesApproved = false; |
|
1652 | + } else { |
|
1653 | + isAllowedTo('post_new'); |
|
1654 | + } |
|
1584 | 1655 | |
1585 | 1656 | if (isset($_POST['lock'])) |
1586 | 1657 | { |
1587 | 1658 | // New topics are by default not locked. |
1588 | - if (empty($_POST['lock'])) |
|
1589 | - unset($_POST['lock']); |
|
1659 | + if (empty($_POST['lock'])) { |
|
1660 | + unset($_POST['lock']); |
|
1661 | + } |
|
1590 | 1662 | // Besides, you need permission. |
1591 | - elseif (!allowedTo(array('lock_any', 'lock_own'))) |
|
1592 | - unset($_POST['lock']); |
|
1663 | + elseif (!allowedTo(array('lock_any', 'lock_own'))) { |
|
1664 | + unset($_POST['lock']); |
|
1665 | + } |
|
1593 | 1666 | // A moderator-lock (1) can override a user-lock (2). |
1594 | - else |
|
1595 | - $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1667 | + else { |
|
1668 | + $_POST['lock'] = allowedTo('lock_any') ? 1 : 2; |
|
1669 | + } |
|
1596 | 1670 | } |
1597 | 1671 | |
1598 | - if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
|
1599 | - unset($_POST['sticky']); |
|
1672 | + if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) { |
|
1673 | + unset($_POST['sticky']); |
|
1674 | + } |
|
1600 | 1675 | |
1601 | 1676 | // Saving your new topic as a draft first? |
1602 | 1677 | if (!empty($modSettings['drafts_post_enabled']) && isset($_POST['save_draft'])) |
@@ -1621,31 +1696,37 @@ discard block |
||
1621 | 1696 | 'id_msg' => $_REQUEST['msg'], |
1622 | 1697 | ) |
1623 | 1698 | ); |
1624 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1625 | - fatal_lang_error('cant_find_messages', false); |
|
1699 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1700 | + fatal_lang_error('cant_find_messages', false); |
|
1701 | + } |
|
1626 | 1702 | $row = $smcFunc['db_fetch_assoc']($request); |
1627 | 1703 | $smcFunc['db_free_result']($request); |
1628 | 1704 | |
1629 | - if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
|
1630 | - fatal_lang_error('topic_locked', false); |
|
1705 | + if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) { |
|
1706 | + fatal_lang_error('topic_locked', false); |
|
1707 | + } |
|
1631 | 1708 | |
1632 | 1709 | if (isset($_POST['lock'])) |
1633 | 1710 | { |
1634 | 1711 | // Nothing changes to the lock status. |
1635 | - if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) |
|
1636 | - unset($_POST['lock']); |
|
1712 | + if ((empty($_POST['lock']) && empty($topic_info['locked'])) || (!empty($_POST['lock']) && !empty($topic_info['locked']))) { |
|
1713 | + unset($_POST['lock']); |
|
1714 | + } |
|
1637 | 1715 | // You're simply not allowed to (un)lock this. |
1638 | - elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
|
1639 | - unset($_POST['lock']); |
|
1716 | + elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) { |
|
1717 | + unset($_POST['lock']); |
|
1718 | + } |
|
1640 | 1719 | // You're only allowed to lock your own topics. |
1641 | 1720 | elseif (!allowedTo('lock_any')) |
1642 | 1721 | { |
1643 | 1722 | // You're not allowed to break a moderator's lock. |
1644 | - if ($topic_info['locked'] == 1) |
|
1645 | - unset($_POST['lock']); |
|
1723 | + if ($topic_info['locked'] == 1) { |
|
1724 | + unset($_POST['lock']); |
|
1725 | + } |
|
1646 | 1726 | // Lock it with a soft lock or unlock it. |
1647 | - else |
|
1648 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1727 | + else { |
|
1728 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
1729 | + } |
|
1649 | 1730 | } |
1650 | 1731 | // You must be the moderator. |
1651 | 1732 | else |
@@ -1653,44 +1734,46 @@ discard block |
||
1653 | 1734 | $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
1654 | 1735 | |
1655 | 1736 | // Did someone (un)lock this while you were posting? |
1656 | - if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) |
|
1657 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1737 | + if (isset($_POST['already_locked']) && $_POST['already_locked'] != $topic_info['locked']) { |
|
1738 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'locked'; |
|
1739 | + } |
|
1658 | 1740 | } |
1659 | 1741 | } |
1660 | 1742 | |
1661 | 1743 | // Change the sticky status of this topic? |
1662 | - if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
|
1663 | - unset($_POST['sticky']); |
|
1664 | - elseif (isset($_POST['sticky'])) |
|
1744 | + if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) { |
|
1745 | + unset($_POST['sticky']); |
|
1746 | + } elseif (isset($_POST['sticky'])) |
|
1665 | 1747 | { |
1666 | 1748 | // Did someone (un)sticky this while you were posting? |
1667 | - if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) |
|
1668 | - $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1749 | + if (isset($_POST['already_sticky']) && $_POST['already_sticky'] != $topic_info['is_sticky']) { |
|
1750 | + $post_errors[] = 'topic_' . (empty($topic_info['locked']) ? 'un' : '') . 'stickied'; |
|
1751 | + } |
|
1669 | 1752 | } |
1670 | 1753 | |
1671 | 1754 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1672 | 1755 | { |
1673 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
1674 | - fatal_lang_error('modify_post_time_passed', false); |
|
1675 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
1676 | - isAllowedTo('modify_replies'); |
|
1677 | - else |
|
1678 | - isAllowedTo('modify_own'); |
|
1679 | - } |
|
1680 | - elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1756 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
1757 | + fatal_lang_error('modify_post_time_passed', false); |
|
1758 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
1759 | + isAllowedTo('modify_replies'); |
|
1760 | + } else { |
|
1761 | + isAllowedTo('modify_own'); |
|
1762 | + } |
|
1763 | + } elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
1681 | 1764 | { |
1682 | 1765 | isAllowedTo('modify_replies'); |
1683 | 1766 | |
1684 | 1767 | // If you're modifying a reply, I say it better be logged... |
1685 | 1768 | $moderationAction = true; |
1686 | - } |
|
1687 | - else |
|
1769 | + } else |
|
1688 | 1770 | { |
1689 | 1771 | isAllowedTo('modify_any'); |
1690 | 1772 | |
1691 | 1773 | // Log it, assuming you're not modifying your own post. |
1692 | - if ($row['id_member'] != $user_info['id']) |
|
1693 | - $moderationAction = true; |
|
1774 | + if ($row['id_member'] != $user_info['id']) { |
|
1775 | + $moderationAction = true; |
|
1776 | + } |
|
1694 | 1777 | } |
1695 | 1778 | |
1696 | 1779 | // If drafts are enabled, then lets send this off to save |
@@ -1727,20 +1810,24 @@ discard block |
||
1727 | 1810 | $_POST['guestname'] = !isset($_POST['guestname']) ? '' : trim($_POST['guestname']); |
1728 | 1811 | $_POST['email'] = !isset($_POST['email']) ? '' : trim($_POST['email']); |
1729 | 1812 | |
1730 | - if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
|
1731 | - $post_errors[] = 'no_name'; |
|
1732 | - if ($smcFunc['strlen']($_POST['guestname']) > 25) |
|
1733 | - $post_errors[] = 'long_name'; |
|
1813 | + if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') { |
|
1814 | + $post_errors[] = 'no_name'; |
|
1815 | + } |
|
1816 | + if ($smcFunc['strlen']($_POST['guestname']) > 25) { |
|
1817 | + $post_errors[] = 'long_name'; |
|
1818 | + } |
|
1734 | 1819 | |
1735 | 1820 | if (empty($modSettings['guest_post_no_email'])) |
1736 | 1821 | { |
1737 | 1822 | // Only check if they changed it! |
1738 | 1823 | if (!isset($row) || $row['poster_email'] != $_POST['email']) |
1739 | 1824 | { |
1740 | - if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) |
|
1741 | - $post_errors[] = 'no_email'; |
|
1742 | - if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) |
|
1743 | - $post_errors[] = 'bad_email'; |
|
1825 | + if (!allowedTo('moderate_forum') && (!isset($_POST['email']) || $_POST['email'] == '')) { |
|
1826 | + $post_errors[] = 'no_email'; |
|
1827 | + } |
|
1828 | + if (!allowedTo('moderate_forum') && !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { |
|
1829 | + $post_errors[] = 'bad_email'; |
|
1830 | + } |
|
1744 | 1831 | } |
1745 | 1832 | |
1746 | 1833 | // Now make sure this email address is not banned from posting. |
@@ -1756,75 +1843,89 @@ discard block |
||
1756 | 1843 | } |
1757 | 1844 | |
1758 | 1845 | // Coming from the quickReply? |
1759 | - if (isset($_POST['quickReply'])) |
|
1760 | - $_POST['message'] = $_POST['quickReply']; |
|
1846 | + if (isset($_POST['quickReply'])) { |
|
1847 | + $_POST['message'] = $_POST['quickReply']; |
|
1848 | + } |
|
1761 | 1849 | |
1762 | 1850 | // Check the subject and message. |
1763 | - if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') |
|
1764 | - $post_errors[] = 'no_subject'; |
|
1765 | - if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') |
|
1766 | - $post_errors[] = 'no_message'; |
|
1767 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
1768 | - $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1769 | - else |
|
1851 | + if (!isset($_POST['subject']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['subject'])) === '') { |
|
1852 | + $post_errors[] = 'no_subject'; |
|
1853 | + } |
|
1854 | + if (!isset($_POST['message']) || $smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['message']), ENT_QUOTES) === '') { |
|
1855 | + $post_errors[] = 'no_message'; |
|
1856 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) { |
|
1857 | + $post_errors[] = array('long_message', array($modSettings['max_messageLength'])); |
|
1858 | + } else |
|
1770 | 1859 | { |
1771 | 1860 | // Prepare the message a bit for some additional testing. |
1772 | 1861 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
1773 | 1862 | |
1774 | 1863 | // Preparse code. (Zef) |
1775 | - if ($user_info['is_guest']) |
|
1776 | - $user_info['name'] = $_POST['guestname']; |
|
1864 | + if ($user_info['is_guest']) { |
|
1865 | + $user_info['name'] = $_POST['guestname']; |
|
1866 | + } |
|
1777 | 1867 | preparsecode($_POST['message']); |
1778 | 1868 | |
1779 | 1869 | // Let's see if there's still some content left without the tags. |
1780 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
|
1781 | - $post_errors[] = 'no_message'; |
|
1870 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($_POST['message'], false), implode('', $context['allowed_html_tags']))) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) { |
|
1871 | + $post_errors[] = 'no_message'; |
|
1872 | + } |
|
1873 | + } |
|
1874 | + if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
1875 | + $post_errors[] = 'no_event'; |
|
1782 | 1876 | } |
1783 | - if (isset($_POST['calendar']) && !isset($_REQUEST['deleteevent']) && $smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
1784 | - $post_errors[] = 'no_event'; |
|
1785 | 1877 | // You are not! |
1786 | - if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) |
|
1787 | - fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1878 | + if (isset($_POST['message']) && strtolower($_POST['message']) == 'i am the administrator.' && !$user_info['is_admin']) { |
|
1879 | + fatal_error('Knave! Masquerader! Charlatan!', false); |
|
1880 | + } |
|
1788 | 1881 | |
1789 | 1882 | // Validate the poll... |
1790 | 1883 | if (isset($_REQUEST['poll']) && $modSettings['pollMode'] == '1') |
1791 | 1884 | { |
1792 | - if (!empty($topic) && !isset($_REQUEST['msg'])) |
|
1793 | - fatal_lang_error('no_access', false); |
|
1885 | + if (!empty($topic) && !isset($_REQUEST['msg'])) { |
|
1886 | + fatal_lang_error('no_access', false); |
|
1887 | + } |
|
1794 | 1888 | |
1795 | 1889 | // This is a new topic... so it's a new poll. |
1796 | - if (empty($topic)) |
|
1797 | - isAllowedTo('poll_post'); |
|
1890 | + if (empty($topic)) { |
|
1891 | + isAllowedTo('poll_post'); |
|
1892 | + } |
|
1798 | 1893 | // Can you add to your own topics? |
1799 | - elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) |
|
1800 | - isAllowedTo('poll_add_own'); |
|
1894 | + elseif ($user_info['id'] == $topic_info['id_member_started'] && !allowedTo('poll_add_any')) { |
|
1895 | + isAllowedTo('poll_add_own'); |
|
1896 | + } |
|
1801 | 1897 | // Can you add polls to any topic, then? |
1802 | - else |
|
1803 | - isAllowedTo('poll_add_any'); |
|
1898 | + else { |
|
1899 | + isAllowedTo('poll_add_any'); |
|
1900 | + } |
|
1804 | 1901 | |
1805 | - if (!isset($_POST['question']) || trim($_POST['question']) == '') |
|
1806 | - $post_errors[] = 'no_question'; |
|
1902 | + if (!isset($_POST['question']) || trim($_POST['question']) == '') { |
|
1903 | + $post_errors[] = 'no_question'; |
|
1904 | + } |
|
1807 | 1905 | |
1808 | 1906 | $_POST['options'] = empty($_POST['options']) ? array() : htmltrim__recursive($_POST['options']); |
1809 | 1907 | |
1810 | 1908 | // Get rid of empty ones. |
1811 | - foreach ($_POST['options'] as $k => $option) |
|
1812 | - if ($option == '') |
|
1909 | + foreach ($_POST['options'] as $k => $option) { |
|
1910 | + if ($option == '') |
|
1813 | 1911 | unset($_POST['options'][$k], $_POST['options'][$k]); |
1912 | + } |
|
1814 | 1913 | |
1815 | 1914 | // What are you going to vote between with one choice?!? |
1816 | - if (count($_POST['options']) < 2) |
|
1817 | - $post_errors[] = 'poll_few'; |
|
1818 | - elseif (count($_POST['options']) > 256) |
|
1819 | - $post_errors[] = 'poll_many'; |
|
1915 | + if (count($_POST['options']) < 2) { |
|
1916 | + $post_errors[] = 'poll_few'; |
|
1917 | + } elseif (count($_POST['options']) > 256) { |
|
1918 | + $post_errors[] = 'poll_many'; |
|
1919 | + } |
|
1820 | 1920 | } |
1821 | 1921 | |
1822 | 1922 | if ($posterIsGuest) |
1823 | 1923 | { |
1824 | 1924 | // If user is a guest, make sure the chosen name isn't taken. |
1825 | 1925 | require_once($sourcedir . '/Subs-Members.php'); |
1826 | - if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) |
|
1827 | - $post_errors[] = 'bad_name'; |
|
1926 | + if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($row['poster_name']) || $_POST['guestname'] != $row['poster_name'])) { |
|
1927 | + $post_errors[] = 'bad_name'; |
|
1928 | + } |
|
1828 | 1929 | } |
1829 | 1930 | // If the user isn't a guest, get his or her name and email. |
1830 | 1931 | elseif (!isset($_REQUEST['msg'])) |
@@ -1855,8 +1956,9 @@ discard block |
||
1855 | 1956 | } |
1856 | 1957 | |
1857 | 1958 | // Make sure the user isn't spamming the board. |
1858 | - if (!isset($_REQUEST['msg'])) |
|
1859 | - spamProtection('post'); |
|
1959 | + if (!isset($_REQUEST['msg'])) { |
|
1960 | + spamProtection('post'); |
|
1961 | + } |
|
1860 | 1962 | |
1861 | 1963 | // At about this point, we're posting and that's that. |
1862 | 1964 | ignore_user_abort(true); |
@@ -1869,32 +1971,36 @@ discard block |
||
1869 | 1971 | $_POST['modify_reason'] = empty($_POST['modify_reason']) ? '' : strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
1870 | 1972 | |
1871 | 1973 | // At this point, we want to make sure the subject isn't too long. |
1872 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
1873 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1974 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
1975 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
1976 | + } |
|
1874 | 1977 | |
1875 | 1978 | // Same with the "why did you edit this" text. |
1876 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
1877 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1979 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
1980 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
1981 | + } |
|
1878 | 1982 | |
1879 | 1983 | // Make the poll... |
1880 | 1984 | if (isset($_REQUEST['poll'])) |
1881 | 1985 | { |
1882 | 1986 | // Make sure that the user has not entered a ridiculous number of options.. |
1883 | - if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) |
|
1884 | - $_POST['poll_max_votes'] = 1; |
|
1885 | - elseif ($_POST['poll_max_votes'] > count($_POST['options'])) |
|
1886 | - $_POST['poll_max_votes'] = count($_POST['options']); |
|
1887 | - else |
|
1888 | - $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1987 | + if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) { |
|
1988 | + $_POST['poll_max_votes'] = 1; |
|
1989 | + } elseif ($_POST['poll_max_votes'] > count($_POST['options'])) { |
|
1990 | + $_POST['poll_max_votes'] = count($_POST['options']); |
|
1991 | + } else { |
|
1992 | + $_POST['poll_max_votes'] = (int) $_POST['poll_max_votes']; |
|
1993 | + } |
|
1889 | 1994 | |
1890 | 1995 | $_POST['poll_expire'] = (int) $_POST['poll_expire']; |
1891 | 1996 | $_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']); |
1892 | 1997 | |
1893 | 1998 | // Just set it to zero if it's not there.. |
1894 | - if (!isset($_POST['poll_hide'])) |
|
1895 | - $_POST['poll_hide'] = 0; |
|
1896 | - else |
|
1897 | - $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
1999 | + if (!isset($_POST['poll_hide'])) { |
|
2000 | + $_POST['poll_hide'] = 0; |
|
2001 | + } else { |
|
2002 | + $_POST['poll_hide'] = (int) $_POST['poll_hide']; |
|
2003 | + } |
|
1898 | 2004 | $_POST['poll_change_vote'] = isset($_POST['poll_change_vote']) ? 1 : 0; |
1899 | 2005 | |
1900 | 2006 | $_POST['poll_guest_vote'] = isset($_POST['poll_guest_vote']) ? 1 : 0; |
@@ -1903,16 +2009,19 @@ discard block |
||
1903 | 2009 | { |
1904 | 2010 | require_once($sourcedir . '/Subs-Members.php'); |
1905 | 2011 | $allowedVoteGroups = groupsAllowedTo('poll_vote', $board); |
1906 | - if (!in_array(-1, $allowedVoteGroups['allowed'])) |
|
1907 | - $_POST['poll_guest_vote'] = 0; |
|
2012 | + if (!in_array(-1, $allowedVoteGroups['allowed'])) { |
|
2013 | + $_POST['poll_guest_vote'] = 0; |
|
2014 | + } |
|
1908 | 2015 | } |
1909 | 2016 | |
1910 | 2017 | // If the user tries to set the poll too far in advance, don't let them. |
1911 | - if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) |
|
1912 | - fatal_lang_error('poll_range_error', false); |
|
2018 | + if (!empty($_POST['poll_expire']) && $_POST['poll_expire'] < 1) { |
|
2019 | + fatal_lang_error('poll_range_error', false); |
|
2020 | + } |
|
1913 | 2021 | // Don't allow them to select option 2 for hidden results if it's not time limited. |
1914 | - elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) |
|
1915 | - $_POST['poll_hide'] = 1; |
|
2022 | + elseif (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) { |
|
2023 | + $_POST['poll_hide'] = 1; |
|
2024 | + } |
|
1916 | 2025 | |
1917 | 2026 | // Clean up the question and answers. |
1918 | 2027 | $_POST['question'] = $smcFunc['htmlspecialchars']($_POST['question']); |
@@ -1926,13 +2035,15 @@ discard block |
||
1926 | 2035 | { |
1927 | 2036 | $attachIDs = array(); |
1928 | 2037 | $attach_errors = array(); |
1929 | - if (!empty($context['we_are_history'])) |
|
1930 | - $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2038 | + if (!empty($context['we_are_history'])) { |
|
2039 | + $attach_errors[] = '<dd>' . $txt['error_temp_attachments_flushed'] . '<br><br></dd>'; |
|
2040 | + } |
|
1931 | 2041 | |
1932 | 2042 | foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) |
1933 | 2043 | { |
1934 | - if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) |
|
1935 | - continue; |
|
2044 | + if ($attachID != 'initial_error' && strpos($attachID, 'post_tmp_' . $user_info['id']) === false) { |
|
2045 | + continue; |
|
2046 | + } |
|
1936 | 2047 | |
1937 | 2048 | // If there was an initial error just show that message. |
1938 | 2049 | if ($attachID == 'initial_error') |
@@ -1961,12 +2072,13 @@ discard block |
||
1961 | 2072 | if (createAttachment($attachmentOptions)) |
1962 | 2073 | { |
1963 | 2074 | $attachIDs[] = $attachmentOptions['id']; |
1964 | - if (!empty($attachmentOptions['thumb'])) |
|
1965 | - $attachIDs[] = $attachmentOptions['thumb']; |
|
2075 | + if (!empty($attachmentOptions['thumb'])) { |
|
2076 | + $attachIDs[] = $attachmentOptions['thumb']; |
|
2077 | + } |
|
1966 | 2078 | } |
2079 | + } else { |
|
2080 | + $attach_errors[] = '<dt> </dt>'; |
|
1967 | 2081 | } |
1968 | - else |
|
1969 | - $attach_errors[] = '<dt> </dt>'; |
|
1970 | 2082 | |
1971 | 2083 | if (!empty($attachmentOptions['errors'])) |
1972 | 2084 | { |
@@ -1978,14 +2090,16 @@ discard block |
||
1978 | 2090 | if (!is_array($error)) |
1979 | 2091 | { |
1980 | 2092 | $attach_errors[] = '<dd>' . $txt[$error] . '</dd>'; |
1981 | - if (in_array($error, $log_these)) |
|
1982 | - log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2093 | + if (in_array($error, $log_these)) { |
|
2094 | + log_error($attachment['name'] . ': ' . $txt[$error], 'critical'); |
|
2095 | + } |
|
2096 | + } else { |
|
2097 | + $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1983 | 2098 | } |
1984 | - else |
|
1985 | - $attach_errors[] = '<dd>' . vsprintf($txt[$error[0]], $error[1]) . '</dd>'; |
|
1986 | 2099 | } |
1987 | - if (file_exists($attachment['tmp_name'])) |
|
1988 | - unlink($attachment['tmp_name']); |
|
2100 | + if (file_exists($attachment['tmp_name'])) { |
|
2101 | + unlink($attachment['tmp_name']); |
|
2102 | + } |
|
1989 | 2103 | } |
1990 | 2104 | } |
1991 | 2105 | unset($_SESSION['temp_attachments']); |
@@ -2026,24 +2140,24 @@ discard block |
||
2026 | 2140 | ); |
2027 | 2141 | |
2028 | 2142 | call_integration_hook('integrate_poll_add_edit', array($id_poll, false)); |
2143 | + } else { |
|
2144 | + $id_poll = 0; |
|
2029 | 2145 | } |
2030 | - else |
|
2031 | - $id_poll = 0; |
|
2032 | 2146 | |
2033 | 2147 | // Creating a new topic? |
2034 | 2148 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
2035 | 2149 | |
2036 | 2150 | // Check the icon. |
2037 | - if (!isset($_POST['icon'])) |
|
2038 | - $_POST['icon'] = 'xx'; |
|
2039 | - |
|
2040 | - else |
|
2151 | + if (!isset($_POST['icon'])) { |
|
2152 | + $_POST['icon'] = 'xx'; |
|
2153 | + } else |
|
2041 | 2154 | { |
2042 | 2155 | $_POST['icon'] = $smcFunc['htmlspecialchars']($_POST['icon']); |
2043 | 2156 | |
2044 | 2157 | // Need to figure it out if this is a valid icon name. |
2045 | - if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) |
|
2046 | - $_POST['icon'] = 'xx'; |
|
2158 | + if ((!file_exists($settings['theme_dir'] . '/images/post/' . $_POST['icon'] . '.png')) && (!file_exists($settings['default_theme_dir'] . '/images/post/' . $_POST['icon'] . '.png'))) { |
|
2159 | + $_POST['icon'] = 'xx'; |
|
2160 | + } |
|
2047 | 2161 | } |
2048 | 2162 | |
2049 | 2163 | // Collect all parameters for the creation or modification of a post. |
@@ -2084,8 +2198,9 @@ discard block |
||
2084 | 2198 | } |
2085 | 2199 | |
2086 | 2200 | // This will save some time... |
2087 | - if (empty($approve_has_changed)) |
|
2088 | - unset($msgOptions['approved']); |
|
2201 | + if (empty($approve_has_changed)) { |
|
2202 | + unset($msgOptions['approved']); |
|
2203 | + } |
|
2089 | 2204 | |
2090 | 2205 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2091 | 2206 | } |
@@ -2094,8 +2209,9 @@ discard block |
||
2094 | 2209 | { |
2095 | 2210 | createPost($msgOptions, $topicOptions, $posterOptions); |
2096 | 2211 | |
2097 | - if (isset($topicOptions['id'])) |
|
2098 | - $topic = $topicOptions['id']; |
|
2212 | + if (isset($topicOptions['id'])) { |
|
2213 | + $topic = $topicOptions['id']; |
|
2214 | + } |
|
2099 | 2215 | } |
2100 | 2216 | |
2101 | 2217 | // Assign the previously uploaded attachments to the brand new message. |
@@ -2107,8 +2223,9 @@ discard block |
||
2107 | 2223 | } |
2108 | 2224 | |
2109 | 2225 | // If we had a draft for this, its time to remove it since it was just posted |
2110 | - if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) |
|
2111 | - DeleteDraft($_POST['id_draft']); |
|
2226 | + if (!empty($modSettings['drafts_post_enabled']) && !empty($_POST['id_draft'])) { |
|
2227 | + DeleteDraft($_POST['id_draft']); |
|
2228 | + } |
|
2112 | 2229 | |
2113 | 2230 | // Editing or posting an event? |
2114 | 2231 | if (isset($_POST['calendar']) && (!isset($_REQUEST['eventid']) || $_REQUEST['eventid'] == -1)) |
@@ -2127,8 +2244,7 @@ discard block |
||
2127 | 2244 | 'member' => $user_info['id'], |
2128 | 2245 | ); |
2129 | 2246 | insertEvent($eventOptions); |
2130 | - } |
|
2131 | - elseif (isset($_POST['calendar'])) |
|
2247 | + } elseif (isset($_POST['calendar'])) |
|
2132 | 2248 | { |
2133 | 2249 | $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
2134 | 2250 | |
@@ -2156,14 +2272,15 @@ discard block |
||
2156 | 2272 | } |
2157 | 2273 | |
2158 | 2274 | // Delete it? |
2159 | - if (isset($_REQUEST['deleteevent'])) |
|
2160 | - $smcFunc['db_query']('', ' |
|
2275 | + if (isset($_REQUEST['deleteevent'])) { |
|
2276 | + $smcFunc['db_query']('', ' |
|
2161 | 2277 | DELETE FROM {db_prefix}calendar |
2162 | 2278 | WHERE id_event = {int:id_event}', |
2163 | 2279 | array( |
2164 | 2280 | 'id_event' => $_REQUEST['eventid'], |
2165 | 2281 | ) |
2166 | 2282 | ); |
2283 | + } |
|
2167 | 2284 | // ... or just update it? |
2168 | 2285 | else |
2169 | 2286 | { |
@@ -2205,9 +2322,8 @@ discard block |
||
2205 | 2322 | array($user_info['id'], $topic, 0), |
2206 | 2323 | array('id_member', 'id_topic', 'id_board') |
2207 | 2324 | ); |
2208 | - } |
|
2209 | - elseif (!$newTopic) |
|
2210 | - $smcFunc['db_query']('', ' |
|
2325 | + } elseif (!$newTopic) { |
|
2326 | + $smcFunc['db_query']('', ' |
|
2211 | 2327 | DELETE FROM {db_prefix}log_notify |
2212 | 2328 | WHERE id_member = {int:current_member} |
2213 | 2329 | AND id_topic = {int:current_topic}', |
@@ -2216,16 +2332,20 @@ discard block |
||
2216 | 2332 | 'current_topic' => $topic, |
2217 | 2333 | ) |
2218 | 2334 | ); |
2335 | + } |
|
2219 | 2336 | |
2220 | 2337 | // Log an act of moderation - modifying. |
2221 | - if (!empty($moderationAction)) |
|
2222 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2338 | + if (!empty($moderationAction)) { |
|
2339 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
2340 | + } |
|
2223 | 2341 | |
2224 | - if (isset($_POST['lock']) && $_POST['lock'] != 2) |
|
2225 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2342 | + if (isset($_POST['lock']) && $_POST['lock'] != 2) { |
|
2343 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2344 | + } |
|
2226 | 2345 | |
2227 | - if (isset($_POST['sticky'])) |
|
2228 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2346 | + if (isset($_POST['sticky'])) { |
|
2347 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
2348 | + } |
|
2229 | 2349 | |
2230 | 2350 | // Returning to the topic? |
2231 | 2351 | if (!empty($_REQUEST['goback'])) |
@@ -2244,26 +2364,31 @@ discard block |
||
2244 | 2364 | ); |
2245 | 2365 | } |
2246 | 2366 | |
2247 | - if ($board_info['num_topics'] == 0) |
|
2248 | - cache_put_data('board-' . $board, null, 120); |
|
2367 | + if ($board_info['num_topics'] == 0) { |
|
2368 | + cache_put_data('board-' . $board, null, 120); |
|
2369 | + } |
|
2249 | 2370 | |
2250 | 2371 | call_integration_hook('integrate_post2_end'); |
2251 | 2372 | |
2252 | - if (!empty($_POST['announce_topic'])) |
|
2253 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2373 | + if (!empty($_POST['announce_topic'])) { |
|
2374 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2375 | + } |
|
2254 | 2376 | |
2255 | - if (!empty($_POST['move']) && allowedTo('move_any')) |
|
2256 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2377 | + if (!empty($_POST['move']) && allowedTo('move_any')) { |
|
2378 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2379 | + } |
|
2257 | 2380 | |
2258 | 2381 | // Return to post if the mod is on. |
2259 | - if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
|
2260 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2261 | - elseif (!empty($_REQUEST['goback'])) |
|
2262 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2382 | + if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) { |
|
2383 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
2384 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2385 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
2386 | + } |
|
2263 | 2387 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
2264 | - else |
|
2265 | - redirectexit('board=' . $board . '.0'); |
|
2266 | -} |
|
2388 | + else { |
|
2389 | + redirectexit('board=' . $board . '.0'); |
|
2390 | + } |
|
2391 | + } |
|
2267 | 2392 | |
2268 | 2393 | /** |
2269 | 2394 | * Handle the announce topic function (action=announce). |
@@ -2281,8 +2406,9 @@ discard block |
||
2281 | 2406 | |
2282 | 2407 | validateSession(); |
2283 | 2408 | |
2284 | - if (empty($topic)) |
|
2285 | - fatal_lang_error('topic_gone', false); |
|
2409 | + if (empty($topic)) { |
|
2410 | + fatal_lang_error('topic_gone', false); |
|
2411 | + } |
|
2286 | 2412 | |
2287 | 2413 | loadLanguage('Post'); |
2288 | 2414 | loadTemplate('Post'); |
@@ -2309,8 +2435,9 @@ discard block |
||
2309 | 2435 | global $txt, $context, $topic, $board, $board_info, $smcFunc; |
2310 | 2436 | |
2311 | 2437 | $groups = array_merge($board_info['groups'], array(1)); |
2312 | - foreach ($groups as $id => $group) |
|
2313 | - $groups[$id] = (int) $group; |
|
2438 | + foreach ($groups as $id => $group) { |
|
2439 | + $groups[$id] = (int) $group; |
|
2440 | + } |
|
2314 | 2441 | |
2315 | 2442 | $context['groups'] = array(); |
2316 | 2443 | if (in_array(0, $groups)) |
@@ -2353,8 +2480,9 @@ discard block |
||
2353 | 2480 | 'group_list' => $groups, |
2354 | 2481 | ) |
2355 | 2482 | ); |
2356 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2357 | - $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2483 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2484 | + $context['groups'][$row['id_group']]['name'] = $row['group_name']; |
|
2485 | + } |
|
2358 | 2486 | $smcFunc['db_free_result']($request); |
2359 | 2487 | |
2360 | 2488 | // Get the subject of the topic we're about to announce. |
@@ -2396,16 +2524,19 @@ discard block |
||
2396 | 2524 | $context['start'] = empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start']; |
2397 | 2525 | $groups = array_merge($board_info['groups'], array(1)); |
2398 | 2526 | |
2399 | - if (isset($_POST['membergroups'])) |
|
2400 | - $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2527 | + if (isset($_POST['membergroups'])) { |
|
2528 | + $_POST['who'] = explode(',', $_POST['membergroups']); |
|
2529 | + } |
|
2401 | 2530 | |
2402 | 2531 | // Check whether at least one membergroup was selected. |
2403 | - if (empty($_POST['who'])) |
|
2404 | - fatal_lang_error('no_membergroup_selected'); |
|
2532 | + if (empty($_POST['who'])) { |
|
2533 | + fatal_lang_error('no_membergroup_selected'); |
|
2534 | + } |
|
2405 | 2535 | |
2406 | 2536 | // Make sure all membergroups are integers and can access the board of the announcement. |
2407 | - foreach ($_POST['who'] as $id => $mg) |
|
2408 | - $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2537 | + foreach ($_POST['who'] as $id => $mg) { |
|
2538 | + $_POST['who'][$id] = in_array((int) $mg, $groups) ? (int) $mg : 0; |
|
2539 | + } |
|
2409 | 2540 | |
2410 | 2541 | // Get the topic subject and censor it. |
2411 | 2542 | $request = $smcFunc['db_query']('', ' |
@@ -2451,12 +2582,13 @@ discard block |
||
2451 | 2582 | if ($smcFunc['db_num_rows']($request) == 0) |
2452 | 2583 | { |
2453 | 2584 | logAction('announce_topic', array('topic' => $topic), 'user'); |
2454 | - if (!empty($_REQUEST['move']) && allowedTo('move_any')) |
|
2455 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2456 | - elseif (!empty($_REQUEST['goback'])) |
|
2457 | - redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2458 | - else |
|
2459 | - redirectexit('board=' . $board . '.0'); |
|
2585 | + if (!empty($_REQUEST['move']) && allowedTo('move_any')) { |
|
2586 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
2587 | + } elseif (!empty($_REQUEST['goback'])) { |
|
2588 | + redirectexit('topic=' . $topic . '.new;boardseen#new', isBrowser('ie')); |
|
2589 | + } else { |
|
2590 | + redirectexit('board=' . $board . '.0'); |
|
2591 | + } |
|
2460 | 2592 | } |
2461 | 2593 | |
2462 | 2594 | $announcements = array(); |
@@ -2475,8 +2607,9 @@ discard block |
||
2475 | 2607 | foreach ($rows as $row) |
2476 | 2608 | { |
2477 | 2609 | // Force them to have it? |
2478 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
2479 | - continue; |
|
2610 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
2611 | + continue; |
|
2612 | + } |
|
2480 | 2613 | |
2481 | 2614 | $cur_language = empty($row['lngfile']) || empty($modSettings['userLanguage']) ? $language : $row['lngfile']; |
2482 | 2615 | |
@@ -2504,8 +2637,9 @@ discard block |
||
2504 | 2637 | } |
2505 | 2638 | |
2506 | 2639 | // For each language send a different mail - low priority... |
2507 | - foreach ($announcements as $lang => $mail) |
|
2508 | - sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2640 | + foreach ($announcements as $lang => $mail) { |
|
2641 | + sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, 'ann-' . $lang, $mail['is_html'], 5); |
|
2642 | + } |
|
2509 | 2643 | |
2510 | 2644 | $context['percentage_done'] = round(100 * $context['start'] / $modSettings['latestMember'], 1); |
2511 | 2645 | |
@@ -2515,9 +2649,10 @@ discard block |
||
2515 | 2649 | $context['sub_template'] = 'announcement_send'; |
2516 | 2650 | |
2517 | 2651 | // Go back to the correct language for the user ;). |
2518 | - if (!empty($modSettings['userLanguage'])) |
|
2519 | - loadLanguage('Post'); |
|
2520 | -} |
|
2652 | + if (!empty($modSettings['userLanguage'])) { |
|
2653 | + loadLanguage('Post'); |
|
2654 | + } |
|
2655 | + } |
|
2521 | 2656 | |
2522 | 2657 | /** |
2523 | 2658 | * Get the topic for display purposes. |
@@ -2530,12 +2665,13 @@ discard block |
||
2530 | 2665 | { |
2531 | 2666 | global $topic, $modSettings, $context, $smcFunc, $counter, $options; |
2532 | 2667 | |
2533 | - if (isset($_REQUEST['xml'])) |
|
2534 | - $limit = ' |
|
2668 | + if (isset($_REQUEST['xml'])) { |
|
2669 | + $limit = ' |
|
2535 | 2670 | LIMIT ' . (empty($context['new_replies']) ? '0' : $context['new_replies']); |
2536 | - else |
|
2537 | - $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2671 | + } else { |
|
2672 | + $limit = empty($modSettings['topicSummaryPosts']) ? '' : ' |
|
2538 | 2673 | LIMIT ' . (int) $modSettings['topicSummaryPosts']; |
2674 | + } |
|
2539 | 2675 | |
2540 | 2676 | // If you're modifying, get only those posts before the current one. (otherwise get all.) |
2541 | 2677 | $request = $smcFunc['db_query']('', ' |
@@ -2573,8 +2709,9 @@ discard block |
||
2573 | 2709 | 'is_ignored' => !empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($row['id_member'], $context['user']['ignoreusers']), |
2574 | 2710 | ); |
2575 | 2711 | |
2576 | - if (!empty($context['new_replies'])) |
|
2577 | - $context['new_replies']--; |
|
2712 | + if (!empty($context['new_replies'])) { |
|
2713 | + $context['new_replies']--; |
|
2714 | + } |
|
2578 | 2715 | } |
2579 | 2716 | $smcFunc['db_free_result']($request); |
2580 | 2717 | } |
@@ -2591,8 +2728,9 @@ discard block |
||
2591 | 2728 | global $sourcedir, $smcFunc; |
2592 | 2729 | |
2593 | 2730 | loadLanguage('Post'); |
2594 | - if (!isset($_REQUEST['xml'])) |
|
2595 | - loadTemplate('Post'); |
|
2731 | + if (!isset($_REQUEST['xml'])) { |
|
2732 | + loadTemplate('Post'); |
|
2733 | + } |
|
2596 | 2734 | |
2597 | 2735 | include_once($sourcedir . '/Subs-Post.php'); |
2598 | 2736 | |
@@ -2623,8 +2761,9 @@ discard block |
||
2623 | 2761 | $smcFunc['db_free_result']($request); |
2624 | 2762 | |
2625 | 2763 | $context['sub_template'] = 'quotefast'; |
2626 | - if (!empty($row)) |
|
2627 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2764 | + if (!empty($row)) { |
|
2765 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
2766 | + } |
|
2628 | 2767 | |
2629 | 2768 | if (!empty($can_view_post)) |
2630 | 2769 | { |
@@ -2657,8 +2796,9 @@ discard block |
||
2657 | 2796 | } |
2658 | 2797 | |
2659 | 2798 | // Remove any nested quotes. |
2660 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
2661 | - $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2799 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
2800 | + $row['body'] = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $row['body']); |
|
2801 | + } |
|
2662 | 2802 | |
2663 | 2803 | $lb = "\n"; |
2664 | 2804 | |
@@ -2684,14 +2824,14 @@ discard block |
||
2684 | 2824 | 'time' => '', |
2685 | 2825 | ), |
2686 | 2826 | ); |
2687 | - } |
|
2688 | - else |
|
2689 | - $context['quote'] = array( |
|
2827 | + } else { |
|
2828 | + $context['quote'] = array( |
|
2690 | 2829 | 'xml' => '', |
2691 | 2830 | 'mozilla' => '', |
2692 | 2831 | 'text' => '', |
2693 | 2832 | ); |
2694 | -} |
|
2833 | + } |
|
2834 | + } |
|
2695 | 2835 | |
2696 | 2836 | /** |
2697 | 2837 | * Used to edit the body or subject of a message inline |
@@ -2703,8 +2843,9 @@ discard block |
||
2703 | 2843 | global $user_info, $context, $smcFunc, $language, $board_info; |
2704 | 2844 | |
2705 | 2845 | // We have to have a topic! |
2706 | - if (empty($topic)) |
|
2707 | - obExit(false); |
|
2846 | + if (empty($topic)) { |
|
2847 | + obExit(false); |
|
2848 | + } |
|
2708 | 2849 | |
2709 | 2850 | checkSession('get'); |
2710 | 2851 | require_once($sourcedir . '/Subs-Post.php'); |
@@ -2730,31 +2871,35 @@ discard block |
||
2730 | 2871 | 'guest_id' => 0, |
2731 | 2872 | ) |
2732 | 2873 | ); |
2733 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
2734 | - fatal_lang_error('no_board', false); |
|
2874 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
2875 | + fatal_lang_error('no_board', false); |
|
2876 | + } |
|
2735 | 2877 | $row = $smcFunc['db_fetch_assoc']($request); |
2736 | 2878 | $smcFunc['db_free_result']($request); |
2737 | 2879 | |
2738 | 2880 | // Change either body or subject requires permissions to modify messages. |
2739 | 2881 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
2740 | 2882 | { |
2741 | - if (!empty($row['locked'])) |
|
2742 | - isAllowedTo('moderate_board'); |
|
2883 | + if (!empty($row['locked'])) { |
|
2884 | + isAllowedTo('moderate_board'); |
|
2885 | + } |
|
2743 | 2886 | |
2744 | 2887 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
2745 | 2888 | { |
2746 | - if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
|
2747 | - fatal_lang_error('modify_post_time_passed', false); |
|
2748 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
|
2749 | - isAllowedTo('modify_replies'); |
|
2750 | - else |
|
2751 | - isAllowedTo('modify_own'); |
|
2889 | + if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) { |
|
2890 | + fatal_lang_error('modify_post_time_passed', false); |
|
2891 | + } elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) { |
|
2892 | + isAllowedTo('modify_replies'); |
|
2893 | + } else { |
|
2894 | + isAllowedTo('modify_own'); |
|
2895 | + } |
|
2752 | 2896 | } |
2753 | 2897 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
2754 | - elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
|
2755 | - isAllowedTo('modify_replies'); |
|
2756 | - else |
|
2757 | - isAllowedTo('modify_any'); |
|
2898 | + elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) { |
|
2899 | + isAllowedTo('modify_replies'); |
|
2900 | + } else { |
|
2901 | + isAllowedTo('modify_any'); |
|
2902 | + } |
|
2758 | 2903 | |
2759 | 2904 | // Only log this action if it wasn't your message. |
2760 | 2905 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -2766,10 +2911,10 @@ discard block |
||
2766 | 2911 | $_POST['subject'] = strtr($smcFunc['htmlspecialchars']($_POST['subject']), array("\r" => '', "\n" => '', "\t" => '')); |
2767 | 2912 | |
2768 | 2913 | // Maximum number of characters. |
2769 | - if ($smcFunc['strlen']($_POST['subject']) > 100) |
|
2770 | - $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2771 | - } |
|
2772 | - elseif (isset($_POST['subject'])) |
|
2914 | + if ($smcFunc['strlen']($_POST['subject']) > 100) { |
|
2915 | + $_POST['subject'] = $smcFunc['substr']($_POST['subject'], 0, 100); |
|
2916 | + } |
|
2917 | + } elseif (isset($_POST['subject'])) |
|
2773 | 2918 | { |
2774 | 2919 | $post_errors[] = 'no_subject'; |
2775 | 2920 | unset($_POST['subject']); |
@@ -2781,13 +2926,11 @@ discard block |
||
2781 | 2926 | { |
2782 | 2927 | $post_errors[] = 'no_message'; |
2783 | 2928 | unset($_POST['message']); |
2784 | - } |
|
2785 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2929 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_POST['message']) > $modSettings['max_messageLength']) |
|
2786 | 2930 | { |
2787 | 2931 | $post_errors[] = 'long_message'; |
2788 | 2932 | unset($_POST['message']); |
2789 | - } |
|
2790 | - else |
|
2933 | + } else |
|
2791 | 2934 | { |
2792 | 2935 | $_POST['message'] = $smcFunc['htmlspecialchars']($_POST['message'], ENT_QUOTES); |
2793 | 2936 | |
@@ -2803,31 +2946,34 @@ discard block |
||
2803 | 2946 | |
2804 | 2947 | if (isset($_POST['lock'])) |
2805 | 2948 | { |
2806 | - if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) |
|
2807 | - unset($_POST['lock']); |
|
2808 | - elseif (!allowedTo('lock_any')) |
|
2949 | + if (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $row['id_member'])) { |
|
2950 | + unset($_POST['lock']); |
|
2951 | + } elseif (!allowedTo('lock_any')) |
|
2809 | 2952 | { |
2810 | - if ($row['locked'] == 1) |
|
2811 | - unset($_POST['lock']); |
|
2812 | - else |
|
2813 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2953 | + if ($row['locked'] == 1) { |
|
2954 | + unset($_POST['lock']); |
|
2955 | + } else { |
|
2956 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 2; |
|
2957 | + } |
|
2958 | + } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) { |
|
2959 | + unset($_POST['lock']); |
|
2960 | + } else { |
|
2961 | + $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2814 | 2962 | } |
2815 | - elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) |
|
2816 | - unset($_POST['lock']); |
|
2817 | - else |
|
2818 | - $_POST['lock'] = empty($_POST['lock']) ? 0 : 1; |
|
2819 | 2963 | } |
2820 | 2964 | |
2821 | - if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
|
2822 | - unset($_POST['sticky']); |
|
2965 | + if (isset($_POST['sticky']) && !allowedTo('make_sticky')) { |
|
2966 | + unset($_POST['sticky']); |
|
2967 | + } |
|
2823 | 2968 | |
2824 | 2969 | if (isset($_POST['modify_reason'])) |
2825 | 2970 | { |
2826 | 2971 | $_POST['modify_reason'] = strtr($smcFunc['htmlspecialchars']($_POST['modify_reason']), array("\r" => '', "\n" => '', "\t" => '')); |
2827 | 2972 | |
2828 | 2973 | // Maximum number of characters. |
2829 | - if ($smcFunc['strlen']($_POST['modify_reason']) > 100) |
|
2830 | - $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2974 | + if ($smcFunc['strlen']($_POST['modify_reason']) > 100) { |
|
2975 | + $_POST['modify_reason'] = $smcFunc['substr']($_POST['modify_reason'], 0, 100); |
|
2976 | + } |
|
2831 | 2977 | } |
2832 | 2978 | |
2833 | 2979 | if (empty($post_errors)) |
@@ -2864,8 +3010,9 @@ discard block |
||
2864 | 3010 | } |
2865 | 3011 | } |
2866 | 3012 | // If nothing was changed there's no need to add an entry to the moderation log. |
2867 | - else |
|
2868 | - $moderationAction = false; |
|
3013 | + else { |
|
3014 | + $moderationAction = false; |
|
3015 | + } |
|
2869 | 3016 | |
2870 | 3017 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
2871 | 3018 | |
@@ -2883,9 +3030,9 @@ discard block |
||
2883 | 3030 | // Get the proper (default language) response prefix first. |
2884 | 3031 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
2885 | 3032 | { |
2886 | - if ($language === $user_info['language']) |
|
2887 | - $context['response_prefix'] = $txt['response_prefix']; |
|
2888 | - else |
|
3033 | + if ($language === $user_info['language']) { |
|
3034 | + $context['response_prefix'] = $txt['response_prefix']; |
|
3035 | + } else |
|
2889 | 3036 | { |
2890 | 3037 | loadLanguage('index', $language, false); |
2891 | 3038 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -2907,8 +3054,9 @@ discard block |
||
2907 | 3054 | ); |
2908 | 3055 | } |
2909 | 3056 | |
2910 | - if (!empty($moderationAction)) |
|
2911 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3057 | + if (!empty($moderationAction)) { |
|
3058 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
3059 | + } |
|
2912 | 3060 | } |
2913 | 3061 | |
2914 | 3062 | if (isset($_REQUEST['xml'])) |
@@ -2949,8 +3097,7 @@ discard block |
||
2949 | 3097 | ); |
2950 | 3098 | |
2951 | 3099 | censorText($context['message']['subject']); |
2952 | - } |
|
2953 | - else |
|
3100 | + } else |
|
2954 | 3101 | { |
2955 | 3102 | $context['message'] = array( |
2956 | 3103 | 'id' => $row['id_msg'], |
@@ -2962,15 +3109,16 @@ discard block |
||
2962 | 3109 | loadLanguage('Errors'); |
2963 | 3110 | foreach ($post_errors as $post_error) |
2964 | 3111 | { |
2965 | - if ($post_error == 'long_message') |
|
2966 | - $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
2967 | - else |
|
2968 | - $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3112 | + if ($post_error == 'long_message') { |
|
3113 | + $context['message']['errors'][] = sprintf($txt['error_' . $post_error], $modSettings['max_messageLength']); |
|
3114 | + } else { |
|
3115 | + $context['message']['errors'][] = $txt['error_' . $post_error]; |
|
3116 | + } |
|
2969 | 3117 | } |
2970 | 3118 | } |
3119 | + } else { |
|
3120 | + obExit(false); |
|
3121 | + } |
|
2971 | 3122 | } |
2972 | - else |
|
2973 | - obExit(false); |
|
2974 | -} |
|
2975 | 3123 | |
2976 | 3124 | ?> |
2977 | 3125 | \ No newline at end of file |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | <div class="windowbg2 noup">'; |
27 | 27 | |
28 | - if (!empty($context['move_board'])) |
|
29 | - echo ' |
|
28 | + if (!empty($context['move_board'])) { |
|
29 | + echo ' |
|
30 | 30 | <div class="noticebox"> |
31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
32 | 32 | </div>'; |
33 | + } |
|
33 | 34 | |
34 | 35 | // No categories so show a label. |
35 | - if (empty($context['categories'])) |
|
36 | - echo ' |
|
36 | + if (empty($context['categories'])) { |
|
37 | + echo ' |
|
37 | 38 | <div class="windowbg centertext"> |
38 | 39 | ', $txt['mboards_no_cats'], ' |
39 | 40 | </div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Loop through every category, listing the boards in each as we go. |
42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
56 | 58 | |
57 | - if (!empty($category['move_link'])) |
|
58 | - echo ' |
|
59 | + if (!empty($category['move_link'])) { |
|
60 | + echo ' |
|
59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -81,9 +84,10 @@ discard block |
||
81 | 84 | echo ' |
82 | 85 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
83 | 86 | |
84 | - foreach ($board['move_links'] as $link) |
|
85 | - echo ' |
|
87 | + foreach ($board['move_links'] as $link) { |
|
88 | + echo ' |
|
86 | 89 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
90 | + } |
|
87 | 91 | |
88 | 92 | echo ' |
89 | 93 | </li>'; |
@@ -132,9 +136,10 @@ discard block |
||
132 | 136 | <select name="cat_order">'; |
133 | 137 | |
134 | 138 | // Print every existing category into a select box. |
135 | - foreach ($context['category_order'] as $order) |
|
136 | - echo ' |
|
139 | + foreach ($context['category_order'] as $order) { |
|
140 | + echo ' |
|
137 | 141 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
142 | + } |
|
138 | 143 | echo ' |
139 | 144 | </select> |
140 | 145 | </dd>'; |
@@ -169,14 +174,15 @@ discard block |
||
169 | 174 | { |
170 | 175 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
171 | 176 | { |
172 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
173 | - echo ' |
|
177 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
178 | + echo ' |
|
174 | 179 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
175 | 180 | ', $catset['dt'], ' |
176 | 181 | </dt> |
177 | 182 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
178 | 183 | ', $catset['dd'], ' |
179 | 184 | </dd>'; |
185 | + } |
|
180 | 186 | } |
181 | 187 | } |
182 | 188 | |
@@ -184,21 +190,23 @@ discard block |
||
184 | 190 | echo ' |
185 | 191 | </dl>'; |
186 | 192 | |
187 | - if (isset($context['category']['is_new'])) |
|
188 | - echo ' |
|
193 | + if (isset($context['category']['is_new'])) { |
|
194 | + echo ' |
|
189 | 195 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">'; |
190 | - else |
|
191 | - echo ' |
|
196 | + } else { |
|
197 | + echo ' |
|
192 | 198 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit"> |
193 | 199 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button_submit you_sure">'; |
200 | + } |
|
194 | 201 | echo ' |
195 | 202 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
196 | 203 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
197 | 204 | |
198 | 205 | // If this category is empty we don't bother with the next confirmation screen. |
199 | - if ($context['category']['is_empty']) |
|
200 | - echo ' |
|
206 | + if ($context['category']['is_empty']) { |
|
207 | + echo ' |
|
201 | 208 | <input type="hidden" name="empty" value="1">'; |
209 | + } |
|
202 | 210 | |
203 | 211 | echo ' |
204 | 212 | </div> |
@@ -225,9 +233,10 @@ discard block |
||
225 | 233 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
226 | 234 | <ul>'; |
227 | 235 | |
228 | - foreach ($context['category']['children'] as $child) |
|
229 | - echo ' |
|
236 | + foreach ($context['category']['children'] as $child) { |
|
237 | + echo ' |
|
230 | 238 | <li>', $child, '</li>'; |
239 | + } |
|
231 | 240 | |
232 | 241 | echo ' |
233 | 242 | </ul> |
@@ -241,10 +250,11 @@ discard block |
||
241 | 250 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
242 | 251 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
243 | 252 | |
244 | - foreach ($context['category_order'] as $cat) |
|
245 | - if ($cat['id'] != 0) |
|
253 | + foreach ($context['category_order'] as $cat) { |
|
254 | + if ($cat['id'] != 0) |
|
246 | 255 | echo ' |
247 | 256 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
257 | + } |
|
248 | 258 | |
249 | 259 | echo ' |
250 | 260 | </select> |
@@ -288,9 +298,10 @@ discard block |
||
288 | 298 | </dt> |
289 | 299 | <dd> |
290 | 300 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
291 | - foreach ($context['categories'] as $category) |
|
292 | - echo ' |
|
301 | + foreach ($context['categories'] as $category) { |
|
302 | + echo ' |
|
293 | 303 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
304 | + } |
|
294 | 305 | echo ' |
295 | 306 | </select> |
296 | 307 | </dd>'; |
@@ -317,9 +328,10 @@ discard block |
||
317 | 328 | echo ' |
318 | 329 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
319 | 330 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
320 | - foreach ($context['board_order'] as $order) |
|
321 | - echo ' |
|
331 | + foreach ($context['board_order'] as $order) { |
|
332 | + echo ' |
|
322 | 333 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
334 | + } |
|
323 | 335 | echo ' |
324 | 336 | </select> |
325 | 337 | </dd>'; |
@@ -348,13 +360,15 @@ discard block |
||
348 | 360 | <dd> |
349 | 361 | <select name="profile">'; |
350 | 362 | |
351 | - if (isset($context['board']['is_new'])) |
|
352 | - echo ' |
|
363 | + if (isset($context['board']['is_new'])) { |
|
364 | + echo ' |
|
353 | 365 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
366 | + } |
|
354 | 367 | |
355 | - foreach ($context['profiles'] as $id => $profile) |
|
356 | - echo ' |
|
368 | + foreach ($context['profiles'] as $id => $profile) { |
|
369 | + echo ' |
|
357 | 370 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
371 | + } |
|
358 | 372 | |
359 | 373 | echo ' |
360 | 374 | </select> |
@@ -367,8 +381,8 @@ discard block |
||
367 | 381 | </dt> |
368 | 382 | <dd>'; |
369 | 383 | |
370 | - if (!empty($modSettings['deny_boards_access'])) |
|
371 | - echo ' |
|
384 | + if (!empty($modSettings['deny_boards_access'])) { |
|
385 | + echo ' |
|
372 | 386 | <table> |
373 | 387 | <tr> |
374 | 388 | <td></td> |
@@ -376,10 +390,11 @@ discard block |
||
376 | 390 | <th>', $txt['permissions_option_off'], '</th> |
377 | 391 | <th>', $txt['permissions_option_deny'], '</th> |
378 | 392 | </tr>'; |
393 | + } |
|
379 | 394 | |
380 | 395 | // List all the membergroups so the user can choose who may access this board. |
381 | - foreach ($context['groups'] as $group) |
|
382 | - if (empty($modSettings['deny_boards_access'])) |
|
396 | + foreach ($context['groups'] as $group) { |
|
397 | + if (empty($modSettings['deny_boards_access'])) |
|
383 | 398 | echo ' |
384 | 399 | <label for="groups_', $group['id'], '"> |
385 | 400 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), ' class="input_check"> |
@@ -387,8 +402,9 @@ discard block |
||
387 | 402 | ', $group['name'], ' |
388 | 403 | </span> |
389 | 404 | </label><br>'; |
390 | - else |
|
391 | - echo ' |
|
405 | + } |
|
406 | + else { |
|
407 | + echo ' |
|
392 | 408 | <tr> |
393 | 409 | <td> |
394 | 410 | <label for="groups_', $group['id'], '_a"> |
@@ -408,16 +424,17 @@ discard block |
||
408 | 424 | </td> |
409 | 425 | <td></td> |
410 | 426 | </tr>'; |
427 | + } |
|
411 | 428 | |
412 | - if (empty($modSettings['deny_boards_access'])) |
|
413 | - echo ' |
|
429 | + if (empty($modSettings['deny_boards_access'])) { |
|
430 | + echo ' |
|
414 | 431 | <span class="select_all_box"> |
415 | 432 | <em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[\');"> |
416 | 433 | </span> |
417 | 434 | <br><br> |
418 | 435 | </dd>'; |
419 | - else |
|
420 | - echo ' |
|
436 | + } else { |
|
437 | + echo ' |
|
421 | 438 | <tr class="select_all_box"> |
422 | 439 | <td> |
423 | 440 | </td> |
@@ -436,6 +453,7 @@ discard block |
||
436 | 453 | </tr> |
437 | 454 | </table> |
438 | 455 | </dd>'; |
456 | + } |
|
439 | 457 | |
440 | 458 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
441 | 459 | echo ' |
@@ -490,8 +508,8 @@ discard block |
||
490 | 508 | </dl> |
491 | 509 | </div>'; |
492 | 510 | |
493 | - if ($context['board']['redirect']) |
|
494 | - echo ' |
|
511 | + if ($context['board']['redirect']) { |
|
512 | + echo ' |
|
495 | 513 | <div id="reset_redirect_div"> |
496 | 514 | <dl class="settings"> |
497 | 515 | <dt> |
@@ -504,6 +522,7 @@ discard block |
||
504 | 522 | </dd> |
505 | 523 | </dl> |
506 | 524 | </div>'; |
525 | + } |
|
507 | 526 | } |
508 | 527 | |
509 | 528 | echo ' |
@@ -531,9 +550,10 @@ discard block |
||
531 | 550 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
532 | 551 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
533 | 552 | |
534 | - foreach ($context['themes'] as $theme) |
|
535 | - echo ' |
|
553 | + foreach ($context['themes'] as $theme) { |
|
554 | + echo ' |
|
536 | 555 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
556 | + } |
|
537 | 557 | |
538 | 558 | echo ' |
539 | 559 | </select> |
@@ -562,14 +582,15 @@ discard block |
||
562 | 582 | |
563 | 583 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
564 | 584 | { |
565 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
566 | - echo ' |
|
585 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
586 | + echo ' |
|
567 | 587 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
568 | 588 | ', $cbs['dt'], ' |
569 | 589 | </dt> |
570 | 590 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
571 | 591 | ', $cbs['dd'], ' |
572 | 592 | </dd>'; |
593 | + } |
|
573 | 594 | } |
574 | 595 | |
575 | 596 | echo ' |
@@ -577,9 +598,10 @@ discard block |
||
577 | 598 | </div>'; |
578 | 599 | } |
579 | 600 | |
580 | - if (!empty($context['board']['is_recycle'])) |
|
581 | - echo ' |
|
601 | + if (!empty($context['board']['is_recycle'])) { |
|
602 | + echo ' |
|
582 | 603 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
604 | + } |
|
583 | 605 | |
584 | 606 | echo ' |
585 | 607 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -587,21 +609,24 @@ discard block |
||
587 | 609 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
588 | 610 | |
589 | 611 | // If this board has no children don't bother with the next confirmation screen. |
590 | - if ($context['board']['no_children']) |
|
591 | - echo ' |
|
612 | + if ($context['board']['no_children']) { |
|
613 | + echo ' |
|
592 | 614 | <input type="hidden" name="no_children" value="1">'; |
615 | + } |
|
593 | 616 | |
594 | - if (isset($context['board']['is_new'])) |
|
595 | - echo ' |
|
617 | + if (isset($context['board']['is_new'])) { |
|
618 | + echo ' |
|
596 | 619 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
597 | 620 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
598 | - else |
|
599 | - echo ' |
|
621 | + } else { |
|
622 | + echo ' |
|
600 | 623 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">'; |
624 | + } |
|
601 | 625 | |
602 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
603 | - echo ' |
|
626 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
627 | + echo ' |
|
604 | 628 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button_submit you_sure">'; |
629 | + } |
|
605 | 630 | echo ' |
606 | 631 | </div> |
607 | 632 | </form> |
@@ -622,12 +647,13 @@ discard block |
||
622 | 647 | sItemListContainerId: \'moderator_container\', |
623 | 648 | aListItems: ['; |
624 | 649 | |
625 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
626 | - echo ' |
|
650 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
651 | + echo ' |
|
627 | 652 | { |
628 | 653 | sItemId: ', JavaScriptEscape($id_member), ', |
629 | 654 | sItemName: ', JavaScriptEscape($member_name), ' |
630 | 655 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
656 | + } |
|
631 | 657 | |
632 | 658 | echo ' |
633 | 659 | ] |
@@ -647,12 +673,13 @@ discard block |
||
647 | 673 | sItemListContainerId: \'moderator_group_container\', |
648 | 674 | aListItems: ['; |
649 | 675 | |
650 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
651 | - echo ' |
|
676 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
677 | + echo ' |
|
652 | 678 | { |
653 | 679 | sItemId: ', JavaScriptEscape($id_group), ', |
654 | 680 | sItemName: ', JavaScriptEscape($group_name), ' |
655 | 681 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
682 | + } |
|
656 | 683 | |
657 | 684 | echo ' |
658 | 685 | ] |
@@ -678,17 +705,19 @@ discard block |
||
678 | 705 | echo ' |
679 | 706 | document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; |
680 | 707 | |
681 | - if ($context['board']['redirect']) |
|
682 | - echo ' |
|
708 | + if ($context['board']['redirect']) { |
|
709 | + echo ' |
|
683 | 710 | document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; |
711 | + } |
|
684 | 712 | } |
685 | 713 | |
686 | 714 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
687 | 715 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
688 | 716 | { |
689 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
690 | - echo ' |
|
717 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
718 | + echo ' |
|
691 | 719 | ', $refreshOption; |
720 | + } |
|
692 | 721 | } |
693 | 722 | |
694 | 723 | echo ' |
@@ -717,9 +746,10 @@ discard block |
||
717 | 746 | <p>', $txt['mboards_delete_board_contains'], '</p> |
718 | 747 | <ul>'; |
719 | 748 | |
720 | - foreach ($context['children'] as $child) |
|
721 | - echo ' |
|
749 | + foreach ($context['children'] as $child) { |
|
750 | + echo ' |
|
722 | 751 | <li>', $child['node']['name'], '</li>'; |
752 | + } |
|
723 | 753 | |
724 | 754 | echo ' |
725 | 755 | </ul> |
@@ -733,10 +763,11 @@ discard block |
||
733 | 763 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
734 | 764 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
735 | 765 | |
736 | - foreach ($context['board_order'] as $board) |
|
737 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
766 | + foreach ($context['board_order'] as $board) { |
|
767 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
738 | 768 | echo ' |
739 | 769 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
770 | + } |
|
740 | 771 | |
741 | 772 | echo ' |
742 | 773 | </select> |
@@ -670,7 +670,7 @@ |
||
670 | 670 | // Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified! |
671 | 671 | // Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it. |
672 | 672 | echo ' |
673 | - <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
|
673 | + <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '', '" id="modified_', $message['id'], '">'; |
|
674 | 674 | |
675 | 675 | if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
676 | 676 | echo |
@@ -51,11 +51,13 @@ discard block |
||
51 | 51 | <p>'; |
52 | 52 | |
53 | 53 | // Show just numbers...? |
54 | - if ($settings['display_who_viewing'] == 1) |
|
55 | - echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
54 | + if ($settings['display_who_viewing'] == 1) { |
|
55 | + echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members']; |
|
56 | + } |
|
56 | 57 | // Or show the actual people viewing the topic? |
57 | - else |
|
58 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
58 | + else { |
|
59 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | // Now show how many guests are here too. |
61 | 63 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], ' |
@@ -93,10 +95,11 @@ discard block |
||
93 | 95 | <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt> |
94 | 96 | <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">'; |
95 | 97 | |
96 | - if ($context['allow_results_view']) |
|
97 | - echo ' |
|
98 | + if ($context['allow_results_view']) { |
|
99 | + echo ' |
|
98 | 100 | ', $option['bar_ndt'], ' |
99 | 101 | <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>'; |
102 | + } |
|
100 | 103 | |
101 | 104 | echo ' |
102 | 105 | </dd>'; |
@@ -105,9 +108,10 @@ discard block |
||
105 | 108 | echo ' |
106 | 109 | </dl>'; |
107 | 110 | |
108 | - if ($context['allow_results_view']) |
|
109 | - echo ' |
|
111 | + if ($context['allow_results_view']) { |
|
112 | + echo ' |
|
110 | 113 | <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>'; |
114 | + } |
|
111 | 115 | } |
112 | 116 | // They are allowed to vote! Go to it! |
113 | 117 | else |
@@ -116,17 +120,19 @@ discard block |
||
116 | 120 | <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">'; |
117 | 121 | |
118 | 122 | // Show a warning if they are allowed more than one option. |
119 | - if ($context['poll']['allowed_warning']) |
|
120 | - echo ' |
|
123 | + if ($context['poll']['allowed_warning']) { |
|
124 | + echo ' |
|
121 | 125 | <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | echo ' |
124 | 129 | <ul class="options">'; |
125 | 130 | |
126 | 131 | // Show each option with its button - a radio likely. |
127 | - foreach ($context['poll']['options'] as $option) |
|
128 | - echo ' |
|
132 | + foreach ($context['poll']['options'] as $option) { |
|
133 | + echo ' |
|
129 | 134 | <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>'; |
135 | + } |
|
130 | 136 | |
131 | 137 | echo ' |
132 | 138 | </ul> |
@@ -138,9 +144,10 @@ discard block |
||
138 | 144 | } |
139 | 145 | |
140 | 146 | // Is the clock ticking? |
141 | - if (!empty($context['poll']['expire_time'])) |
|
142 | - echo ' |
|
147 | + if (!empty($context['poll']['expire_time'])) { |
|
148 | + echo ' |
|
143 | 149 | <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>'; |
150 | + } |
|
144 | 151 | |
145 | 152 | echo ' |
146 | 153 | </div> |
@@ -170,11 +177,13 @@ discard block |
||
170 | 177 | <li> |
171 | 178 | <b class="event_title"><a href="', $scripturl, '?action=calendar;event=', $event['id'], '">', $event['title'], '</a></b>'; |
172 | 179 | |
173 | - if ($event['can_edit']) |
|
174 | - echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
180 | + if ($event['can_edit']) { |
|
181 | + echo ' <a href="' . $event['modify_href'] . '"><span class="generic_icons calendar_modify" title="', $txt['calendar_edit'], '"></span></a>'; |
|
182 | + } |
|
175 | 183 | |
176 | - if ($event['can_export']) |
|
177 | - echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
184 | + if ($event['can_export']) { |
|
185 | + echo ' <a href="' . $event['export_href'] . '"><span class="generic_icons calendar_export" title="', $txt['calendar_export'], '"></span></a>'; |
|
186 | + } |
|
178 | 187 | |
179 | 188 | echo ' |
180 | 189 | <br>'; |
@@ -182,14 +191,14 @@ discard block |
||
182 | 191 | if (!empty($event['allday'])) |
183 | 192 | { |
184 | 193 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), '</time>', ($event['start_date'] != $event['end_date']) ? ' – <time datetime="' . $event['end_iso_gmdate'] . '">' . trim($event['end_date_local']) . '</time>' : ''; |
185 | - } |
|
186 | - else |
|
194 | + } else |
|
187 | 195 | { |
188 | 196 | // Display event info relative to user's local timezone |
189 | 197 | echo '<time datetime="' . $event['start_iso_gmdate'] . '">', trim($event['start_date_local']), ', ', trim($event['start_time_local']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
190 | 198 | |
191 | - if ($event['start_date_local'] != $event['end_date_local']) |
|
192 | - echo trim($event['end_date_local']) . ', '; |
|
199 | + if ($event['start_date_local'] != $event['end_date_local']) { |
|
200 | + echo trim($event['end_date_local']) . ', '; |
|
201 | + } |
|
193 | 202 | |
194 | 203 | echo trim($event['end_time_local']); |
195 | 204 | |
@@ -198,23 +207,27 @@ discard block |
||
198 | 207 | { |
199 | 208 | echo '</time> (<time datetime="' . $event['start_iso_gmdate'] . '">'; |
200 | 209 | |
201 | - if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) |
|
202 | - echo trim($event['start_date_orig']), ', '; |
|
210 | + if ($event['start_date_orig'] != $event['start_date_local'] || $event['end_date_orig'] != $event['end_date_local'] || $event['start_date_orig'] != $event['end_date_orig']) { |
|
211 | + echo trim($event['start_date_orig']), ', '; |
|
212 | + } |
|
203 | 213 | |
204 | 214 | echo trim($event['start_time_orig']), '</time> – <time datetime="' . $event['end_iso_gmdate'] . '">'; |
205 | 215 | |
206 | - if ($event['start_date_orig'] != $event['end_date_orig']) |
|
207 | - echo trim($event['end_date_orig']) . ', '; |
|
216 | + if ($event['start_date_orig'] != $event['end_date_orig']) { |
|
217 | + echo trim($event['end_date_orig']) . ', '; |
|
218 | + } |
|
208 | 219 | |
209 | 220 | echo trim($event['end_time_orig']), ' ', $event['tz_abbrev'], '</time>)'; |
210 | 221 | } |
211 | 222 | // Event is scheduled in the user's own timezone? Let 'em know, just to avoid confusion |
212 | - else |
|
213 | - echo ' ', $event['tz_abbrev'], '</time>'; |
|
223 | + else { |
|
224 | + echo ' ', $event['tz_abbrev'], '</time>'; |
|
225 | + } |
|
214 | 226 | } |
215 | 227 | |
216 | - if (!empty($event['location'])) |
|
217 | - echo '<br>', $event['location']; |
|
228 | + if (!empty($event['location'])) { |
|
229 | + echo '<br>', $event['location']; |
|
230 | + } |
|
218 | 231 | |
219 | 232 | echo ' |
220 | 233 | </li>'; |
@@ -252,8 +265,9 @@ discard block |
||
252 | 265 | $context['removableMessageIDs'] = array(); |
253 | 266 | |
254 | 267 | // Get all the messages... |
255 | - while ($message = $context['get_message']()) |
|
256 | - template_single_post($message); |
|
268 | + while ($message = $context['get_message']()) { |
|
269 | + template_single_post($message); |
|
270 | + } |
|
257 | 271 | |
258 | 272 | echo ' |
259 | 273 | </form> |
@@ -290,8 +304,9 @@ discard block |
||
290 | 304 | <div id="display_jump_to"> </div>'; |
291 | 305 | |
292 | 306 | // Show quickreply |
293 | - if ($context['can_reply']) |
|
294 | - template_quickreply(); |
|
307 | + if ($context['can_reply']) { |
|
308 | + template_quickreply(); |
|
309 | + } |
|
295 | 310 | |
296 | 311 | // User action pop on mobile screen (or actually small screen), this uses responsive css does not check mobile device. |
297 | 312 | echo ' |
@@ -304,8 +319,8 @@ discard block |
||
304 | 319 | </div>'; |
305 | 320 | |
306 | 321 | // Show the moderation button & pop only if user can moderate |
307 | - if ($context['can_moderate_forum'] || $context['user']['is_mod']) |
|
308 | - echo ' |
|
322 | + if ($context['can_moderate_forum'] || $context['user']['is_mod']) { |
|
323 | + echo ' |
|
309 | 324 | <div id="mobile_moderation" class="popup_container"> |
310 | 325 | <div class="popup_window description"> |
311 | 326 | <div class="popup_heading">', $txt['mobile_moderation'], ' |
@@ -315,6 +330,7 @@ discard block |
||
315 | 330 | </div> |
316 | 331 | </div> |
317 | 332 | </div>'; |
333 | + } |
|
318 | 334 | |
319 | 335 | echo ' |
320 | 336 | <script>'; |
@@ -438,9 +454,10 @@ discard block |
||
438 | 454 | }); |
439 | 455 | }'; |
440 | 456 | |
441 | - if (!empty($context['ignoredMsgs'])) |
|
442 | - echo ' |
|
457 | + if (!empty($context['ignoredMsgs'])) { |
|
458 | + echo ' |
|
443 | 459 | ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');'; |
460 | + } |
|
444 | 461 | |
445 | 462 | echo ' |
446 | 463 | </script>'; |
@@ -457,8 +474,9 @@ discard block |
||
457 | 474 | |
458 | 475 | $ignoring = false; |
459 | 476 | |
460 | - if ($message['can_remove']) |
|
461 | - $context['removableMessageIDs'][] = $message['id']; |
|
477 | + if ($message['can_remove']) { |
|
478 | + $context['removableMessageIDs'][] = $message['id']; |
|
479 | + } |
|
462 | 480 | |
463 | 481 | // Are we ignoring this message? |
464 | 482 | if (!empty($message['is_ignored'])) |
@@ -484,9 +502,10 @@ discard block |
||
484 | 502 | <div class="custom_fields_above_member"> |
485 | 503 | <ul class="nolist">'; |
486 | 504 | |
487 | - foreach ($message['custom_fields']['above_member'] as $custom) |
|
488 | - echo ' |
|
505 | + foreach ($message['custom_fields']['above_member'] as $custom) { |
|
506 | + echo ' |
|
489 | 507 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
508 | + } |
|
490 | 509 | |
491 | 510 | echo ' |
492 | 511 | </ul> |
@@ -497,9 +516,10 @@ discard block |
||
497 | 516 | <h4>'; |
498 | 517 | |
499 | 518 | // Show online and offline buttons? |
500 | - if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) |
|
501 | - echo ' |
|
519 | + if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) { |
|
520 | + echo ' |
|
502 | 521 | ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>', $context['can_send_pm'] ? '</a>' : ''; |
522 | + } |
|
503 | 523 | |
504 | 524 | |
505 | 525 | // Show a link to the member's profile. |
@@ -512,51 +532,59 @@ discard block |
||
512 | 532 | |
513 | 533 | |
514 | 534 | // Show the user's avatar. |
515 | - if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) |
|
516 | - echo ' |
|
535 | + if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { |
|
536 | + echo ' |
|
517 | 537 | <li class="avatar"> |
518 | 538 | <a href="', $message['member']['href'], '">', $message['member']['avatar']['image'], '</a> |
519 | 539 | </li>'; |
540 | + } |
|
520 | 541 | |
521 | 542 | // Are there any custom fields below the avatar? |
522 | - if (!empty($message['custom_fields']['below_avatar'])) |
|
523 | - foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
543 | + if (!empty($message['custom_fields']['below_avatar'])) { |
|
544 | + foreach ($message['custom_fields']['below_avatar'] as $custom) |
|
524 | 545 | echo ' |
525 | 546 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
547 | + } |
|
526 | 548 | |
527 | 549 | // Show the post group icons, but not for guests. |
528 | - if (!$message['member']['is_guest']) |
|
529 | - echo ' |
|
550 | + if (!$message['member']['is_guest']) { |
|
551 | + echo ' |
|
530 | 552 | <li class="icons">', $message['member']['group_icons'], '</li>'; |
553 | + } |
|
531 | 554 | |
532 | 555 | // Show the member's primary group (like 'Administrator') if they have one. |
533 | - if (!empty($message['member']['group'])) |
|
534 | - echo ' |
|
556 | + if (!empty($message['member']['group'])) { |
|
557 | + echo ' |
|
535 | 558 | <li class="membergroup">', $message['member']['group'], '</li>'; |
559 | + } |
|
536 | 560 | |
537 | 561 | // Show the member's custom title, if they have one. |
538 | - if (!empty($message['member']['title'])) |
|
539 | - echo ' |
|
562 | + if (!empty($message['member']['title'])) { |
|
563 | + echo ' |
|
540 | 564 | <li class="title">', $message['member']['title'], '</li>'; |
565 | + } |
|
541 | 566 | |
542 | 567 | // Don't show these things for guests. |
543 | 568 | if (!$message['member']['is_guest']) |
544 | 569 | { |
545 | 570 | |
546 | 571 | // Show the post group if and only if they have no other group or the option is on, and they are in a post group. |
547 | - if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) |
|
548 | - echo ' |
|
572 | + if ((empty($modSettings['hide_post_group']) || empty($message['member']['group'])) && !empty($message['member']['post_group'])) { |
|
573 | + echo ' |
|
549 | 574 | <li class="postgroup">', $message['member']['post_group'], '</li>'; |
575 | + } |
|
550 | 576 | |
551 | 577 | // Show how many posts they have made. |
552 | - if (!isset($context['disabled_fields']['posts'])) |
|
553 | - echo ' |
|
578 | + if (!isset($context['disabled_fields']['posts'])) { |
|
579 | + echo ' |
|
554 | 580 | <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>'; |
581 | + } |
|
555 | 582 | |
556 | 583 | // Show their personal text? |
557 | - if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) |
|
558 | - echo ' |
|
584 | + if (!empty($modSettings['show_blurb']) && !empty($message['member']['blurb'])) { |
|
585 | + echo ' |
|
559 | 586 | <li class="blurb">', $message['member']['blurb'], '</li>'; |
587 | + } |
|
560 | 588 | |
561 | 589 | // Any custom fields to show as icons? |
562 | 590 | if (!empty($message['custom_fields']['icons'])) |
@@ -565,9 +593,10 @@ discard block |
||
565 | 593 | <li class="im_icons"> |
566 | 594 | <ol>'; |
567 | 595 | |
568 | - foreach ($message['custom_fields']['icons'] as $custom) |
|
569 | - echo ' |
|
596 | + foreach ($message['custom_fields']['icons'] as $custom) { |
|
597 | + echo ' |
|
570 | 598 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
599 | + } |
|
571 | 600 | |
572 | 601 | echo ' |
573 | 602 | </ol> |
@@ -582,19 +611,22 @@ discard block |
||
582 | 611 | <ol class="profile_icons">'; |
583 | 612 | |
584 | 613 | // Don't show an icon if they haven't specified a website. |
585 | - if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) |
|
586 | - echo ' |
|
614 | + if (!empty($message['member']['website']['url']) && !isset($context['disabled_fields']['website'])) { |
|
615 | + echo ' |
|
587 | 616 | <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>'; |
617 | + } |
|
588 | 618 | |
589 | 619 | // Since we know this person isn't a guest, you *can* message them. |
590 | - if ($context['can_send_pm']) |
|
591 | - echo ' |
|
620 | + if ($context['can_send_pm']) { |
|
621 | + echo ' |
|
592 | 622 | <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>'; |
623 | + } |
|
593 | 624 | |
594 | 625 | // Show the email if necessary |
595 | - if (!empty($message['member']['email']) && $message['member']['show_email']) |
|
596 | - echo ' |
|
626 | + if (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
627 | + echo ' |
|
597 | 628 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
629 | + } |
|
598 | 630 | |
599 | 631 | echo ' |
600 | 632 | </ol> |
@@ -602,48 +634,56 @@ discard block |
||
602 | 634 | } |
603 | 635 | |
604 | 636 | // Any custom fields for standard placement? |
605 | - if (!empty($message['custom_fields']['standard'])) |
|
606 | - foreach ($message['custom_fields']['standard'] as $custom) |
|
637 | + if (!empty($message['custom_fields']['standard'])) { |
|
638 | + foreach ($message['custom_fields']['standard'] as $custom) |
|
607 | 639 | echo ' |
608 | 640 | <li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>'; |
641 | + } |
|
609 | 642 | |
610 | 643 | } |
611 | 644 | // Otherwise, show the guest's email. |
612 | - elseif (!empty($message['member']['email']) && $message['member']['show_email']) |
|
613 | - echo ' |
|
645 | + elseif (!empty($message['member']['email']) && $message['member']['show_email']) { |
|
646 | + echo ' |
|
614 | 647 | <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>'; |
648 | + } |
|
615 | 649 | |
616 | 650 | // Show the IP to this user for this post - because you can moderate? |
617 | - if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) |
|
618 | - echo ' |
|
651 | + if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) { |
|
652 | + echo ' |
|
619 | 653 | <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>'; |
654 | + } |
|
620 | 655 | |
621 | 656 | // Or, should we show it because this is you? |
622 | - elseif ($message['can_see_ip']) |
|
623 | - echo ' |
|
657 | + elseif ($message['can_see_ip']) { |
|
658 | + echo ' |
|
624 | 659 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>'; |
660 | + } |
|
625 | 661 | |
626 | 662 | // Okay, are you at least logged in? Then we can show something about why IPs are logged... |
627 | - elseif (!$context['user']['is_guest']) |
|
628 | - echo ' |
|
663 | + elseif (!$context['user']['is_guest']) { |
|
664 | + echo ' |
|
629 | 665 | <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>'; |
666 | + } |
|
630 | 667 | |
631 | 668 | // Otherwise, you see NOTHING! |
632 | - else |
|
633 | - echo ' |
|
669 | + else { |
|
670 | + echo ' |
|
634 | 671 | <li class="poster_ip">', $txt['logged'], '</li>'; |
672 | + } |
|
635 | 673 | |
636 | 674 | // Are we showing the warning status? |
637 | 675 | // Don't show these things for guests. |
638 | - if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) |
|
639 | - echo ' |
|
676 | + if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) { |
|
677 | + echo ' |
|
640 | 678 | <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span> ', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>'; |
679 | + } |
|
641 | 680 | |
642 | 681 | // Are there any custom fields to show at the bottom of the poster info? |
643 | - if (!empty($message['custom_fields']['bottom_poster'])) |
|
644 | - foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
682 | + if (!empty($message['custom_fields']['bottom_poster'])) { |
|
683 | + foreach ($message['custom_fields']['bottom_poster'] as $custom) |
|
645 | 684 | echo ' |
646 | 685 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
686 | + } |
|
647 | 687 | |
648 | 688 | // Poster info ends. |
649 | 689 | echo ' |
@@ -672,9 +712,10 @@ discard block |
||
672 | 712 | echo ' |
673 | 713 | <span class="smalltext modified floatright', !empty($modSettings['show_modify']) && !empty($message['modified']['name']) ? ' mvisible' : '','" id="modified_', $message['id'], '">'; |
674 | 714 | |
675 | - if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) |
|
676 | - echo |
|
715 | + if (!empty($modSettings['show_modify']) && !empty($message['modified']['name'])) { |
|
716 | + echo |
|
677 | 717 | $message['modified']['last_edit_text']; |
718 | + } |
|
678 | 719 | |
679 | 720 | echo ' |
680 | 721 | </span> |
@@ -683,22 +724,24 @@ discard block |
||
683 | 724 | </div>'; |
684 | 725 | |
685 | 726 | // Ignoring this user? Hide the post. |
686 | - if ($ignoring) |
|
687 | - echo ' |
|
727 | + if ($ignoring) { |
|
728 | + echo ' |
|
688 | 729 | <div id="msg_', $message['id'], '_ignored_prompt"> |
689 | 730 | ', $txt['ignoring_user'], ' |
690 | 731 | <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a> |
691 | 732 | </div>'; |
733 | + } |
|
692 | 734 | |
693 | 735 | // Show the post itself, finally! |
694 | 736 | echo ' |
695 | 737 | <div class="post">'; |
696 | 738 | |
697 | - if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) |
|
698 | - echo ' |
|
739 | + if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) { |
|
740 | + echo ' |
|
699 | 741 | <div class="approve_post"> |
700 | 742 | ', $txt['post_awaiting_approval'], ' |
701 | 743 | </div>'; |
744 | + } |
|
702 | 745 | echo ' |
703 | 746 | <div class="inner" data-msgid="', $message['id'], '" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div> |
704 | 747 | </div>'; |
@@ -715,9 +758,9 @@ discard block |
||
715 | 758 | foreach ($message['attachment'] as $attachment) |
716 | 759 | { |
717 | 760 | // Do we want this attachment to not be showed here? |
718 | - if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) |
|
719 | - continue; |
|
720 | - elseif (!$div_output) |
|
761 | + if (!empty($modSettings['dont_show_attach_under_post']) && !empty($context['show_attach_under_post'][$attachment['id']])) { |
|
762 | + continue; |
|
763 | + } elseif (!$div_output) |
|
721 | 764 | { |
722 | 765 | $div_output = true; |
723 | 766 | |
@@ -733,9 +776,10 @@ discard block |
||
733 | 776 | <fieldset> |
734 | 777 | <legend>', $txt['attach_awaiting_approve']; |
735 | 778 | |
736 | - if ($context['can_approve']) |
|
737 | - echo ' |
|
779 | + if ($context['can_approve']) { |
|
780 | + echo ' |
|
738 | 781 | [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]'; |
782 | + } |
|
739 | 783 | |
740 | 784 | echo ' |
741 | 785 | </legend>'; |
@@ -749,12 +793,13 @@ discard block |
||
749 | 793 | echo ' |
750 | 794 | <div class="attachments_top">'; |
751 | 795 | |
752 | - if ($attachment['thumbnail']['has_thumb']) |
|
753 | - echo ' |
|
796 | + if ($attachment['thumbnail']['has_thumb']) { |
|
797 | + echo ' |
|
754 | 798 | <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" class="atc_img"></a>'; |
755 | - else |
|
756 | - echo ' |
|
799 | + } else { |
|
800 | + echo ' |
|
757 | 801 | <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '" class="atc_img">'; |
802 | + } |
|
758 | 803 | |
759 | 804 | echo ' |
760 | 805 | </div>'; |
@@ -764,9 +809,10 @@ discard block |
||
764 | 809 | <div class="attachments_bot"> |
765 | 810 | <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*"> ' . $attachment['name'] . '</a> '; |
766 | 811 | |
767 | - if (!$attachment['is_approved'] && $context['can_approve']) |
|
768 | - echo ' |
|
812 | + if (!$attachment['is_approved'] && $context['can_approve']) { |
|
813 | + echo ' |
|
769 | 814 | [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] '; |
815 | + } |
|
770 | 816 | echo ' |
771 | 817 | <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), ' |
772 | 818 | </div>'; |
@@ -775,33 +821,38 @@ discard block |
||
775 | 821 | </div>'; |
776 | 822 | |
777 | 823 | // Next attachment line ? |
778 | - if (++$i % $attachments_per_line === 0) |
|
779 | - echo ' |
|
824 | + if (++$i % $attachments_per_line === 0) { |
|
825 | + echo ' |
|
780 | 826 | <br>'; |
827 | + } |
|
781 | 828 | } |
782 | 829 | |
783 | 830 | // If we had unapproved attachments clean up. |
784 | - if ($last_approved_state == 0) |
|
785 | - echo ' |
|
831 | + if ($last_approved_state == 0) { |
|
832 | + echo ' |
|
786 | 833 | </fieldset>'; |
834 | + } |
|
787 | 835 | |
788 | 836 | // Only do this if we output a div above - otherwise it'll break things |
789 | - if ($div_output) |
|
790 | - echo ' |
|
837 | + if ($div_output) { |
|
838 | + echo ' |
|
791 | 839 | </div>'; |
840 | + } |
|
792 | 841 | } |
793 | 842 | |
794 | 843 | // And stuff below the attachments. |
795 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
796 | - echo ' |
|
844 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
845 | + echo ' |
|
797 | 846 | <div class="under_message">'; |
847 | + } |
|
798 | 848 | |
799 | 849 | // Maybe they want to report this post to the moderator(s)? |
800 | - if ($context['can_report_moderator']) |
|
801 | - echo ' |
|
850 | + if ($context['can_report_moderator']) { |
|
851 | + echo ' |
|
802 | 852 | <ul class="floatright smalltext"> |
803 | 853 | <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li> |
804 | 854 | </ul>'; |
855 | + } |
|
805 | 856 | |
806 | 857 | // What about likes? |
807 | 858 | if (!empty($modSettings['enable_likes'])) |
@@ -842,78 +893,91 @@ discard block |
||
842 | 893 | <ul class="quickbuttons">'; |
843 | 894 | |
844 | 895 | // Can they quote? if so they can select and quote as well! |
845 | - if ($context['can_quote']) |
|
846 | - echo ' |
|
896 | + if ($context['can_quote']) { |
|
897 | + echo ' |
|
847 | 898 | <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li> |
848 | 899 | <li style="display:none;" id="quoteSelected_', $message['id'], '"><a href="javascript:void(0)"><span class="generic_icons quote_selected"></span>', $txt['quote_selected_action'], '</a></li>'; |
900 | + } |
|
849 | 901 | |
850 | 902 | // Can the user modify the contents of this post? Show the modify inline image. |
851 | - if ($message['can_modify']) |
|
852 | - echo ' |
|
903 | + if ($message['can_modify']) { |
|
904 | + echo ' |
|
853 | 905 | <li class="quick_edit"><a title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\', \'', !empty($modSettings['toggle_subject']), '\')"><span class="generic_icons quick_edit_button"></span>', $txt['quick_edit'], '</a></li>'; |
906 | + } |
|
854 | 907 | |
855 | - if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
856 | - echo ' |
|
908 | + if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
909 | + echo ' |
|
857 | 910 | <li class="post_options">', $txt['post_options']; |
911 | + } |
|
858 | 912 | |
859 | 913 | echo ' |
860 | 914 | <ul>'; |
861 | 915 | |
862 | 916 | // Can the user modify the contents of this post? |
863 | - if ($message['can_modify']) |
|
864 | - echo ' |
|
917 | + if ($message['can_modify']) { |
|
918 | + echo ' |
|
865 | 919 | <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '"><span class="generic_icons modify_button"></span>', $txt['modify'], '</a></li>'; |
920 | + } |
|
866 | 921 | |
867 | 922 | // How about... even... remove it entirely?! |
868 | - if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) |
|
869 | - echo ' |
|
923 | + if ($context['can_delete'] && ($context['topic_first_message'] == $message['id'])) { |
|
924 | + echo ' |
|
870 | 925 | <li><a href="', $scripturl, '?action=removetopic2;topic=', $context['current_topic'], '.', $context['start'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['are_sure_remove_topic'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove_topic'], '</a></li>'; |
871 | - elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) |
|
872 | - echo ' |
|
926 | + } elseif ($message['can_remove'] && ($context['topic_first_message'] != $message['id'])) { |
|
927 | + echo ' |
|
873 | 928 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message_question'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
929 | + } |
|
874 | 930 | |
875 | 931 | // What about splitting it off the rest of the topic? |
876 | - if ($context['can_split'] && !empty($context['real_num_replies'])) |
|
877 | - echo ' |
|
932 | + if ($context['can_split'] && !empty($context['real_num_replies'])) { |
|
933 | + echo ' |
|
878 | 934 | <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '"><span class="generic_icons split_button"></span>', $txt['split'], '</a></li>'; |
935 | + } |
|
879 | 936 | |
880 | 937 | // Can we issue a warning because of this post? Remember, we can't give guests warnings. |
881 | - if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) |
|
882 | - echo ' |
|
938 | + if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) { |
|
939 | + echo ' |
|
883 | 940 | <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><span class="generic_icons warn_button"></span>', $txt['issue_warning'], '</a></li>'; |
941 | + } |
|
884 | 942 | |
885 | 943 | // Can we restore topics? |
886 | - if ($context['can_restore_msg']) |
|
887 | - echo ' |
|
944 | + if ($context['can_restore_msg']) { |
|
945 | + echo ' |
|
888 | 946 | <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons restore_button"></span>', $txt['restore_message'], '</a></li>'; |
947 | + } |
|
889 | 948 | |
890 | 949 | // Maybe we can approve it, maybe we should? |
891 | - if ($message['can_approve']) |
|
892 | - echo ' |
|
950 | + if ($message['can_approve']) { |
|
951 | + echo ' |
|
893 | 952 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons approve_button"></span>', $txt['approve'], '</a></li>'; |
953 | + } |
|
894 | 954 | |
895 | 955 | // Maybe we can unapprove it? |
896 | - if ($message['can_unapprove']) |
|
897 | - echo ' |
|
956 | + if ($message['can_unapprove']) { |
|
957 | + echo ' |
|
898 | 958 | <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons unapprove_button"></span>', $txt['unapprove'], '</a></li>'; |
959 | + } |
|
899 | 960 | |
900 | 961 | echo ' |
901 | 962 | </ul> |
902 | 963 | </li>'; |
903 | 964 | |
904 | 965 | // Show a checkbox for quick moderation? |
905 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) |
|
906 | - echo ' |
|
966 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) { |
|
967 | + echo ' |
|
907 | 968 | <li style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>'; |
969 | + } |
|
908 | 970 | |
909 | - if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) |
|
910 | - echo ' |
|
971 | + if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) { |
|
972 | + echo ' |
|
911 | 973 | </ul>'; |
974 | + } |
|
912 | 975 | } |
913 | 976 | |
914 | - if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) |
|
915 | - echo ' |
|
977 | + if ($context['can_report_moderator'] || !empty($context['can_see_likes']) || !empty($context['can_like']) || $message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote']) { |
|
978 | + echo ' |
|
916 | 979 | </div>'; |
980 | + } |
|
917 | 981 | |
918 | 982 | echo ' |
919 | 983 | </div> |
@@ -926,9 +990,10 @@ discard block |
||
926 | 990 | <div class="custom_fields_above_signature"> |
927 | 991 | <ul class="nolist">'; |
928 | 992 | |
929 | - foreach ($message['custom_fields']['above_signature'] as $custom) |
|
930 | - echo ' |
|
993 | + foreach ($message['custom_fields']['above_signature'] as $custom) { |
|
994 | + echo ' |
|
931 | 995 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
996 | + } |
|
932 | 997 | |
933 | 998 | echo ' |
934 | 999 | </ul> |
@@ -936,9 +1001,10 @@ discard block |
||
936 | 1001 | } |
937 | 1002 | |
938 | 1003 | // Show the member's signature? |
939 | - if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) |
|
940 | - echo ' |
|
1004 | + if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) { |
|
1005 | + echo ' |
|
941 | 1006 | <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>'; |
1007 | + } |
|
942 | 1008 | |
943 | 1009 | |
944 | 1010 | // Are there any custom profile fields for below the signature? |
@@ -948,9 +1014,10 @@ discard block |
||
948 | 1014 | <div class="custom_fields_below_signature"> |
949 | 1015 | <ul class="nolist">'; |
950 | 1016 | |
951 | - foreach ($message['custom_fields']['below_signature'] as $custom) |
|
952 | - echo ' |
|
1017 | + foreach ($message['custom_fields']['below_signature'] as $custom) { |
|
1018 | + echo ' |
|
953 | 1019 | <li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>'; |
1020 | + } |
|
954 | 1021 | |
955 | 1022 | echo ' |
956 | 1023 | </ul> |
@@ -998,8 +1065,8 @@ discard block |
||
998 | 1065 | <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">'; |
999 | 1066 | |
1000 | 1067 | // Guests just need more. |
1001 | - if ($context['user']['is_guest']) |
|
1002 | - echo ' |
|
1068 | + if ($context['user']['is_guest']) { |
|
1069 | + echo ' |
|
1003 | 1070 | <dl id="post_header"> |
1004 | 1071 | <dt> |
1005 | 1072 | ', $txt['name'], ': |
@@ -1014,6 +1081,7 @@ discard block |
||
1014 | 1081 | <input type="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required> |
1015 | 1082 | </dd> |
1016 | 1083 | </dl>'; |
1084 | + } |
|
1017 | 1085 | |
1018 | 1086 | echo ' |
1019 | 1087 | ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), ' |
@@ -1061,8 +1129,8 @@ discard block |
||
1061 | 1129 | <br class="clear">'; |
1062 | 1130 | |
1063 | 1131 | // draft autosave available and the user has it enabled? |
1064 | - if (!empty($context['drafts_autosave'])) |
|
1065 | - echo ' |
|
1132 | + if (!empty($context['drafts_autosave'])) { |
|
1133 | + echo ' |
|
1066 | 1134 | <script> |
1067 | 1135 | var oDraftAutoSave = new smf_DraftAutoSave({ |
1068 | 1136 | sSelf: \'oDraftAutoSave\', |
@@ -1074,10 +1142,12 @@ discard block |
||
1074 | 1142 | iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), ' |
1075 | 1143 | }); |
1076 | 1144 | </script>'; |
1145 | + } |
|
1077 | 1146 | |
1078 | - if ($context['show_spellchecking']) |
|
1079 | - echo ' |
|
1147 | + if ($context['show_spellchecking']) { |
|
1148 | + echo ' |
|
1080 | 1149 | <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>'; |
1150 | + } |
|
1081 | 1151 | |
1082 | 1152 | echo ' |
1083 | 1153 | <script> |
@@ -118,7 +118,7 @@ |
||
118 | 118 | |
119 | 119 | // Right, image not cached? Simply redirect, then. |
120 | 120 | if (!$response) |
121 | - redirectexit($request); |
|
121 | + redirectexit($request); |
|
122 | 122 | |
123 | 123 | // Make sure we're serving an image |
124 | 124 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
@@ -63,26 +63,31 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function checkRequest() |
65 | 65 | { |
66 | - if (!$this->enabled) |
|
67 | - return false; |
|
66 | + if (!$this->enabled) { |
|
67 | + return false; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | // Try to create the image cache directory if it doesn't exist |
70 | - if (!file_exists($this->cache)) |
|
71 | - if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
71 | + if (!file_exists($this->cache)) { |
|
72 | + if (!mkdir($this->cache) || !copy(dirname($this->cache) . '/index.php', $this->cache . '/index.php')) |
|
72 | 73 | return false; |
74 | + } |
|
73 | 75 | |
74 | - if (empty($_GET['hash']) || empty($_GET['request'])) |
|
75 | - return false; |
|
76 | + if (empty($_GET['hash']) || empty($_GET['request'])) { |
|
77 | + return false; |
|
78 | + } |
|
76 | 79 | |
77 | 80 | $hash = $_GET['hash']; |
78 | 81 | $request = $_GET['request']; |
79 | 82 | |
80 | - if (md5($request . $this->secret) != $hash) |
|
81 | - return false; |
|
83 | + if (md5($request . $this->secret) != $hash) { |
|
84 | + return false; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // Attempt to cache the request if it doesn't exist |
84 | - if (!$this->isCached($request)) |
|
85 | - return $this->cacheImage($request); |
|
88 | + if (!$this->isCached($request)) { |
|
89 | + return $this->cacheImage($request); |
|
90 | + } |
|
86 | 91 | |
87 | 92 | return true; |
88 | 93 | } |
@@ -111,19 +116,22 @@ discard block |
||
111 | 116 | if (!$cached || time() - $cached['time'] > (5 * 86400)) |
112 | 117 | { |
113 | 118 | @unlink($cached_file); |
114 | - if ($this->checkRequest()) |
|
115 | - $this->serve(); |
|
119 | + if ($this->checkRequest()) { |
|
120 | + $this->serve(); |
|
121 | + } |
|
116 | 122 | redirectexit($request); |
117 | 123 | } |
118 | 124 | |
119 | 125 | // Right, image not cached? Simply redirect, then. |
120 | - if (!$response) |
|
121 | - redirectexit($request); |
|
126 | + if (!$response) { |
|
127 | + redirectexit($request); |
|
128 | + } |
|
122 | 129 | |
123 | 130 | // Make sure we're serving an image |
124 | 131 | $contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : ''); |
125 | - if ($contentParts[0] != 'image') |
|
126 | - exit; |
|
132 | + if ($contentParts[0] != 'image') { |
|
133 | + exit; |
|
134 | + } |
|
127 | 135 | |
128 | 136 | header('Content-type: ' . $cached['content_type']); |
129 | 137 | header('Content-length: ' . $cached['size']); |
@@ -170,8 +178,9 @@ discard block |
||
170 | 178 | $responseCode = $request->result('code'); |
171 | 179 | $response = $request->result(); |
172 | 180 | |
173 | - if (empty($response)) |
|
174 | - return false; |
|
181 | + if (empty($response)) { |
|
182 | + return false; |
|
183 | + } |
|
175 | 184 | |
176 | 185 | if ($responseCode != 200) { |
177 | 186 | return $request->result('code'); |
@@ -181,12 +190,14 @@ discard block |
||
181 | 190 | |
182 | 191 | // Make sure the url is returning an image |
183 | 192 | $contentParts = explode('/', !empty($headers['content-type']) ? $headers['content-type'] : ''); |
184 | - if ($contentParts[0] != 'image') |
|
185 | - return false; |
|
193 | + if ($contentParts[0] != 'image') { |
|
194 | + return false; |
|
195 | + } |
|
186 | 196 | |
187 | 197 | // Validate the filesize |
188 | - if ($response['size'] > ($this->maxSize * 1024)) |
|
189 | - return false; |
|
198 | + if ($response['size'] > ($this->maxSize * 1024)) { |
|
199 | + return false; |
|
200 | + } |
|
190 | 201 | |
191 | 202 | return file_put_contents($dest, json_encode(array( |
192 | 203 | 'content_type' => $headers['content-type'], |