@@ -21,7 +21,7 @@ |
||
21 | 21 | <div id="recent" class="main_section"> |
22 | 22 | <div class="cat_bar"> |
23 | 23 | <h3 class="catbg"> |
24 | - <span class="xx"></span>',$txt['recent_posts'],' |
|
24 | + <span class="xx"></span>',$txt['recent_posts'], ' |
|
25 | 25 | </h3> |
26 | 26 | </div> |
27 | 27 | <div class="pagesection">', $context['page_index'], '</div>'; |
@@ -43,28 +43,33 @@ discard block |
||
43 | 43 | </div> |
44 | 44 | <div class="list_posts">', $post['message'], '</div>'; |
45 | 45 | |
46 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
47 | - echo ' |
|
46 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
47 | + echo ' |
|
48 | 48 | <ul class="quickbuttons">'; |
49 | + } |
|
49 | 50 | |
50 | 51 | // If they *can* reply? |
51 | - if ($post['can_reply']) |
|
52 | - echo ' |
|
52 | + if ($post['can_reply']) { |
|
53 | + echo ' |
|
53 | 54 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
55 | + } |
|
54 | 56 | |
55 | 57 | // If they *can* quote? |
56 | - if ($post['can_quote']) |
|
57 | - echo ' |
|
58 | + if ($post['can_quote']) { |
|
59 | + echo ' |
|
58 | 60 | <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
61 | + } |
|
59 | 62 | |
60 | 63 | // How about... even... remove it entirely?! |
61 | - if ($post['can_delete']) |
|
62 | - echo ' |
|
64 | + if ($post['can_delete']) { |
|
65 | + echo ' |
|
63 | 66 | <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>'; |
67 | + } |
|
64 | 68 | |
65 | - if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) |
|
66 | - echo ' |
|
69 | + if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) { |
|
70 | + echo ' |
|
67 | 71 | </ul>'; |
72 | + } |
|
68 | 73 | |
69 | 74 | echo ' |
70 | 75 | </div>'; |
@@ -86,12 +91,13 @@ discard block |
||
86 | 91 | echo ' |
87 | 92 | <div id="recent" class="main_content">'; |
88 | 93 | |
89 | - if ($context['showCheckboxes']) |
|
90 | - echo ' |
|
94 | + if ($context['showCheckboxes']) { |
|
95 | + echo ' |
|
91 | 96 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
92 | 97 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
93 | 98 | <input type="hidden" name="qaction" value="markread"> |
94 | 99 | <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
100 | + } |
|
95 | 101 | |
96 | 102 | if (!empty($context['topics'])) |
97 | 103 | { |
@@ -117,11 +123,12 @@ discard block |
||
117 | 123 | </div>'; |
118 | 124 | |
119 | 125 | // Show a "select all" box for quick moderation? |
120 | - if ($context['showCheckboxes']) |
|
121 | - echo ' |
|
126 | + if ($context['showCheckboxes']) { |
|
127 | + echo ' |
|
122 | 128 | <div class="moderation"> |
123 | 129 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"> |
124 | 130 | </div>'; |
131 | + } |
|
125 | 132 | |
126 | 133 | echo ' |
127 | 134 | </div> |
@@ -140,15 +147,18 @@ discard block |
||
140 | 147 | // Now we handle the icons |
141 | 148 | echo ' |
142 | 149 | <div class="icons floatright">'; |
143 | - if ($topic['is_locked']) |
|
144 | - echo ' |
|
150 | + if ($topic['is_locked']) { |
|
151 | + echo ' |
|
145 | 152 | <span class="generic_icons lock"></span>'; |
146 | - if ($topic['is_sticky']) |
|
147 | - echo ' |
|
153 | + } |
|
154 | + if ($topic['is_sticky']) { |
|
155 | + echo ' |
|
148 | 156 | <span class="generic_icons sticky"></span>'; |
149 | - if ($topic['is_poll']) |
|
150 | - echo ' |
|
157 | + } |
|
158 | + if ($topic['is_poll']) { |
|
159 | + echo ' |
|
151 | 160 | <span class="generic_icons poll"></span>'; |
161 | + } |
|
152 | 162 | echo ' |
153 | 163 | </div>'; |
154 | 164 | |
@@ -173,19 +183,21 @@ discard block |
||
173 | 183 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
174 | 184 | </div>'; |
175 | 185 | |
176 | - if ($context['showCheckboxes']) |
|
177 | - echo ' |
|
186 | + if ($context['showCheckboxes']) { |
|
187 | + echo ' |
|
178 | 188 | <div class="moderation"> |
179 | 189 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check"> |
180 | 190 | </div>'; |
191 | + } |
|
181 | 192 | |
182 | 193 | echo ' |
183 | 194 | </div>'; |
184 | 195 | } |
185 | 196 | |
186 | - if (empty($context['topics'])) |
|
187 | - echo ' |
|
197 | + if (empty($context['topics'])) { |
|
198 | + echo ' |
|
188 | 199 | <div style="display: none;"></div>'; |
200 | + } |
|
189 | 201 | |
190 | 202 | echo ' |
191 | 203 | </div> |
@@ -197,25 +209,27 @@ discard block |
||
197 | 209 | ', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a> |
198 | 210 | <div class="pagelinks">', $context['page_index'], '</div> |
199 | 211 | </div>'; |
200 | - } |
|
201 | - else |
|
202 | - echo ' |
|
212 | + } else { |
|
213 | + echo ' |
|
203 | 214 | <div class="cat_bar"> |
204 | 215 | <h3 class="catbg centertext"> |
205 | 216 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
206 | 217 | </h3> |
207 | 218 | </div>'; |
219 | + } |
|
208 | 220 | |
209 | - if ($context['showCheckboxes']) |
|
210 | - echo ' |
|
221 | + if ($context['showCheckboxes']) { |
|
222 | + echo ' |
|
211 | 223 | </form>'; |
224 | + } |
|
212 | 225 | |
213 | 226 | echo ' |
214 | 227 | </div>'; |
215 | 228 | |
216 | - if (empty($context['no_topic_listing'])) |
|
217 | - template_topic_legend(); |
|
218 | -} |
|
229 | + if (empty($context['no_topic_listing'])) { |
|
230 | + template_topic_legend(); |
|
231 | + } |
|
232 | + } |
|
219 | 233 | |
220 | 234 | /** |
221 | 235 | * Template for showing unread replies (eg new replies to topics you've posted in) |
@@ -227,12 +241,13 @@ discard block |
||
227 | 241 | echo ' |
228 | 242 | <div id="recent">'; |
229 | 243 | |
230 | - if ($context['showCheckboxes']) |
|
231 | - echo ' |
|
244 | + if ($context['showCheckboxes']) { |
|
245 | + echo ' |
|
232 | 246 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;"> |
233 | 247 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
234 | 248 | <input type="hidden" name="qaction" value="markread"> |
235 | 249 | <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">'; |
250 | + } |
|
236 | 251 | |
237 | 252 | if (!empty($context['topics'])) |
238 | 253 | { |
@@ -258,11 +273,12 @@ discard block |
||
258 | 273 | </div>'; |
259 | 274 | |
260 | 275 | // Show a "select all" box for quick moderation? |
261 | - if ($context['showCheckboxes']) |
|
262 | - echo ' |
|
276 | + if ($context['showCheckboxes']) { |
|
277 | + echo ' |
|
263 | 278 | <div class="moderation"> |
264 | 279 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check"> |
265 | 280 | </div>'; |
281 | + } |
|
266 | 282 | |
267 | 283 | echo ' |
268 | 284 | </div> |
@@ -281,15 +297,18 @@ discard block |
||
281 | 297 | // Now we handle the icons |
282 | 298 | echo ' |
283 | 299 | <div class="icons floatright">'; |
284 | - if ($topic['is_locked']) |
|
285 | - echo ' |
|
300 | + if ($topic['is_locked']) { |
|
301 | + echo ' |
|
286 | 302 | <span class="generic_icons lock"></span>'; |
287 | - if ($topic['is_sticky']) |
|
288 | - echo ' |
|
303 | + } |
|
304 | + if ($topic['is_sticky']) { |
|
305 | + echo ' |
|
289 | 306 | <span class="generic_icons sticky"></span>'; |
290 | - if ($topic['is_poll']) |
|
291 | - echo ' |
|
307 | + } |
|
308 | + if ($topic['is_poll']) { |
|
309 | + echo ' |
|
292 | 310 | <span class="generic_icons poll"></span>'; |
311 | + } |
|
293 | 312 | echo ' |
294 | 313 | </div>'; |
295 | 314 | |
@@ -314,11 +333,12 @@ discard block |
||
314 | 333 | ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), ' |
315 | 334 | </div>'; |
316 | 335 | |
317 | - if ($context['showCheckboxes']) |
|
318 | - echo ' |
|
336 | + if ($context['showCheckboxes']) { |
|
337 | + echo ' |
|
319 | 338 | <div class="moderation"> |
320 | 339 | <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check"> |
321 | 340 | </div>'; |
341 | + } |
|
322 | 342 | echo ' |
323 | 343 | </div>'; |
324 | 344 | } |
@@ -331,24 +351,26 @@ discard block |
||
331 | 351 | ', $context['menu_separator'], '<a href="#recent" class="topbottom floatleft">', $txt['go_up'], '</a> |
332 | 352 | <div class="pagelinks">', $context['page_index'], '</div> |
333 | 353 | </div>'; |
334 | - } |
|
335 | - else |
|
336 | - echo ' |
|
354 | + } else { |
|
355 | + echo ' |
|
337 | 356 | <div class="cat_bar"> |
338 | 357 | <h3 class="catbg centertext"> |
339 | 358 | ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], ' |
340 | 359 | </h3> |
341 | 360 | </div>'; |
361 | + } |
|
342 | 362 | |
343 | - if ($context['showCheckboxes']) |
|
344 | - echo ' |
|
363 | + if ($context['showCheckboxes']) { |
|
364 | + echo ' |
|
345 | 365 | </form>'; |
366 | + } |
|
346 | 367 | |
347 | 368 | echo ' |
348 | 369 | </div>'; |
349 | 370 | |
350 | - if (empty($context['no_topic_listing'])) |
|
351 | - template_topic_legend(); |
|
352 | -} |
|
371 | + if (empty($context['no_topic_listing'])) { |
|
372 | + template_topic_legend(); |
|
373 | + } |
|
374 | + } |
|
353 | 375 | |
354 | 376 | ?> |
355 | 377 | \ No newline at end of file |
@@ -89,8 +89,9 @@ discard block |
||
89 | 89 | foreach ($section['areas'] as $i => $area) |
90 | 90 | { |
91 | 91 | // Not supposed to be printed? |
92 | - if (empty($area['label'])) |
|
93 | - continue; |
|
92 | + if (empty($area['label'])) { |
|
93 | + continue; |
|
94 | + } |
|
94 | 95 | |
95 | 96 | echo ' |
96 | 97 | <li', !empty($area['subsections']) ? ' class="subsections"' : '', '>'; |
@@ -99,8 +100,9 @@ discard block |
||
99 | 100 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], '</a>'; |
100 | 101 | |
101 | 102 | // Is this the current area, or just some area? |
102 | - if (!empty($area['selected']) && empty($context['tabs'])) |
|
103 | - $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
103 | + if (!empty($area['selected']) && empty($context['tabs'])) { |
|
104 | + $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
|
105 | + } |
|
104 | 106 | |
105 | 107 | // Are there any subsections? |
106 | 108 | if (!empty($area['subsections'])) |
@@ -110,8 +112,9 @@ discard block |
||
110 | 112 | |
111 | 113 | foreach ($area['subsections'] as $sa => $sub) |
112 | 114 | { |
113 | - if (!empty($sub['disabled'])) |
|
114 | - continue; |
|
115 | + if (!empty($sub['disabled'])) { |
|
116 | + continue; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
117 | 120 | |
@@ -158,8 +161,9 @@ discard block |
||
158 | 161 | <h3 class="catbg">'; |
159 | 162 | |
160 | 163 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
161 | - if (function_exists('template_admin_quick_search')) |
|
162 | - template_admin_quick_search(); |
|
164 | + if (function_exists('template_admin_quick_search')) { |
|
165 | + template_admin_quick_search(); |
|
166 | + } |
|
163 | 167 | |
164 | 168 | // Exactly how many tabs do we have? |
165 | 169 | if (!empty($context['tabs'])) |
@@ -174,30 +178,36 @@ discard block |
||
174 | 178 | } |
175 | 179 | |
176 | 180 | // Did this not even exist - or do we not have a label? |
177 | - if (!isset($tab_context['tabs'][$id])) |
|
178 | - $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
179 | - elseif (!isset($tab_context['tabs'][$id]['label'])) |
|
180 | - $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
181 | + if (!isset($tab_context['tabs'][$id])) { |
|
182 | + $tab_context['tabs'][$id] = array('label' => $tab['label']); |
|
183 | + } elseif (!isset($tab_context['tabs'][$id]['label'])) { |
|
184 | + $tab_context['tabs'][$id]['label'] = $tab['label']; |
|
185 | + } |
|
181 | 186 | |
182 | 187 | // Has a custom URL defined in the main admin structure? |
183 | - if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
|
184 | - $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
188 | + if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) { |
|
189 | + $tab_context['tabs'][$id]['url'] = $tab['url']; |
|
190 | + } |
|
185 | 191 | |
186 | 192 | // Any additional paramaters for the url? |
187 | - if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
|
188 | - $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
193 | + if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) { |
|
194 | + $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
|
195 | + } |
|
189 | 196 | |
190 | 197 | // Has it been deemed selected? |
191 | - if (!empty($tab['is_selected'])) |
|
192 | - $tab_context['tabs'][$id]['is_selected'] = true; |
|
198 | + if (!empty($tab['is_selected'])) { |
|
199 | + $tab_context['tabs'][$id]['is_selected'] = true; |
|
200 | + } |
|
193 | 201 | |
194 | 202 | // Does it have its own help? |
195 | - if (!empty($tab['help'])) |
|
196 | - $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
203 | + if (!empty($tab['help'])) { |
|
204 | + $tab_context['tabs'][$id]['help'] = $tab['help']; |
|
205 | + } |
|
197 | 206 | |
198 | 207 | // Is this the last one? |
199 | - if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
|
200 | - $tab_context['tabs'][$id]['is_last'] = true; |
|
208 | + if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) { |
|
209 | + $tab_context['tabs'][$id]['is_last'] = true; |
|
210 | + } |
|
201 | 211 | } |
202 | 212 | |
203 | 213 | // Find the selected tab |
@@ -214,17 +224,18 @@ discard block |
||
214 | 224 | // Show an icon and/or a help item? |
215 | 225 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
216 | 226 | { |
217 | - if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
|
218 | - echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
219 | - elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
|
220 | - echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
227 | + if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) { |
|
228 | + echo '<span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
|
229 | + } elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) { |
|
230 | + echo '<img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
|
231 | + } |
|
221 | 232 | |
222 | - if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
|
223 | - echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
233 | + if (!empty($selected_tab['help']) || !empty($tab_context['help'])) { |
|
234 | + echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a>'; |
|
235 | + } |
|
224 | 236 | |
225 | 237 | echo $tab_context['title']; |
226 | - } |
|
227 | - else |
|
238 | + } else |
|
228 | 239 | { |
229 | 240 | echo ' |
230 | 241 | ', $tab_context['title']; |
@@ -237,11 +248,12 @@ discard block |
||
237 | 248 | } |
238 | 249 | |
239 | 250 | // Shall we use the tabs? Yes, it's the only known way! |
240 | - if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
|
241 | - echo ' |
|
251 | + if (!empty($selected_tab['description']) || !empty($tab_context['description'])) { |
|
252 | + echo ' |
|
242 | 253 | <p class="information"> |
243 | 254 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
244 | 255 | </p>'; |
256 | + } |
|
245 | 257 | |
246 | 258 | // Print out all the items in this tab (if any). |
247 | 259 | if (!empty($context['tabs'])) |
@@ -253,8 +265,9 @@ discard block |
||
253 | 265 | |
254 | 266 | foreach ($tab_context['tabs'] as $sa => $tab) |
255 | 267 | { |
256 | - if (!empty($tab['disabled'])) |
|
257 | - continue; |
|
268 | + if (!empty($tab['disabled'])) { |
|
269 | + continue; |
|
270 | + } |
|
258 | 271 | |
259 | 272 | if (!empty($tab['is_selected'])) |
260 | 273 | { |
@@ -262,12 +275,12 @@ discard block |
||
262 | 275 | <li> |
263 | 276 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
264 | 277 | </li>'; |
265 | - } |
|
266 | - else |
|
267 | - echo ' |
|
278 | + } else { |
|
279 | + echo ' |
|
268 | 280 | <li> |
269 | 281 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
270 | 282 | </li>'; |
283 | + } |
|
271 | 284 | } |
272 | 285 | |
273 | 286 | // the end of tabs |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Entry point function, permission checks, admin bars, etc. |
@@ -99,27 +100,27 @@ discard block |
||
99 | 100 | 'function' => function($rowData) use ($scripturl) |
100 | 101 | { |
101 | 102 | // Since the moderator group has no explicit members, no link is needed. |
102 | - if ($rowData['id_group'] == 3) |
|
103 | - $group_name = $rowData['group_name']; |
|
104 | - else |
|
103 | + if ($rowData['id_group'] == 3) { |
|
104 | + $group_name = $rowData['group_name']; |
|
105 | + } else |
|
105 | 106 | { |
106 | 107 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
107 | 108 | |
108 | 109 | if (allowedTo('manage_membergroups')) |
109 | 110 | { |
110 | 111 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
111 | - } |
|
112 | - else |
|
112 | + } else |
|
113 | 113 | { |
114 | 114 | $group_name = sprintf('<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | 118 | // Add a help option for moderator and administrator. |
119 | - if ($rowData['id_group'] == 1) |
|
120 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | - elseif ($rowData['id_group'] == 3) |
|
122 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
119 | + if ($rowData['id_group'] == 1) { |
|
120 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
121 | + } elseif ($rowData['id_group'] == 3) { |
|
122 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
123 | + } |
|
123 | 124 | |
124 | 125 | return $group_name; |
125 | 126 | }, |
@@ -198,8 +199,9 @@ discard block |
||
198 | 199 | $_REQUEST['group'] = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0; |
199 | 200 | |
200 | 201 | // No browsing of guests, membergroup 0 or moderators. |
201 | - if (in_array($_REQUEST['group'], array(-1, 0, 3))) |
|
202 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
202 | + if (in_array($_REQUEST['group'], array(-1, 0, 3))) { |
|
203 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
204 | + } |
|
203 | 205 | |
204 | 206 | // Load up the group details. |
205 | 207 | $request = $smcFunc['db_query']('', ' |
@@ -214,8 +216,9 @@ discard block |
||
214 | 216 | ) |
215 | 217 | ); |
216 | 218 | // Doesn't exist? |
217 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
218 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
219 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
220 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
221 | + } |
|
219 | 222 | $context['group'] = $smcFunc['db_fetch_assoc']($request); |
220 | 223 | $smcFunc['db_free_result']($request); |
221 | 224 | |
@@ -248,21 +251,25 @@ discard block |
||
248 | 251 | 'name' => $row['real_name'] |
249 | 252 | ); |
250 | 253 | |
251 | - if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) |
|
252 | - $context['group']['can_moderate'] = true; |
|
254 | + if ($user_info['id'] == $row['id_member'] && $context['group']['group_type'] != 1) { |
|
255 | + $context['group']['can_moderate'] = true; |
|
256 | + } |
|
253 | 257 | } |
254 | 258 | $smcFunc['db_free_result']($request); |
255 | 259 | |
256 | 260 | // If this group is hidden then it can only "exists" if the user can moderate it! |
257 | - if ($context['group']['hidden'] && !$context['group']['can_moderate']) |
|
258 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
261 | + if ($context['group']['hidden'] && !$context['group']['can_moderate']) { |
|
262 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
263 | + } |
|
259 | 264 | |
260 | 265 | // You can only assign membership if you are the moderator and/or can manage groups! |
261 | - if (!$context['group']['can_moderate']) |
|
262 | - $context['group']['assignable'] = 0; |
|
266 | + if (!$context['group']['can_moderate']) { |
|
267 | + $context['group']['assignable'] = 0; |
|
268 | + } |
|
263 | 269 | // Non-admins cannot assign admins. |
264 | - elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) |
|
265 | - $context['group']['assignable'] = 0; |
|
270 | + elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) { |
|
271 | + $context['group']['assignable'] = 0; |
|
272 | + } |
|
266 | 273 | |
267 | 274 | // Removing member from group? |
268 | 275 | if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) |
@@ -271,8 +278,9 @@ discard block |
||
271 | 278 | validateToken('mod-mgm'); |
272 | 279 | |
273 | 280 | // Make sure we're dealing with integers only. |
274 | - foreach ($_REQUEST['rem'] as $key => $group) |
|
275 | - $_REQUEST['rem'][$key] = (int) $group; |
|
281 | + foreach ($_REQUEST['rem'] as $key => $group) { |
|
282 | + $_REQUEST['rem'][$key] = (int) $group; |
|
283 | + } |
|
276 | 284 | |
277 | 285 | require_once($sourcedir . '/Subs-Membergroups.php'); |
278 | 286 | removeMembersFromGroups($_REQUEST['rem'], $_REQUEST['group'], true); |
@@ -295,16 +303,18 @@ discard block |
||
295 | 303 | { |
296 | 304 | $member_names[$index] = trim($smcFunc['strtolower']($member_names[$index])); |
297 | 305 | |
298 | - if (strlen($member_names[$index]) == 0) |
|
299 | - unset($member_names[$index]); |
|
306 | + if (strlen($member_names[$index]) == 0) { |
|
307 | + unset($member_names[$index]); |
|
308 | + } |
|
300 | 309 | } |
301 | 310 | |
302 | 311 | // Any passed by ID? |
303 | 312 | $member_ids = array(); |
304 | - if (!empty($_REQUEST['member_add'])) |
|
305 | - foreach ($_REQUEST['member_add'] as $id) |
|
313 | + if (!empty($_REQUEST['member_add'])) { |
|
314 | + foreach ($_REQUEST['member_add'] as $id) |
|
306 | 315 | if ($id > 0) |
307 | 316 | $member_ids[] = (int) $id; |
317 | + } |
|
308 | 318 | |
309 | 319 | // Construct the query pelements. |
310 | 320 | if (!empty($member_ids)) |
@@ -332,8 +342,9 @@ discard block |
||
332 | 342 | 'id_group' => $_REQUEST['group'], |
333 | 343 | )) |
334 | 344 | ); |
335 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
336 | - $members[] = $row['id_member']; |
|
345 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
346 | + $members[] = $row['id_member']; |
|
347 | + } |
|
337 | 348 | $smcFunc['db_free_result']($request); |
338 | 349 | } |
339 | 350 | |
@@ -372,10 +383,11 @@ discard block |
||
372 | 383 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
373 | 384 | |
374 | 385 | // The where on the query is interesting. Non-moderators should only see people who are in this group as primary. |
375 | - if ($context['group']['can_moderate']) |
|
376 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
377 | - else |
|
378 | - $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
386 | + if ($context['group']['can_moderate']) { |
|
387 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0'; |
|
388 | + } else { |
|
389 | + $where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}'; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // Count members of the group. |
381 | 393 | $request = $smcFunc['db_query']('', ' |
@@ -416,8 +428,9 @@ discard block |
||
416 | 428 | $last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']); |
417 | 429 | |
418 | 430 | // Italicize the online note if they aren't activated. |
419 | - if ($row['is_activated'] % 10 != 1) |
|
420 | - $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
431 | + if ($row['is_activated'] % 10 != 1) { |
|
432 | + $last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>'; |
|
433 | + } |
|
421 | 434 | |
422 | 435 | $context['members'][] = array( |
423 | 436 | 'id' => $row['id_member'], |
@@ -437,9 +450,10 @@ discard block |
||
437 | 450 | $context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name']; |
438 | 451 | createToken('mod-mgm'); |
439 | 452 | |
440 | - if ($context['group']['assignable']) |
|
441 | - loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
442 | -} |
|
453 | + if ($context['group']['assignable']) { |
|
454 | + loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
|
455 | + } |
|
456 | + } |
|
443 | 457 | |
444 | 458 | /** |
445 | 459 | * Show and manage all group requests. |
@@ -453,16 +467,18 @@ discard block |
||
453 | 467 | $context['sub_template'] = 'show_list'; |
454 | 468 | |
455 | 469 | // Verify we can be here. |
456 | - if ($user_info['mod_cache']['gq'] == '0=1') |
|
457 | - isAllowedTo('manage_membergroups'); |
|
470 | + if ($user_info['mod_cache']['gq'] == '0=1') { |
|
471 | + isAllowedTo('manage_membergroups'); |
|
472 | + } |
|
458 | 473 | |
459 | 474 | // Normally, we act normally... |
460 | 475 | $where = ($user_info['mod_cache']['gq'] == '1=1' || $user_info['mod_cache']['gq'] == '0=1' ? $user_info['mod_cache']['gq'] : 'lgr.' . $user_info['mod_cache']['gq']); |
461 | 476 | |
462 | - if (isset($_GET['closed'])) |
|
463 | - $where .= ' AND lgr.status != {int:status_open}'; |
|
464 | - else |
|
465 | - $where .= ' AND lgr.status = {int:status_open}'; |
|
477 | + if (isset($_GET['closed'])) { |
|
478 | + $where .= ' AND lgr.status != {int:status_open}'; |
|
479 | + } else { |
|
480 | + $where .= ' AND lgr.status = {int:status_open}'; |
|
481 | + } |
|
466 | 482 | |
467 | 483 | $where_parameters = array( |
468 | 484 | 'status_open' => 0, |
@@ -475,8 +491,9 @@ discard block |
||
475 | 491 | validateToken('mod-gr'); |
476 | 492 | |
477 | 493 | // Clean the values. |
478 | - foreach ($_POST['groupr'] as $k => $request) |
|
479 | - $_POST['groupr'][$k] = (int) $request; |
|
494 | + foreach ($_POST['groupr'] as $k => $request) { |
|
495 | + $_POST['groupr'][$k] = (int) $request; |
|
496 | + } |
|
480 | 497 | |
481 | 498 | $log_changes = array(); |
482 | 499 | |
@@ -513,8 +530,8 @@ discard block |
||
513 | 530 | $request_list = array(); |
514 | 531 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
515 | 532 | { |
516 | - if (!isset($log_changes[$row['id_request']])) |
|
517 | - $log_changes[$row['id_request']] = array( |
|
533 | + if (!isset($log_changes[$row['id_request']])) { |
|
534 | + $log_changes[$row['id_request']] = array( |
|
518 | 535 | 'id_request' => $row['id_request'], |
519 | 536 | 'status' => $_POST['req_action'] == 'approve' ? 1 : 2, // 1 = approved, 2 = rejected |
520 | 537 | 'id_member_acted' => $user_info['id'], |
@@ -522,6 +539,7 @@ discard block |
||
522 | 539 | 'time_acted' => time(), |
523 | 540 | 'act_reason' => $_POST['req_action'] != 'approve' && !empty($_POST['groupreason']) && !empty($_POST['groupreason'][$row['id_request']]) ? $smcFunc['htmlspecialchars']($_POST['groupreason'][$row['id_request']], ENT_QUOTES) : '', |
524 | 541 | ); |
542 | + } |
|
525 | 543 | $request_list[] = $row['id_request']; |
526 | 544 | } |
527 | 545 | $smcFunc['db_free_result']($request); |
@@ -744,21 +762,24 @@ discard block |
||
744 | 762 | $group_requests = array(); |
745 | 763 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
746 | 764 | { |
747 | - if (empty($row['reason'])) |
|
748 | - $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
749 | - else |
|
750 | - $reason = censorText($row['reason']); |
|
765 | + if (empty($row['reason'])) { |
|
766 | + $reason = '<em>(' . $txt['mc_groupr_no_reason'] . ')</em>'; |
|
767 | + } else { |
|
768 | + $reason = censorText($row['reason']); |
|
769 | + } |
|
751 | 770 | |
752 | 771 | if (isset($_GET['closed'])) |
753 | 772 | { |
754 | - if ($row['status'] == 1) |
|
755 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
756 | - elseif ($row['status'] == 2) |
|
757 | - $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
773 | + if ($row['status'] == 1) { |
|
774 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_approved'] . '</strong>'; |
|
775 | + } elseif ($row['status'] == 2) { |
|
776 | + $reason .= '<br><br><strong>' . $txt['mc_groupr_rejected'] . '</strong>'; |
|
777 | + } |
|
758 | 778 | |
759 | 779 | $reason .= ' (' . timeformat($row['time_acted']) . ')'; |
760 | - if (!empty($row['act_reason'])) |
|
761 | - $reason .= '<br><br>' . censorText($row['act_reason']); |
|
780 | + if (!empty($row['act_reason'])) { |
|
781 | + $reason .= '<br><br>' . censorText($row['act_reason']); |
|
782 | + } |
|
762 | 783 | } |
763 | 784 | |
764 | 785 | $group_requests[] = array( |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Ask them for their login information. (shows a page for the user to type |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | global $txt, $context, $scripturl, $user_info; |
30 | 31 | |
31 | 32 | // You are already logged in, go take a tour of the boards |
32 | - if (!empty($user_info['id'])) |
|
33 | - redirectexit(); |
|
33 | + if (!empty($user_info['id'])) { |
|
34 | + redirectexit(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | // We need to load the Login template/language file. |
36 | 38 | loadLanguage('Login'); |
@@ -57,10 +59,11 @@ discard block |
||
57 | 59 | ); |
58 | 60 | |
59 | 61 | // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment). |
60 | - if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) |
|
61 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
62 | - elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) |
|
63 | - unset($_SESSION['login_url']); |
|
62 | + if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) { |
|
63 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
64 | + } elseif (isset($_SESSION['login_url']) && strpos($_SESSION['login_url'], 'dlattach') !== false) { |
|
65 | + unset($_SESSION['login_url']); |
|
66 | + } |
|
64 | 67 | |
65 | 68 | // Create a one time token. |
66 | 69 | createToken('login'); |
@@ -83,8 +86,9 @@ discard block |
||
83 | 86 | global $cookiename, $modSettings, $context, $sourcedir, $maintenance; |
84 | 87 | |
85 | 88 | // Check to ensure we're forcing SSL for authentication |
86 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
87 | - fatal_lang_error('login_ssl_required'); |
|
89 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
90 | + fatal_lang_error('login_ssl_required'); |
|
91 | + } |
|
88 | 92 | |
89 | 93 | // Load cookie authentication stuff. |
90 | 94 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -102,19 +106,20 @@ discard block |
||
102 | 106 | list (,, $timeout) = smf_json_decode($_COOKIE[$cookiename], true); |
103 | 107 | |
104 | 108 | // That didn't work... Maybe it's using serialize? |
105 | - if (is_null($timeout)) |
|
106 | - list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
107 | - } |
|
108 | - elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | + if (is_null($timeout)) { |
|
110 | + list (,, $timeout) = safe_unserialize($_COOKIE[$cookiename]); |
|
111 | + } |
|
112 | + } elseif (isset($_SESSION['login_' . $cookiename])) |
|
109 | 113 | { |
110 | 114 | list (,, $timeout) = smf_json_decode($_SESSION['login_' . $cookiename]); |
111 | 115 | |
112 | 116 | // Try for old format |
113 | - if (is_null($timeout)) |
|
114 | - list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
117 | + if (is_null($timeout)) { |
|
118 | + list (,, $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]); |
|
119 | + } |
|
120 | + } else { |
|
121 | + trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
115 | 122 | } |
116 | - else |
|
117 | - trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR); |
|
118 | 123 | |
119 | 124 | $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4); |
120 | 125 | updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt'])); |
@@ -125,16 +130,18 @@ discard block |
||
125 | 130 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
126 | 131 | |
127 | 132 | // If that didn't work, try unserialize instead... |
128 | - if (is_null($tfadata)) |
|
129 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
133 | + if (is_null($tfadata)) { |
|
134 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
135 | + } |
|
130 | 136 | |
131 | 137 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
132 | 138 | |
133 | 139 | // If we're preserving the cookie, reset it with updated salt |
134 | - if ($preserve && time() < $exp) |
|
135 | - setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
136 | - else |
|
137 | - setTFACookie(-3600, 0, ''); |
|
140 | + if ($preserve && time() < $exp) { |
|
141 | + setTFACookie(3153600, $user_info['password_salt'], hash_salt($user_settings['tfa_backup'], $user_settings['password_salt']), true); |
|
142 | + } else { |
|
143 | + setTFACookie(-3600, 0, ''); |
|
144 | + } |
|
138 | 145 | } |
139 | 146 | |
140 | 147 | setLoginCookie($timeout - time(), $user_info['id'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
@@ -145,20 +152,20 @@ discard block |
||
145 | 152 | elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') |
146 | 153 | { |
147 | 154 | // Strike! You're outta there! |
148 | - if ($_GET['member'] != $user_info['id']) |
|
149 | - fatal_lang_error('login_cookie_error', false); |
|
155 | + if ($_GET['member'] != $user_info['id']) { |
|
156 | + fatal_lang_error('login_cookie_error', false); |
|
157 | + } |
|
150 | 158 | |
151 | 159 | $user_info['can_mod'] = allowedTo('access_mod_center') || (!$user_info['is_guest'] && ($user_info['mod_cache']['gq'] != '0=1' || $user_info['mod_cache']['bq'] != '0=1' || ($modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap'])))); |
152 | 160 | |
153 | 161 | // Some whitelisting for login_url... |
154 | - if (empty($_SESSION['login_url'])) |
|
155 | - redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
156 | - elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
162 | + if (empty($_SESSION['login_url'])) { |
|
163 | + redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
|
164 | + } elseif (!empty($_SESSION['login_url']) && (strpos($_SESSION['login_url'], 'http://') === false && strpos($_SESSION['login_url'], 'https://') === false)) |
|
157 | 165 | { |
158 | 166 | unset ($_SESSION['login_url']); |
159 | 167 | redirectexit(empty($user_settings['tfa_secret']) ? '' : 'action=logintfa'); |
160 | - } |
|
161 | - else |
|
168 | + } else |
|
162 | 169 | { |
163 | 170 | // Best not to clutter the session data too much... |
164 | 171 | $temp = $_SESSION['login_url']; |
@@ -169,8 +176,9 @@ discard block |
||
169 | 176 | } |
170 | 177 | |
171 | 178 | // Beyond this point you are assumed to be a guest trying to login. |
172 | - if (!$user_info['is_guest']) |
|
173 | - redirectexit(); |
|
179 | + if (!$user_info['is_guest']) { |
|
180 | + redirectexit(); |
|
181 | + } |
|
174 | 182 | |
175 | 183 | // Are you guessing with a script? |
176 | 184 | checkSession(); |
@@ -178,18 +186,21 @@ discard block |
||
178 | 186 | spamProtection('login'); |
179 | 187 | |
180 | 188 | // Set the login_url if it's not already set (but careful not to send us to an attachment). |
181 | - if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) |
|
182 | - $_SESSION['login_url'] = $_SESSION['old_url']; |
|
189 | + if ((empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) || (isset($_GET['quicklogin']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'login') === false)) { |
|
190 | + $_SESSION['login_url'] = $_SESSION['old_url']; |
|
191 | + } |
|
183 | 192 | |
184 | 193 | // Been guessing a lot, haven't we? |
185 | - if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) |
|
186 | - fatal_lang_error('login_threshold_fail', 'critical'); |
|
194 | + if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) { |
|
195 | + fatal_lang_error('login_threshold_fail', 'critical'); |
|
196 | + } |
|
187 | 197 | |
188 | 198 | // Set up the cookie length. (if it's invalid, just fall through and use the default.) |
189 | - if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) |
|
190 | - $modSettings['cookieTime'] = 3153600; |
|
191 | - elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) |
|
192 | - $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
199 | + if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1)) { |
|
200 | + $modSettings['cookieTime'] = 3153600; |
|
201 | + } elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 && $_POST['cookielength'] <= 525600)) { |
|
202 | + $modSettings['cookieTime'] = (int) $_POST['cookielength']; |
|
203 | + } |
|
193 | 204 | |
194 | 205 | loadLanguage('Login'); |
195 | 206 | // Load the template stuff. |
@@ -309,8 +320,9 @@ discard block |
||
309 | 320 | $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd'])); |
310 | 321 | |
311 | 322 | // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway. |
312 | - if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) |
|
313 | - $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
323 | + if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256')) { |
|
324 | + $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd'])); |
|
325 | + } |
|
314 | 326 | |
315 | 327 | // phpBB3 users new hashing. We now support it as well ;). |
316 | 328 | $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']); |
@@ -330,27 +342,29 @@ discard block |
||
330 | 342 | // Some common md5 ones. |
331 | 343 | $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']); |
332 | 344 | $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']); |
333 | - } |
|
334 | - elseif (strlen($user_settings['passwd']) == 40) |
|
345 | + } elseif (strlen($user_settings['passwd']) == 40) |
|
335 | 346 | { |
336 | 347 | // Maybe they are using a hash from before the password fix. |
337 | 348 | // This is also valid for SMF 1.1 to 2.0 style of hashing, changed to bcrypt in SMF 2.1 |
338 | 349 | $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd'])); |
339 | 350 | |
340 | 351 | // BurningBoard3 style of hashing. |
341 | - if (!empty($modSettings['enable_password_conversion'])) |
|
342 | - $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
352 | + if (!empty($modSettings['enable_password_conversion'])) { |
|
353 | + $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd']))); |
|
354 | + } |
|
343 | 355 | |
344 | 356 | // Perhaps we converted to UTF-8 and have a valid password being hashed differently. |
345 | 357 | if ($context['character_set'] == 'UTF-8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8') |
346 | 358 | { |
347 | 359 | // Try iconv first, for no particular reason. |
348 | - if (function_exists('iconv')) |
|
349 | - $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
360 | + if (function_exists('iconv')) { |
|
361 | + $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd']))); |
|
362 | + } |
|
350 | 363 | |
351 | 364 | // Say it aint so, iconv failed! |
352 | - if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) |
|
353 | - $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
365 | + if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding')) { |
|
366 | + $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet']))); |
|
367 | + } |
|
354 | 368 | } |
355 | 369 | } |
356 | 370 | |
@@ -380,8 +394,9 @@ discard block |
||
380 | 394 | $_SESSION['failed_login'] = isset($_SESSION['failed_login']) ? ($_SESSION['failed_login'] + 1) : 1; |
381 | 395 | |
382 | 396 | // Hmm... don't remember it, do you? Here, try the password reminder ;). |
383 | - if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) |
|
384 | - redirectexit('action=reminder'); |
|
397 | + if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold']) { |
|
398 | + redirectexit('action=reminder'); |
|
399 | + } |
|
385 | 400 | // We'll give you another chance... |
386 | 401 | else |
387 | 402 | { |
@@ -392,8 +407,7 @@ discard block |
||
392 | 407 | return; |
393 | 408 | } |
394 | 409 | } |
395 | - } |
|
396 | - elseif (!empty($user_settings['passwd_flood'])) |
|
410 | + } elseif (!empty($user_settings['passwd_flood'])) |
|
397 | 411 | { |
398 | 412 | // Let's be sure they weren't a little hacker. |
399 | 413 | validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true); |
@@ -410,8 +424,9 @@ discard block |
||
410 | 424 | } |
411 | 425 | |
412 | 426 | // Check their activation status. |
413 | - if (!checkActivation()) |
|
414 | - return; |
|
427 | + if (!checkActivation()) { |
|
428 | + return; |
|
429 | + } |
|
415 | 430 | |
416 | 431 | DoLogin(); |
417 | 432 | } |
@@ -423,8 +438,9 @@ discard block |
||
423 | 438 | { |
424 | 439 | global $sourcedir, $txt, $context, $user_info, $modSettings, $scripturl; |
425 | 440 | |
426 | - if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) |
|
427 | - fatal_lang_error('no_access', false); |
|
441 | + if (!$user_info['is_guest'] || empty($context['tfa_member']) || empty($modSettings['tfa_mode'])) { |
|
442 | + fatal_lang_error('no_access', false); |
|
443 | + } |
|
428 | 444 | |
429 | 445 | loadLanguage('Profile'); |
430 | 446 | require_once($sourcedir . '/Class-TOTP.php'); |
@@ -432,8 +448,9 @@ discard block |
||
432 | 448 | $member = $context['tfa_member']; |
433 | 449 | |
434 | 450 | // Prevent replay attacks by limiting at least 2 minutes before they can log in again via 2FA |
435 | - if (time() - $member['last_login'] < 120) |
|
436 | - fatal_lang_error('tfa_wait', false); |
|
451 | + if (time() - $member['last_login'] < 120) { |
|
452 | + fatal_lang_error('tfa_wait', false); |
|
453 | + } |
|
437 | 454 | |
438 | 455 | $totp = new \TOTP\Auth($member['tfa_secret']); |
439 | 456 | $totp->setRange(1); |
@@ -447,8 +464,9 @@ discard block |
||
447 | 464 | if (!empty($_POST['tfa_code']) && empty($_POST['tfa_backup'])) |
448 | 465 | { |
449 | 466 | // Check to ensure we're forcing SSL for authentication |
450 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
451 | - fatal_lang_error('login_ssl_required'); |
|
467 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
468 | + fatal_lang_error('login_ssl_required'); |
|
469 | + } |
|
452 | 470 | |
453 | 471 | $code = $_POST['tfa_code']; |
454 | 472 | |
@@ -458,20 +476,19 @@ discard block |
||
458 | 476 | |
459 | 477 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt']), !empty($_POST['tfa_preserve'])); |
460 | 478 | redirectexit(); |
461 | - } |
|
462 | - else |
|
479 | + } else |
|
463 | 480 | { |
464 | 481 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
465 | 482 | |
466 | 483 | $context['tfa_error'] = true; |
467 | 484 | $context['tfa_value'] = $_POST['tfa_code']; |
468 | 485 | } |
469 | - } |
|
470 | - elseif (!empty($_POST['tfa_backup'])) |
|
486 | + } elseif (!empty($_POST['tfa_backup'])) |
|
471 | 487 | { |
472 | 488 | // Check to ensure we're forcing SSL for authentication |
473 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) |
|
474 | - fatal_lang_error('login_ssl_required'); |
|
489 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) { |
|
490 | + fatal_lang_error('login_ssl_required'); |
|
491 | + } |
|
475 | 492 | |
476 | 493 | $backup = $_POST['tfa_backup']; |
477 | 494 | |
@@ -485,8 +502,7 @@ discard block |
||
485 | 502 | )); |
486 | 503 | setTFACookie(3153600, $member['id_member'], hash_salt($member['tfa_backup'], $member['password_salt'])); |
487 | 504 | redirectexit('action=profile;area=tfasetup;backup'); |
488 | - } |
|
489 | - else |
|
505 | + } else |
|
490 | 506 | { |
491 | 507 | validatePasswordFlood($member['id_member'], $member['passwd_flood'], false, true); |
492 | 508 | |
@@ -509,8 +525,9 @@ discard block |
||
509 | 525 | { |
510 | 526 | global $context, $txt, $scripturl, $user_settings, $modSettings; |
511 | 527 | |
512 | - if (!isset($context['login_errors'])) |
|
513 | - $context['login_errors'] = array(); |
|
528 | + if (!isset($context['login_errors'])) { |
|
529 | + $context['login_errors'] = array(); |
|
530 | + } |
|
514 | 531 | |
515 | 532 | // What is the true activation status of this account? |
516 | 533 | $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated']; |
@@ -522,8 +539,9 @@ discard block |
||
522 | 539 | return false; |
523 | 540 | } |
524 | 541 | // Awaiting approval still? |
525 | - elseif ($activation_status == 3) |
|
526 | - fatal_lang_error('still_awaiting_approval', 'user'); |
|
542 | + elseif ($activation_status == 3) { |
|
543 | + fatal_lang_error('still_awaiting_approval', 'user'); |
|
544 | + } |
|
527 | 545 | // Awaiting deletion, changed their mind? |
528 | 546 | elseif ($activation_status == 4) |
529 | 547 | { |
@@ -531,8 +549,7 @@ discard block |
||
531 | 549 | { |
532 | 550 | updateMemberData($user_settings['id_member'], array('is_activated' => 1)); |
533 | 551 | updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0))); |
534 | - } |
|
535 | - else |
|
552 | + } else |
|
536 | 553 | { |
537 | 554 | $context['disable_login_hashing'] = true; |
538 | 555 | $context['login_errors'][] = $txt['awaiting_delete_account']; |
@@ -573,8 +590,9 @@ discard block |
||
573 | 590 | setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash_salt($user_settings['passwd'], $user_settings['password_salt'])); |
574 | 591 | |
575 | 592 | // Reset the login threshold. |
576 | - if (isset($_SESSION['failed_login'])) |
|
577 | - unset($_SESSION['failed_login']); |
|
593 | + if (isset($_SESSION['failed_login'])) { |
|
594 | + unset($_SESSION['failed_login']); |
|
595 | + } |
|
578 | 596 | |
579 | 597 | $user_info['is_guest'] = false; |
580 | 598 | $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']); |
@@ -596,16 +614,18 @@ discard block |
||
596 | 614 | 'id_member' => $user_info['id'], |
597 | 615 | ) |
598 | 616 | ); |
599 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
600 | - $_SESSION['first_login'] = true; |
|
601 | - else |
|
602 | - unset($_SESSION['first_login']); |
|
617 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
618 | + $_SESSION['first_login'] = true; |
|
619 | + } else { |
|
620 | + unset($_SESSION['first_login']); |
|
621 | + } |
|
603 | 622 | $smcFunc['db_free_result']($request); |
604 | 623 | |
605 | 624 | // You've logged in, haven't you? |
606 | 625 | $update = array('member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']); |
607 | - if (empty($user_settings['tfa_secret'])) |
|
608 | - $update['last_login'] = time(); |
|
626 | + if (empty($user_settings['tfa_secret'])) { |
|
627 | + $update['last_login'] = time(); |
|
628 | + } |
|
609 | 629 | updateMemberData($user_info['id'], $update); |
610 | 630 | |
611 | 631 | // Get rid of the online entry for that old guest.... |
@@ -619,8 +639,8 @@ discard block |
||
619 | 639 | $_SESSION['log_time'] = 0; |
620 | 640 | |
621 | 641 | // Log this entry, only if we have it enabled. |
622 | - if (!empty($modSettings['loginHistoryDays'])) |
|
623 | - $smcFunc['db_insert']('insert', |
|
642 | + if (!empty($modSettings['loginHistoryDays'])) { |
|
643 | + $smcFunc['db_insert']('insert', |
|
624 | 644 | '{db_prefix}member_logins', |
625 | 645 | array( |
626 | 646 | 'id_member' => 'int', 'time' => 'int', 'ip' => 'inet', 'ip2' => 'inet', |
@@ -632,13 +652,15 @@ discard block |
||
632 | 652 | 'id_member', 'time' |
633 | 653 | ) |
634 | 654 | ); |
655 | + } |
|
635 | 656 | |
636 | 657 | // Just log you back out if it's in maintenance mode and you AREN'T an admin. |
637 | - if (empty($maintenance) || allowedTo('admin_forum')) |
|
638 | - redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
639 | - else |
|
640 | - redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
641 | -} |
|
658 | + if (empty($maintenance) || allowedTo('admin_forum')) { |
|
659 | + redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']); |
|
660 | + } else { |
|
661 | + redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']); |
|
662 | + } |
|
663 | + } |
|
642 | 664 | |
643 | 665 | /** |
644 | 666 | * Logs the current user out of their account. |
@@ -654,13 +676,15 @@ discard block |
||
654 | 676 | global $sourcedir, $user_info, $user_settings, $context, $smcFunc, $cookiename, $modSettings; |
655 | 677 | |
656 | 678 | // Make sure they aren't being auto-logged out. |
657 | - if (!$internal) |
|
658 | - checkSession('get'); |
|
679 | + if (!$internal) { |
|
680 | + checkSession('get'); |
|
681 | + } |
|
659 | 682 | |
660 | 683 | require_once($sourcedir . '/Subs-Auth.php'); |
661 | 684 | |
662 | - if (isset($_SESSION['pack_ftp'])) |
|
663 | - $_SESSION['pack_ftp'] = null; |
|
685 | + if (isset($_SESSION['pack_ftp'])) { |
|
686 | + $_SESSION['pack_ftp'] = null; |
|
687 | + } |
|
664 | 688 | |
665 | 689 | // It won't be first login anymore. |
666 | 690 | unset($_SESSION['first_login']); |
@@ -688,24 +712,27 @@ discard block |
||
688 | 712 | |
689 | 713 | // And some other housekeeping while we're at it. |
690 | 714 | $salt = substr(md5(mt_rand()), 0, 4); |
691 | - if (!empty($user_info['id'])) |
|
692 | - updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
715 | + if (!empty($user_info['id'])) { |
|
716 | + updateMemberData($user_info['id'], array('password_salt' => $salt)); |
|
717 | + } |
|
693 | 718 | |
694 | 719 | if (!empty($modSettings['tfa_mode']) && !empty($user_info['id']) && !empty($_COOKIE[$cookiename . '_tfa'])) |
695 | 720 | { |
696 | 721 | $tfadata = smf_json_decode($_COOKIE[$cookiename . '_tfa'], true); |
697 | 722 | |
698 | 723 | // If that failed, try the old method |
699 | - if (is_null($tfadata)) |
|
700 | - $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
724 | + if (is_null($tfadata)) { |
|
725 | + $tfadata = safe_unserialize($_COOKIE[$cookiename . '_tfa']); |
|
726 | + } |
|
701 | 727 | |
702 | 728 | list ($tfamember, $tfasecret, $exp, $state, $preserve) = $tfadata; |
703 | 729 | |
704 | 730 | // If we're preserving the cookie, reset it with updated salt |
705 | - if ($preserve && time() < $exp) |
|
706 | - setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
707 | - else |
|
708 | - setTFACookie(-3600, 0, ''); |
|
731 | + if ($preserve && time() < $exp) { |
|
732 | + setTFACookie(3153600, $user_info['id'], hash_salt($user_settings['tfa_backup'], $salt), true); |
|
733 | + } else { |
|
734 | + setTFACookie(-3600, 0, ''); |
|
735 | + } |
|
709 | 736 | } |
710 | 737 | |
711 | 738 | session_destroy(); |
@@ -713,14 +740,13 @@ discard block |
||
713 | 740 | // Off to the merry board index we go! |
714 | 741 | if ($redirect) |
715 | 742 | { |
716 | - if (empty($_SESSION['logout_url'])) |
|
717 | - redirectexit('', $context['server']['needs_login_fix']); |
|
718 | - elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
743 | + if (empty($_SESSION['logout_url'])) { |
|
744 | + redirectexit('', $context['server']['needs_login_fix']); |
|
745 | + } elseif (!empty($_SESSION['logout_url']) && (strpos($_SESSION['logout_url'], 'http://') === false && strpos($_SESSION['logout_url'], 'https://') === false)) |
|
719 | 746 | { |
720 | 747 | unset ($_SESSION['logout_url']); |
721 | 748 | redirectexit(); |
722 | - } |
|
723 | - else |
|
749 | + } else |
|
724 | 750 | { |
725 | 751 | $temp = $_SESSION['logout_url']; |
726 | 752 | unset($_SESSION['logout_url']); |
@@ -753,8 +779,9 @@ discard block |
||
753 | 779 | function phpBB3_password_check($passwd, $passwd_hash) |
754 | 780 | { |
755 | 781 | // Too long or too short? |
756 | - if (strlen($passwd_hash) != 34) |
|
757 | - return; |
|
782 | + if (strlen($passwd_hash) != 34) { |
|
783 | + return; |
|
784 | + } |
|
758 | 785 | |
759 | 786 | // Range of characters allowed. |
760 | 787 | $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
@@ -766,8 +793,9 @@ discard block |
||
766 | 793 | $salt = substr($passwd_hash, 4, 8); |
767 | 794 | |
768 | 795 | $hash = md5($salt . $passwd, true); |
769 | - for (; $count != 0; --$count) |
|
770 | - $hash = md5($hash . $passwd, true); |
|
796 | + for (; $count != 0; --$count) { |
|
797 | + $hash = md5($hash . $passwd, true); |
|
798 | + } |
|
771 | 799 | |
772 | 800 | $output = substr($passwd_hash, 0, 12); |
773 | 801 | $i = 0; |
@@ -776,21 +804,25 @@ discard block |
||
776 | 804 | $value = ord($hash[$i++]); |
777 | 805 | $output .= $range[$value & 0x3f]; |
778 | 806 | |
779 | - if ($i < 16) |
|
780 | - $value |= ord($hash[$i]) << 8; |
|
807 | + if ($i < 16) { |
|
808 | + $value |= ord($hash[$i]) << 8; |
|
809 | + } |
|
781 | 810 | |
782 | 811 | $output .= $range[($value >> 6) & 0x3f]; |
783 | 812 | |
784 | - if ($i++ >= 16) |
|
785 | - break; |
|
813 | + if ($i++ >= 16) { |
|
814 | + break; |
|
815 | + } |
|
786 | 816 | |
787 | - if ($i < 16) |
|
788 | - $value |= ord($hash[$i]) << 16; |
|
817 | + if ($i < 16) { |
|
818 | + $value |= ord($hash[$i]) << 16; |
|
819 | + } |
|
789 | 820 | |
790 | 821 | $output .= $range[($value >> 12) & 0x3f]; |
791 | 822 | |
792 | - if ($i++ >= 16) |
|
793 | - break; |
|
823 | + if ($i++ >= 16) { |
|
824 | + break; |
|
825 | + } |
|
794 | 826 | |
795 | 827 | $output .= $range[($value >> 18) & 0x3f]; |
796 | 828 | } |
@@ -821,8 +853,9 @@ discard block |
||
821 | 853 | require_once($sourcedir . '/Subs-Auth.php'); |
822 | 854 | setLoginCookie(-3600, 0); |
823 | 855 | |
824 | - if (isset($_SESSION['login_' . $cookiename])) |
|
825 | - unset($_SESSION['login_' . $cookiename]); |
|
856 | + if (isset($_SESSION['login_' . $cookiename])) { |
|
857 | + unset($_SESSION['login_' . $cookiename]); |
|
858 | + } |
|
826 | 859 | } |
827 | 860 | |
828 | 861 | // We need a member! |
@@ -836,8 +869,9 @@ discard block |
||
836 | 869 | } |
837 | 870 | |
838 | 871 | // Right, have we got a flood value? |
839 | - if ($password_flood_value !== false) |
|
840 | - @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
872 | + if ($password_flood_value !== false) { |
|
873 | + @list ($time_stamp, $number_tries) = explode('|', $password_flood_value); |
|
874 | + } |
|
841 | 875 | |
842 | 876 | // Timestamp or number of tries invalid? |
843 | 877 | if (empty($number_tries) || empty($time_stamp)) |
@@ -853,15 +887,17 @@ discard block |
||
853 | 887 | $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries; |
854 | 888 | |
855 | 889 | // They are trying too fast, make them wait longer |
856 | - if ($time_stamp < time() - 10) |
|
857 | - $time_stamp = time(); |
|
890 | + if ($time_stamp < time() - 10) { |
|
891 | + $time_stamp = time(); |
|
892 | + } |
|
858 | 893 | } |
859 | 894 | |
860 | 895 | $number_tries++; |
861 | 896 | |
862 | 897 | // Broken the law? |
863 | - if ($number_tries > 5) |
|
864 | - fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
898 | + if ($number_tries > 5) { |
|
899 | + fatal_lang_error('login_threshold_brute_fail', 'critical'); |
|
900 | + } |
|
865 | 901 | |
866 | 902 | // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it! |
867 | 903 | updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries)); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the functions implemented in this file to the $smcFunc array. |
@@ -23,8 +24,8 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_backup_table' => 'smf_db_backup_table', |
29 | 30 | 'db_optimize_table' => 'smf_db_optimize_table', |
30 | 31 | 'db_table_sql' => 'smf_db_table_sql', |
@@ -32,7 +33,8 @@ discard block |
||
32 | 33 | 'db_get_version' => 'smf_db_get_version', |
33 | 34 | 'db_get_engine' => 'smf_db_get_engine', |
34 | 35 | ); |
35 | -} |
|
36 | + } |
|
37 | + } |
|
36 | 38 | |
37 | 39 | /** |
38 | 40 | * Backup $table to $backup_table. |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | )); |
75 | 77 | |
76 | 78 | // Old school or no school? |
77 | - if ($request) |
|
78 | - return $request; |
|
79 | + if ($request) { |
|
80 | + return $request; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // At this point, the quick method failed. |
@@ -99,8 +102,9 @@ discard block |
||
99 | 102 | foreach ($create as $k => $l) |
100 | 103 | { |
101 | 104 | // Get the name of the auto_increment column. |
102 | - if (strpos($l, 'auto_increment')) |
|
103 | - $auto_inc = trim($l); |
|
105 | + if (strpos($l, 'auto_increment')) { |
|
106 | + $auto_inc = trim($l); |
|
107 | + } |
|
104 | 108 | |
105 | 109 | // For the engine type, see if we can work out what it is. |
106 | 110 | if (strpos($l, 'ENGINE') !== false || strpos($l, 'TYPE') !== false) |
@@ -108,30 +112,36 @@ discard block |
||
108 | 112 | // Extract the engine type. |
109 | 113 | preg_match('~(ENGINE|TYPE)=(\w+)(\sDEFAULT)?(\sCHARSET=(\w+))?(\sCOLLATE=(\w+))?~', $l, $match); |
110 | 114 | |
111 | - if (!empty($match[1])) |
|
112 | - $engine = $match[1]; |
|
115 | + if (!empty($match[1])) { |
|
116 | + $engine = $match[1]; |
|
117 | + } |
|
113 | 118 | |
114 | - if (!empty($match[2])) |
|
115 | - $engine = $match[2]; |
|
119 | + if (!empty($match[2])) { |
|
120 | + $engine = $match[2]; |
|
121 | + } |
|
116 | 122 | |
117 | - if (!empty($match[5])) |
|
118 | - $charset = $match[5]; |
|
123 | + if (!empty($match[5])) { |
|
124 | + $charset = $match[5]; |
|
125 | + } |
|
119 | 126 | |
120 | - if (!empty($match[7])) |
|
121 | - $collate = $match[7]; |
|
127 | + if (!empty($match[7])) { |
|
128 | + $collate = $match[7]; |
|
129 | + } |
|
122 | 130 | } |
123 | 131 | |
124 | 132 | // Skip everything but keys... |
125 | - if (strpos($l, 'KEY') === false) |
|
126 | - unset($create[$k]); |
|
133 | + if (strpos($l, 'KEY') === false) { |
|
134 | + unset($create[$k]); |
|
135 | + } |
|
127 | 136 | } |
128 | 137 | |
129 | - if (!empty($create)) |
|
130 | - $create = '( |
|
138 | + if (!empty($create)) { |
|
139 | + $create = '( |
|
131 | 140 | ' . implode(' |
132 | 141 | ', $create) . ')'; |
133 | - else |
|
134 | - $create = ''; |
|
142 | + } else { |
|
143 | + $create = ''; |
|
144 | + } |
|
135 | 145 | |
136 | 146 | $request = $smcFunc['db_query']('', ' |
137 | 147 | CREATE TABLE {raw:backup_table} {raw:create} |
@@ -150,8 +160,9 @@ discard block |
||
150 | 160 | |
151 | 161 | if ($auto_inc != '') |
152 | 162 | { |
153 | - if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') |
|
154 | - $auto_inc = substr($auto_inc, 0, -1); |
|
163 | + if (preg_match('~\`(.+?)\`\s~', $auto_inc, $match) != 0 && substr($auto_inc, -1, 1) == ',') { |
|
164 | + $auto_inc = substr($auto_inc, 0, -1); |
|
165 | + } |
|
155 | 166 | |
156 | 167 | $smcFunc['db_query']('', ' |
157 | 168 | ALTER TABLE {raw:backup_table} |
@@ -195,8 +206,9 @@ discard block |
||
195 | 206 | 'table' => $table, |
196 | 207 | ) |
197 | 208 | ); |
198 | - if (!$request) |
|
199 | - return -1; |
|
209 | + if (!$request) { |
|
210 | + return -1; |
|
211 | + } |
|
200 | 212 | |
201 | 213 | // How much left? |
202 | 214 | $request = $smcFunc['db_query']('', ' |
@@ -239,8 +251,9 @@ discard block |
||
239 | 251 | ) |
240 | 252 | ); |
241 | 253 | $tables = array(); |
242 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
243 | - $tables[] = $row[0]; |
|
254 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
255 | + $tables[] = $row[0]; |
|
256 | + } |
|
244 | 257 | $smcFunc['db_free_result']($request); |
245 | 258 | |
246 | 259 | return $tables; |
@@ -284,8 +297,9 @@ discard block |
||
284 | 297 | if (!empty($row['Default']) || $row['Null'] !== 'YES') |
285 | 298 | { |
286 | 299 | // Make a special case of auto-timestamp. |
287 | - if ($row['Default'] == 'CURRENT_TIMESTAMP') |
|
288 | - $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
300 | + if ($row['Default'] == 'CURRENT_TIMESTAMP') { |
|
301 | + $schema_create .= ' /*!40102 NOT NULL default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP */'; |
|
302 | + } |
|
289 | 303 | // Text shouldn't have a default. |
290 | 304 | elseif ($row['Default'] !== null) |
291 | 305 | { |
@@ -320,14 +334,16 @@ discard block |
||
320 | 334 | $row['Key_name'] = $row['Key_name'] == 'PRIMARY' ? 'PRIMARY KEY' : (empty($row['Non_unique']) ? 'UNIQUE ' : ($row['Comment'] == 'FULLTEXT' || (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT') ? 'FULLTEXT ' : 'KEY ')) . '`' . $row['Key_name'] . '`'; |
321 | 335 | |
322 | 336 | // Is this the first column in the index? |
323 | - if (empty($indexes[$row['Key_name']])) |
|
324 | - $indexes[$row['Key_name']] = array(); |
|
337 | + if (empty($indexes[$row['Key_name']])) { |
|
338 | + $indexes[$row['Key_name']] = array(); |
|
339 | + } |
|
325 | 340 | |
326 | 341 | // A sub part, like only indexing 15 characters of a varchar. |
327 | - if (!empty($row['Sub_part'])) |
|
328 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
329 | - else |
|
330 | - $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
342 | + if (!empty($row['Sub_part'])) { |
|
343 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`(' . $row['Sub_part'] . ')'; |
|
344 | + } else { |
|
345 | + $indexes[$row['Key_name']][$row['Seq_in_index']] = '`' . $row['Column_name'] . '`'; |
|
346 | + } |
|
331 | 347 | } |
332 | 348 | $smcFunc['db_free_result']($result); |
333 | 349 | |
@@ -365,8 +381,9 @@ discard block |
||
365 | 381 | { |
366 | 382 | static $ver; |
367 | 383 | |
368 | - if (!empty($ver)) |
|
369 | - return $ver; |
|
384 | + if (!empty($ver)) { |
|
385 | + return $ver; |
|
386 | + } |
|
370 | 387 | |
371 | 388 | global $smcFunc; |
372 | 389 | |
@@ -391,8 +408,9 @@ discard block |
||
391 | 408 | global $smcFunc; |
392 | 409 | static $db_type; |
393 | 410 | |
394 | - if (!empty($db_type)) |
|
395 | - return $db_type; |
|
411 | + if (!empty($db_type)) { |
|
412 | + return $db_type; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $request = $smcFunc['db_query']('', 'SELECT @@version_comment'); |
398 | 416 | list ($comment) = $smcFunc['db_fetch_row']($request); |
@@ -401,13 +419,15 @@ discard block |
||
401 | 419 | // Skip these if we don't have a comment. |
402 | 420 | if (!empty($comment)) |
403 | 421 | { |
404 | - if (stripos($comment, 'percona') !== false) |
|
405 | - return 'Percona'; |
|
406 | - if (stripos($comment, 'mariadb') !== false) |
|
407 | - return 'MariaDB'; |
|
422 | + if (stripos($comment, 'percona') !== false) { |
|
423 | + return 'Percona'; |
|
424 | + } |
|
425 | + if (stripos($comment, 'mariadb') !== false) { |
|
426 | + return 'MariaDB'; |
|
427 | + } |
|
428 | + } else { |
|
429 | + return 'fail'; |
|
408 | 430 | } |
409 | - else |
|
410 | - return 'fail'; |
|
411 | 431 | |
412 | 432 | return 'MySQL'; |
413 | 433 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
109 | 110 | |
110 | 111 | // We do not want to output debug information here. |
111 | - if ($this->_js) |
|
112 | - $db_show_debug = false; |
|
112 | + if ($this->_js) { |
|
113 | + $db_show_debug = false; |
|
114 | + } |
|
113 | 115 | } |
114 | 116 | |
115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
143 | 145 | $call = $this->_sa; |
144 | 146 | |
145 | 147 | // Guest can only view likes. |
146 | - if ($call != 'view') |
|
147 | - is_not_guest(); |
|
148 | + if ($call != 'view') { |
|
149 | + is_not_guest(); |
|
150 | + } |
|
148 | 151 | |
149 | 152 | checkSession('get'); |
150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
182 | 185 | global $smcFunc, $modSettings; |
183 | 186 | |
184 | 187 | // This feature is currently disable. |
185 | - if (empty($modSettings['enable_likes'])) |
|
186 | - return $this->_error = 'like_disable'; |
|
188 | + if (empty($modSettings['enable_likes'])) { |
|
189 | + return $this->_error = 'like_disable'; |
|
190 | + } |
|
187 | 191 | |
188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
191 | 195 | |
192 | - if ($this->_type == '' || $this->_content <= 0) |
|
193 | - return $this->_error = 'cannot_'; |
|
196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
197 | + return $this->_error = 'cannot_'; |
|
198 | + } |
|
194 | 199 | |
195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
209 | 214 | 'msg' => $this->_content, |
210 | 215 | ) |
211 | 216 | ); |
212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
219 | + } |
|
214 | 220 | |
215 | 221 | $smcFunc['db_free_result']($request); |
216 | - if (empty($this->_idTopic)) |
|
217 | - return $this->_error = 'cannot_'; |
|
222 | + if (empty($this->_idTopic)) { |
|
223 | + return $this->_error = 'cannot_'; |
|
224 | + } |
|
218 | 225 | |
219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
225 | 232 | |
226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
227 | - } |
|
228 | - |
|
229 | - else |
|
234 | + } else |
|
230 | 235 | { |
231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
244 | 249 | if ($result !== false) |
245 | 250 | { |
246 | 251 | // Match the type with what we already have. |
247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
248 | - return $this->_error = 'not_valid_like_type'; |
|
252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
253 | + return $this->_error = 'not_valid_like_type'; |
|
254 | + } |
|
249 | 255 | |
250 | 256 | // Fill out the rest. |
251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
256 | 262 | } |
257 | 263 | } |
258 | 264 | |
259 | - if (!$found) |
|
260 | - return $this->_error = 'cannot_'; |
|
265 | + if (!$found) { |
|
266 | + return $this->_error = 'cannot_'; |
|
267 | + } |
|
261 | 268 | } |
262 | 269 | |
263 | 270 | // Does the user can see this? |
264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
265 | - return $this->_error = $this->_validLikes['can_see']; |
|
271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
272 | + return $this->_error = $this->_validLikes['can_see']; |
|
273 | + } |
|
266 | 274 | |
267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
269 | - return $this->_error = $this->_validLikes['can_like']; |
|
276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
277 | + return $this->_error = $this->_validLikes['can_like']; |
|
278 | + } |
|
270 | 279 | } |
271 | 280 | |
272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | ); |
292 | 301 | |
293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
294 | - if ($this->_sa == __FUNCTION__) |
|
295 | - $this->_data = __FUNCTION__; |
|
303 | + if ($this->_sa == __FUNCTION__) { |
|
304 | + $this->_data = __FUNCTION__; |
|
305 | + } |
|
296 | 306 | } |
297 | 307 | |
298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
322 | 332 | |
323 | 333 | // Add a background task to process sending alerts. |
324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
325 | - if ($this->_type == 'msg') |
|
326 | - $smcFunc['db_insert']('insert', |
|
335 | + if ($this->_type == 'msg') { |
|
336 | + $smcFunc['db_insert']('insert', |
|
327 | 337 | '{db_prefix}background_tasks', |
328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array( |
@@ -335,10 +345,12 @@ discard block |
||
335 | 345 | )), 0), |
336 | 346 | array('id_task') |
337 | 347 | ); |
348 | + } |
|
338 | 349 | |
339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
340 | - if ($this->_sa == __FUNCTION__) |
|
341 | - $this->_data = __FUNCTION__; |
|
351 | + if ($this->_sa == __FUNCTION__) { |
|
352 | + $this->_data = __FUNCTION__; |
|
353 | + } |
|
342 | 354 | } |
343 | 355 | |
344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
364 | 376 | $smcFunc['db_free_result']($request); |
365 | 377 | |
366 | 378 | // If you want to call this directly, fill out _data property too. |
367 | - if ($this->_sa == __FUNCTION__) |
|
368 | - $this->_data = $this->_numLikes; |
|
379 | + if ($this->_sa == __FUNCTION__) { |
|
380 | + $this->_data = $this->_numLikes; |
|
381 | + } |
|
369 | 382 | } |
370 | 383 | |
371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
378 | 391 | global $smcFunc; |
379 | 392 | |
380 | 393 | // Safety first! |
381 | - if (empty($this->_type) || empty($this->_content)) |
|
382 | - return $this->_error = 'cannot_'; |
|
394 | + if (empty($this->_type) || empty($this->_content)) { |
|
395 | + return $this->_error = 'cannot_'; |
|
396 | + } |
|
383 | 397 | |
384 | 398 | // Do we already like this? |
385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
398 | 412 | $smcFunc['db_free_result']($request); |
399 | 413 | |
400 | - if ($this->_alreadyLiked) |
|
401 | - $this->delete(); |
|
402 | - |
|
403 | - else |
|
404 | - $this->insert(); |
|
414 | + if ($this->_alreadyLiked) { |
|
415 | + $this->delete(); |
|
416 | + } else { |
|
417 | + $this->insert(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
407 | 421 | $this->_count(); |
408 | 422 | |
409 | 423 | // Update the likes count for messages. |
410 | - if ($this->_type == 'msg') |
|
411 | - $this->msgIssueLike(); |
|
424 | + if ($this->_type == 'msg') { |
|
425 | + $this->msgIssueLike(); |
|
426 | + } |
|
412 | 427 | |
413 | 428 | // Any callbacks? |
414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
415 | 430 | { |
416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
417 | 432 | |
418 | - if (!empty($call)) |
|
419 | - call_user_func_array($call, array($this)); |
|
433 | + if (!empty($call)) { |
|
434 | + call_user_func_array($call, array($this)); |
|
435 | + } |
|
420 | 436 | } |
421 | 437 | |
422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
446 | + } |
|
430 | 447 | |
431 | 448 | // All done, start building the data to pass as response. |
432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
450 | 467 | { |
451 | 468 | global $smcFunc; |
452 | 469 | |
453 | - if ($this->_type !== 'msg') |
|
454 | - return; |
|
470 | + if ($this->_type !== 'msg') { |
|
471 | + return; |
|
472 | + } |
|
455 | 473 | |
456 | 474 | $smcFunc['db_query']('', ' |
457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
492 | 510 | 'like_type' => $this->_type, |
493 | 511 | ) |
494 | 512 | ); |
495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
515 | + } |
|
497 | 516 | |
498 | 517 | // Now to get member data, including avatars and so on. |
499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
501 | 520 | if (count($loaded) != count($members)) |
502 | 521 | { |
503 | 522 | $members = array_diff($members, $loaded); |
504 | - foreach ($members as $not_loaded) |
|
505 | - unset ($context['likers'][$not_loaded]); |
|
523 | + foreach ($members as $not_loaded) { |
|
524 | + unset ($context['likers'][$not_loaded]); |
|
525 | + } |
|
506 | 526 | } |
507 | 527 | |
508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
544 | 564 | global $context, $txt; |
545 | 565 | |
546 | 566 | // Don't do anything if someone else has already take care of the response. |
547 | - if (!$this->_setResponse) |
|
548 | - return; |
|
567 | + if (!$this->_setResponse) { |
|
568 | + return; |
|
569 | + } |
|
549 | 570 | |
550 | 571 | // Want a json response huh? |
551 | - if ($this->_validLikes['json']) |
|
552 | - return $this->jsonResponse(); |
|
572 | + if ($this->_validLikes['json']) { |
|
573 | + return $this->jsonResponse(); |
|
574 | + } |
|
553 | 575 | |
554 | 576 | // Set everything up for display. |
555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
559 | 581 | if ($this->_error) |
560 | 582 | { |
561 | 583 | // If this is a generic error, set it up good. |
562 | - if ($this->_error == 'cannot_') |
|
563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
584 | + if ($this->_error == 'cannot_') { |
|
585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
586 | + } |
|
564 | 587 | |
565 | 588 | // Is this request coming from an ajax call? |
566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
570 | 593 | } |
571 | 594 | |
572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
573 | - else |
|
574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
596 | + else { |
|
597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
598 | + } |
|
575 | 599 | |
576 | 600 | return; |
577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
580 | 604 | else |
581 | 605 | { |
582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
583 | - if (!$this->_js) |
|
584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
607 | + if (!$this->_js) { |
|
608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
609 | + } |
|
585 | 610 | |
586 | 611 | // These fine gentlemen all share the same template. |
587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -612,8 +637,9 @@ discard block |
||
612 | 637 | // If there is an error, send it. |
613 | 638 | if ($this->_error) |
614 | 639 | { |
615 | - if ($this->_error == 'cannot_') |
|
616 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
640 | + if ($this->_error == 'cannot_') { |
|
641 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
642 | + } |
|
617 | 643 | |
618 | 644 | $print['error'] = $this->_error; |
619 | 645 | } |
@@ -649,33 +675,36 @@ discard block |
||
649 | 675 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
650 | 676 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
651 | 677 | |
652 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
653 | - $_GET['verse'] = '4:16'; |
|
678 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
679 | + $_GET['verse'] = '4:16'; |
|
680 | + } |
|
654 | 681 | |
655 | - if ($_GET['verse'] == '2:18') |
|
656 | - echo ' |
|
682 | + if ($_GET['verse'] == '2:18') { |
|
683 | + echo ' |
|
657 | 684 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
658 | - elseif ($_GET['verse'] == '4:16') |
|
659 | - echo ' |
|
685 | + } elseif ($_GET['verse'] == '4:16') { |
|
686 | + echo ' |
|
660 | 687 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
661 | - elseif ($_GET['verse'] == '22:1-2') |
|
662 | - echo ' |
|
688 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
689 | + echo ' |
|
663 | 690 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
664 | 691 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
692 | + } |
|
665 | 693 | |
666 | 694 | echo ' |
667 | 695 | </div> |
668 | 696 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
669 | 697 | |
670 | - if ($_GET['verse'] == '2:18') |
|
671 | - echo ' |
|
698 | + if ($_GET['verse'] == '2:18') { |
|
699 | + echo ' |
|
672 | 700 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
673 | - elseif ($_GET['verse'] == '4:16') |
|
674 | - echo ' |
|
701 | + } elseif ($_GET['verse'] == '4:16') { |
|
702 | + echo ' |
|
675 | 703 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
676 | - elseif ($_GET['verse'] == '22:1-2') |
|
677 | - echo ' |
|
704 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
705 | + echo ' |
|
678 | 706 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
707 | + } |
|
679 | 708 | |
680 | 709 | echo ' |
681 | 710 | </div> |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $maxindex, true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -257,8 +270,9 @@ discard block |
||
257 | 270 | $context['sort_direction'] = $ascending ? 'up' : 'down'; |
258 | 271 | $txt['starter'] = $txt['started_by']; |
259 | 272 | |
260 | - foreach ($sort_methods as $key => $val) |
|
261 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
273 | + foreach ($sort_methods as $key => $val) { |
|
274 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
275 | + } |
|
262 | 276 | |
263 | 277 | // Calculate the fastest way to get the topics. |
264 | 278 | $start = (int) $_REQUEST['start']; |
@@ -268,14 +282,15 @@ discard block |
||
268 | 282 | $fake_ascending = true; |
269 | 283 | $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex; |
270 | 284 | $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex; |
285 | + } else { |
|
286 | + $fake_ascending = false; |
|
271 | 287 | } |
272 | - else |
|
273 | - $fake_ascending = false; |
|
274 | 288 | |
275 | 289 | // Setup the default topic icons... |
276 | 290 | $context['icon_sources'] = array(); |
277 | - foreach ($context['stable_icons'] as $icon) |
|
278 | - $context['icon_sources'][$icon] = 'images_url'; |
|
291 | + foreach ($context['stable_icons'] as $icon) { |
|
292 | + $context['icon_sources'][$icon] = 'images_url'; |
|
293 | + } |
|
279 | 294 | |
280 | 295 | $topic_ids = array(); |
281 | 296 | $context['topics'] = array(); |
@@ -306,8 +321,9 @@ discard block |
||
306 | 321 | ) |
307 | 322 | ); |
308 | 323 | $topic_ids = array(); |
309 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
310 | - $topic_ids[] = $row['id_topic']; |
|
324 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
325 | + $topic_ids[] = $row['id_topic']; |
|
326 | + } |
|
311 | 327 | } |
312 | 328 | |
313 | 329 | // Grab the appropriate topic information... |
@@ -363,11 +379,13 @@ discard block |
||
363 | 379 | // Begin 'printing' the message index for current board. |
364 | 380 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
365 | 381 | { |
366 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
367 | - continue; |
|
382 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
383 | + continue; |
|
384 | + } |
|
368 | 385 | |
369 | - if (!$pre_query) |
|
370 | - $topic_ids[] = $row['id_topic']; |
|
386 | + if (!$pre_query) { |
|
387 | + $topic_ids[] = $row['id_topic']; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // Reference the main color class. |
373 | 391 | $colorClass = 'windowbg'; |
@@ -377,8 +395,9 @@ discard block |
||
377 | 395 | { |
378 | 396 | // Limit them to $modSettings['preview_characters'] characters |
379 | 397 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
380 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
381 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
398 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
399 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
400 | + } |
|
382 | 401 | |
383 | 402 | // Censor the subject and message preview. |
384 | 403 | censorText($row['first_subject']); |
@@ -389,27 +408,27 @@ discard block |
||
389 | 408 | { |
390 | 409 | $row['last_subject'] = $row['first_subject']; |
391 | 410 | $row['last_body'] = $row['first_body']; |
392 | - } |
|
393 | - else |
|
411 | + } else |
|
394 | 412 | { |
395 | 413 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
396 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
397 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
414 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
415 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
416 | + } |
|
398 | 417 | |
399 | 418 | censorText($row['last_subject']); |
400 | 419 | censorText($row['last_body']); |
401 | 420 | } |
402 | - } |
|
403 | - else |
|
421 | + } else |
|
404 | 422 | { |
405 | 423 | $row['first_body'] = ''; |
406 | 424 | $row['last_body'] = ''; |
407 | 425 | censorText($row['first_subject']); |
408 | 426 | |
409 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
410 | - $row['last_subject'] = $row['first_subject']; |
|
411 | - else |
|
412 | - censorText($row['last_subject']); |
|
427 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
428 | + $row['last_subject'] = $row['first_subject']; |
|
429 | + } else { |
|
430 | + censorText($row['last_subject']); |
|
431 | + } |
|
413 | 432 | } |
414 | 433 | |
415 | 434 | // Decide how many pages the topic should have. |
@@ -420,42 +439,50 @@ discard block |
||
420 | 439 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
421 | 440 | |
422 | 441 | // If we can use all, show all. |
423 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
424 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
442 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
443 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
444 | + } |
|
445 | + } else { |
|
446 | + $pages = ''; |
|
425 | 447 | } |
426 | - else |
|
427 | - $pages = ''; |
|
428 | 448 | |
429 | 449 | // We need to check the topic icons exist... |
430 | 450 | if (!empty($modSettings['messageIconChecks_enable'])) |
431 | 451 | { |
432 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
433 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
434 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
435 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
436 | - } |
|
437 | - else |
|
452 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
453 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
454 | + } |
|
455 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
456 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
457 | + } |
|
458 | + } else |
|
438 | 459 | { |
439 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
440 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
441 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
442 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
460 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
461 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
462 | + } |
|
463 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
464 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
465 | + } |
|
443 | 466 | } |
444 | 467 | |
445 | - if (!empty($board_info['recycle'])) |
|
446 | - $row['first_icon'] = 'recycled'; |
|
468 | + if (!empty($board_info['recycle'])) { |
|
469 | + $row['first_icon'] = 'recycled'; |
|
470 | + } |
|
447 | 471 | |
448 | 472 | // Is this topic pending approval, or does it have any posts pending approval? |
449 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
450 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
473 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
474 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
475 | + } |
|
451 | 476 | |
452 | 477 | // Sticky topics should get a different color, too. |
453 | - if ($row['is_sticky']) |
|
454 | - $colorClass .= ' sticky'; |
|
478 | + if ($row['is_sticky']) { |
|
479 | + $colorClass .= ' sticky'; |
|
480 | + } |
|
455 | 481 | |
456 | 482 | // Locked topics get special treatment as well. |
457 | - if ($row['locked']) |
|
458 | - $colorClass .= ' locked'; |
|
483 | + if ($row['locked']) { |
|
484 | + $colorClass .= ' locked'; |
|
485 | + } |
|
459 | 486 | |
460 | 487 | // 'Print' the topic info. |
461 | 488 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -536,8 +563,9 @@ discard block |
||
536 | 563 | $smcFunc['db_free_result']($result); |
537 | 564 | |
538 | 565 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
539 | - if ($fake_ascending) |
|
540 | - $context['topics'] = array_reverse($context['topics'], true); |
|
566 | + if ($fake_ascending) { |
|
567 | + $context['topics'] = array_reverse($context['topics'], true); |
|
568 | + } |
|
541 | 569 | |
542 | 570 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) |
543 | 571 | { |
@@ -554,8 +582,9 @@ discard block |
||
554 | 582 | 'limit' => count($topic_ids), |
555 | 583 | ) |
556 | 584 | ); |
557 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
558 | - $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
586 | + $context['topics'][$row['id_topic']]['is_posted_in'] = true; |
|
587 | + } |
|
559 | 588 | $smcFunc['db_free_result']($result); |
560 | 589 | } |
561 | 590 | } |
@@ -580,9 +609,9 @@ discard block |
||
580 | 609 | // Can we restore topics? |
581 | 610 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
582 | 611 | |
583 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
584 | - $context['can_move_any'] = true; |
|
585 | - else |
|
612 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
613 | + $context['can_move_any'] = true; |
|
614 | + } else |
|
586 | 615 | { |
587 | 616 | // We'll use this in a minute |
588 | 617 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -609,11 +638,13 @@ discard block |
||
609 | 638 | } |
610 | 639 | |
611 | 640 | // Can we use quick moderation checkboxes? |
612 | - if ($options['display_quick_mod'] == 1) |
|
613 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
641 | + if ($options['display_quick_mod'] == 1) { |
|
642 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
643 | + } |
|
614 | 644 | // Or the icons? |
615 | - else |
|
616 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
645 | + else { |
|
646 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
647 | + } |
|
617 | 648 | } |
618 | 649 | |
619 | 650 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -647,13 +678,15 @@ discard block |
||
647 | 678 | ); |
648 | 679 | |
649 | 680 | // We've seen all these boards now! |
650 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
651 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
681 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
682 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
652 | 683 | unset($_SESSION['topicseen_cache'][$k]); |
684 | + } |
|
653 | 685 | } |
654 | 686 | |
655 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
656 | - unset($_SESSION['topicseen_cache'][$board]); |
|
687 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
688 | + unset($_SESSION['topicseen_cache'][$board]); |
|
689 | + } |
|
657 | 690 | |
658 | 691 | $request = $smcFunc['db_query']('', ' |
659 | 692 | SELECT id_topic, id_board, sent |
@@ -675,8 +708,9 @@ discard block |
||
675 | 708 | $context['is_marked_notify'] = true; |
676 | 709 | $board_sent = $row['sent']; |
677 | 710 | } |
678 | - if (!empty($row['id_topic'])) |
|
679 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
711 | + if (!empty($row['id_topic'])) { |
|
712 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
713 | + } |
|
680 | 714 | } |
681 | 715 | $smcFunc['db_free_result']($request); |
682 | 716 | |
@@ -700,8 +734,7 @@ discard block |
||
700 | 734 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
701 | 735 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
702 | 736 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
703 | - } |
|
704 | - else |
|
737 | + } else |
|
705 | 738 | { |
706 | 739 | $context['is_marked_notify'] = false; |
707 | 740 | $context['board_notification_mode'] = 1; |
@@ -714,23 +747,27 @@ discard block |
||
714 | 747 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
715 | 748 | |
716 | 749 | // Don't want to show this forever... |
717 | - if ($context['becomesUnapproved']) |
|
718 | - unset($_SESSION['becomesUnapproved']); |
|
750 | + if ($context['becomesUnapproved']) { |
|
751 | + unset($_SESSION['becomesUnapproved']); |
|
752 | + } |
|
719 | 753 | |
720 | 754 | // Build the message index button array. |
721 | 755 | $context['normal_buttons'] = array(); |
722 | 756 | |
723 | - if ($context['can_post_new']) |
|
724 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
757 | + if ($context['can_post_new']) { |
|
758 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
759 | + } |
|
725 | 760 | |
726 | - if ($context['can_post_poll']) |
|
727 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
761 | + if ($context['can_post_poll']) { |
|
762 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
763 | + } |
|
728 | 764 | |
729 | - if (!$context['user']['is_logged']) |
|
730 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
765 | + if (!$context['user']['is_logged']) { |
|
766 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
767 | + } |
|
731 | 768 | |
732 | - if ($context['can_mark_notify']) |
|
733 | - $context['normal_buttons']['notify'] = array( |
|
769 | + if ($context['can_mark_notify']) { |
|
770 | + $context['normal_buttons']['notify'] = array( |
|
734 | 771 | 'lang' => true, |
735 | 772 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
736 | 773 | 'sub_buttons' => array( |
@@ -748,6 +785,7 @@ discard block |
||
748 | 785 | ), |
749 | 786 | ), |
750 | 787 | ); |
788 | + } |
|
751 | 789 | |
752 | 790 | // Javascript for inline editing. |
753 | 791 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -769,18 +807,21 @@ discard block |
||
769 | 807 | checkSession('request'); |
770 | 808 | |
771 | 809 | // Lets go straight to the restore area. |
772 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
773 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
810 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
811 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
812 | + } |
|
774 | 813 | |
775 | - if (isset($_SESSION['topicseen_cache'])) |
|
776 | - $_SESSION['topicseen_cache'] = array(); |
|
814 | + if (isset($_SESSION['topicseen_cache'])) { |
|
815 | + $_SESSION['topicseen_cache'] = array(); |
|
816 | + } |
|
777 | 817 | |
778 | 818 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
779 | 819 | require_once($sourcedir . '/Subs-Post.php'); |
780 | 820 | |
781 | 821 | // Remember the last board they moved things to. |
782 | - if (isset($_REQUEST['move_to'])) |
|
783 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
822 | + if (isset($_REQUEST['move_to'])) { |
|
823 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
824 | + } |
|
784 | 825 | |
785 | 826 | // Only a few possible actions. |
786 | 827 | $possibleActions = array(); |
@@ -800,8 +841,7 @@ discard block |
||
800 | 841 | ); |
801 | 842 | |
802 | 843 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
803 | - } |
|
804 | - else |
|
844 | + } else |
|
805 | 845 | { |
806 | 846 | /** |
807 | 847 | * @todo Ugly. There's no getting around this, is there? |
@@ -819,8 +859,7 @@ discard block |
||
819 | 859 | if (!empty($board)) |
820 | 860 | { |
821 | 861 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
822 | - } |
|
823 | - else |
|
862 | + } else |
|
824 | 863 | { |
825 | 864 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
826 | 865 | } |
@@ -831,55 +870,67 @@ discard block |
||
831 | 870 | } |
832 | 871 | } |
833 | 872 | |
834 | - if (!$user_info['is_guest']) |
|
835 | - $possibleActions[] = 'markread'; |
|
836 | - if (!empty($boards_can['make_sticky'])) |
|
837 | - $possibleActions[] = 'sticky'; |
|
838 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
839 | - $possibleActions[] = 'move'; |
|
840 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
841 | - $possibleActions[] = 'remove'; |
|
842 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
843 | - $possibleActions[] = 'lock'; |
|
844 | - if (!empty($boards_can['merge_any'])) |
|
845 | - $possibleActions[] = 'merge'; |
|
846 | - if (!empty($boards_can['approve_posts'])) |
|
847 | - $possibleActions[] = 'approve'; |
|
873 | + if (!$user_info['is_guest']) { |
|
874 | + $possibleActions[] = 'markread'; |
|
875 | + } |
|
876 | + if (!empty($boards_can['make_sticky'])) { |
|
877 | + $possibleActions[] = 'sticky'; |
|
878 | + } |
|
879 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
880 | + $possibleActions[] = 'move'; |
|
881 | + } |
|
882 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
883 | + $possibleActions[] = 'remove'; |
|
884 | + } |
|
885 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
886 | + $possibleActions[] = 'lock'; |
|
887 | + } |
|
888 | + if (!empty($boards_can['merge_any'])) { |
|
889 | + $possibleActions[] = 'merge'; |
|
890 | + } |
|
891 | + if (!empty($boards_can['approve_posts'])) { |
|
892 | + $possibleActions[] = 'approve'; |
|
893 | + } |
|
848 | 894 | |
849 | 895 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
850 | 896 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
851 | 897 | if (!empty($_REQUEST['topics'])) |
852 | 898 | { |
853 | 899 | // If the action isn't valid, just quit now. |
854 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
855 | - redirectexit($redirect_url); |
|
900 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
901 | + redirectexit($redirect_url); |
|
902 | + } |
|
856 | 903 | |
857 | 904 | // Merge requires all topics as one parameter and can be done at once. |
858 | 905 | if ($_REQUEST['qaction'] == 'merge') |
859 | 906 | { |
860 | 907 | // Merge requires at least two topics. |
861 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
862 | - redirectexit($redirect_url); |
|
908 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
909 | + redirectexit($redirect_url); |
|
910 | + } |
|
863 | 911 | |
864 | 912 | require_once($sourcedir . '/SplitTopics.php'); |
865 | 913 | return MergeExecute($_REQUEST['topics']); |
866 | 914 | } |
867 | 915 | |
868 | 916 | // Just convert to the other method, to make it easier. |
869 | - foreach ($_REQUEST['topics'] as $topic) |
|
870 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
917 | + foreach ($_REQUEST['topics'] as $topic) { |
|
918 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
919 | + } |
|
871 | 920 | } |
872 | 921 | |
873 | 922 | // Weird... how'd you get here? |
874 | - if (empty($_REQUEST['actions'])) |
|
875 | - redirectexit($redirect_url); |
|
923 | + if (empty($_REQUEST['actions'])) { |
|
924 | + redirectexit($redirect_url); |
|
925 | + } |
|
876 | 926 | |
877 | 927 | // Validate each action. |
878 | 928 | $temp = array(); |
879 | 929 | foreach ($_REQUEST['actions'] as $topic => $action) |
880 | 930 | { |
881 | - if (in_array($action, $possibleActions)) |
|
882 | - $temp[(int) $topic] = $action; |
|
931 | + if (in_array($action, $possibleActions)) { |
|
932 | + $temp[(int) $topic] = $action; |
|
933 | + } |
|
883 | 934 | } |
884 | 935 | $_REQUEST['actions'] = $temp; |
885 | 936 | |
@@ -900,27 +951,31 @@ discard block |
||
900 | 951 | { |
901 | 952 | if (!empty($board)) |
902 | 953 | { |
903 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
904 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
905 | - } |
|
906 | - else |
|
954 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
955 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
956 | + } |
|
957 | + } else |
|
907 | 958 | { |
908 | 959 | // Don't allow them to act on unapproved posts they can't see... |
909 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
910 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
960 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
961 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
962 | + } |
|
911 | 963 | // Goodness, this is fun. We need to validate the action. |
912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
916 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
917 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
964 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
968 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
969 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
970 | + } |
|
918 | 971 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
919 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
920 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
972 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
973 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
974 | + } |
|
921 | 975 | // If the topic is approved then you need permission to approve the posts within. |
922 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
923 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
976 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
977 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
978 | + } |
|
924 | 979 | } |
925 | 980 | } |
926 | 981 | $smcFunc['db_free_result']($request); |
@@ -938,11 +993,11 @@ discard block |
||
938 | 993 | { |
939 | 994 | $topic = (int) $topic; |
940 | 995 | |
941 | - if ($action == 'markread') |
|
942 | - $markCache[] = $topic; |
|
943 | - elseif ($action == 'sticky') |
|
944 | - $stickyCache[] = $topic; |
|
945 | - elseif ($action == 'move') |
|
996 | + if ($action == 'markread') { |
|
997 | + $markCache[] = $topic; |
|
998 | + } elseif ($action == 'sticky') { |
|
999 | + $stickyCache[] = $topic; |
|
1000 | + } elseif ($action == 'move') |
|
946 | 1001 | { |
947 | 1002 | require_once($sourcedir . '/MoveTopic.php'); |
948 | 1003 | moveTopicConcurrence(); |
@@ -950,23 +1005,25 @@ discard block |
||
950 | 1005 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
951 | 1006 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
952 | 1007 | |
953 | - if (empty($moveCache[1][$topic])) |
|
954 | - continue; |
|
1008 | + if (empty($moveCache[1][$topic])) { |
|
1009 | + continue; |
|
1010 | + } |
|
955 | 1011 | |
956 | 1012 | $moveCache[0][] = $topic; |
1013 | + } elseif ($action == 'remove') { |
|
1014 | + $removeCache[] = $topic; |
|
1015 | + } elseif ($action == 'lock') { |
|
1016 | + $lockCache[] = $topic; |
|
1017 | + } elseif ($action == 'approve') { |
|
1018 | + $approveCache[] = $topic; |
|
957 | 1019 | } |
958 | - elseif ($action == 'remove') |
|
959 | - $removeCache[] = $topic; |
|
960 | - elseif ($action == 'lock') |
|
961 | - $lockCache[] = $topic; |
|
962 | - elseif ($action == 'approve') |
|
963 | - $approveCache[] = $topic; |
|
964 | 1020 | } |
965 | 1021 | |
966 | - if (empty($board)) |
|
967 | - $affectedBoards = array(); |
|
968 | - else |
|
969 | - $affectedBoards = array($board => array(0, 0)); |
|
1022 | + if (empty($board)) { |
|
1023 | + $affectedBoards = array(); |
|
1024 | + } else { |
|
1025 | + $affectedBoards = array($board => array(0, 0)); |
|
1026 | + } |
|
970 | 1027 | |
971 | 1028 | // Do all the stickies... |
972 | 1029 | if (!empty($stickyCache)) |
@@ -1026,14 +1083,16 @@ discard block |
||
1026 | 1083 | { |
1027 | 1084 | $to = $moveCache[1][$row['id_topic']]; |
1028 | 1085 | |
1029 | - if (empty($to)) |
|
1030 | - continue; |
|
1086 | + if (empty($to)) { |
|
1087 | + continue; |
|
1088 | + } |
|
1031 | 1089 | |
1032 | 1090 | // Does this topic's board count the posts or not? |
1033 | 1091 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1034 | 1092 | |
1035 | - if (!isset($moveTos[$to])) |
|
1036 | - $moveTos[$to] = array(); |
|
1093 | + if (!isset($moveTos[$to])) { |
|
1094 | + $moveTos[$to] = array(); |
|
1095 | + } |
|
1037 | 1096 | |
1038 | 1097 | $moveTos[$to][] = $row['id_topic']; |
1039 | 1098 | |
@@ -1047,8 +1106,9 @@ discard block |
||
1047 | 1106 | require_once($sourcedir . '/MoveTopic.php'); |
1048 | 1107 | |
1049 | 1108 | // Do the actual moves... |
1050 | - foreach ($moveTos as $to => $topics) |
|
1051 | - moveTopics($topics, $to); |
|
1109 | + foreach ($moveTos as $to => $topics) { |
|
1110 | + moveTopics($topics, $to); |
|
1111 | + } |
|
1052 | 1112 | |
1053 | 1113 | // Does the post counts need to be updated? |
1054 | 1114 | if (!empty($moveTos)) |
@@ -1097,20 +1157,23 @@ discard block |
||
1097 | 1157 | |
1098 | 1158 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1099 | 1159 | { |
1100 | - if (!isset($members[$row['id_member']])) |
|
1101 | - $members[$row['id_member']] = 0; |
|
1160 | + if (!isset($members[$row['id_member']])) { |
|
1161 | + $members[$row['id_member']] = 0; |
|
1162 | + } |
|
1102 | 1163 | |
1103 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1104 | - $members[$row['id_member']] += 1; |
|
1105 | - else |
|
1106 | - $members[$row['id_member']] -= 1; |
|
1164 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1165 | + $members[$row['id_member']] += 1; |
|
1166 | + } else { |
|
1167 | + $members[$row['id_member']] -= 1; |
|
1168 | + } |
|
1107 | 1169 | } |
1108 | 1170 | |
1109 | 1171 | $smcFunc['db_free_result']($request); |
1110 | 1172 | |
1111 | 1173 | // And now update them member's post counts |
1112 | - foreach ($members as $id_member => $post_adj) |
|
1113 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1174 | + foreach ($members as $id_member => $post_adj) { |
|
1175 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1176 | + } |
|
1114 | 1177 | |
1115 | 1178 | } |
1116 | 1179 | } |
@@ -1190,8 +1253,9 @@ discard block |
||
1190 | 1253 | approveTopics($approveCache); |
1191 | 1254 | |
1192 | 1255 | // Time for some logging! |
1193 | - foreach ($approveCache as $topic) |
|
1194 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1256 | + foreach ($approveCache as $topic) { |
|
1257 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1258 | + } |
|
1195 | 1259 | } |
1196 | 1260 | } |
1197 | 1261 | |
@@ -1226,8 +1290,7 @@ discard block |
||
1226 | 1290 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1227 | 1291 | } |
1228 | 1292 | $smcFunc['db_free_result']($result); |
1229 | - } |
|
1230 | - else |
|
1293 | + } else |
|
1231 | 1294 | { |
1232 | 1295 | $result = $smcFunc['db_query']('', ' |
1233 | 1296 | SELECT id_topic, locked, id_board |
@@ -1277,13 +1340,15 @@ discard block |
||
1277 | 1340 | ) |
1278 | 1341 | ); |
1279 | 1342 | $logged_topics = array(); |
1280 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1281 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1343 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1344 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1345 | + } |
|
1282 | 1346 | $smcFunc['db_free_result']($request); |
1283 | 1347 | |
1284 | 1348 | $markArray = array(); |
1285 | - foreach ($markCache as $topic) |
|
1286 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1349 | + foreach ($markCache as $topic) { |
|
1350 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1351 | + } |
|
1287 | 1352 | |
1288 | 1353 | $smcFunc['db_insert']('replace', |
1289 | 1354 | '{db_prefix}log_topics', |
@@ -1296,8 +1361,9 @@ discard block |
||
1296 | 1361 | foreach ($moveCache as $topic) |
1297 | 1362 | { |
1298 | 1363 | // Didn't actually move anything! |
1299 | - if (!isset($topic[0])) |
|
1300 | - break; |
|
1364 | + if (!isset($topic[0])) { |
|
1365 | + break; |
|
1366 | + } |
|
1301 | 1367 | |
1302 | 1368 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1303 | 1369 | sendNotifications($topic[0], 'move'); |
@@ -1319,8 +1385,9 @@ discard block |
||
1319 | 1385 | 'calendar_updated' => time(), |
1320 | 1386 | )); |
1321 | 1387 | |
1322 | - if (!empty($affectedBoards)) |
|
1323 | - updateLastMessages(array_keys($affectedBoards)); |
|
1388 | + if (!empty($affectedBoards)) { |
|
1389 | + updateLastMessages(array_keys($affectedBoards)); |
|
1390 | + } |
|
1324 | 1391 | |
1325 | 1392 | redirectexit($redirect_url); |
1326 | 1393 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $board, $topic, $scripturl, $sourcedir, $modSettings, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
171 | 179 | { |
172 | - if ($id_member_started == $user_info['id']) |
|
173 | - isAllowedTo('move_own'); |
|
174 | - else |
|
175 | - isAllowedTo('move_any'); |
|
180 | + if ($id_member_started == $user_info['id']) { |
|
181 | + isAllowedTo('move_own'); |
|
182 | + } else { |
|
183 | + isAllowedTo('move_any'); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | |
178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | 'blank_redirect' => '', |
198 | 207 | ) |
199 | 208 | ); |
200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
201 | - fatal_lang_error('no_board'); |
|
209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
210 | + fatal_lang_error('no_board'); |
|
211 | + } |
|
202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
203 | 213 | $smcFunc['db_free_result']($request); |
204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
210 | 220 | { |
211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
212 | 222 | // Keep checking the length. |
213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
225 | + } |
|
215 | 226 | |
216 | 227 | // If it's still valid move onwards and upwards. |
217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
221 | 232 | // Get a response prefix, but in the forum's default language. |
222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
223 | 234 | { |
224 | - if ($language === $user_info['language']) |
|
225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
226 | - else |
|
235 | + if ($language === $user_info['language']) { |
|
236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
237 | + } else |
|
227 | 238 | { |
228 | 239 | loadLanguage('index', $language, false); |
229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
263 | 274 | if (isset($_POST['postRedirect'])) |
264 | 275 | { |
265 | 276 | // Should be in the boardwide language. |
266 | - if ($user_info['language'] != $language) |
|
267 | - loadLanguage('index', $language); |
|
277 | + if ($user_info['language'] != $language) { |
|
278 | + loadLanguage('index', $language); |
|
279 | + } |
|
268 | 280 | |
269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
328 | 340 | $posters = array(); |
329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
330 | 342 | { |
331 | - if (!isset($posters[$row['id_member']])) |
|
332 | - $posters[$row['id_member']] = 0; |
|
343 | + if (!isset($posters[$row['id_member']])) { |
|
344 | + $posters[$row['id_member']] = 0; |
|
345 | + } |
|
333 | 346 | |
334 | 347 | $posters[$row['id_member']]++; |
335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
338 | 351 | foreach ($posters as $id_member => $posts) |
339 | 352 | { |
340 | 353 | // The board we're moving from counted posts, but not to. |
341 | - if (empty($pcounter_from)) |
|
342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
354 | + if (empty($pcounter_from)) { |
|
355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
356 | + } |
|
343 | 357 | // The reverse: from didn't, to did. |
344 | - else |
|
345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
358 | + else { |
|
359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
360 | + } |
|
346 | 361 | } |
347 | 362 | } |
348 | 363 | |
@@ -350,17 +365,19 @@ discard block |
||
350 | 365 | moveTopics($topic, $_POST['toboard']); |
351 | 366 | |
352 | 367 | // Log that they moved this topic. |
353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
370 | + } |
|
355 | 371 | // Notify people that this topic has been moved? |
356 | 372 | sendNotifications($topic, 'move'); |
357 | 373 | |
358 | 374 | // Why not go back to the original board in case they want to keep moving? |
359 | - if (!isset($_REQUEST['goback'])) |
|
360 | - redirectexit('board=' . $board . '.0'); |
|
361 | - else |
|
362 | - redirectexit('topic=' . $topic . '.0'); |
|
363 | -} |
|
375 | + if (!isset($_REQUEST['goback'])) { |
|
376 | + redirectexit('board=' . $board . '.0'); |
|
377 | + } else { |
|
378 | + redirectexit('topic=' . $topic . '.0'); |
|
379 | + } |
|
380 | + } |
|
364 | 381 | |
365 | 382 | /** |
366 | 383 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -376,18 +393,21 @@ discard block |
||
376 | 393 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
377 | 394 | |
378 | 395 | // Empty array? |
379 | - if (empty($topics)) |
|
380 | - return; |
|
396 | + if (empty($topics)) { |
|
397 | + return; |
|
398 | + } |
|
381 | 399 | |
382 | 400 | // Only a single topic. |
383 | - if (is_numeric($topics)) |
|
384 | - $topics = array($topics); |
|
401 | + if (is_numeric($topics)) { |
|
402 | + $topics = array($topics); |
|
403 | + } |
|
385 | 404 | |
386 | 405 | $fromBoards = array(); |
387 | 406 | |
388 | 407 | // Destination board empty or equal to 0? |
389 | - if (empty($toBoard)) |
|
390 | - return; |
|
408 | + if (empty($toBoard)) { |
|
409 | + return; |
|
410 | + } |
|
391 | 411 | |
392 | 412 | // Are we moving to the recycle board? |
393 | 413 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -395,8 +415,9 @@ discard block |
||
395 | 415 | // Callback for search APIs to do their thing |
396 | 416 | require_once($sourcedir . '/Search.php'); |
397 | 417 | $searchAPI = findSearchAPI(); |
398 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
399 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
418 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
419 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
420 | + } |
|
400 | 421 | |
401 | 422 | // Determine the source boards... |
402 | 423 | $request = $smcFunc['db_query']('', ' |
@@ -410,8 +431,9 @@ discard block |
||
410 | 431 | ) |
411 | 432 | ); |
412 | 433 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
413 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
414 | - return; |
|
434 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
435 | + return; |
|
436 | + } |
|
415 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
416 | 438 | { |
417 | 439 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -429,10 +451,11 @@ discard block |
||
429 | 451 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
430 | 452 | |
431 | 453 | // Add the topics to the right type. |
432 | - if ($row['approved']) |
|
433 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
434 | - else |
|
435 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
454 | + if ($row['approved']) { |
|
455 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
456 | + } else { |
|
457 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
458 | + } |
|
436 | 459 | } |
437 | 460 | $smcFunc['db_free_result']($request); |
438 | 461 | |
@@ -558,13 +581,14 @@ discard block |
||
558 | 581 | ) |
559 | 582 | ); |
560 | 583 | $approval_msgs = array(); |
561 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
562 | - $approval_msgs[] = $row['id_msg']; |
|
584 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
585 | + $approval_msgs[] = $row['id_msg']; |
|
586 | + } |
|
563 | 587 | $smcFunc['db_free_result']($request); |
564 | 588 | |
565 | 589 | // Empty the approval queue for these, as we're going to approve them next. |
566 | - if (!empty($approval_msgs)) |
|
567 | - $smcFunc['db_query']('', ' |
|
590 | + if (!empty($approval_msgs)) { |
|
591 | + $smcFunc['db_query']('', ' |
|
568 | 592 | DELETE FROM {db_prefix}approval_queue |
569 | 593 | WHERE id_msg IN ({array_int:message_list}) |
570 | 594 | AND id_attach = {int:id_attach}', |
@@ -573,6 +597,7 @@ discard block |
||
573 | 597 | 'id_attach' => 0, |
574 | 598 | ) |
575 | 599 | ); |
600 | + } |
|
576 | 601 | |
577 | 602 | // Get all the current max and mins. |
578 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -606,8 +631,8 @@ discard block |
||
606 | 631 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
607 | 632 | { |
608 | 633 | // If not, update. |
609 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
610 | - $smcFunc['db_query']('', ' |
|
634 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
635 | + $smcFunc['db_query']('', ' |
|
611 | 636 | UPDATE {db_prefix}topics |
612 | 637 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
613 | 638 | WHERE id_topic = {int:selected_topic}', |
@@ -617,6 +642,7 @@ discard block |
||
617 | 642 | 'selected_topic' => $row['id_topic'], |
618 | 643 | ) |
619 | 644 | ); |
645 | + } |
|
620 | 646 | } |
621 | 647 | $smcFunc['db_free_result']($request); |
622 | 648 | } |
@@ -675,9 +701,10 @@ discard block |
||
675 | 701 | } |
676 | 702 | |
677 | 703 | // Update the cache? |
678 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
679 | - foreach ($topics as $topic_id) |
|
704 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
705 | + foreach ($topics as $topic_id) |
|
680 | 706 | cache_put_data('topic_board-' . $topic_id, null, 120); |
707 | + } |
|
681 | 708 | |
682 | 709 | require_once($sourcedir . '/Subs-Post.php'); |
683 | 710 | |
@@ -701,15 +728,17 @@ discard block |
||
701 | 728 | { |
702 | 729 | global $board, $topic, $smcFunc, $scripturl; |
703 | 730 | |
704 | - if (isset($_GET['current_board'])) |
|
705 | - $move_from = (int) $_GET['current_board']; |
|
731 | + if (isset($_GET['current_board'])) { |
|
732 | + $move_from = (int) $_GET['current_board']; |
|
733 | + } |
|
706 | 734 | |
707 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
708 | - return true; |
|
735 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
736 | + return true; |
|
737 | + } |
|
709 | 738 | |
710 | - if ($move_from == $board) |
|
711 | - return true; |
|
712 | - else |
|
739 | + if ($move_from == $board) { |
|
740 | + return true; |
|
741 | + } else |
|
713 | 742 | { |
714 | 743 | $request = $smcFunc['db_query']('', ' |
715 | 744 | SELECT m.subject, b.name |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 3 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -65,19 +68,21 @@ discard block |
||
65 | 68 | @ini_set('session.serialize_handler', 'php'); |
66 | 69 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
67 | 70 | @ini_set('session.gc_probability', '1'); |
71 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
72 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
68 | 73 | } |
69 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
70 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
71 | 74 | |
72 | 75 | // Use cache setting sessions? |
73 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
74 | - call_integration_hook('integrate_session_handlers'); |
|
76 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
77 | + call_integration_hook('integrate_session_handlers'); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | session_start(); |
77 | 81 | |
78 | 82 | // Change it so the cache settings are a little looser than default. |
79 | - if (!empty($modSettings['databaseSession_loose'])) |
|
80 | - header('Cache-Control: private'); |
|
83 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
84 | + header('Cache-Control: private'); |
|
85 | + } |
|
81 | 86 | } |
82 | 87 | |
83 | 88 | // Set the randomly generated code. |
@@ -123,8 +128,9 @@ discard block |
||
123 | 128 | { |
124 | 129 | global $smcFunc; |
125 | 130 | |
126 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
127 | - return ''; |
|
131 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
132 | + return ''; |
|
133 | + } |
|
128 | 134 | |
129 | 135 | // Look for it in the database. |
130 | 136 | $result = $smcFunc['db_query']('', ' |
@@ -153,8 +159,9 @@ discard block |
||
153 | 159 | { |
154 | 160 | global $smcFunc; |
155 | 161 | |
156 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
157 | - return false; |
|
162 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
163 | + return false; |
|
164 | + } |
|
158 | 165 | |
159 | 166 | // First try to update an existing row... |
160 | 167 | $smcFunc['db_query']('', ' |
@@ -169,13 +176,14 @@ discard block |
||
169 | 176 | ); |
170 | 177 | |
171 | 178 | // If that didn't work, try inserting a new one. |
172 | - if ($smcFunc['db_affected_rows']() == 0) |
|
173 | - $smcFunc['db_insert']('ignore', |
|
179 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
180 | + $smcFunc['db_insert']('ignore', |
|
174 | 181 | '{db_prefix}sessions', |
175 | 182 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
176 | 183 | array($session_id, $data, time()), |
177 | 184 | array('session_id') |
178 | 185 | ); |
186 | + } |
|
179 | 187 | |
180 | 188 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
181 | 189 | } |
@@ -190,8 +198,9 @@ discard block |
||
190 | 198 | { |
191 | 199 | global $smcFunc; |
192 | 200 | |
193 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
194 | - return false; |
|
201 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
202 | + return false; |
|
203 | + } |
|
195 | 204 | |
196 | 205 | // Just delete the row... |
197 | 206 | $smcFunc['db_query']('', ' |
@@ -217,8 +226,9 @@ discard block |
||
217 | 226 | global $modSettings, $smcFunc; |
218 | 227 | |
219 | 228 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
220 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
221 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
229 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
230 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
231 | + } |
|
222 | 232 | |
223 | 233 | // Clean up after yerself ;). |
224 | 234 | $smcFunc['db_query']('', ' |