@@ -1,9 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Try to handle it with the upper level index.php. (it should know what to do.) |
4 | -if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) |
|
4 | +if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) { |
|
5 | 5 | include (dirname(dirname(__FILE__)) . '/index.php'); |
6 | -else |
|
6 | +} else { |
|
7 | 7 | exit; |
8 | +} |
|
8 | 9 | |
9 | 10 | ?> |
10 | 11 | \ No newline at end of file |
@@ -583,8 +583,7 @@ discard block |
||
583 | 583 | { |
584 | 584 | $header = '<?php require("' . ($user_info['is_admin'] ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?>' . "\n" . $header; |
585 | 585 | return $header . template_homepage_sample1_html() . $footer; |
586 | - } |
|
587 | - else |
|
586 | + } else |
|
588 | 587 | { |
589 | 588 | echo $header; |
590 | 589 | template_homepage_sample1_php(); |
@@ -599,9 +598,10 @@ discard block |
||
599 | 598 | |
600 | 599 | $topics = ssi_recentTopics(8, null, null, 'array'); |
601 | 600 | |
602 | - foreach ($topics as $topic) |
|
603 | - echo ' |
|
601 | + foreach ($topics as $topic) { |
|
602 | + echo ' |
|
604 | 603 | <li><a href="', $topic['href'], '">', $topic['subject'], '</a> ', $txt['by'], ' ', $topic['poster']['link'], '</li>'; |
604 | + } |
|
605 | 605 | |
606 | 606 | unset($topics); |
607 | 607 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | |
40 | 40 | foreach ($category['boards'] as $board) |
41 | 41 | echo ' |
42 | - <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
|
42 | + <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=> ' : '', $board['name'], '</option>'; |
|
43 | 43 | echo ' |
44 | 44 | </optgroup>'; |
45 | 45 | } |
@@ -37,9 +37,10 @@ discard block |
||
37 | 37 | echo ' |
38 | 38 | <optgroup label="', $category['name'], '">'; |
39 | 39 | |
40 | - foreach ($category['boards'] as $board) |
|
41 | - echo ' |
|
40 | + foreach ($category['boards'] as $board) { |
|
41 | + echo ' |
|
42 | 42 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', $board['id'] == $context['current_board'] ? ' disabled' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level']-1) . '=> ' : '', $board['name'], '</option>'; |
43 | + } |
|
43 | 44 | echo ' |
44 | 45 | </optgroup>'; |
45 | 46 | } |
@@ -70,9 +71,10 @@ discard block |
||
70 | 71 | </div><!-- .move_topic --> |
71 | 72 | </div><!-- .windowbg -->'; |
72 | 73 | |
73 | - if ($context['back_to_topic']) |
|
74 | - echo ' |
|
74 | + if ($context['back_to_topic']) { |
|
75 | + echo ' |
|
75 | 76 | <input type="hidden" name="goback" value="1">'; |
77 | + } |
|
76 | 78 | |
77 | 79 | echo ' |
78 | 80 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -125,10 +127,10 @@ discard block |
||
125 | 127 | <option value="86400">', $txt['two_months'], '</option> |
126 | 128 | </select> |
127 | 129 | </dd>'; |
128 | - } |
|
129 | - else |
|
130 | - echo ' |
|
130 | + } else { |
|
131 | + echo ' |
|
131 | 132 | <input type="hidden" name="redirect_expires" value="0">'; |
133 | + } |
|
132 | 134 | |
133 | 135 | echo ' |
134 | 136 | </dl> |
@@ -207,9 +209,10 @@ discard block |
||
207 | 209 | echo ' |
208 | 210 | <optgroup label="', $cat['name'], '">'; |
209 | 211 | |
210 | - foreach ($cat['boards'] as $board) |
|
211 | - echo ' |
|
212 | + foreach ($cat['boards'] as $board) { |
|
213 | + echo ' |
|
212 | 214 | <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=>' : '', ' ', $board['name'], '</option>'; |
215 | + } |
|
213 | 216 | |
214 | 217 | echo ' |
215 | 218 | </optgroup>'; |
@@ -219,9 +222,9 @@ discard block |
||
219 | 222 | <input type="hidden" name="from" value="' . $context['origin_topic'] . '"> |
220 | 223 | <input type="submit" value="', $txt['go'], '" class="button"> |
221 | 224 | </form>'; |
225 | + } else { |
|
226 | + echo $txt['target_below']; |
|
222 | 227 | } |
223 | - else |
|
224 | - echo $txt['target_below']; |
|
225 | 228 | |
226 | 229 | echo ' </h4> |
227 | 230 | </div><!-- .title_bar --> |
@@ -239,12 +242,13 @@ discard block |
||
239 | 242 | |
240 | 243 | $merge_button = create_button('merge', 'merge', ''); |
241 | 244 | |
242 | - foreach ($context['topics'] as $topic) |
|
243 | - echo ' |
|
245 | + foreach ($context['topics'] as $topic) { |
|
246 | + echo ' |
|
244 | 247 | <li> |
245 | 248 | <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a> |
246 | 249 | <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" rel="noopener">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], ' |
247 | 250 | </li>'; |
251 | + } |
|
248 | 252 | |
249 | 253 | echo ' |
250 | 254 | </ul> |
@@ -255,9 +259,10 @@ discard block |
||
255 | 259 | </div>'; |
256 | 260 | } |
257 | 261 | // Just a nice "There aren't any topics" message |
258 | - else |
|
259 | - echo ' |
|
262 | + else { |
|
263 | + echo ' |
|
260 | 264 | <div class="windowbg">', $txt['topic_alert_none'], '</div>'; |
265 | + } |
|
261 | 266 | |
262 | 267 | echo ' |
263 | 268 | <br> |
@@ -307,8 +312,8 @@ discard block |
||
307 | 312 | </thead> |
308 | 313 | <tbody>'; |
309 | 314 | |
310 | - foreach ($context['topics'] as $topic) |
|
311 | - echo ' |
|
315 | + foreach ($context['topics'] as $topic) { |
|
316 | + echo ' |
|
312 | 317 | <tr class="windowbg"> |
313 | 318 | <td> |
314 | 319 | <input type="checkbox" name="topics[]" value="' . $topic['id'] . '" checked> |
@@ -328,6 +333,7 @@ discard block |
||
328 | 333 | <input type="checkbox" name="notifications[]" value="' . $topic['id'] . '" checked> |
329 | 334 | </td> |
330 | 335 | </tr>'; |
336 | + } |
|
331 | 337 | echo ' |
332 | 338 | </tbody> |
333 | 339 | </table> |
@@ -337,9 +343,10 @@ discard block |
||
337 | 343 | <legend>', $txt['merge_select_subject'], '</legend> |
338 | 344 | <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">'; |
339 | 345 | |
340 | - foreach ($context['topics'] as $topic) |
|
341 | - echo ' |
|
346 | + foreach ($context['topics'] as $topic) { |
|
347 | + echo ' |
|
342 | 348 | <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected' : '') . '>', $topic['subject'], '</option>'; |
349 | + } |
|
343 | 350 | echo ' |
344 | 351 | <option value="0">', $txt['merge_custom_subject'], ':</option> |
345 | 352 | </select> |
@@ -358,11 +365,12 @@ discard block |
||
358 | 365 | <legend>', $txt['merge_select_target_board'], '</legend> |
359 | 366 | <ul>'; |
360 | 367 | |
361 | - foreach ($context['boards'] as $board) |
|
362 | - echo ' |
|
368 | + foreach ($context['boards'] as $board) { |
|
369 | + echo ' |
|
363 | 370 | <li> |
364 | 371 | <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked' : '') . '> ' . $board['name'] . ' |
365 | 372 | </li>'; |
373 | + } |
|
366 | 374 | echo ' |
367 | 375 | </ul> |
368 | 376 | </fieldset>'; |
@@ -374,11 +382,12 @@ discard block |
||
374 | 382 | <legend>' . $txt['merge_select_poll'] . '</legend> |
375 | 383 | <ul>'; |
376 | 384 | |
377 | - foreach ($context['polls'] as $poll) |
|
378 | - echo ' |
|
385 | + foreach ($context['polls'] as $poll) { |
|
386 | + echo ' |
|
379 | 387 | <li> |
380 | 388 | <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked' : '') . '> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" rel="noopener">' . $poll['topic']['subject'] . '</a>) |
381 | 389 | </li>'; |
390 | + } |
|
382 | 391 | echo ' |
383 | 392 | <li> |
384 | 393 | <input type="radio" name="poll" value="-1"> (' . $txt['merge_no_poll'] . ') |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | <meta charset="', $context['character_set'], '"> |
25 | 25 | <meta name="robots" content="noindex"> |
26 | 26 | <title>', $context['page_title'], '</title> |
27 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
28 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
27 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
28 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
29 | 29 | </head> |
30 | 30 | <body id="help_popup"> |
31 | 31 | <div class="windowbg description"> |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | <title>', $txt['find_members'], '</title> |
51 | 51 | <meta charset="', $context['character_set'], '"> |
52 | 52 | <meta name="robots" content="noindex"> |
53 | - <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'] ,'"> |
|
54 | - <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'] ,'"></script> |
|
53 | + <link rel="stylesheet" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css', $modSettings['browser_cache'], '"> |
|
54 | + <script src="', $settings['default_theme_url'], '/scripts/script.js', $modSettings['browser_cache'], '"></script> |
|
55 | 55 | <script> |
56 | 56 | var membersAdded = []; |
57 | 57 | function addMember(name) |
@@ -86,11 +86,12 @@ discard block |
||
86 | 86 | <span class="smalltext"><em>', $txt['find_wildcards'], '</em></span><br>'; |
87 | 87 | |
88 | 88 | // Only offer to search for buddies if we have some! |
89 | - if (!empty($context['show_buddies'])) |
|
90 | - echo ' |
|
89 | + if (!empty($context['show_buddies'])) { |
|
90 | + echo ' |
|
91 | 91 | <span class="smalltext"> |
92 | 92 | <label for="buddies"><input type="checkbox" name="buddies" id="buddies"', !empty($context['buddy_search']) ? ' checked' : '', '> ', $txt['find_buddies'], '</label> |
93 | 93 | </span><br>'; |
94 | + } |
|
94 | 95 | |
95 | 96 | echo ' |
96 | 97 | <div class="padding righttext"> |
@@ -105,20 +106,21 @@ discard block |
||
105 | 106 | <h3 class="catbg">', $txt['find_results'], '</h3> |
106 | 107 | </div>'; |
107 | 108 | |
108 | - if (empty($context['results'])) |
|
109 | - echo ' |
|
109 | + if (empty($context['results'])) { |
|
110 | + echo ' |
|
110 | 111 | <p class="error">', $txt['find_no_results'], '</p>'; |
111 | - else |
|
112 | + } else |
|
112 | 113 | { |
113 | 114 | echo ' |
114 | 115 | <ul class="padding">'; |
115 | 116 | |
116 | - foreach ($context['results'] as $result) |
|
117 | - echo ' |
|
117 | + foreach ($context['results'] as $result) { |
|
118 | + echo ' |
|
118 | 119 | <li class="windowbg"> |
119 | 120 | <a href="', $result['href'], '" target="_blank" rel="noopener"> <span class="generic_icons profile_sm"></span> |
120 | 121 | <a href="javascript:void(0);" onclick="addMember(this.innerHTML); return false;">', $result['name'], '</a> |
121 | 122 | </li>'; |
123 | + } |
|
122 | 124 | |
123 | 125 | echo ' |
124 | 126 | </ul> |
@@ -134,11 +136,12 @@ discard block |
||
134 | 136 | <input type="hidden" name="quote" value="', $context['quote_results'] ? '1' : '0', '"> |
135 | 137 | </form>'; |
136 | 138 | |
137 | - if (empty($context['results'])) |
|
138 | - echo ' |
|
139 | + if (empty($context['results'])) { |
|
140 | + echo ' |
|
139 | 141 | <script> |
140 | 142 | document.getElementById("search").focus(); |
141 | 143 | </script>'; |
144 | + } |
|
142 | 145 | |
143 | 146 | echo ' |
144 | 147 | </body> |
@@ -162,9 +165,10 @@ discard block |
||
162 | 165 | <p>', $txt['manual_introduction'], '</p> |
163 | 166 | <ul>'; |
164 | 167 | |
165 | - foreach ($context['manual_sections'] as $section_id => $wiki_id) |
|
166 | - echo ' |
|
168 | + foreach ($context['manual_sections'] as $section_id => $wiki_id) { |
|
169 | + echo ' |
|
167 | 170 | <li><a href="', $context['wiki_url'], '/', $context['wiki_prefix'], $wiki_id, ($txt['lang_dictionary'] != 'en' ? '/' . $txt['lang_dictionary'] : ''), '" target="_blank" rel="noopener">', $txt['manual_section_' . $section_id . '_title'], '</a> - ', $txt['manual_section_' . $section_id . '_desc'], '</li>'; |
171 | + } |
|
168 | 172 | |
169 | 173 | echo ' |
170 | 174 | </ul> |
@@ -180,8 +184,8 @@ discard block |
||
180 | 184 | { |
181 | 185 | global $txt, $context, $modSettings; |
182 | 186 | |
183 | - if (!empty($modSettings['requireAgreement'])) |
|
184 | - echo ' |
|
187 | + if (!empty($modSettings['requireAgreement'])) { |
|
188 | + echo ' |
|
185 | 189 | <div class="cat_bar"> |
186 | 190 | <h3 class="catbg"> |
187 | 191 | ', $txt['terms_and_rules'], ' - ', $context['forum_name_html_safe'], ' |
@@ -190,11 +194,12 @@ discard block |
||
190 | 194 | <div class="roundframe"> |
191 | 195 | ', $context['agreement'], ' |
192 | 196 | </div>'; |
193 | - else |
|
194 | - echo ' |
|
197 | + } else { |
|
198 | + echo ' |
|
195 | 199 | <div class="noticebox"> |
196 | 200 | ', $txt['agreement_disabled'], ' |
197 | 201 | </div>'; |
198 | -} |
|
202 | + } |
|
203 | + } |
|
199 | 204 | |
200 | 205 | ?> |
201 | 206 | \ No newline at end of file |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | </div> |
102 | 102 | <ul id="messages_not_selected" class="split_messages smalltext">'; |
103 | 103 | |
104 | - foreach ($context['not_selected']['messages'] as $message) |
|
105 | - echo ' |
|
104 | + foreach ($context['not_selected']['messages'] as $message) { |
|
105 | + echo ' |
|
106 | 106 | <li class="windowbg" id="not_selected_', $message['id'], '"> |
107 | 107 | <div class="message_header"> |
108 | 108 | <a class="split_icon floatright" href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=down;msg=', $message['id'], '" onclick="return select(\'down\', ', $message['id'], ');"><span class="generic_icons split_sel" title="->"></span></a> |
@@ -111,6 +111,7 @@ discard block |
||
111 | 111 | </div> |
112 | 112 | <div class="post">', $message['body'], '</div> |
113 | 113 | </li>'; |
114 | + } |
|
114 | 115 | |
115 | 116 | echo ' |
116 | 117 | <li class="dummy"> |
@@ -130,8 +131,8 @@ discard block |
||
130 | 131 | </div> |
131 | 132 | <ul id="messages_selected" class="split_messages smalltext">'; |
132 | 133 | |
133 | - if (!empty($context['selected']['messages'])) |
|
134 | - foreach ($context['selected']['messages'] as $message) |
|
134 | + if (!empty($context['selected']['messages'])) { |
|
135 | + foreach ($context['selected']['messages'] as $message) |
|
135 | 136 | echo ' |
136 | 137 | <li class="windowbg" id="selected_', $message['id'], '"> |
137 | 138 | <div class="message_header"> |
@@ -141,6 +142,7 @@ discard block |
||
141 | 142 | </div> |
142 | 143 | <div class="post">', $message['body'], '</div> |
143 | 144 | </li>'; |
145 | + } |
|
144 | 146 | |
145 | 147 | echo ' |
146 | 148 | <li class="dummy"> |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | $members = array(); |
53 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
54 | - $members[$row['id_member']] = array( |
|
53 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
54 | + $members[$row['id_member']] = array( |
|
55 | 55 | 'id' => $row['id_member'], |
56 | 56 | 'real_name' => $row['real_name'], |
57 | 57 | 'email_address' => $row['email_address'], |
@@ -62,6 +62,7 @@ discard block |
||
62 | 62 | ), |
63 | 63 | 'lngfile' => $row['lngfile'], |
64 | 64 | ); |
65 | + } |
|
65 | 66 | $smcFunc['db_free_result']($request); |
66 | 67 | |
67 | 68 | return $members; |
@@ -83,13 +84,14 @@ discard block |
||
83 | 84 | |
84 | 85 | call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); |
85 | 86 | |
86 | - foreach ($members as $member) |
|
87 | - $smcFunc['db_insert']('ignore', |
|
87 | + foreach ($members as $member) { |
|
88 | + $smcFunc['db_insert']('ignore', |
|
88 | 89 | '{db_prefix}mentions', |
89 | 90 | array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), |
90 | 91 | array((int) $content_id, $content_type, $id_member, $member['id'], time()), |
91 | 92 | array('content_id', 'content_type', 'id_mentioned') |
92 | 93 | ); |
94 | + } |
|
93 | 95 | } |
94 | 96 | |
95 | 97 | /** |
@@ -103,8 +105,9 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public static function getBody($body, array $members) |
105 | 107 | { |
106 | - foreach ($members as $member) |
|
107 | - $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
108 | + foreach ($members as $member) { |
|
109 | + $body = str_ireplace(static::$char . $member['real_name'], '[member=' . $member['id'] . ']' . $member['real_name'] . '[/member]', $body); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | return $body; |
110 | 113 | } |
@@ -123,8 +126,9 @@ discard block |
||
123 | 126 | |
124 | 127 | $possible_names = self::getPossibleMentions($body); |
125 | 128 | |
126 | - if (empty($possible_names) || !allowedTo('mention')) |
|
127 | - return array(); |
|
129 | + if (empty($possible_names) || !allowedTo('mention')) { |
|
130 | + return array(); |
|
131 | + } |
|
128 | 132 | |
129 | 133 | $request = $smcFunc['db_query']('', ' |
130 | 134 | SELECT id_member, real_name |
@@ -140,8 +144,9 @@ discard block |
||
140 | 144 | $members = array(); |
141 | 145 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
142 | 146 | { |
143 | - if (stripos($body, static::$char . $row['real_name']) === false) |
|
144 | - continue; |
|
147 | + if (stripos($body, static::$char . $row['real_name']) === false) { |
|
148 | + continue; |
|
149 | + } |
|
145 | 150 | |
146 | 151 | $members[$row['id_member']] = array( |
147 | 152 | 'id' => $row['id_member'], |
@@ -185,8 +190,9 @@ discard block |
||
185 | 190 | $body = htmlspecialchars_decode(preg_replace('~<br\s*/?\>~', "\n", str_replace(' ', ' ', $body)), ENT_QUOTES); |
186 | 191 | |
187 | 192 | // Remove quotes, we don't want to get double mentions. |
188 | - while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) |
|
189 | - $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
193 | + while (preg_match('~\[quote[^\]]*\](.+?)\[\/quote\]~s', $body)) { |
|
194 | + $body = preg_replace('~\[quote[^\]]*\](.+?)\[\/quote\]~s', '', $body); |
|
195 | + } |
|
190 | 196 | |
191 | 197 | $matches = array(); |
192 | 198 | $string = str_split($body); |
@@ -197,9 +203,9 @@ discard block |
||
197 | 203 | { |
198 | 204 | $depth++; |
199 | 205 | $matches[] = array(); |
206 | + } elseif ($char == "\n") { |
|
207 | + $depth = 0; |
|
200 | 208 | } |
201 | - elseif ($char == "\n") |
|
202 | - $depth = 0; |
|
203 | 209 | |
204 | 210 | for ($i = $depth; $i > 0; $i--) |
205 | 211 | { |
@@ -212,8 +218,9 @@ discard block |
||
212 | 218 | } |
213 | 219 | } |
214 | 220 | |
215 | - foreach ($matches as $k => $match) |
|
216 | - $matches[$k] = substr(implode('', $match), 1); |
|
221 | + foreach ($matches as $k => $match) { |
|
222 | + $matches[$k] = substr(implode('', $match), 1); |
|
223 | + } |
|
217 | 224 | |
218 | 225 | // Names can have spaces, other breaks, or they can't...we try to match every possible |
219 | 226 | // combination. |
@@ -223,8 +230,9 @@ discard block |
||
223 | 230 | $match = preg_split('/([^\w])/', $match, -1, PREG_SPLIT_DELIM_CAPTURE); |
224 | 231 | $count = count($match); |
225 | 232 | |
226 | - for ($i = 1; $i <= $count; $i++) |
|
227 | - $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
233 | + for ($i = 1; $i <= $count; $i++) { |
|
234 | + $names[] = $smcFunc['htmlspecialchars']($smcFunc['htmltrim'](implode('', array_slice($match, 0, $i)))); |
|
235 | + } |
|
228 | 236 | } |
229 | 237 | |
230 | 238 | $names = array_unique($names); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | 'member_name' => $regOptions['username'], |
587 | 587 | 'email_address' => $regOptions['email'], |
588 | 588 | 'passwd' => hash_password($regOptions['username'], $regOptions['password']), |
589 | - 'password_salt' => substr(md5(mt_rand()), 0, 4) , |
|
589 | + 'password_salt' => substr(md5(mt_rand()), 0, 4), |
|
590 | 590 | 'posts' => 0, |
591 | 591 | 'date_registered' => time(), |
592 | 592 | 'member_ip' => $regOptions['interface'] == 'admin' ? '127.0.0.1' : $user_info['ip'], |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | 'time_offset', |
677 | 677 | ); |
678 | 678 | $knownInets = array( |
679 | - 'member_ip','member_ip2', |
|
679 | + 'member_ip', 'member_ip2', |
|
680 | 680 | ); |
681 | 681 | |
682 | 682 | // Call an optional function to validate the users' input. |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
905 | 905 | |
906 | 906 | //when we got no wildcard we can use equal -> fast |
907 | - $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '=' ); |
|
907 | + $operator = (strpos($checkName, '%') || strpos($checkName, '_') ? 'LIKE' : '='); |
|
908 | 908 | |
909 | 909 | // Make sure they don't want someone else's name. |
910 | 910 | $request = $smcFunc['db_query']('', ' |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | $user_info['buddies'][] = $userReceiver; |
1274 | 1274 | |
1275 | 1275 | // And add a nice alert. Don't abuse though! |
1276 | - if ((cache_get_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, 86400)) == null) |
|
1276 | + if ((cache_get_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, 86400)) == null) |
|
1277 | 1277 | { |
1278 | 1278 | $smcFunc['db_insert']('insert', |
1279 | 1279 | '{db_prefix}background_tasks', |
@@ -1288,7 +1288,7 @@ discard block |
||
1288 | 1288 | ); |
1289 | 1289 | |
1290 | 1290 | // Store this in a cache entry to avoid creating multiple alerts. Give it a long life cycle. |
1291 | - cache_put_data('Buddy-sent-'. $user_info['id'] .'-'. $userReceiver, '1', 86400); |
|
1291 | + cache_put_data('Buddy-sent-' . $user_info['id'] . '-' . $userReceiver, '1', 86400); |
|
1292 | 1292 | } |
1293 | 1293 | } |
1294 | 1294 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Delete one or more members. |
@@ -43,30 +44,32 @@ discard block |
||
43 | 44 | setMemoryLimit('128M'); |
44 | 45 | |
45 | 46 | // If it's not an array, make it so! |
46 | - if (!is_array($users)) |
|
47 | - $users = array($users); |
|
48 | - else |
|
49 | - $users = array_unique($users); |
|
47 | + if (!is_array($users)) { |
|
48 | + $users = array($users); |
|
49 | + } else { |
|
50 | + $users = array_unique($users); |
|
51 | + } |
|
50 | 52 | |
51 | 53 | // Make sure there's no void user in here. |
52 | 54 | $users = array_diff($users, array(0)); |
53 | 55 | |
54 | 56 | // How many are they deleting? |
55 | - if (empty($users)) |
|
56 | - return; |
|
57 | - elseif (count($users) == 1) |
|
57 | + if (empty($users)) { |
|
58 | + return; |
|
59 | + } elseif (count($users) == 1) |
|
58 | 60 | { |
59 | 61 | list ($user) = $users; |
60 | 62 | |
61 | - if ($user == $user_info['id']) |
|
62 | - isAllowedTo('profile_remove_own'); |
|
63 | - else |
|
64 | - isAllowedTo('profile_remove_any'); |
|
65 | - } |
|
66 | - else |
|
63 | + if ($user == $user_info['id']) { |
|
64 | + isAllowedTo('profile_remove_own'); |
|
65 | + } else { |
|
66 | + isAllowedTo('profile_remove_any'); |
|
67 | + } |
|
68 | + } else |
|
67 | 69 | { |
68 | - foreach ($users as $k => $v) |
|
69 | - $users[$k] = (int) $v; |
|
70 | + foreach ($users as $k => $v) { |
|
71 | + $users[$k] = (int) $v; |
|
72 | + } |
|
70 | 73 | |
71 | 74 | // Deleting more than one? You can't have more than one account... |
72 | 75 | isAllowedTo('profile_remove_any'); |
@@ -88,26 +91,30 @@ discard block |
||
88 | 91 | $user_log_details = array(); |
89 | 92 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
90 | 93 | { |
91 | - if ($row['is_admin']) |
|
92 | - $admins[] = $row['id_member']; |
|
94 | + if ($row['is_admin']) { |
|
95 | + $admins[] = $row['id_member']; |
|
96 | + } |
|
93 | 97 | $user_log_details[$row['id_member']] = array($row['id_member'], $row['member_name']); |
94 | 98 | } |
95 | 99 | $smcFunc['db_free_result']($request); |
96 | 100 | |
97 | - if (empty($user_log_details)) |
|
98 | - return; |
|
101 | + if (empty($user_log_details)) { |
|
102 | + return; |
|
103 | + } |
|
99 | 104 | |
100 | 105 | // Make sure they aren't trying to delete administrators if they aren't one. But don't bother checking if it's just themself. |
101 | 106 | if (!empty($admins) && ($check_not_admin || (!allowedTo('admin_forum') && (count($users) != 1 || $users[0] != $user_info['id'])))) |
102 | 107 | { |
103 | 108 | $users = array_diff($users, $admins); |
104 | - foreach ($admins as $id) |
|
105 | - unset($user_log_details[$id]); |
|
109 | + foreach ($admins as $id) { |
|
110 | + unset($user_log_details[$id]); |
|
111 | + } |
|
106 | 112 | } |
107 | 113 | |
108 | 114 | // No one left? |
109 | - if (empty($users)) |
|
110 | - return; |
|
115 | + if (empty($users)) { |
|
116 | + return; |
|
117 | + } |
|
111 | 118 | |
112 | 119 | // Log the action - regardless of who is deleting it. |
113 | 120 | $log_changes = array(); |
@@ -124,8 +131,9 @@ discard block |
||
124 | 131 | ); |
125 | 132 | |
126 | 133 | // Remove any cached data if enabled. |
127 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
128 | - cache_put_data('user_settings-' . $user[0], null, 60); |
|
134 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
135 | + cache_put_data('user_settings-' . $user[0], null, 60); |
|
136 | + } |
|
129 | 137 | } |
130 | 138 | |
131 | 139 | // Make these peoples' posts guest posts. |
@@ -388,8 +396,8 @@ discard block |
||
388 | 396 | 'buddy_list' => implode(', buddy_list) != 0 OR FIND_IN_SET(', $users), |
389 | 397 | ) |
390 | 398 | ); |
391 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
392 | - $smcFunc['db_query']('', ' |
|
399 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
400 | + $smcFunc['db_query']('', ' |
|
393 | 401 | UPDATE {db_prefix}members |
394 | 402 | SET |
395 | 403 | pm_ignore_list = {string:pm_ignore_list}, |
@@ -401,6 +409,7 @@ discard block |
||
401 | 409 | 'buddy_list' => implode(',', array_diff(explode(',', $row['buddy_list']), $users)), |
402 | 410 | ) |
403 | 411 | ); |
412 | + } |
|
404 | 413 | $smcFunc['db_free_result']($request); |
405 | 414 | |
406 | 415 | // Make sure no member's birthday is still sticking in the calendar... |
@@ -455,29 +464,34 @@ discard block |
||
455 | 464 | elseif ($regOptions['interface'] == 'guest') |
456 | 465 | { |
457 | 466 | // You cannot register twice... |
458 | - if (empty($user_info['is_guest'])) |
|
459 | - redirectexit(); |
|
467 | + if (empty($user_info['is_guest'])) { |
|
468 | + redirectexit(); |
|
469 | + } |
|
460 | 470 | |
461 | 471 | // Make sure they didn't just register with this session. |
462 | - if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) |
|
463 | - fatal_lang_error('register_only_once', false); |
|
472 | + if (!empty($_SESSION['just_registered']) && empty($modSettings['disableRegisterCheck'])) { |
|
473 | + fatal_lang_error('register_only_once', false); |
|
474 | + } |
|
464 | 475 | } |
465 | 476 | |
466 | 477 | // Spaces and other odd characters are evil... |
467 | 478 | $regOptions['username'] = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $regOptions['username'])); |
468 | 479 | |
469 | 480 | // @todo Separate the sprintf? |
470 | - if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) |
|
471 | - $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
481 | + if (empty($regOptions['email']) || !filter_var($regOptions['email'], FILTER_VALIDATE_EMAIL) || strlen($regOptions['email']) > 255) { |
|
482 | + $reg_errors[] = array('lang', 'profile_error_bad_email'); |
|
483 | + } |
|
472 | 484 | |
473 | 485 | $username_validation_errors = validateUsername(0, $regOptions['username'], true, !empty($regOptions['check_reserved_name'])); |
474 | - if (!empty($username_validation_errors)) |
|
475 | - $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
486 | + if (!empty($username_validation_errors)) { |
|
487 | + $reg_errors = array_merge($reg_errors, $username_validation_errors); |
|
488 | + } |
|
476 | 489 | |
477 | 490 | // Generate a validation code if it's supposed to be emailed. |
478 | 491 | $validation_code = ''; |
479 | - if ($regOptions['require'] == 'activation') |
|
480 | - $validation_code = generateValidationCode(); |
|
492 | + if ($regOptions['require'] == 'activation') { |
|
493 | + $validation_code = generateValidationCode(); |
|
494 | + } |
|
481 | 495 | |
482 | 496 | // If you haven't put in a password generate one. |
483 | 497 | if ($regOptions['interface'] == 'admin' && $regOptions['password'] == '') |
@@ -487,8 +501,9 @@ discard block |
||
487 | 501 | $regOptions['password_check'] = $regOptions['password']; |
488 | 502 | } |
489 | 503 | // Does the first password match the second? |
490 | - elseif ($regOptions['password'] != $regOptions['password_check']) |
|
491 | - $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
504 | + elseif ($regOptions['password'] != $regOptions['password_check']) { |
|
505 | + $reg_errors[] = array('lang', 'passwords_dont_match'); |
|
506 | + } |
|
492 | 507 | |
493 | 508 | // That's kind of easy to guess... |
494 | 509 | if ($regOptions['password'] == '') |
@@ -502,13 +517,15 @@ discard block |
||
502 | 517 | $passwordError = validatePassword($regOptions['password'], $regOptions['username'], array($regOptions['email'])); |
503 | 518 | |
504 | 519 | // Password isn't legal? |
505 | - if ($passwordError != null) |
|
506 | - $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
520 | + if ($passwordError != null) { |
|
521 | + $reg_errors[] = array('lang', 'profile_error_password_' . $passwordError); |
|
522 | + } |
|
507 | 523 | } |
508 | 524 | |
509 | 525 | // You may not be allowed to register this email. |
510 | - if (!empty($regOptions['check_email_ban'])) |
|
511 | - isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
526 | + if (!empty($regOptions['check_email_ban'])) { |
|
527 | + isBannedEmail($regOptions['email'], 'cannot_register', $txt['ban_register_prohibited']); |
|
528 | + } |
|
512 | 529 | |
513 | 530 | // Check if the email address is in use. |
514 | 531 | $request = $smcFunc['db_query']('', ' |
@@ -523,8 +540,9 @@ discard block |
||
523 | 540 | ) |
524 | 541 | ); |
525 | 542 | // @todo Separate the sprintf? |
526 | - if ($smcFunc['db_num_rows']($request) != 0) |
|
527 | - $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
543 | + if ($smcFunc['db_num_rows']($request) != 0) { |
|
544 | + $reg_errors[] = array('lang', 'email_in_use', false, array($smcFunc['htmlspecialchars']($regOptions['email']))); |
|
545 | + } |
|
528 | 546 | |
529 | 547 | $smcFunc['db_free_result']($request); |
530 | 548 | |
@@ -539,24 +557,27 @@ discard block |
||
539 | 557 | 1 = The text/index. |
540 | 558 | 2 = Whether to log. |
541 | 559 | 3 = sprintf data if necessary. */ |
542 | - if ($error[0] == 'lang') |
|
543 | - loadLanguage('Errors'); |
|
560 | + if ($error[0] == 'lang') { |
|
561 | + loadLanguage('Errors'); |
|
562 | + } |
|
544 | 563 | $message = $error[0] == 'lang' ? (empty($error[3]) ? $txt[$error[1]] : vsprintf($txt[$error[1]], $error[3])) : $error[1]; |
545 | 564 | |
546 | 565 | // What to do, what to do, what to do. |
547 | 566 | if ($return_errors) |
548 | 567 | { |
549 | - if (!empty($error[2])) |
|
550 | - log_error($message, $error[2]); |
|
568 | + if (!empty($error[2])) { |
|
569 | + log_error($message, $error[2]); |
|
570 | + } |
|
551 | 571 | $reg_errors[$key] = $message; |
572 | + } else { |
|
573 | + fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
552 | 574 | } |
553 | - else |
|
554 | - fatal_error($message, empty($error[2]) ? false : $error[2]); |
|
555 | 575 | } |
556 | 576 | |
557 | 577 | // If there's any errors left return them at once! |
558 | - if (!empty($reg_errors)) |
|
559 | - return $reg_errors; |
|
578 | + if (!empty($reg_errors)) { |
|
579 | + return $reg_errors; |
|
580 | + } |
|
560 | 581 | |
561 | 582 | $reservedVars = array( |
562 | 583 | 'actual_theme_url', |
@@ -578,8 +599,9 @@ discard block |
||
578 | 599 | ); |
579 | 600 | |
580 | 601 | // Can't change reserved vars. |
581 | - if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) |
|
582 | - fatal_lang_error('no_theme'); |
|
602 | + if (isset($regOptions['theme_vars']) && count(array_intersect(array_keys($regOptions['theme_vars']), $reservedVars)) != 0) { |
|
603 | + fatal_lang_error('no_theme'); |
|
604 | + } |
|
583 | 605 | |
584 | 606 | // Some of these might be overwritten. (the lower ones that are in the arrays below.) |
585 | 607 | $regOptions['register_vars'] = array( |
@@ -621,14 +643,17 @@ discard block |
||
621 | 643 | $regOptions['register_vars']['validation_code'] = ''; |
622 | 644 | } |
623 | 645 | // Maybe it can be activated right away? |
624 | - elseif ($regOptions['require'] == 'nothing') |
|
625 | - $regOptions['register_vars']['is_activated'] = 1; |
|
646 | + elseif ($regOptions['require'] == 'nothing') { |
|
647 | + $regOptions['register_vars']['is_activated'] = 1; |
|
648 | + } |
|
626 | 649 | // Maybe it must be activated by email? |
627 | - elseif ($regOptions['require'] == 'activation') |
|
628 | - $regOptions['register_vars']['is_activated'] = 0; |
|
650 | + elseif ($regOptions['require'] == 'activation') { |
|
651 | + $regOptions['register_vars']['is_activated'] = 0; |
|
652 | + } |
|
629 | 653 | // Otherwise it must be awaiting approval! |
630 | - else |
|
631 | - $regOptions['register_vars']['is_activated'] = 3; |
|
654 | + else { |
|
655 | + $regOptions['register_vars']['is_activated'] = 3; |
|
656 | + } |
|
632 | 657 | |
633 | 658 | if (isset($regOptions['memberGroup'])) |
634 | 659 | { |
@@ -647,24 +672,28 @@ discard block |
||
647 | 672 | 'is_protected' => 1, |
648 | 673 | ) |
649 | 674 | ); |
650 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
651 | - $unassignableGroups[] = $row['id_group']; |
|
675 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
676 | + $unassignableGroups[] = $row['id_group']; |
|
677 | + } |
|
652 | 678 | $smcFunc['db_free_result']($request); |
653 | 679 | |
654 | - if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) |
|
655 | - $regOptions['register_vars']['id_group'] = 0; |
|
680 | + if (in_array($regOptions['register_vars']['id_group'], $unassignableGroups)) { |
|
681 | + $regOptions['register_vars']['id_group'] = 0; |
|
682 | + } |
|
656 | 683 | } |
657 | 684 | |
658 | 685 | // Integrate optional member settings to be set. |
659 | - if (!empty($regOptions['extra_register_vars'])) |
|
660 | - foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
686 | + if (!empty($regOptions['extra_register_vars'])) { |
|
687 | + foreach ($regOptions['extra_register_vars'] as $var => $value) |
|
661 | 688 | $regOptions['register_vars'][$var] = $value; |
689 | + } |
|
662 | 690 | |
663 | 691 | // Integrate optional user theme options to be set. |
664 | 692 | $theme_vars = array(); |
665 | - if (!empty($regOptions['theme_vars'])) |
|
666 | - foreach ($regOptions['theme_vars'] as $var => $value) |
|
693 | + if (!empty($regOptions['theme_vars'])) { |
|
694 | + foreach ($regOptions['theme_vars'] as $var => $value) |
|
667 | 695 | $theme_vars[$var] = $value; |
696 | + } |
|
668 | 697 | |
669 | 698 | // Right, now let's prepare for insertion. |
670 | 699 | $knownInts = array( |
@@ -687,14 +716,15 @@ discard block |
||
687 | 716 | foreach ($regOptions['register_vars'] as $var => $val) |
688 | 717 | { |
689 | 718 | $type = 'string'; |
690 | - if (in_array($var, $knownInts)) |
|
691 | - $type = 'int'; |
|
692 | - elseif (in_array($var, $knownFloats)) |
|
693 | - $type = 'float'; |
|
694 | - elseif (in_array($var, $knownInets)) |
|
695 | - $type = 'inet'; |
|
696 | - elseif ($var == 'birthdate') |
|
697 | - $type = 'date'; |
|
719 | + if (in_array($var, $knownInts)) { |
|
720 | + $type = 'int'; |
|
721 | + } elseif (in_array($var, $knownFloats)) { |
|
722 | + $type = 'float'; |
|
723 | + } elseif (in_array($var, $knownInets)) { |
|
724 | + $type = 'inet'; |
|
725 | + } elseif ($var == 'birthdate') { |
|
726 | + $type = 'date'; |
|
727 | + } |
|
698 | 728 | |
699 | 729 | $column_names[$var] = $type; |
700 | 730 | $values[$var] = $val; |
@@ -713,17 +743,19 @@ discard block |
||
713 | 743 | call_integration_hook('integrate_post_register', array(&$regOptions, &$theme_vars, &$memberID)); |
714 | 744 | |
715 | 745 | // Update the number of members and latest member's info - and pass the name, but remove the 's. |
716 | - if ($regOptions['register_vars']['is_activated'] == 1) |
|
717 | - updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
718 | - else |
|
719 | - updateStats('member'); |
|
746 | + if ($regOptions['register_vars']['is_activated'] == 1) { |
|
747 | + updateStats('member', $memberID, $regOptions['register_vars']['real_name']); |
|
748 | + } else { |
|
749 | + updateStats('member'); |
|
750 | + } |
|
720 | 751 | |
721 | 752 | // Theme variables too? |
722 | 753 | if (!empty($theme_vars)) |
723 | 754 | { |
724 | 755 | $inserts = array(); |
725 | - foreach ($theme_vars as $var => $val) |
|
726 | - $inserts[] = array($memberID, $var, $val); |
|
756 | + foreach ($theme_vars as $var => $val) { |
|
757 | + $inserts[] = array($memberID, $var, $val); |
|
758 | + } |
|
727 | 759 | $smcFunc['db_insert']('insert', |
728 | 760 | '{db_prefix}themes', |
729 | 761 | array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'), |
@@ -738,10 +770,11 @@ discard block |
||
738 | 770 | // Administrative registrations are a bit different... |
739 | 771 | if ($regOptions['interface'] == 'admin') |
740 | 772 | { |
741 | - if ($regOptions['require'] == 'activation') |
|
742 | - $email_message = 'admin_register_activate'; |
|
743 | - elseif (!empty($regOptions['send_welcome_email'])) |
|
744 | - $email_message = 'admin_register_immediate'; |
|
773 | + if ($regOptions['require'] == 'activation') { |
|
774 | + $email_message = 'admin_register_activate'; |
|
775 | + } elseif (!empty($regOptions['send_welcome_email'])) { |
|
776 | + $email_message = 'admin_register_immediate'; |
|
777 | + } |
|
745 | 778 | |
746 | 779 | if (isset($email_message)) |
747 | 780 | { |
@@ -792,16 +825,17 @@ discard block |
||
792 | 825 | 'FORGOTPASSWORDLINK' => $scripturl . '?action=reminder', |
793 | 826 | ); |
794 | 827 | |
795 | - if ($regOptions['require'] == 'activation') |
|
796 | - $replacements += array( |
|
828 | + if ($regOptions['require'] == 'activation') { |
|
829 | + $replacements += array( |
|
797 | 830 | 'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $memberID . ';code=' . $validation_code, |
798 | 831 | 'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $memberID, |
799 | 832 | 'ACTIVATIONCODE' => $validation_code, |
800 | 833 | ); |
801 | - else |
|
802 | - $replacements += array( |
|
834 | + } else { |
|
835 | + $replacements += array( |
|
803 | 836 | 'COPPALINK' => $scripturl . '?action=coppa;u=' . $memberID, |
804 | 837 | ); |
838 | + } |
|
805 | 839 | |
806 | 840 | $emaildata = loadEmailTemplate('register_' . ($regOptions['require'] == 'activation' ? 'activate' : 'coppa'), $replacements); |
807 | 841 | |
@@ -866,39 +900,45 @@ discard block |
||
866 | 900 | // Check each name in the list... |
867 | 901 | foreach ($reservedNames as $reserved) |
868 | 902 | { |
869 | - if ($reserved == '') |
|
870 | - continue; |
|
903 | + if ($reserved == '') { |
|
904 | + continue; |
|
905 | + } |
|
871 | 906 | |
872 | 907 | // The admin might've used entities too, level the playing field. |
873 | 908 | $reservedCheck = preg_replace('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'replaceEntities__callback', $reserved); |
874 | 909 | |
875 | 910 | // Case sensitive name? |
876 | - if (empty($modSettings['reserveCase'])) |
|
877 | - $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
911 | + if (empty($modSettings['reserveCase'])) { |
|
912 | + $reservedCheck = $smcFunc['strtolower']($reservedCheck); |
|
913 | + } |
|
878 | 914 | |
879 | 915 | // If it's not just entire word, check for it in there somewhere... |
880 | - if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) |
|
881 | - if ($fatal) |
|
916 | + if ($checkMe == $reservedCheck || ($smcFunc['strpos']($checkMe, $reservedCheck) !== false && empty($modSettings['reserveWord']))) { |
|
917 | + if ($fatal) |
|
882 | 918 | fatal_lang_error('username_reserved', 'password', array($reserved)); |
883 | - else |
|
884 | - return true; |
|
919 | + } else { |
|
920 | + return true; |
|
921 | + } |
|
885 | 922 | } |
886 | 923 | |
887 | 924 | $censor_name = $name; |
888 | - if (censorText($censor_name) != $name) |
|
889 | - if ($fatal) |
|
925 | + if (censorText($censor_name) != $name) { |
|
926 | + if ($fatal) |
|
890 | 927 | fatal_lang_error('name_censored', 'password', array($name)); |
891 | - else |
|
892 | - return true; |
|
928 | + } else { |
|
929 | + return true; |
|
930 | + } |
|
893 | 931 | } |
894 | 932 | |
895 | 933 | // Characters we just shouldn't allow, regardless. |
896 | - foreach (array('*') as $char) |
|
897 | - if (strpos($checkName, $char) !== false) |
|
934 | + foreach (array('*') as $char) { |
|
935 | + if (strpos($checkName, $char) !== false) |
|
898 | 936 | if ($fatal) |
899 | 937 | fatal_lang_error('username_reserved', 'password', array($char)); |
900 | - else |
|
901 | - return true; |
|
938 | + } |
|
939 | + else { |
|
940 | + return true; |
|
941 | + } |
|
902 | 942 | |
903 | 943 | // Get rid of any SQL parts of the reserved name... |
904 | 944 | $checkName = strtr($name, array('_' => '\\_', '%' => '\\%')); |
@@ -980,8 +1020,9 @@ discard block |
||
980 | 1020 | 'permission' => $permission, |
981 | 1021 | ) |
982 | 1022 | ); |
983 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
984 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1023 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1024 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1025 | + } |
|
985 | 1026 | $smcFunc['db_free_result']($request); |
986 | 1027 | } |
987 | 1028 | |
@@ -989,9 +1030,9 @@ discard block |
||
989 | 1030 | else |
990 | 1031 | { |
991 | 1032 | // First get the profile of the given board. |
992 | - if (isset($board_info['id']) && $board_info['id'] == $board_id) |
|
993 | - $profile_id = $board_info['profile']; |
|
994 | - elseif ($board_id !== 0) |
|
1033 | + if (isset($board_info['id']) && $board_info['id'] == $board_id) { |
|
1034 | + $profile_id = $board_info['profile']; |
|
1035 | + } elseif ($board_id !== 0) |
|
995 | 1036 | { |
996 | 1037 | $request = $smcFunc['db_query']('', ' |
997 | 1038 | SELECT id_profile |
@@ -1002,13 +1043,14 @@ discard block |
||
1002 | 1043 | 'id_board' => $board_id, |
1003 | 1044 | ) |
1004 | 1045 | ); |
1005 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1006 | - fatal_lang_error('no_board'); |
|
1046 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1047 | + fatal_lang_error('no_board'); |
|
1048 | + } |
|
1007 | 1049 | list ($profile_id) = $smcFunc['db_fetch_row']($request); |
1008 | 1050 | $smcFunc['db_free_result']($request); |
1051 | + } else { |
|
1052 | + $profile_id = 1; |
|
1009 | 1053 | } |
1010 | - else |
|
1011 | - $profile_id = 1; |
|
1012 | 1054 | |
1013 | 1055 | $request = $smcFunc['db_query']('', ' |
1014 | 1056 | SELECT bp.id_group, bp.add_deny |
@@ -1020,8 +1062,9 @@ discard block |
||
1020 | 1062 | 'permission' => $permission, |
1021 | 1063 | ) |
1022 | 1064 | ); |
1023 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1024 | - $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1065 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1066 | + $member_groups[$row['add_deny'] === '1' ? 'allowed' : 'denied'][] = $row['id_group']; |
|
1067 | + } |
|
1025 | 1068 | $smcFunc['db_free_result']($request); |
1026 | 1069 | |
1027 | 1070 | $moderator_groups = array(); |
@@ -1030,8 +1073,7 @@ discard block |
||
1030 | 1073 | if (isset($board_info['moderator_groups'])) |
1031 | 1074 | { |
1032 | 1075 | $moderator_groups = array_keys($board_info['moderator_groups']); |
1033 | - } |
|
1034 | - elseif ($board_id !== 0) |
|
1076 | + } elseif ($board_id !== 0) |
|
1035 | 1077 | { |
1036 | 1078 | // Get the groups that can moderate this board |
1037 | 1079 | $request = $smcFunc['db_query']('', ' |
@@ -1116,8 +1158,9 @@ discard block |
||
1116 | 1158 | ) |
1117 | 1159 | ); |
1118 | 1160 | $members = array(); |
1119 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1120 | - $members[] = $row['id_member']; |
|
1161 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1162 | + $members[] = $row['id_member']; |
|
1163 | + } |
|
1121 | 1164 | $smcFunc['db_free_result']($request); |
1122 | 1165 | |
1123 | 1166 | return $members; |
@@ -1190,10 +1233,12 @@ discard block |
||
1190 | 1233 | } |
1191 | 1234 | |
1192 | 1235 | $query_parts = array(); |
1193 | - if (!empty($email)) |
|
1194 | - $query_parts[] = 'poster_email = {string:email_address}'; |
|
1195 | - if (!empty($membername)) |
|
1196 | - $query_parts[] = 'poster_name = {string:member_name}'; |
|
1236 | + if (!empty($email)) { |
|
1237 | + $query_parts[] = 'poster_email = {string:email_address}'; |
|
1238 | + } |
|
1239 | + if (!empty($membername)) { |
|
1240 | + $query_parts[] = 'poster_name = {string:member_name}'; |
|
1241 | + } |
|
1197 | 1242 | $query = implode(' AND ', $query_parts); |
1198 | 1243 | |
1199 | 1244 | // Finally, update the posts themselves! |
@@ -1260,12 +1305,14 @@ discard block |
||
1260 | 1305 | |
1261 | 1306 | $userReceiver = (int) !empty($_REQUEST['u']) ? $_REQUEST['u'] : 0; |
1262 | 1307 | |
1263 | - if (empty($userReceiver)) |
|
1264 | - fatal_lang_error('no_access', false); |
|
1308 | + if (empty($userReceiver)) { |
|
1309 | + fatal_lang_error('no_access', false); |
|
1310 | + } |
|
1265 | 1311 | |
1266 | 1312 | // Remove if it's already there... |
1267 | - if (in_array($userReceiver, $user_info['buddies'])) |
|
1268 | - $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1313 | + if (in_array($userReceiver, $user_info['buddies'])) { |
|
1314 | + $user_info['buddies'] = array_diff($user_info['buddies'], array($userReceiver)); |
|
1315 | + } |
|
1269 | 1316 | |
1270 | 1317 | // ...or add if it's not and if it's not you. |
1271 | 1318 | elseif ($user_info['id'] != $userReceiver) |
@@ -1340,8 +1387,9 @@ discard block |
||
1340 | 1387 | $smcFunc['db_free_result']($request); |
1341 | 1388 | |
1342 | 1389 | // If we want duplicates pass the members array off. |
1343 | - if ($get_duplicates) |
|
1344 | - populateDuplicateMembers($members); |
|
1390 | + if ($get_duplicates) { |
|
1391 | + populateDuplicateMembers($members); |
|
1392 | + } |
|
1345 | 1393 | |
1346 | 1394 | return $members; |
1347 | 1395 | } |
@@ -1358,8 +1406,9 @@ discard block |
||
1358 | 1406 | global $smcFunc, $modSettings; |
1359 | 1407 | |
1360 | 1408 | // We know how many members there are in total. |
1361 | - if (empty($where) || $where == '1=1') |
|
1362 | - $num_members = $modSettings['totalMembers']; |
|
1409 | + if (empty($where) || $where == '1=1') { |
|
1410 | + $num_members = $modSettings['totalMembers']; |
|
1411 | + } |
|
1363 | 1412 | |
1364 | 1413 | // The database knows the amount when there are extra conditions. |
1365 | 1414 | else |
@@ -1395,16 +1444,19 @@ discard block |
||
1395 | 1444 | $members[$key]['duplicate_members'] = array(); |
1396 | 1445 | |
1397 | 1446 | // Store the IPs. |
1398 | - if (!empty($member['member_ip'])) |
|
1399 | - $ips[] = $member['member_ip']; |
|
1400 | - if (!empty($member['member_ip2'])) |
|
1401 | - $ips[] = $member['member_ip2']; |
|
1447 | + if (!empty($member['member_ip'])) { |
|
1448 | + $ips[] = $member['member_ip']; |
|
1449 | + } |
|
1450 | + if (!empty($member['member_ip2'])) { |
|
1451 | + $ips[] = $member['member_ip2']; |
|
1452 | + } |
|
1402 | 1453 | } |
1403 | 1454 | |
1404 | 1455 | $ips = array_unique($ips); |
1405 | 1456 | |
1406 | - if (empty($ips)) |
|
1407 | - return false; |
|
1457 | + if (empty($ips)) { |
|
1458 | + return false; |
|
1459 | + } |
|
1408 | 1460 | |
1409 | 1461 | // Fetch all members with this IP address, we'll filter out the current ones in a sec. |
1410 | 1462 | $request = $smcFunc['db_query']('', ' |
@@ -1434,10 +1486,12 @@ discard block |
||
1434 | 1486 | 'ip2' => $row['member_ip2'], |
1435 | 1487 | ); |
1436 | 1488 | |
1437 | - if (in_array($row['member_ip'], $ips)) |
|
1438 | - $duplicate_members[$row['member_ip']][] = $member_context; |
|
1439 | - if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) |
|
1440 | - $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1489 | + if (in_array($row['member_ip'], $ips)) { |
|
1490 | + $duplicate_members[$row['member_ip']][] = $member_context; |
|
1491 | + } |
|
1492 | + if ($row['member_ip'] != $row['member_ip2'] && in_array($row['member_ip2'], $ips)) { |
|
1493 | + $duplicate_members[$row['member_ip2']][] = $member_context; |
|
1494 | + } |
|
1441 | 1495 | } |
1442 | 1496 | $smcFunc['db_free_result']($request); |
1443 | 1497 | |
@@ -1462,8 +1516,9 @@ discard block |
||
1462 | 1516 | $row['poster_ip'] = inet_dtop($row['poster_ip']); |
1463 | 1517 | |
1464 | 1518 | // Don't collect lots of the same. |
1465 | - if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) |
|
1466 | - continue; |
|
1519 | + if (isset($had_ips[$row['poster_ip']]) && in_array($row['id_member'], $had_ips[$row['poster_ip']])) { |
|
1520 | + continue; |
|
1521 | + } |
|
1467 | 1522 | $had_ips[$row['poster_ip']][] = $row['id_member']; |
1468 | 1523 | |
1469 | 1524 | $duplicate_members[$row['poster_ip']][] = array( |
@@ -1478,13 +1533,15 @@ discard block |
||
1478 | 1533 | $smcFunc['db_free_result']($request); |
1479 | 1534 | |
1480 | 1535 | // Now we have all the duplicate members, stick them with their respective member in the list. |
1481 | - if (!empty($duplicate_members)) |
|
1482 | - foreach ($members as $key => $member) |
|
1536 | + if (!empty($duplicate_members)) { |
|
1537 | + foreach ($members as $key => $member) |
|
1483 | 1538 | { |
1484 | 1539 | if (isset($duplicate_members[$member['member_ip']])) |
1485 | 1540 | $members[$key]['duplicate_members'] = $duplicate_members[$member['member_ip']]; |
1486 | - if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) |
|
1487 | - $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1541 | + } |
|
1542 | + if ($member['member_ip'] != $member['member_ip2'] && isset($duplicate_members[$member['member_ip2']])) { |
|
1543 | + $members[$key]['duplicate_members'] = array_merge($member['duplicate_members'], $duplicate_members[$member['member_ip2']]); |
|
1544 | + } |
|
1488 | 1545 | |
1489 | 1546 | // Check we don't have lots of the same member. |
1490 | 1547 | $member_track = array($member['id_member']); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | else |
238 | 238 | { |
239 | 239 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
240 | - AND b.id_board != {int:recycle_board}' : ''). ' |
|
240 | + AND b.id_board != {int:recycle_board}' : '') . ' |
|
241 | 241 | AND m.id_msg >= {int:max_id_msg}'; |
242 | 242 | $query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 100 - $_REQUEST['start'] * 6); |
243 | 243 | $query_parameters['recycle_board'] = $modSettings['recycle_board']; |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | ); |
1125 | 1125 | else |
1126 | 1126 | $request = $smcFunc['db_query']('', ' |
1127 | - SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
|
1127 | + SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'] . ' |
|
1128 | 1128 | FROM {db_prefix}topics AS t |
1129 | 1129 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
1130 | 1130 | INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)') . (strpos($_REQUEST['sort'], 'mems.') === false ? '' : ' |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | if ($is_topics) |
1392 | 1392 | { |
1393 | 1393 | $context['recent_buttons'] = array( |
1394 | - 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1394 | + 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1395 | 1395 | ); |
1396 | 1396 | |
1397 | 1397 | if ($context['showCheckboxes']) |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | elseif (!$is_topics && isset($context['topics_to_mark'])) |
1408 | 1408 | { |
1409 | 1409 | $context['recent_buttons'] = array( |
1410 | - 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1410 | + 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
|
1411 | 1411 | ); |
1412 | 1412 | |
1413 | 1413 | if ($context['showCheckboxes']) |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get the latest post made on the system |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | 'is_approved' => 1, |
45 | 46 | ) |
46 | 47 | ); |
47 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
48 | - return array(); |
|
48 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
49 | + return array(); |
|
50 | + } |
|
49 | 51 | $row = $smcFunc['db_fetch_assoc']($request); |
50 | 52 | $smcFunc['db_free_result']($request); |
51 | 53 | |
@@ -54,8 +56,9 @@ discard block |
||
54 | 56 | censorText($row['body']); |
55 | 57 | |
56 | 58 | $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br>' => ' '))); |
57 | - if ($smcFunc['strlen']($row['body']) > 128) |
|
58 | - $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
59 | + if ($smcFunc['strlen']($row['body']) > 128) { |
|
60 | + $row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...'; |
|
61 | + } |
|
59 | 62 | |
60 | 63 | // Send the data. |
61 | 64 | return array( |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | |
84 | 87 | $context['is_redirect'] = false; |
85 | 88 | |
86 | - if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) |
|
87 | - $_REQUEST['start'] = 95; |
|
89 | + if (isset($_REQUEST['start']) && $_REQUEST['start'] > 95) { |
|
90 | + $_REQUEST['start'] = 95; |
|
91 | + } |
|
88 | 92 | |
89 | 93 | $_REQUEST['start'] = (int) $_REQUEST['start']; |
90 | 94 | |
@@ -92,8 +96,9 @@ discard block |
||
92 | 96 | if (!empty($_REQUEST['c']) && empty($board)) |
93 | 97 | { |
94 | 98 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
95 | - foreach ($_REQUEST['c'] as $i => $c) |
|
96 | - $_REQUEST['c'][$i] = (int) $c; |
|
99 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
100 | + $_REQUEST['c'][$i] = (int) $c; |
|
101 | + } |
|
97 | 102 | |
98 | 103 | if (count($_REQUEST['c']) == 1) |
99 | 104 | { |
@@ -109,8 +114,9 @@ discard block |
||
109 | 114 | list ($name) = $smcFunc['db_fetch_row']($request); |
110 | 115 | $smcFunc['db_free_result']($request); |
111 | 116 | |
112 | - if (empty($name)) |
|
113 | - fatal_lang_error('no_access', false); |
|
117 | + if (empty($name)) { |
|
118 | + fatal_lang_error('no_access', false); |
|
119 | + } |
|
114 | 120 | |
115 | 121 | $context['linktree'][] = array( |
116 | 122 | 'url' => $scripturl . '#c' . (int) $_REQUEST['c'], |
@@ -142,8 +148,9 @@ discard block |
||
142 | 148 | } |
143 | 149 | $smcFunc['db_free_result']($request); |
144 | 150 | |
145 | - if (empty($boards)) |
|
146 | - fatal_lang_error('error_no_boards_selected'); |
|
151 | + if (empty($boards)) { |
|
152 | + fatal_lang_error('error_no_boards_selected'); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
149 | 156 | $query_parameters['boards'] = $boards; |
@@ -157,12 +164,12 @@ discard block |
||
157 | 164 | } |
158 | 165 | |
159 | 166 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;c=' . implode(',', $_REQUEST['c']), $_REQUEST['start'], min(100, $total_cat_posts), 10, false); |
160 | - } |
|
161 | - elseif (!empty($_REQUEST['boards'])) |
|
167 | + } elseif (!empty($_REQUEST['boards'])) |
|
162 | 168 | { |
163 | 169 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
164 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
165 | - $_REQUEST['boards'][$i] = (int) $b; |
|
170 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
171 | + $_REQUEST['boards'][$i] = (int) $b; |
|
172 | + } |
|
166 | 173 | |
167 | 174 | $request = $smcFunc['db_query']('', ' |
168 | 175 | SELECT b.id_board, b.num_posts |
@@ -186,8 +193,9 @@ discard block |
||
186 | 193 | } |
187 | 194 | $smcFunc['db_free_result']($request); |
188 | 195 | |
189 | - if (empty($boards)) |
|
190 | - fatal_lang_error('error_no_boards_selected'); |
|
196 | + if (empty($boards)) { |
|
197 | + fatal_lang_error('error_no_boards_selected'); |
|
198 | + } |
|
191 | 199 | |
192 | 200 | $query_this_board = 'b.id_board IN ({array_int:boards})'; |
193 | 201 | $query_parameters['boards'] = $boards; |
@@ -201,8 +209,7 @@ discard block |
||
201 | 209 | } |
202 | 210 | |
203 | 211 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;boards=' . implode(',', $_REQUEST['boards']), $_REQUEST['start'], min(100, $total_posts), 10, false); |
204 | - } |
|
205 | - elseif (!empty($board)) |
|
212 | + } elseif (!empty($board)) |
|
206 | 213 | { |
207 | 214 | $request = $smcFunc['db_query']('', ' |
208 | 215 | SELECT num_posts, redirect |
@@ -235,8 +242,7 @@ discard block |
||
235 | 242 | } |
236 | 243 | |
237 | 244 | $context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $total_posts), 10, true); |
238 | - } |
|
239 | - else |
|
245 | + } else |
|
240 | 246 | { |
241 | 247 | $query_this_board = '{query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? ' |
242 | 248 | AND b.id_board != {int:recycle_board}' : ''). ' |
@@ -271,8 +277,9 @@ discard block |
||
271 | 277 | ); |
272 | 278 | |
273 | 279 | // If you selected a redirection board, don't try getting posts for it... |
274 | - if ($context['is_redirect']) |
|
275 | - $messages = 0; |
|
280 | + if ($context['is_redirect']) { |
|
281 | + $messages = 0; |
|
282 | + } |
|
276 | 283 | |
277 | 284 | $key = 'recent-' . $user_info['id'] . '-' . md5($smcFunc['json_encode'](array_diff_key($query_parameters, array('max_id_msg' => 0)))) . '-' . (int) $_REQUEST['start']; |
278 | 285 | if (!$context['is_redirect'] && (empty($modSettings['cache_enable']) || ($messages = cache_get_data($key, 120)) == null)) |
@@ -303,16 +310,18 @@ discard block |
||
303 | 310 | $query_this_board = str_replace('AND m.id_msg >= {int:max_id_msg}', '', $query_this_board); |
304 | 311 | $cache_results = true; |
305 | 312 | unset($query_parameters['max_id_msg']); |
313 | + } else { |
|
314 | + $done = true; |
|
306 | 315 | } |
307 | - else |
|
308 | - $done = true; |
|
309 | 316 | } |
310 | 317 | $messages = array(); |
311 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
312 | - $messages[] = $row['id_msg']; |
|
318 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
319 | + $messages[] = $row['id_msg']; |
|
320 | + } |
|
313 | 321 | $smcFunc['db_free_result']($request); |
314 | - if (!empty($cache_results)) |
|
315 | - cache_put_data($key, $messages, 120); |
|
322 | + if (!empty($cache_results)) { |
|
323 | + cache_put_data($key, $messages, 120); |
|
324 | + } |
|
316 | 325 | } |
317 | 326 | |
318 | 327 | // Nothing here... Or at least, nothing you can see... |
@@ -399,8 +408,9 @@ discard block |
||
399 | 408 | 'css_class' => 'windowbg', |
400 | 409 | ); |
401 | 410 | |
402 | - if ($user_info['id'] == $row['id_first_member']) |
|
403 | - $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
411 | + if ($user_info['id'] == $row['id_first_member']) { |
|
412 | + $board_ids['own'][$row['id_board']][] = $row['id_msg']; |
|
413 | + } |
|
404 | 414 | $board_ids['any'][$row['id_board']][] = $row['id_msg']; |
405 | 415 | } |
406 | 416 | $smcFunc['db_free_result']($request); |
@@ -426,20 +436,23 @@ discard block |
||
426 | 436 | $boards = boardsAllowedTo($permission); |
427 | 437 | |
428 | 438 | // If 0 is the only thing in the array, they can do it everywhere! |
429 | - if (!empty($boards) && $boards[0] == 0) |
|
430 | - $boards = array_keys($board_ids[$type]); |
|
439 | + if (!empty($boards) && $boards[0] == 0) { |
|
440 | + $boards = array_keys($board_ids[$type]); |
|
441 | + } |
|
431 | 442 | |
432 | 443 | // Go through the boards, and look for posts they can do this on. |
433 | 444 | foreach ($boards as $board_id) |
434 | 445 | { |
435 | 446 | // Hmm, they have permission, but there are no topics from that board on this page. |
436 | - if (!isset($board_ids[$type][$board_id])) |
|
437 | - continue; |
|
447 | + if (!isset($board_ids[$type][$board_id])) { |
|
448 | + continue; |
|
449 | + } |
|
438 | 450 | |
439 | 451 | // Okay, looks like they can do it for these posts. |
440 | - foreach ($board_ids[$type][$board_id] as $counter) |
|
441 | - if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
452 | + foreach ($board_ids[$type][$board_id] as $counter) { |
|
453 | + if ($type == 'any' || $context['posts'][$counter]['poster']['id'] == $user_info['id']) |
|
442 | 454 | $context['posts'][$counter][$allowed] = true; |
455 | + } |
|
443 | 456 | } |
444 | 457 | } |
445 | 458 | } |
@@ -482,17 +495,19 @@ discard block |
||
482 | 495 | $context['showing_all_topics'] = isset($_GET['all']); |
483 | 496 | $context['start'] = (int) $_REQUEST['start']; |
484 | 497 | $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics']; |
485 | - if ($_REQUEST['action'] == 'unread') |
|
486 | - $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
487 | - else |
|
488 | - $context['page_title'] = $txt['unread_replies']; |
|
498 | + if ($_REQUEST['action'] == 'unread') { |
|
499 | + $context['page_title'] = $context['showing_all_topics'] ? $txt['unread_topics_all'] : $txt['unread_topics_visit']; |
|
500 | + } else { |
|
501 | + $context['page_title'] = $txt['unread_replies']; |
|
502 | + } |
|
489 | 503 | |
490 | - if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) |
|
491 | - fatal_lang_error('loadavg_allunread_disabled', false); |
|
492 | - elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) |
|
493 | - fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
494 | - elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) |
|
495 | - fatal_lang_error('loadavg_unread_disabled', false); |
|
504 | + if ($context['showing_all_topics'] && !empty($context['load_average']) && !empty($modSettings['loadavg_allunread']) && $context['load_average'] >= $modSettings['loadavg_allunread']) { |
|
505 | + fatal_lang_error('loadavg_allunread_disabled', false); |
|
506 | + } elseif ($_REQUEST['action'] != 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unreadreplies']) && $context['load_average'] >= $modSettings['loadavg_unreadreplies']) { |
|
507 | + fatal_lang_error('loadavg_unreadreplies_disabled', false); |
|
508 | + } elseif (!$context['showing_all_topics'] && $_REQUEST['action'] == 'unread' && !empty($context['load_average']) && !empty($modSettings['loadavg_unread']) && $context['load_average'] >= $modSettings['loadavg_unread']) { |
|
509 | + fatal_lang_error('loadavg_unread_disabled', false); |
|
510 | + } |
|
496 | 511 | |
497 | 512 | // Parameters for the main query. |
498 | 513 | $query_parameters = array(); |
@@ -505,12 +520,14 @@ discard block |
||
505 | 520 | if (!empty($_REQUEST['boards'])) |
506 | 521 | { |
507 | 522 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
508 | - foreach ($_REQUEST['boards'] as $b) |
|
509 | - $boards[] = (int) $b; |
|
523 | + foreach ($_REQUEST['boards'] as $b) { |
|
524 | + $boards[] = (int) $b; |
|
525 | + } |
|
510 | 526 | } |
511 | 527 | |
512 | - if (!empty($board)) |
|
513 | - $boards[] = (int) $board; |
|
528 | + if (!empty($board)) { |
|
529 | + $boards[] = (int) $board; |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // The easiest thing is to just get all the boards they can see, but since we've specified the top of tree we ignore some of them |
516 | 533 | $request = $smcFunc['db_query']('', ' |
@@ -527,30 +544,31 @@ discard block |
||
527 | 544 | ) |
528 | 545 | ); |
529 | 546 | |
530 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
531 | - if (in_array($row['id_parent'], $boards)) |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
548 | + if (in_array($row['id_parent'], $boards)) |
|
532 | 549 | $boards[] = $row['id_board']; |
550 | + } |
|
533 | 551 | |
534 | 552 | $smcFunc['db_free_result']($request); |
535 | 553 | |
536 | - if (empty($boards)) |
|
537 | - fatal_lang_error('error_no_boards_selected'); |
|
554 | + if (empty($boards)) { |
|
555 | + fatal_lang_error('error_no_boards_selected'); |
|
556 | + } |
|
538 | 557 | |
539 | 558 | $query_this_board = 'id_board IN ({array_int:boards})'; |
540 | 559 | $query_parameters['boards'] = $boards; |
541 | 560 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%d'; |
542 | - } |
|
543 | - elseif (!empty($board)) |
|
561 | + } elseif (!empty($board)) |
|
544 | 562 | { |
545 | 563 | $query_this_board = 'id_board = {int:board}'; |
546 | 564 | $query_parameters['board'] = $board; |
547 | 565 | $context['querystring_board_limits'] = ';board=' . $board . '.%1$d'; |
548 | - } |
|
549 | - elseif (!empty($_REQUEST['boards'])) |
|
566 | + } elseif (!empty($_REQUEST['boards'])) |
|
550 | 567 | { |
551 | 568 | $_REQUEST['boards'] = explode(',', $_REQUEST['boards']); |
552 | - foreach ($_REQUEST['boards'] as $i => $b) |
|
553 | - $_REQUEST['boards'][$i] = (int) $b; |
|
569 | + foreach ($_REQUEST['boards'] as $i => $b) { |
|
570 | + $_REQUEST['boards'][$i] = (int) $b; |
|
571 | + } |
|
554 | 572 | |
555 | 573 | $request = $smcFunc['db_query']('', ' |
556 | 574 | SELECT b.id_board |
@@ -562,22 +580,24 @@ discard block |
||
562 | 580 | ) |
563 | 581 | ); |
564 | 582 | $boards = array(); |
565 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
566 | - $boards[] = $row['id_board']; |
|
583 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
584 | + $boards[] = $row['id_board']; |
|
585 | + } |
|
567 | 586 | $smcFunc['db_free_result']($request); |
568 | 587 | |
569 | - if (empty($boards)) |
|
570 | - fatal_lang_error('error_no_boards_selected'); |
|
588 | + if (empty($boards)) { |
|
589 | + fatal_lang_error('error_no_boards_selected'); |
|
590 | + } |
|
571 | 591 | |
572 | 592 | $query_this_board = 'id_board IN ({array_int:boards})'; |
573 | 593 | $query_parameters['boards'] = $boards; |
574 | 594 | $context['querystring_board_limits'] = ';boards=' . implode(',', $boards) . ';start=%1$d'; |
575 | - } |
|
576 | - elseif (!empty($_REQUEST['c'])) |
|
595 | + } elseif (!empty($_REQUEST['c'])) |
|
577 | 596 | { |
578 | 597 | $_REQUEST['c'] = explode(',', $_REQUEST['c']); |
579 | - foreach ($_REQUEST['c'] as $i => $c) |
|
580 | - $_REQUEST['c'][$i] = (int) $c; |
|
598 | + foreach ($_REQUEST['c'] as $i => $c) { |
|
599 | + $_REQUEST['c'][$i] = (int) $c; |
|
600 | + } |
|
581 | 601 | |
582 | 602 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
583 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -590,18 +610,19 @@ discard block |
||
590 | 610 | ) |
591 | 611 | ); |
592 | 612 | $boards = array(); |
593 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
594 | - $boards[] = $row['id_board']; |
|
613 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
614 | + $boards[] = $row['id_board']; |
|
615 | + } |
|
595 | 616 | $smcFunc['db_free_result']($request); |
596 | 617 | |
597 | - if (empty($boards)) |
|
598 | - fatal_lang_error('error_no_boards_selected'); |
|
618 | + if (empty($boards)) { |
|
619 | + fatal_lang_error('error_no_boards_selected'); |
|
620 | + } |
|
599 | 621 | |
600 | 622 | $query_this_board = 'id_board IN ({array_int:boards})'; |
601 | 623 | $query_parameters['boards'] = $boards; |
602 | 624 | $context['querystring_board_limits'] = ';c=' . implode(',', $_REQUEST['c']) . ';start=%1$d'; |
603 | - } |
|
604 | - else |
|
625 | + } else |
|
605 | 626 | { |
606 | 627 | $see_board = isset($_REQUEST['action']) && $_REQUEST['action'] == 'unreadreplies' ? 'query_see_board' : 'query_wanna_see_board'; |
607 | 628 | // Don't bother to show deleted posts! |
@@ -615,12 +636,14 @@ discard block |
||
615 | 636 | ) |
616 | 637 | ); |
617 | 638 | $boards = array(); |
618 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
619 | - $boards[] = $row['id_board']; |
|
639 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
640 | + $boards[] = $row['id_board']; |
|
641 | + } |
|
620 | 642 | $smcFunc['db_free_result']($request); |
621 | 643 | |
622 | - if (empty($boards)) |
|
623 | - fatal_lang_error('error_no_boards_available', false); |
|
644 | + if (empty($boards)) { |
|
645 | + fatal_lang_error('error_no_boards_available', false); |
|
646 | + } |
|
624 | 647 | |
625 | 648 | $query_this_board = 'id_board IN ({array_int:boards})'; |
626 | 649 | $query_parameters['boards'] = $boards; |
@@ -682,13 +705,14 @@ discard block |
||
682 | 705 | 'name' => $_REQUEST['action'] == 'unread' ? $txt['unread_topics_visit'] : $txt['unread_replies'] |
683 | 706 | ); |
684 | 707 | |
685 | - if ($context['showing_all_topics']) |
|
686 | - $context['linktree'][] = array( |
|
708 | + if ($context['showing_all_topics']) { |
|
709 | + $context['linktree'][] = array( |
|
687 | 710 | 'url' => $scripturl . '?action=' . $_REQUEST['action'] . ';all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'], |
688 | 711 | 'name' => $txt['unread_topics_all'] |
689 | 712 | ); |
690 | - else |
|
691 | - $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
713 | + } else { |
|
714 | + $txt['unread_topics_visit_none'] = strtr($txt['unread_topics_visit_none'], array('?action=unread;all' => '?action=unread;all' . sprintf($context['querystring_board_limits'], 0) . $context['querystring_sort_limits'])); |
|
715 | + } |
|
692 | 716 | |
693 | 717 | loadTemplate('Recent'); |
694 | 718 | loadTemplate('MessageIndex'); |
@@ -696,8 +720,9 @@ discard block |
||
696 | 720 | |
697 | 721 | // Setup the default topic icons... for checking they exist and the like ;) |
698 | 722 | $context['icon_sources'] = array(); |
699 | - foreach ($context['stable_icons'] as $icon) |
|
700 | - $context['icon_sources'][$icon] = 'images_url'; |
|
723 | + foreach ($context['stable_icons'] as $icon) { |
|
724 | + $context['icon_sources'][$icon] = 'images_url'; |
|
725 | + } |
|
701 | 726 | |
702 | 727 | $is_topics = $_REQUEST['action'] == 'unread'; |
703 | 728 | |
@@ -727,8 +752,7 @@ discard block |
||
727 | 752 | ); |
728 | 753 | list ($earliest_msg) = $smcFunc['db_fetch_row']($request); |
729 | 754 | $smcFunc['db_free_result']($request); |
730 | - } |
|
731 | - else |
|
755 | + } else |
|
732 | 756 | { |
733 | 757 | $request = $smcFunc['db_query']('', ' |
734 | 758 | SELECT MIN(lmr.id_msg) |
@@ -744,14 +768,14 @@ discard block |
||
744 | 768 | } |
745 | 769 | |
746 | 770 | // This is needed in case of topics marked unread. |
747 | - if (empty($earliest_msg)) |
|
748 | - $earliest_msg = 0; |
|
749 | - else |
|
771 | + if (empty($earliest_msg)) { |
|
772 | + $earliest_msg = 0; |
|
773 | + } else |
|
750 | 774 | { |
751 | 775 | // Using caching, when possible, to ignore the below slow query. |
752 | - if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) |
|
753 | - $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
754 | - else |
|
776 | + if (isset($_SESSION['cached_log_time']) && $_SESSION['cached_log_time'][0] + 45 > time()) { |
|
777 | + $earliest_msg2 = $_SESSION['cached_log_time'][1]; |
|
778 | + } else |
|
755 | 779 | { |
756 | 780 | // This query is pretty slow, but it's needed to ensure nothing crucial is ignored. |
757 | 781 | $request = $smcFunc['db_query']('', ' |
@@ -766,8 +790,9 @@ discard block |
||
766 | 790 | $smcFunc['db_free_result']($request); |
767 | 791 | |
768 | 792 | // In theory this could be zero, if the first ever post is unread, so fudge it ;) |
769 | - if ($earliest_msg2 == 0) |
|
770 | - $earliest_msg2 = -1; |
|
793 | + if ($earliest_msg2 == 0) { |
|
794 | + $earliest_msg2 = -1; |
|
795 | + } |
|
771 | 796 | |
772 | 797 | $_SESSION['cached_log_time'] = array(time(), $earliest_msg2); |
773 | 798 | } |
@@ -805,9 +830,9 @@ discard block |
||
805 | 830 | 'db_error_skip' => true, |
806 | 831 | )) |
807 | 832 | ) !== false; |
833 | + } else { |
|
834 | + $have_temp_table = false; |
|
808 | 835 | } |
809 | - else |
|
810 | - $have_temp_table = false; |
|
811 | 836 | |
812 | 837 | if ($context['showing_all_topics'] && $have_temp_table) |
813 | 838 | { |
@@ -853,14 +878,15 @@ discard block |
||
853 | 878 | |
854 | 879 | $context['topics'] = array(); |
855 | 880 | $context['no_topic_listing'] = true; |
856 | - if ($context['querystring_board_limits'] == ';start=%1$d') |
|
857 | - $context['querystring_board_limits'] = ''; |
|
858 | - else |
|
859 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
881 | + if ($context['querystring_board_limits'] == ';start=%1$d') { |
|
882 | + $context['querystring_board_limits'] = ''; |
|
883 | + } else { |
|
884 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
885 | + } |
|
860 | 886 | return; |
887 | + } else { |
|
888 | + $min_message = (int) $min_message; |
|
861 | 889 | } |
862 | - else |
|
863 | - $min_message = (int) $min_message; |
|
864 | 890 | |
865 | 891 | $request = $smcFunc['db_query']('substring', ' |
866 | 892 | SELECT ' . $select_clause . ' |
@@ -889,8 +915,7 @@ discard block |
||
889 | 915 | 'limit' => $context['topics_per_page'], |
890 | 916 | )) |
891 | 917 | ); |
892 | - } |
|
893 | - elseif ($is_topics) |
|
918 | + } elseif ($is_topics) |
|
894 | 919 | { |
895 | 920 | $request = $smcFunc['db_query']('', ' |
896 | 921 | SELECT COUNT(*), MIN(t.id_last_msg) |
@@ -941,14 +966,15 @@ discard block |
||
941 | 966 | |
942 | 967 | $context['topics'] = array(); |
943 | 968 | $context['no_topic_listing'] = true; |
944 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
945 | - $context['querystring_board_limits'] = ''; |
|
946 | - else |
|
947 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
969 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
970 | + $context['querystring_board_limits'] = ''; |
|
971 | + } else { |
|
972 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
973 | + } |
|
948 | 974 | return; |
975 | + } else { |
|
976 | + $min_message = (int) $min_message; |
|
949 | 977 | } |
950 | - else |
|
951 | - $min_message = (int) $min_message; |
|
952 | 978 | |
953 | 979 | $request = $smcFunc['db_query']('substring', ' |
954 | 980 | SELECT ' . $select_clause . ' |
@@ -978,8 +1004,7 @@ discard block |
||
978 | 1004 | 'limit' => $context['topics_per_page'], |
979 | 1005 | )) |
980 | 1006 | ); |
981 | - } |
|
982 | - else |
|
1007 | + } else |
|
983 | 1008 | { |
984 | 1009 | if ($modSettings['totalMessages'] > 100000) |
985 | 1010 | { |
@@ -1031,8 +1056,8 @@ discard block |
||
1031 | 1056 | ) !== false; |
1032 | 1057 | |
1033 | 1058 | // If that worked, create a sample of the log_topics table too. |
1034 | - if ($have_temp_table) |
|
1035 | - $have_temp_table = $smcFunc['db_query']('', ' |
|
1059 | + if ($have_temp_table) { |
|
1060 | + $have_temp_table = $smcFunc['db_query']('', ' |
|
1036 | 1061 | CREATE TEMPORARY TABLE {db_prefix}log_topics_posted_in ( |
1037 | 1062 | PRIMARY KEY (id_topic) |
1038 | 1063 | ) |
@@ -1045,6 +1070,7 @@ discard block |
||
1045 | 1070 | 'db_error_skip' => true, |
1046 | 1071 | ) |
1047 | 1072 | ) !== false; |
1073 | + } |
|
1048 | 1074 | } |
1049 | 1075 | |
1050 | 1076 | if (!empty($have_temp_table)) |
@@ -1060,8 +1086,7 @@ discard block |
||
1060 | 1086 | ); |
1061 | 1087 | list ($num_topics) = $smcFunc['db_fetch_row']($request); |
1062 | 1088 | $smcFunc['db_free_result']($request); |
1063 | - } |
|
1064 | - else |
|
1089 | + } else |
|
1065 | 1090 | { |
1066 | 1091 | $request = $smcFunc['db_query']('unread_fetch_topic_count', ' |
1067 | 1092 | SELECT COUNT(DISTINCT t.id_topic), MIN(t.id_last_msg) |
@@ -1102,15 +1127,16 @@ discard block |
||
1102 | 1127 | { |
1103 | 1128 | $context['topics'] = array(); |
1104 | 1129 | $context['no_topic_listing'] = true; |
1105 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1106 | - $context['querystring_board_limits'] = ''; |
|
1107 | - else |
|
1108 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1130 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1131 | + $context['querystring_board_limits'] = ''; |
|
1132 | + } else { |
|
1133 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1134 | + } |
|
1109 | 1135 | return; |
1110 | 1136 | } |
1111 | 1137 | |
1112 | - if (!empty($have_temp_table)) |
|
1113 | - $request = $smcFunc['db_query']('', ' |
|
1138 | + if (!empty($have_temp_table)) { |
|
1139 | + $request = $smcFunc['db_query']('', ' |
|
1114 | 1140 | SELECT t.id_topic |
1115 | 1141 | FROM {db_prefix}topics_posted_in AS t |
1116 | 1142 | LEFT JOIN {db_prefix}log_topics_posted_in AS lt ON (lt.id_topic = t.id_topic) |
@@ -1124,8 +1150,8 @@ discard block |
||
1124 | 1150 | 'limit' => $context['topics_per_page'], |
1125 | 1151 | )) |
1126 | 1152 | ); |
1127 | - else |
|
1128 | - $request = $smcFunc['db_query']('', ' |
|
1153 | + } else { |
|
1154 | + $request = $smcFunc['db_query']('', ' |
|
1129 | 1155 | SELECT DISTINCT t.id_topic,'.$_REQUEST['sort'].' |
1130 | 1156 | FROM {db_prefix}topics AS t |
1131 | 1157 | INNER JOIN {db_prefix}messages AS m ON (m.id_topic = t.id_topic AND m.id_member = {int:current_member})' . (strpos($_REQUEST['sort'], 'ms.') === false ? '' : ' |
@@ -1149,10 +1175,12 @@ discard block |
||
1149 | 1175 | 'sort' => $_REQUEST['sort'], |
1150 | 1176 | )) |
1151 | 1177 | ); |
1178 | + } |
|
1152 | 1179 | |
1153 | 1180 | $topics = array(); |
1154 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1155 | - $topics[] = $row['id_topic']; |
|
1181 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1182 | + $topics[] = $row['id_topic']; |
|
1183 | + } |
|
1156 | 1184 | $smcFunc['db_free_result']($request); |
1157 | 1185 | |
1158 | 1186 | // Sanity... where have you gone? |
@@ -1160,10 +1188,11 @@ discard block |
||
1160 | 1188 | { |
1161 | 1189 | $context['topics'] = array(); |
1162 | 1190 | $context['no_topic_listing'] = true; |
1163 | - if ($context['querystring_board_limits'] == ';start=%d') |
|
1164 | - $context['querystring_board_limits'] = ''; |
|
1165 | - else |
|
1166 | - $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1191 | + if ($context['querystring_board_limits'] == ';start=%d') { |
|
1192 | + $context['querystring_board_limits'] = ''; |
|
1193 | + } else { |
|
1194 | + $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']); |
|
1195 | + } |
|
1167 | 1196 | return; |
1168 | 1197 | } |
1169 | 1198 | |
@@ -1197,8 +1226,9 @@ discard block |
||
1197 | 1226 | |
1198 | 1227 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1199 | 1228 | { |
1200 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
1201 | - continue; |
|
1229 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
1230 | + continue; |
|
1231 | + } |
|
1202 | 1232 | |
1203 | 1233 | $topic_ids[] = $row['id_topic']; |
1204 | 1234 | |
@@ -1206,11 +1236,13 @@ discard block |
||
1206 | 1236 | { |
1207 | 1237 | // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise. |
1208 | 1238 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
1209 | - if ($smcFunc['strlen']($row['first_body']) > 128) |
|
1210 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1239 | + if ($smcFunc['strlen']($row['first_body']) > 128) { |
|
1240 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...'; |
|
1241 | + } |
|
1211 | 1242 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
1212 | - if ($smcFunc['strlen']($row['last_body']) > 128) |
|
1213 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1243 | + if ($smcFunc['strlen']($row['last_body']) > 128) { |
|
1244 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...'; |
|
1245 | + } |
|
1214 | 1246 | |
1215 | 1247 | // Censor the subject and message preview. |
1216 | 1248 | censorText($row['first_subject']); |
@@ -1221,23 +1253,22 @@ discard block |
||
1221 | 1253 | { |
1222 | 1254 | $row['last_subject'] = $row['first_subject']; |
1223 | 1255 | $row['last_body'] = $row['first_body']; |
1224 | - } |
|
1225 | - else |
|
1256 | + } else |
|
1226 | 1257 | { |
1227 | 1258 | censorText($row['last_subject']); |
1228 | 1259 | censorText($row['last_body']); |
1229 | 1260 | } |
1230 | - } |
|
1231 | - else |
|
1261 | + } else |
|
1232 | 1262 | { |
1233 | 1263 | $row['first_body'] = ''; |
1234 | 1264 | $row['last_body'] = ''; |
1235 | 1265 | censorText($row['first_subject']); |
1236 | 1266 | |
1237 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
1238 | - $row['last_subject'] = $row['first_subject']; |
|
1239 | - else |
|
1240 | - censorText($row['last_subject']); |
|
1267 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
1268 | + $row['last_subject'] = $row['first_subject']; |
|
1269 | + } else { |
|
1270 | + censorText($row['last_subject']); |
|
1271 | + } |
|
1241 | 1272 | } |
1242 | 1273 | |
1243 | 1274 | // Decide how many pages the topic should have. |
@@ -1249,22 +1280,24 @@ discard block |
||
1249 | 1280 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $topic_length, $messages_per_page, true, false); |
1250 | 1281 | |
1251 | 1282 | // If we can use all, show all. |
1252 | - if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) |
|
1253 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1283 | + if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']) { |
|
1284 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
1285 | + } |
|
1286 | + } else { |
|
1287 | + $pages = ''; |
|
1254 | 1288 | } |
1255 | 1289 | |
1256 | - else |
|
1257 | - $pages = ''; |
|
1258 | - |
|
1259 | 1290 | // We need to check the topic icons exist... you can never be too sure! |
1260 | 1291 | if (!empty($modSettings['messageIconChecks_enable'])) |
1261 | 1292 | { |
1262 | 1293 | // First icon first... as you'd expect. |
1263 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
1264 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1294 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
1295 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1296 | + } |
|
1265 | 1297 | // Last icon... last... duh. |
1266 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
1267 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1298 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
1299 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1300 | + } |
|
1268 | 1301 | } |
1269 | 1302 | |
1270 | 1303 | // Force the recycling icon if appropriate |
@@ -1278,12 +1311,14 @@ discard block |
||
1278 | 1311 | $colorClass = 'windowbg'; |
1279 | 1312 | |
1280 | 1313 | // Sticky topics should get a different color, too. |
1281 | - if ($row['is_sticky']) |
|
1282 | - $colorClass .= ' sticky'; |
|
1314 | + if ($row['is_sticky']) { |
|
1315 | + $colorClass .= ' sticky'; |
|
1316 | + } |
|
1283 | 1317 | |
1284 | 1318 | // Locked topics get special treatment as well. |
1285 | - if ($row['locked']) |
|
1286 | - $colorClass .= ' locked'; |
|
1319 | + if ($row['locked']) { |
|
1320 | + $colorClass .= ' locked'; |
|
1321 | + } |
|
1287 | 1322 | |
1288 | 1323 | // And build the array. |
1289 | 1324 | $context['topics'][$row['id_topic']] = array( |
@@ -1380,8 +1415,9 @@ discard block |
||
1380 | 1415 | ); |
1381 | 1416 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1382 | 1417 | { |
1383 | - if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) |
|
1384 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1418 | + if (empty($context['topics'][$row['id_topic']]['is_posted_in'])) { |
|
1419 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
1420 | + } |
|
1385 | 1421 | } |
1386 | 1422 | $smcFunc['db_free_result']($result); |
1387 | 1423 | } |
@@ -1396,28 +1432,30 @@ discard block |
||
1396 | 1432 | 'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']), |
1397 | 1433 | ); |
1398 | 1434 | |
1399 | - if ($context['showCheckboxes']) |
|
1400 | - $context['recent_buttons']['markselectread'] = array( |
|
1435 | + if ($context['showCheckboxes']) { |
|
1436 | + $context['recent_buttons']['markselectread'] = array( |
|
1401 | 1437 | 'text' => 'quick_mod_markread', |
1402 | 1438 | 'image' => 'markselectedread.png', |
1403 | 1439 | 'url' => 'javascript:document.quickModForm.submit();', |
1404 | 1440 | ); |
1441 | + } |
|
1405 | 1442 | |
1406 | - if (!empty($context['topics']) && !$context['showing_all_topics']) |
|
1407 | - $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1408 | - } |
|
1409 | - elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1443 | + if (!empty($context['topics']) && !$context['showing_all_topics']) { |
|
1444 | + $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true); |
|
1445 | + } |
|
1446 | + } elseif (!$is_topics && isset($context['topics_to_mark'])) |
|
1410 | 1447 | { |
1411 | 1448 | $context['recent_buttons'] = array( |
1412 | 1449 | 'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'custom' => 'data-confirm="'. $txt['are_sure_mark_read'] .'"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']), |
1413 | 1450 | ); |
1414 | 1451 | |
1415 | - if ($context['showCheckboxes']) |
|
1416 | - $context['recent_buttons']['markselectread'] = array( |
|
1452 | + if ($context['showCheckboxes']) { |
|
1453 | + $context['recent_buttons']['markselectread'] = array( |
|
1417 | 1454 | 'text' => 'quick_mod_markread', |
1418 | 1455 | 'image' => 'markselectedread.png', |
1419 | 1456 | 'url' => 'javascript:document.quickModForm.submit();', |
1420 | 1457 | ); |
1458 | + } |
|
1421 | 1459 | } |
1422 | 1460 | |
1423 | 1461 | // Allow mods to add additional buttons here |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | $this->MAX_LZW_BITS = 12; |
39 | 39 | unset($this->Next, $this->Vals, $this->Stack, $this->Buf); |
40 | 40 | |
41 | - $this->Next = range(0, (1 << $this->MAX_LZW_BITS) - 1); |
|
42 | - $this->Vals = range(0, (1 << $this->MAX_LZW_BITS) - 1); |
|
41 | + $this->Next = range(0, (1 << $this->MAX_LZW_BITS) - 1); |
|
42 | + $this->Vals = range(0, (1 << $this->MAX_LZW_BITS) - 1); |
|
43 | 43 | $this->Stack = range(0, (1 << ($this->MAX_LZW_BITS + 1)) - 1); |
44 | 44 | $this->Buf = range(0, 279); |
45 | 45 | } |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | for ($i = 0; $i < $this->m_nColors; $i++) |
279 | 279 | { |
280 | 280 | $ret .= |
281 | - chr(($this->m_arColors[$i] & 0x000000FF)) . // R |
|
282 | - chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G |
|
283 | - chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B |
|
281 | + chr(($this->m_arColors[$i] & 0x000000FF)) . // R |
|
282 | + chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G |
|
283 | + chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $ret; |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | { |
291 | 291 | $rgb = intval($rgb) & 0xFFFFFF; |
292 | 292 | $r1 = ($rgb & 0x0000FF); |
293 | - $g1 = ($rgb & 0x00FF00) >> 8; |
|
293 | + $g1 = ($rgb & 0x00FF00) >> 8; |
|
294 | 294 | $b1 = ($rgb & 0xFF0000) >> 16; |
295 | 295 | $idx = -1; |
296 | 296 | |
297 | 297 | for ($i = 0; $i < $this->m_nColors; $i++) |
298 | 298 | { |
299 | 299 | $r2 = ($this->m_arColors[$i] & 0x000000FF); |
300 | - $g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8; |
|
300 | + $g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8; |
|
301 | 301 | $b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16; |
302 | 302 | $d = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1); |
303 | 303 |
@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | * @version 2.1 Beta 4 |
20 | 20 | */ |
21 | 21 | |
22 | -if (!defined('SMF')) |
|
22 | +if (!defined('SMF')) { |
|
23 | 23 | die('No direct access...'); |
24 | +} |
|
24 | 25 | |
25 | 26 | /** |
26 | 27 | * Class gif_lzw_compression |
@@ -52,13 +53,15 @@ discard block |
||
52 | 53 | |
53 | 54 | $this->LZWCommand($data, true); |
54 | 55 | |
55 | - while (($iIndex = $this->LZWCommand($data, false)) >= 0) |
|
56 | - $ret .= chr($iIndex); |
|
56 | + while (($iIndex = $this->LZWCommand($data, false)) >= 0) { |
|
57 | + $ret .= chr($iIndex); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | $datLen = $stLen - strlen($data); |
59 | 61 | |
60 | - if ($iIndex != -2) |
|
61 | - return false; |
|
62 | + if ($iIndex != -2) { |
|
63 | + return false; |
|
64 | + } |
|
62 | 65 | |
63 | 66 | return $ret; |
64 | 67 | } |
@@ -140,8 +143,9 @@ discard block |
||
140 | 143 | return $this->FirstCode; |
141 | 144 | } |
142 | 145 | |
143 | - if ($Code == $this->EndCode) |
|
144 | - return -2; |
|
146 | + if ($Code == $this->EndCode) { |
|
147 | + return -2; |
|
148 | + } |
|
145 | 149 | |
146 | 150 | $InCode = $Code; |
147 | 151 | if ($Code >= $this->MaxCode) |
@@ -156,8 +160,10 @@ discard block |
||
156 | 160 | $this->Stack[$this->sp] = $this->Vals[$Code]; |
157 | 161 | $this->sp++; |
158 | 162 | |
159 | - if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error! |
|
163 | + if ($Code == $this->Next[$Code]) { |
|
164 | + // Circular table entry, big GIF Error! |
|
160 | 165 | return -1; |
166 | + } |
|
161 | 167 | |
162 | 168 | $Code = $this->Next[$Code]; |
163 | 169 | } |
@@ -207,8 +213,9 @@ discard block |
||
207 | 213 | if ($this->Done) |
208 | 214 | { |
209 | 215 | // Ran off the end of my bits... |
210 | - if ($this->CurBit >= $this->LastBit) |
|
211 | - return 0; |
|
216 | + if ($this->CurBit >= $this->LastBit) { |
|
217 | + return 0; |
|
218 | + } |
|
212 | 219 | |
213 | 220 | return -1; |
214 | 221 | } |
@@ -221,13 +228,14 @@ discard block |
||
221 | 228 | |
222 | 229 | if ($count) |
223 | 230 | { |
224 | - for ($i = 0; $i < $count; $i++) |
|
225 | - $this->Buf[2 + $i] = ord($data{$i}); |
|
231 | + for ($i = 0; $i < $count; $i++) { |
|
232 | + $this->Buf[2 + $i] = ord($data{$i}); |
|
233 | + } |
|
226 | 234 | |
227 | 235 | $data = substr($data, $count); |
236 | + } else { |
|
237 | + $this->Done = 1; |
|
228 | 238 | } |
229 | - else |
|
230 | - $this->Done = 1; |
|
231 | 239 | |
232 | 240 | $this->LastByte = 2 + $count; |
233 | 241 | $this->CurBit = ($this->CurBit - $this->LastBit) + 16; |
@@ -235,8 +243,9 @@ discard block |
||
235 | 243 | } |
236 | 244 | |
237 | 245 | $iRet = 0; |
238 | - for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) |
|
239 | - $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
246 | + for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) { |
|
247 | + $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j; |
|
248 | + } |
|
240 | 249 | |
241 | 250 | $this->CurBit += $this->CodeSize; |
242 | 251 | return $iRet; |
@@ -261,8 +270,9 @@ discard block |
||
261 | 270 | for ($i = 0; $i < $num; $i++) |
262 | 271 | { |
263 | 272 | $rgb = substr($lpData, $i * 3, 3); |
264 | - if (strlen($rgb) < 3) |
|
265 | - return false; |
|
273 | + if (strlen($rgb) < 3) { |
|
274 | + return false; |
|
275 | + } |
|
266 | 276 | |
267 | 277 | $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); |
268 | 278 | $this->m_nColors++; |
@@ -329,13 +339,15 @@ discard block |
||
329 | 339 | $hdrLen = 0; |
330 | 340 | |
331 | 341 | $this->m_lpVer = substr($lpData, 0, 6); |
332 | - if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) |
|
333 | - return false; |
|
342 | + if (($this->m_lpVer != 'GIF87a') && ($this->m_lpVer != 'GIF89a')) { |
|
343 | + return false; |
|
344 | + } |
|
334 | 345 | |
335 | 346 | list ($this->m_nWidth, $this->m_nHeight) = array_values(unpack('v2', substr($lpData, 6, 4))); |
336 | 347 | |
337 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
338 | - return false; |
|
348 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
349 | + return false; |
|
350 | + } |
|
339 | 351 | |
340 | 352 | $b = ord(substr($lpData, 10, 1)); |
341 | 353 | $this->m_bGlobalClr = ($b & 0x80) ? true : false; |
@@ -349,8 +361,9 @@ discard block |
||
349 | 361 | if ($this->m_bGlobalClr) |
350 | 362 | { |
351 | 363 | $this->m_colorTable = new gif_color_table(); |
352 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
353 | - return false; |
|
364 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
365 | + return false; |
|
366 | + } |
|
354 | 367 | |
355 | 368 | $hdrLen += 3 * $this->m_nTableSize; |
356 | 369 | } |
@@ -377,8 +390,9 @@ discard block |
||
377 | 390 | // Get the width/height/etc. from the header. |
378 | 391 | list ($this->m_nLeft, $this->m_nTop, $this->m_nWidth, $this->m_nHeight) = array_values(unpack('v4', substr($lpData, 0, 8))); |
379 | 392 | |
380 | - if (!$this->m_nWidth || !$this->m_nHeight) |
|
381 | - return false; |
|
393 | + if (!$this->m_nWidth || !$this->m_nHeight) { |
|
394 | + return false; |
|
395 | + } |
|
382 | 396 | |
383 | 397 | $b = ord($lpData[8]); |
384 | 398 | $this->m_bLocalClr = ($b & 0x80) ? true : false; |
@@ -390,8 +404,9 @@ discard block |
||
390 | 404 | if ($this->m_bLocalClr) |
391 | 405 | { |
392 | 406 | $this->m_colorTable = new gif_color_table(); |
393 | - if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) |
|
394 | - return false; |
|
407 | + if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) { |
|
408 | + return false; |
|
409 | + } |
|
395 | 410 | |
396 | 411 | $hdrLen += 3 * $this->m_nTableSize; |
397 | 412 | } |
@@ -427,8 +442,9 @@ discard block |
||
427 | 442 | // Extension... |
428 | 443 | case 0x21: |
429 | 444 | $len = 0; |
430 | - if (!$this->skipExt($data, $len)) |
|
431 | - return false; |
|
445 | + if (!$this->skipExt($data, $len)) { |
|
446 | + return false; |
|
447 | + } |
|
432 | 448 | |
433 | 449 | $datLen += $len; |
434 | 450 | break; |
@@ -437,21 +453,24 @@ discard block |
||
437 | 453 | case 0x2C: |
438 | 454 | // Load the header and color table. |
439 | 455 | $len = 0; |
440 | - if (!$this->m_gih->load($data, $len)) |
|
441 | - return false; |
|
456 | + if (!$this->m_gih->load($data, $len)) { |
|
457 | + return false; |
|
458 | + } |
|
442 | 459 | |
443 | 460 | $data = substr($data, $len); |
444 | 461 | $datLen += $len; |
445 | 462 | |
446 | 463 | // Decompress the data, and ride on home ;). |
447 | 464 | $len = 0; |
448 | - if (!($this->m_data = $this->m_lzw->decompress($data, $len))) |
|
449 | - return false; |
|
465 | + if (!($this->m_data = $this->m_lzw->decompress($data, $len))) { |
|
466 | + return false; |
|
467 | + } |
|
450 | 468 | |
451 | 469 | $datLen += $len; |
452 | 470 | |
453 | - if ($this->m_gih->m_bInterlace) |
|
454 | - $this->deInterlace(); |
|
471 | + if ($this->m_gih->m_bInterlace) { |
|
472 | + $this->deInterlace(); |
|
473 | + } |
|
455 | 474 | |
456 | 475 | return true; |
457 | 476 | |
@@ -571,17 +590,20 @@ discard block |
||
571 | 590 | |
572 | 591 | public function loadFile($filename, $iIndex) |
573 | 592 | { |
574 | - if ($iIndex < 0) |
|
575 | - return false; |
|
593 | + if ($iIndex < 0) { |
|
594 | + return false; |
|
595 | + } |
|
576 | 596 | |
577 | 597 | $this->data = @file_get_contents($filename); |
578 | - if ($this->data === false) |
|
579 | - return false; |
|
598 | + if ($this->data === false) { |
|
599 | + return false; |
|
600 | + } |
|
580 | 601 | |
581 | 602 | // Tell the header to load up.... |
582 | 603 | $len = 0; |
583 | - if (!$this->header->load($this->data, $len)) |
|
584 | - return false; |
|
604 | + if (!$this->header->load($this->data, $len)) { |
|
605 | + return false; |
|
606 | + } |
|
585 | 607 | |
586 | 608 | $this->data = substr($this->data, $len); |
587 | 609 | |
@@ -589,8 +611,9 @@ discard block |
||
589 | 611 | for ($j = 0; $j <= $iIndex; $j++) |
590 | 612 | { |
591 | 613 | $imgLen = 0; |
592 | - if (!$this->image->load($this->data, $imgLen)) |
|
593 | - return false; |
|
614 | + if (!$this->image->load($this->data, $imgLen)) { |
|
615 | + return false; |
|
616 | + } |
|
594 | 617 | |
595 | 618 | $this->data = substr($this->data, $imgLen); |
596 | 619 | } |
@@ -601,8 +624,9 @@ discard block |
||
601 | 624 | |
602 | 625 | public function get_png_data($background_color) |
603 | 626 | { |
604 | - if (!$this->loaded) |
|
605 | - return false; |
|
627 | + if (!$this->loaded) { |
|
628 | + return false; |
|
629 | + } |
|
606 | 630 | |
607 | 631 | // Prepare the color table. |
608 | 632 | if ($this->image->m_gih->m_bLocalClr) |
@@ -610,25 +634,26 @@ discard block |
||
610 | 634 | $colors = $this->image->m_gih->m_nTableSize; |
611 | 635 | $pal = $this->image->m_gih->m_colorTable->toString(); |
612 | 636 | |
613 | - if ($background_color != -1) |
|
614 | - $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
615 | - } |
|
616 | - elseif ($this->header->m_bGlobalClr) |
|
637 | + if ($background_color != -1) { |
|
638 | + $background_color = $this->image->m_gih->m_colorTable->colorIndex($background_color); |
|
639 | + } |
|
640 | + } elseif ($this->header->m_bGlobalClr) |
|
617 | 641 | { |
618 | 642 | $colors = $this->header->m_nTableSize; |
619 | 643 | $pal = $this->header->m_colorTable->toString(); |
620 | 644 | |
621 | - if ($background_color != -1) |
|
622 | - $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
623 | - } |
|
624 | - else |
|
645 | + if ($background_color != -1) { |
|
646 | + $background_color = $this->header->m_colorTable->colorIndex($background_color); |
|
647 | + } |
|
648 | + } else |
|
625 | 649 | { |
626 | 650 | $colors = 0; |
627 | 651 | $background_color = -1; |
628 | 652 | } |
629 | 653 | |
630 | - if ($background_color == -1) |
|
631 | - $background_color = $this->header->m_nBgColor; |
|
654 | + if ($background_color == -1) { |
|
655 | + $background_color = $this->header->m_nBgColor; |
|
656 | + } |
|
632 | 657 | |
633 | 658 | $data = &$this->image->m_data; |
634 | 659 | $header = &$this->image->m_gih; |
@@ -644,11 +669,13 @@ discard block |
||
644 | 669 | for ($x = 0; $x < $this->header->m_nWidth; $x++, $i++) |
645 | 670 | { |
646 | 671 | // Is this in the proper range? If so, get the specific pixel data... |
647 | - if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) |
|
648 | - $bmp .= $data{$i}; |
|
672 | + if ($x >= $header->m_nLeft && $y >= $header->m_nTop && $x < ($header->m_nLeft + $header->m_nWidth) && $y < ($header->m_nTop + $header->m_nHeight)) { |
|
673 | + $bmp .= $data{$i}; |
|
674 | + } |
|
649 | 675 | // Otherwise, this is background... |
650 | - else |
|
651 | - $bmp .= chr($background_color); |
|
676 | + else { |
|
677 | + $bmp .= chr($background_color); |
|
678 | + } |
|
652 | 679 | } |
653 | 680 | } |
654 | 681 | |
@@ -677,8 +704,9 @@ discard block |
||
677 | 704 | $tmp = 'tRNS'; |
678 | 705 | |
679 | 706 | // Stick each color on - full transparency or none. |
680 | - for ($i = 0; $i < $colors; $i++) |
|
681 | - $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
707 | + for ($i = 0; $i < $colors; $i++) { |
|
708 | + $tmp .= $i == $this->image->m_nTrans ? "\x00" : "\xFF"; |
|
709 | + } |
|
682 | 710 | |
683 | 711 | $out .= $tmp . pack('N', smf_crc32($tmp)); |
684 | 712 | } |