@@ -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 | * Entrance point for the registration center, it checks permissions and forwards |
@@ -31,8 +32,9 @@ discard block |
||
31 | 32 | global $context, $txt; |
32 | 33 | |
33 | 34 | // Old templates might still request this. |
34 | - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') |
|
35 | - redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
35 | + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'browse') { |
|
36 | + redirectexit('action=admin;area=viewmembers;sa=browse' . (isset($_REQUEST['type']) ? ';type=' . $_REQUEST['type'] : '')); |
|
37 | + } |
|
36 | 38 | |
37 | 39 | $subActions = array( |
38 | 40 | 'register' => array('AdminRegister', 'moderate_forum'), |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | checkSession(); |
100 | 102 | validateToken('admin-regc'); |
101 | 103 | |
102 | - foreach ($_POST as $key => $value) |
|
103 | - if (!is_array($_POST[$key])) |
|
104 | + foreach ($_POST as $key => $value) { |
|
105 | + if (!is_array($_POST[$key])) |
|
104 | 106 | $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key])); |
107 | + } |
|
105 | 108 | |
106 | 109 | $regOptions = array( |
107 | 110 | 'interface' => 'admin', |
@@ -161,12 +164,13 @@ discard block |
||
161 | 164 | ) |
162 | 165 | ); |
163 | 166 | $context['member_groups'] = array(0 => $txt['admin_register_group_none']); |
164 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
165 | - $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
167 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
168 | + $context['member_groups'][$row['id_group']] = $row['group_name']; |
|
169 | + } |
|
166 | 170 | $smcFunc['db_free_result']($request); |
171 | + } else { |
|
172 | + $context['member_groups'] = array(); |
|
167 | 173 | } |
168 | - else |
|
169 | - $context['member_groups'] = array(); |
|
170 | 174 | |
171 | 175 | // Basic stuff. |
172 | 176 | $context['sub_template'] = 'admin_register'; |
@@ -207,8 +211,9 @@ discard block |
||
207 | 211 | { |
208 | 212 | $context['editable_agreements']['.' . $lang['filename']] = $lang['name']; |
209 | 213 | // Are we editing this? |
210 | - if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) |
|
211 | - $context['current_agreement'] = '.' . $lang['filename']; |
|
214 | + if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) { |
|
215 | + $context['current_agreement'] = '.' . $lang['filename']; |
|
216 | + } |
|
212 | 217 | } |
213 | 218 | } |
214 | 219 | |
@@ -223,10 +228,11 @@ discard block |
||
223 | 228 | |
224 | 229 | updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement']))); |
225 | 230 | |
226 | - if ($bytes == strlen($to_write)) |
|
227 | - $context['saved_successful'] = true; |
|
228 | - else |
|
229 | - $context['could_not_save'] = true; |
|
231 | + if ($bytes == strlen($to_write)) { |
|
232 | + $context['saved_successful'] = true; |
|
233 | + } else { |
|
234 | + $context['could_not_save'] = true; |
|
235 | + } |
|
230 | 236 | } |
231 | 237 | |
232 | 238 | $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? $smcFunc['htmlspecialchars'](file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : ''; |
@@ -310,8 +316,9 @@ discard block |
||
310 | 316 | |
311 | 317 | call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); |
312 | 318 | |
313 | - if ($return_config) |
|
314 | - return $config_vars; |
|
319 | + if ($return_config) { |
|
320 | + return $config_vars; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // Setup the template |
317 | 324 | $context['sub_template'] = 'show_settings'; |
@@ -322,8 +329,9 @@ discard block |
||
322 | 329 | checkSession(); |
323 | 330 | |
324 | 331 | // Are there some contacts missing? |
325 | - if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) |
|
326 | - fatal_lang_error('admin_setting_coppa_require_contact'); |
|
332 | + if (!empty($_POST['coppaAge']) && !empty($_POST['coppaType']) && empty($_POST['coppaPost']) && empty($_POST['coppaFax'])) { |
|
333 | + fatal_lang_error('admin_setting_coppa_require_contact'); |
|
334 | + } |
|
327 | 335 | |
328 | 336 | // Post needs to take into account line breaks. |
329 | 337 | $_POST['coppaPost'] = str_replace("\n", '<br>', empty($_POST['coppaPost']) ? '' : $_POST['coppaPost']); |
@@ -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 | * The main dispatcher; doesn't do anything, just delegates. |
@@ -92,18 +93,19 @@ discard block |
||
92 | 93 | checkSession('get'); |
93 | 94 | validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); |
94 | 95 | |
95 | - if ($_REQUEST['move_to'] === 'top') |
|
96 | - $boardOptions = array( |
|
96 | + if ($_REQUEST['move_to'] === 'top') { |
|
97 | + $boardOptions = array( |
|
97 | 98 | 'move_to' => $_REQUEST['move_to'], |
98 | 99 | 'target_category' => (int) $_REQUEST['target_cat'], |
99 | 100 | 'move_first_child' => true, |
100 | 101 | ); |
101 | - else |
|
102 | - $boardOptions = array( |
|
102 | + } else { |
|
103 | + $boardOptions = array( |
|
103 | 104 | 'move_to' => $_REQUEST['move_to'], |
104 | 105 | 'target_board' => (int) $_REQUEST['target_board'], |
105 | 106 | 'move_first_child' => true, |
106 | 107 | ); |
108 | + } |
|
107 | 109 | modifyBoard((int) $_REQUEST['src_board'], $boardOptions); |
108 | 110 | } |
109 | 111 | |
@@ -148,15 +150,16 @@ discard block |
||
148 | 150 | $security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token']; |
149 | 151 | foreach ($boardList[$catid] as $boardid) |
150 | 152 | { |
151 | - if (!isset($context['categories'][$catid]['move_link'])) |
|
152 | - $context['categories'][$catid]['move_link'] = array( |
|
153 | + if (!isset($context['categories'][$catid]['move_link'])) { |
|
154 | + $context['categories'][$catid]['move_link'] = array( |
|
153 | 155 | 'child_level' => 0, |
154 | 156 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
155 | 157 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security, |
156 | 158 | ); |
159 | + } |
|
157 | 160 | |
158 | - if (!$context['categories'][$catid]['boards'][$boardid]['move']) |
|
159 | - $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
161 | + if (!$context['categories'][$catid]['boards'][$boardid]['move']) { |
|
162 | + $context['categories'][$catid]['boards'][$boardid]['move_links'] = array( |
|
160 | 163 | array( |
161 | 164 | 'child_level' => $boards[$boardid]['level'], |
162 | 165 | 'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'', |
@@ -170,34 +173,39 @@ discard block |
||
170 | 173 | 'class' => 'here', |
171 | 174 | ), |
172 | 175 | ); |
176 | + } |
|
173 | 177 | |
174 | 178 | $difference = $boards[$boardid]['level'] - $prev_child_level; |
175 | - if ($difference == 1) |
|
176 | - array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
177 | - elseif ($difference < 0) |
|
179 | + if ($difference == 1) { |
|
180 | + array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null); |
|
181 | + } elseif ($difference < 0) |
|
178 | 182 | { |
179 | - if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
180 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
181 | - for ($i = 0; $i < -$difference; $i++) |
|
182 | - if (($temp = array_pop($stack)) != null) |
|
183 | + if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
184 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array(); |
|
185 | + } |
|
186 | + for ($i = 0; $i < -$difference; $i++) { |
|
187 | + if (($temp = array_pop($stack)) != null) |
|
183 | 188 | array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp); |
189 | + } |
|
184 | 190 | } |
185 | 191 | |
186 | 192 | $prev_board = $boardid; |
187 | 193 | $prev_child_level = $boards[$boardid]['level']; |
188 | 194 | |
189 | 195 | } |
190 | - if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) |
|
191 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
192 | - elseif (!empty($stack)) |
|
193 | - $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
196 | + if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links'])) { |
|
197 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']); |
|
198 | + } elseif (!empty($stack)) { |
|
199 | + $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack; |
|
200 | + } |
|
194 | 201 | |
195 | - if (empty($boardList[$catid])) |
|
196 | - $context['categories'][$catid]['move_link'] = array( |
|
202 | + if (empty($boardList[$catid])) { |
|
203 | + $context['categories'][$catid]['move_link'] = array( |
|
197 | 204 | 'child_level' => 0, |
198 | 205 | 'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'', |
199 | 206 | 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security, |
200 | 207 | ); |
208 | + } |
|
201 | 209 | } |
202 | 210 | } |
203 | 211 | |
@@ -253,9 +261,9 @@ discard block |
||
253 | 261 | ); |
254 | 262 | } |
255 | 263 | // Category doesn't exist, man... sorry. |
256 | - elseif (!isset($cat_tree[$_REQUEST['cat']])) |
|
257 | - redirectexit('action=admin;area=manageboards'); |
|
258 | - else |
|
264 | + elseif (!isset($cat_tree[$_REQUEST['cat']])) { |
|
265 | + redirectexit('action=admin;area=manageboards'); |
|
266 | + } else |
|
259 | 267 | { |
260 | 268 | $context['category'] = array( |
261 | 269 | 'id' => $_REQUEST['cat'], |
@@ -267,30 +275,31 @@ discard block |
||
267 | 275 | 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children']) |
268 | 276 | ); |
269 | 277 | |
270 | - foreach ($boardList[$_REQUEST['cat']] as $child_board) |
|
271 | - $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
278 | + foreach ($boardList[$_REQUEST['cat']] as $child_board) { |
|
279 | + $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name']; |
|
280 | + } |
|
272 | 281 | } |
273 | 282 | |
274 | 283 | $prevCat = 0; |
275 | 284 | foreach ($cat_tree as $catid => $tree) |
276 | 285 | { |
277 | - if ($catid == $_REQUEST['cat'] && $prevCat > 0) |
|
278 | - $context['category_order'][$prevCat]['selected'] = true; |
|
279 | - elseif ($catid != $_REQUEST['cat']) |
|
280 | - $context['category_order'][$catid] = array( |
|
286 | + if ($catid == $_REQUEST['cat'] && $prevCat > 0) { |
|
287 | + $context['category_order'][$prevCat]['selected'] = true; |
|
288 | + } elseif ($catid != $_REQUEST['cat']) { |
|
289 | + $context['category_order'][$catid] = array( |
|
281 | 290 | 'id' => $catid, |
282 | 291 | 'name' => $txt['mboards_order_after'] . $tree['node']['name'], |
283 | 292 | 'selected' => false, |
284 | 293 | 'true_name' => $tree['node']['name'] |
285 | 294 | ); |
295 | + } |
|
286 | 296 | $prevCat = $catid; |
287 | 297 | } |
288 | 298 | if (!isset($_REQUEST['delete'])) |
289 | 299 | { |
290 | 300 | $context['sub_template'] = 'modify_category'; |
291 | 301 | $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit']; |
292 | - } |
|
293 | - else |
|
302 | + } else |
|
294 | 303 | { |
295 | 304 | $context['sub_template'] = 'confirm_category_delete'; |
296 | 305 | $context['page_title'] = $txt['mboards_delete_cat']; |
@@ -327,8 +336,9 @@ discard block |
||
327 | 336 | { |
328 | 337 | $catOptions = array(); |
329 | 338 | |
330 | - if (isset($_POST['cat_order'])) |
|
331 | - $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
339 | + if (isset($_POST['cat_order'])) { |
|
340 | + $catOptions['move_after'] = (int) $_POST['cat_order']; |
|
341 | + } |
|
332 | 342 | |
333 | 343 | // Change "This & That" to "This & That" but don't change "¢" to "&cent;"... |
334 | 344 | $catOptions['cat_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['cat_name']), false, '', $context['description_allowed_tags']); |
@@ -336,10 +346,11 @@ discard block |
||
336 | 346 | |
337 | 347 | $catOptions['is_collapsible'] = isset($_POST['collapse']); |
338 | 348 | |
339 | - if (isset($_POST['add'])) |
|
340 | - createCategory($catOptions); |
|
341 | - else |
|
342 | - modifyCategory($_POST['cat'], $catOptions); |
|
349 | + if (isset($_POST['add'])) { |
|
350 | + createCategory($catOptions); |
|
351 | + } else { |
|
352 | + modifyCategory($_POST['cat'], $catOptions); |
|
353 | + } |
|
343 | 354 | } |
344 | 355 | // If they want to delete - first give them confirmation. |
345 | 356 | elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty'])) |
@@ -353,13 +364,14 @@ discard block |
||
353 | 364 | // First off - check if we are moving all the current boards first - before we start deleting! |
354 | 365 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
355 | 366 | { |
356 | - if (empty($_POST['cat_to'])) |
|
357 | - fatal_lang_error('mboards_delete_error'); |
|
367 | + if (empty($_POST['cat_to'])) { |
|
368 | + fatal_lang_error('mboards_delete_error'); |
|
369 | + } |
|
358 | 370 | |
359 | 371 | deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']); |
372 | + } else { |
|
373 | + deleteCategories(array($_POST['cat'])); |
|
360 | 374 | } |
361 | - else |
|
362 | - deleteCategories(array($_POST['cat'])); |
|
363 | 375 | } |
364 | 376 | |
365 | 377 | redirectexit('action=admin;area=manageboards'); |
@@ -404,8 +416,9 @@ discard block |
||
404 | 416 | if ($_REQUEST['sa'] == 'newboard') |
405 | 417 | { |
406 | 418 | // Category doesn't exist, man... sorry. |
407 | - if (empty($_REQUEST['cat'])) |
|
408 | - redirectexit('action=admin;area=manageboards'); |
|
419 | + if (empty($_REQUEST['cat'])) { |
|
420 | + redirectexit('action=admin;area=manageboards'); |
|
421 | + } |
|
409 | 422 | |
410 | 423 | // Some things that need to be setup for a new board. |
411 | 424 | $curBoard = array( |
@@ -429,8 +442,7 @@ discard block |
||
429 | 442 | 'category' => (int) $_REQUEST['cat'], |
430 | 443 | 'no_children' => true, |
431 | 444 | ); |
432 | - } |
|
433 | - else |
|
445 | + } else |
|
434 | 446 | { |
435 | 447 | // Just some easy shortcuts. |
436 | 448 | $curBoard = &$boards[$_REQUEST['boardid']]; |
@@ -478,8 +490,9 @@ discard block |
||
478 | 490 | ); |
479 | 491 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
480 | 492 | { |
481 | - if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) |
|
482 | - $curBoard['member_groups'][] = $row['id_group']; |
|
493 | + if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1) { |
|
494 | + $curBoard['member_groups'][] = $row['id_group']; |
|
495 | + } |
|
483 | 496 | |
484 | 497 | $context['groups'][(int) $row['id_group']] = array( |
485 | 498 | 'id' => $row['id_group'], |
@@ -492,8 +505,9 @@ discard block |
||
492 | 505 | $smcFunc['db_free_result']($request); |
493 | 506 | |
494 | 507 | // Category doesn't exist, man... sorry. |
495 | - if (!isset($boardList[$curBoard['category']])) |
|
496 | - redirectexit('action=admin;area=manageboards'); |
|
508 | + if (!isset($boardList[$curBoard['category']])) { |
|
509 | + redirectexit('action=admin;area=manageboards'); |
|
510 | + } |
|
497 | 511 | |
498 | 512 | foreach ($boardList[$curBoard['category']] as $boardid) |
499 | 513 | { |
@@ -507,8 +521,7 @@ discard block |
||
507 | 521 | 'is_child' => false, |
508 | 522 | 'selected' => true |
509 | 523 | ); |
510 | - } |
|
511 | - else |
|
524 | + } else |
|
512 | 525 | { |
513 | 526 | $context['board_order'][] = array( |
514 | 527 | 'id' => $boardid, |
@@ -525,19 +538,21 @@ discard block |
||
525 | 538 | $context['can_move_children'] = false; |
526 | 539 | $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children']; |
527 | 540 | |
528 | - foreach ($context['board_order'] as $lBoard) |
|
529 | - if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
541 | + foreach ($context['board_order'] as $lBoard) { |
|
542 | + if ($lBoard['is_child'] == false && $lBoard['selected'] == false) |
|
530 | 543 | $context['can_move_children'] = true; |
544 | + } |
|
531 | 545 | } |
532 | 546 | |
533 | 547 | // Get other available categories. |
534 | 548 | $context['categories'] = array(); |
535 | - foreach ($cat_tree as $catID => $tree) |
|
536 | - $context['categories'][] = array( |
|
549 | + foreach ($cat_tree as $catID => $tree) { |
|
550 | + $context['categories'][] = array( |
|
537 | 551 | 'id' => $catID == $curBoard['category'] ? 0 : $catID, |
538 | 552 | 'name' => $tree['node']['name'], |
539 | 553 | 'selected' => $catID == $curBoard['category'] |
540 | 554 | ); |
555 | + } |
|
541 | 556 | |
542 | 557 | $request = $smcFunc['db_query']('', ' |
543 | 558 | SELECT mem.id_member, mem.real_name |
@@ -549,14 +564,16 @@ discard block |
||
549 | 564 | ) |
550 | 565 | ); |
551 | 566 | $context['board']['moderators'] = array(); |
552 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
553 | - $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
567 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
568 | + $context['board']['moderators'][$row['id_member']] = $row['real_name']; |
|
569 | + } |
|
554 | 570 | $smcFunc['db_free_result']($request); |
555 | 571 | |
556 | 572 | $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"'; |
557 | 573 | |
558 | - if (!empty($context['board']['moderators'])) |
|
559 | - list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
574 | + if (!empty($context['board']['moderators'])) { |
|
575 | + list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1); |
|
576 | + } |
|
560 | 577 | |
561 | 578 | // Get all the groups assigned as moderators |
562 | 579 | $request = $smcFunc['db_query']('', ' |
@@ -568,14 +585,16 @@ discard block |
||
568 | 585 | ) |
569 | 586 | ); |
570 | 587 | $context['board']['moderator_groups'] = array(); |
571 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
572 | - $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
588 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
589 | + $context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name']; |
|
590 | + } |
|
573 | 591 | $smcFunc['db_free_result']($request); |
574 | 592 | |
575 | 593 | $context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"'; |
576 | 594 | |
577 | - if (!empty($context['board']['moderator_groups'])) |
|
578 | - list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
595 | + if (!empty($context['board']['moderator_groups'])) { |
|
596 | + list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1); |
|
597 | + } |
|
579 | 598 | |
580 | 599 | // Get all the themes... |
581 | 600 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +606,9 @@ discard block |
||
587 | 606 | ) |
588 | 607 | ); |
589 | 608 | $context['themes'] = array(); |
590 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
591 | - $context['themes'][] = $row; |
|
609 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
610 | + $context['themes'][] = $row; |
|
611 | + } |
|
592 | 612 | $smcFunc['db_free_result']($request); |
593 | 613 | |
594 | 614 | if (!isset($_REQUEST['delete'])) |
@@ -596,8 +616,7 @@ discard block |
||
596 | 616 | $context['sub_template'] = 'modify_board'; |
597 | 617 | $context['page_title'] = $txt['boardsEdit']; |
598 | 618 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
599 | - } |
|
600 | - else |
|
619 | + } else |
|
601 | 620 | { |
602 | 621 | $context['sub_template'] = 'confirm_board_delete'; |
603 | 622 | $context['page_title'] = $txt['mboards_delete_board']; |
@@ -641,8 +660,9 @@ discard block |
||
641 | 660 | // Change the boardorder of this board? |
642 | 661 | elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) |
643 | 662 | { |
644 | - if (!in_array($_POST['placement'], array('before', 'after', 'child'))) |
|
645 | - fatal_lang_error('mangled_post', false); |
|
663 | + if (!in_array($_POST['placement'], array('before', 'after', 'child'))) { |
|
664 | + fatal_lang_error('mangled_post', false); |
|
665 | + } |
|
646 | 666 | |
647 | 667 | $boardOptions['move_to'] = $_POST['placement']; |
648 | 668 | $boardOptions['target_board'] = (int) $_POST['board_order']; |
@@ -655,13 +675,14 @@ discard block |
||
655 | 675 | $boardOptions['access_groups'] = array(); |
656 | 676 | $boardOptions['deny_groups'] = array(); |
657 | 677 | |
658 | - if (!empty($_POST['groups'])) |
|
659 | - foreach ($_POST['groups'] as $group => $action) |
|
678 | + if (!empty($_POST['groups'])) { |
|
679 | + foreach ($_POST['groups'] as $group => $action) |
|
660 | 680 | { |
661 | 681 | if ($action == 'allow') |
662 | 682 | $boardOptions['access_groups'][] = (int) $group; |
663 | - elseif ($action == 'deny') |
|
664 | - $boardOptions['deny_groups'][] = (int) $group; |
|
683 | + } elseif ($action == 'deny') { |
|
684 | + $boardOptions['deny_groups'][] = (int) $group; |
|
685 | + } |
|
665 | 686 | } |
666 | 687 | |
667 | 688 | // People with manage-boards are special. |
@@ -673,8 +694,9 @@ discard block |
||
673 | 694 | // Secondly, make sure those with super cow powers (like apt-get, or in this case manage boards) are upgraded. |
674 | 695 | $boardOptions['access_groups'] = array_unique(array_merge($boardOptions['access_groups'], $board_managers)); |
675 | 696 | |
676 | - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) |
|
677 | - fatal_lang_error('too_many_groups', false); |
|
697 | + if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { |
|
698 | + fatal_lang_error('too_many_groups', false); |
|
699 | + } |
|
678 | 700 | |
679 | 701 | // Do not allow HTML tags. Parse the string. |
680 | 702 | $boardOptions['board_name'] = parse_bbc($smcFunc['htmlspecialchars']($_POST['board_name']), false, '', $context['description_allowed_tags']); |
@@ -685,8 +707,9 @@ discard block |
||
685 | 707 | if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) |
686 | 708 | { |
687 | 709 | $moderators = array(); |
688 | - foreach ($_POST['moderator_list'] as $moderator) |
|
689 | - $moderators[(int) $moderator] = (int) $moderator; |
|
710 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
711 | + $moderators[(int) $moderator] = (int) $moderator; |
|
712 | + } |
|
690 | 713 | $boardOptions['moderators'] = $moderators; |
691 | 714 | } |
692 | 715 | |
@@ -695,8 +718,9 @@ discard block |
||
695 | 718 | if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) |
696 | 719 | { |
697 | 720 | $moderator_groups = array(); |
698 | - foreach ($_POST['moderator_group_list'] as $moderator_group) |
|
699 | - $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
721 | + foreach ($_POST['moderator_group_list'] as $moderator_group) { |
|
722 | + $moderator_groups[(int) $moderator_group] = (int) $moderator_group; |
|
723 | + } |
|
700 | 724 | $boardOptions['moderator_groups'] = $moderator_groups; |
701 | 725 | } |
702 | 726 | |
@@ -722,56 +746,62 @@ discard block |
||
722 | 746 | $smcFunc['db_free_result']($request); |
723 | 747 | |
724 | 748 | // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board. |
725 | - if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) |
|
726 | - unset($boardOptions['redirect']); |
|
749 | + if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts) { |
|
750 | + unset($boardOptions['redirect']); |
|
751 | + } |
|
727 | 752 | // Reset the redirection count when switching on/off. |
728 | - elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) |
|
729 | - $boardOptions['num_posts'] = 0; |
|
753 | + elseif (empty($boardOptions['redirect']) != empty($oldRedirect)) { |
|
754 | + $boardOptions['num_posts'] = 0; |
|
755 | + } |
|
730 | 756 | // Resetting the count? |
731 | - elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) |
|
732 | - $boardOptions['num_posts'] = 0; |
|
757 | + elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect'])) { |
|
758 | + $boardOptions['num_posts'] = 0; |
|
759 | + } |
|
733 | 760 | } |
734 | 761 | |
735 | 762 | // Create a new board... |
736 | 763 | if (isset($_POST['add'])) |
737 | 764 | { |
738 | 765 | // New boards by default go to the bottom of the category. |
739 | - if (empty($_POST['new_cat'])) |
|
740 | - $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
741 | - if (!isset($boardOptions['move_to'])) |
|
742 | - $boardOptions['move_to'] = 'bottom'; |
|
766 | + if (empty($_POST['new_cat'])) { |
|
767 | + $boardOptions['target_category'] = (int) $_POST['cur_cat']; |
|
768 | + } |
|
769 | + if (!isset($boardOptions['move_to'])) { |
|
770 | + $boardOptions['move_to'] = 'bottom'; |
|
771 | + } |
|
743 | 772 | |
744 | 773 | createBoard($boardOptions); |
745 | 774 | } |
746 | 775 | |
747 | 776 | // ...or update an existing board. |
748 | - else |
|
749 | - modifyBoard($_POST['boardid'], $boardOptions); |
|
750 | - } |
|
751 | - elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
777 | + else { |
|
778 | + modifyBoard($_POST['boardid'], $boardOptions); |
|
779 | + } |
|
780 | + } elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children'])) |
|
752 | 781 | { |
753 | 782 | EditBoard(); |
754 | 783 | return; |
755 | - } |
|
756 | - elseif (isset($_POST['delete'])) |
|
784 | + } elseif (isset($_POST['delete'])) |
|
757 | 785 | { |
758 | 786 | // First off - check if we are moving all the current child boards first - before we start deleting! |
759 | 787 | if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1) |
760 | 788 | { |
761 | - if (empty($_POST['board_to'])) |
|
762 | - fatal_lang_error('mboards_delete_board_error'); |
|
789 | + if (empty($_POST['board_to'])) { |
|
790 | + fatal_lang_error('mboards_delete_board_error'); |
|
791 | + } |
|
763 | 792 | |
764 | 793 | deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']); |
794 | + } else { |
|
795 | + deleteBoards(array($_POST['boardid']), 0); |
|
765 | 796 | } |
766 | - else |
|
767 | - deleteBoards(array($_POST['boardid']), 0); |
|
768 | 797 | } |
769 | 798 | |
770 | - if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') |
|
771 | - redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
772 | - else |
|
773 | - redirectexit('action=admin;area=manageboards'); |
|
774 | -} |
|
799 | + if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions') { |
|
800 | + redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']); |
|
801 | + } else { |
|
802 | + redirectexit('action=admin;area=manageboards'); |
|
803 | + } |
|
804 | + } |
|
775 | 805 | |
776 | 806 | /** |
777 | 807 | * Used to retrieve data for modifying a board category |
@@ -808,8 +838,9 @@ discard block |
||
808 | 838 | $smcFunc['db_free_result']($request); |
809 | 839 | |
810 | 840 | // This would probably never happen, but just to be sure. |
811 | - if ($cat .= $allowed_sa[1]) |
|
812 | - die(str_replace(',', ' to', $cat)); |
|
841 | + if ($cat .= $allowed_sa[1]) { |
|
842 | + die(str_replace(',', ' to', $cat)); |
|
843 | + } |
|
813 | 844 | |
814 | 845 | redirectexit(); |
815 | 846 | } |
@@ -835,8 +866,9 @@ discard block |
||
835 | 866 | 'empty_string' => '', |
836 | 867 | ) |
837 | 868 | ); |
838 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
839 | - $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
869 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
870 | + $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name']; |
|
871 | + } |
|
840 | 872 | $smcFunc['db_free_result']($request); |
841 | 873 | |
842 | 874 | require_once($sourcedir . '/Subs-Boards.php'); |
@@ -860,8 +892,9 @@ discard block |
||
860 | 892 | |
861 | 893 | call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); |
862 | 894 | |
863 | - if ($return_config) |
|
864 | - return $config_vars; |
|
895 | + if ($return_config) { |
|
896 | + return $config_vars; |
|
897 | + } |
|
865 | 898 | |
866 | 899 | // Needed for the settings template. |
867 | 900 | require_once($sourcedir . '/ManageServer.php'); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Converts the given UTF-8 string into lowercase. |
@@ -569,8 +570,8 @@ discard block |
||
569 | 570 | ); |
570 | 571 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
571 | 572 | { |
572 | - if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) |
|
573 | - $smcFunc['db_query']('', ' |
|
573 | + if (safe_unserialize($row['extra']) === false && preg_match('~^(a:3:{s:5:"topic";i:\d+;s:7:"subject";s:)(\d+):"(.+)"(;s:6:"member";s:5:"\d+";})$~', $row['extra'], $matches) === 1) { |
|
574 | + $smcFunc['db_query']('', ' |
|
574 | 575 | UPDATE {db_prefix}log_actions |
575 | 576 | SET extra = {string:extra} |
576 | 577 | WHERE id_action = {int:current_action}', |
@@ -579,6 +580,7 @@ discard block |
||
579 | 580 | 'extra' => $matches[1] . strlen($matches[3]) . ':"' . $matches[3] . '"' . $matches[4], |
580 | 581 | ) |
581 | 582 | ); |
583 | + } |
|
582 | 584 | } |
583 | 585 | $smcFunc['db_free_result']($request); |
584 | 586 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcached'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -54,9 +56,9 @@ discard block |
||
54 | 56 | $currentServers = $this->memcached->getServerList(); |
55 | 57 | foreach ($servers as $server) |
56 | 58 | { |
57 | - if (strpos($server,'/') !== false) |
|
58 | - $tempServer = array($server, 0); |
|
59 | - else |
|
59 | + if (strpos($server,'/') !== false) { |
|
60 | + $tempServer = array($server, 0); |
|
61 | + } else |
|
60 | 62 | { |
61 | 63 | $server = explode(':', $server); |
62 | 64 | $tempServer = array($server[0], isset($server[1]) ? $server[1] : 11211); |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | } |
75 | 77 | |
76 | 78 | // Found it? |
77 | - if (empty($foundServer)) |
|
78 | - $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
79 | + if (empty($foundServer)) { |
|
80 | + $this->memcached->addServer($tempServer[0], $tempServer[1]); |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | |
81 | 84 | // Best guess is this worked. |
@@ -92,8 +95,9 @@ discard block |
||
92 | 95 | $value = $this->memcached->get($key); |
93 | 96 | |
94 | 97 | // $value should return either data or false (from failure, key not found or empty array). |
95 | - if ($value === false) |
|
96 | - return null; |
|
98 | + if ($value === false) { |
|
99 | + return null; |
|
100 | + } |
|
97 | 101 | return $value; |
98 | 102 | } |
99 | 103 | |
@@ -136,8 +140,9 @@ discard block |
||
136 | 140 | $config_vars[] = $txt['cache_memcache_settings']; |
137 | 141 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
138 | 142 | |
139 | - if (!isset($context['settings_post_javascript'])) |
|
140 | - $context['settings_post_javascript'] = ''; |
|
143 | + if (!isset($context['settings_post_javascript'])) { |
|
144 | + $context['settings_post_javascript'] = ''; |
|
145 | + } |
|
141 | 146 | |
142 | 147 | $context['settings_post_javascript'] .= ' |
143 | 148 | $("#cache_accelerator").change(function (e) { |
@@ -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 | * The main entrance point for the 'Posts and topics' screen. |
@@ -98,23 +99,23 @@ discard block |
||
98 | 99 | { |
99 | 100 | $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" => ''))); |
100 | 101 | |
101 | - foreach ($_POST['censortext'] as $c) |
|
102 | - list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
103 | - } |
|
104 | - elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
102 | + foreach ($_POST['censortext'] as $c) { |
|
103 | + list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, ''); |
|
104 | + } |
|
105 | + } elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper'])) |
|
105 | 106 | { |
106 | 107 | if (is_array($_POST['censor_vulgar'])) |
107 | 108 | { |
108 | 109 | foreach ($_POST['censor_vulgar'] as $i => $value) |
109 | 110 | { |
110 | - if (trim(strtr($value, '*', ' ')) == '') |
|
111 | - unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
111 | + if (trim(strtr($value, '*', ' ')) == '') { |
|
112 | + unset($_POST['censor_vulgar'][$i], $_POST['censor_proper'][$i]); |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | |
114 | 116 | $censored_vulgar = $_POST['censor_vulgar']; |
115 | 117 | $censored_proper = $_POST['censor_proper']; |
116 | - } |
|
117 | - else |
|
118 | + } else |
|
118 | 119 | { |
119 | 120 | $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" => ''))); |
120 | 121 | $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" => ''))); |
@@ -151,12 +152,14 @@ discard block |
||
151 | 152 | $context['censored_words'] = array(); |
152 | 153 | for ($i = 0, $n = count($censor_vulgar); $i < $n; $i++) |
153 | 154 | { |
154 | - if (empty($censor_vulgar[$i])) |
|
155 | - continue; |
|
155 | + if (empty($censor_vulgar[$i])) { |
|
156 | + continue; |
|
157 | + } |
|
156 | 158 | |
157 | 159 | // Skip it, it's either spaces or stars only. |
158 | - if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') |
|
159 | - continue; |
|
160 | + if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '') { |
|
161 | + continue; |
|
162 | + } |
|
160 | 163 | |
161 | 164 | $context['censored_words'][$smcFunc['htmlspecialchars'](trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? $smcFunc['htmlspecialchars']($censor_proper[$i]) : ''; |
162 | 165 | } |
@@ -187,10 +190,11 @@ discard block |
||
187 | 190 | |
188 | 191 | // Make an inline conditional a little shorter... |
189 | 192 | $can_spell_check = false; |
190 | - if (function_exists('pspell_new')) |
|
191 | - $can_spell_check = true; |
|
192 | - elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) |
|
193 | - $can_spell_check = true; |
|
193 | + if (function_exists('pspell_new')) { |
|
194 | + $can_spell_check = true; |
|
195 | + } elseif (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))) { |
|
196 | + $can_spell_check = true; |
|
197 | + } |
|
194 | 198 | |
195 | 199 | // All the settings... |
196 | 200 | $config_vars = array( |
@@ -221,8 +225,9 @@ discard block |
||
221 | 225 | |
222 | 226 | call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); |
223 | 227 | |
224 | - if ($return_config) |
|
225 | - return $config_vars; |
|
228 | + if ($return_config) { |
|
229 | + return $config_vars; |
|
230 | + } |
|
226 | 231 | |
227 | 232 | // We'll want this for our easy save. |
228 | 233 | require_once($sourcedir . '/ManageServer.php'); |
@@ -242,17 +247,20 @@ discard block |
||
242 | 247 | db_extend('packages'); |
243 | 248 | |
244 | 249 | $colData = $smcFunc['db_list_columns']('{db_prefix}messages', true); |
245 | - foreach ($colData as $column) |
|
246 | - if ($column['name'] == 'body') |
|
250 | + foreach ($colData as $column) { |
|
251 | + if ($column['name'] == 'body') |
|
247 | 252 | $body_type = $column['type']; |
253 | + } |
|
248 | 254 | |
249 | - if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') |
|
250 | - fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
255 | + if (isset($body_type) && ($_POST['max_messageLength'] > 65535 || $_POST['max_messageLength'] == 0) && $body_type == 'text') { |
|
256 | + fatal_lang_error('convert_to_mediumtext', false, array($scripturl . '?action=admin;area=maintain;sa=database')); |
|
257 | + } |
|
251 | 258 | } |
252 | 259 | |
253 | 260 | // If we're changing the post preview length let's check its valid |
254 | - if (!empty($_POST['preview_characters'])) |
|
255 | - $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
261 | + if (!empty($_POST['preview_characters'])) { |
|
262 | + $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); |
|
263 | + } |
|
256 | 264 | |
257 | 265 | call_integration_hook('integrate_save_post_settings'); |
258 | 266 | |
@@ -313,8 +321,9 @@ discard block |
||
313 | 321 | |
314 | 322 | call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); |
315 | 323 | |
316 | - if ($return_config) |
|
317 | - return $config_vars; |
|
324 | + if ($return_config) { |
|
325 | + return $config_vars; |
|
326 | + } |
|
318 | 327 | |
319 | 328 | // Get the settings template ready. |
320 | 329 | require_once($sourcedir . '/ManageServer.php'); |
@@ -367,8 +376,9 @@ discard block |
||
367 | 376 | array('int', 'drafts_autosave_frequency', 'postinput' => $txt['manageposts_seconds'], 'subtext' => $txt['drafts_autosave_frequency_subnote']), |
368 | 377 | ); |
369 | 378 | |
370 | - if ($return_config) |
|
371 | - return $config_vars; |
|
379 | + if ($return_config) { |
|
380 | + return $config_vars; |
|
381 | + } |
|
372 | 382 | |
373 | 383 | // Get the settings template ready. |
374 | 384 | require_once($sourcedir . '/ManageServer.php'); |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 3 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Log an error, if the error logging is enabled. |
@@ -36,8 +37,9 @@ discard block |
||
36 | 37 | static $tried_hook = false; |
37 | 38 | |
38 | 39 | // Check if error logging is actually on. |
39 | - if (empty($modSettings['enableErrorLogging'])) |
|
40 | - return $error_message; |
|
40 | + if (empty($modSettings['enableErrorLogging'])) { |
|
41 | + return $error_message; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | // Basically, htmlspecialchars it minus &. (for entities!) |
43 | 45 | $error_message = strtr($error_message, array('<' => '<', '>' => '>', '"' => '"')); |
@@ -45,22 +47,26 @@ discard block |
||
45 | 47 | |
46 | 48 | // Add a file and line to the error message? |
47 | 49 | // Don't use the actual txt entries for file and line but instead use %1$s for file and %2$s for line |
48 | - if ($file == null) |
|
49 | - $file = ''; |
|
50 | - else |
|
51 | - // Window style slashes don't play well, lets convert them to the unix style. |
|
50 | + if ($file == null) { |
|
51 | + $file = ''; |
|
52 | + } else { |
|
53 | + // Window style slashes don't play well, lets convert them to the unix style. |
|
52 | 54 | $file = str_replace('\\', '/', $file); |
55 | + } |
|
53 | 56 | |
54 | - if ($line == null) |
|
55 | - $line = 0; |
|
56 | - else |
|
57 | - $line = (int) $line; |
|
57 | + if ($line == null) { |
|
58 | + $line = 0; |
|
59 | + } else { |
|
60 | + $line = (int) $line; |
|
61 | + } |
|
58 | 62 | |
59 | 63 | // Just in case there's no id_member or IP set yet. |
60 | - if (empty($user_info['id'])) |
|
61 | - $user_info['id'] = 0; |
|
62 | - if (empty($user_info['ip'])) |
|
63 | - $user_info['ip'] = ''; |
|
64 | + if (empty($user_info['id'])) { |
|
65 | + $user_info['id'] = 0; |
|
66 | + } |
|
67 | + if (empty($user_info['ip'])) { |
|
68 | + $user_info['ip'] = ''; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | // Find the best query string we can... |
66 | 72 | $query_string = empty($_SERVER['QUERY_STRING']) ? (empty($_SERVER['REQUEST_URL']) ? '' : str_replace($scripturl, '', $_SERVER['REQUEST_URL'])) : $_SERVER['QUERY_STRING']; |
@@ -69,8 +75,9 @@ discard block |
||
69 | 75 | $query_string = $smcFunc['htmlspecialchars']((SMF == 'SSI' || SMF == 'BACKGROUND' ? '' : '?') . preg_replace(array('~;sesc=[^&;]+~', '~' . session_name() . '=' . session_id() . '[&;]~'), array(';sesc', ''), $query_string)); |
70 | 76 | |
71 | 77 | // Just so we know what board error messages are from. |
72 | - if (isset($_POST['board']) && !isset($_GET['board'])) |
|
73 | - $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
78 | + if (isset($_POST['board']) && !isset($_GET['board'])) { |
|
79 | + $query_string .= ($query_string == '' ? 'board=' : ';board=') . $_POST['board']; |
|
80 | + } |
|
74 | 81 | |
75 | 82 | // What types of categories do we have? |
76 | 83 | $known_error_types = array( |
@@ -132,12 +139,14 @@ discard block |
||
132 | 139 | global $txt; |
133 | 140 | |
134 | 141 | // Send the appropriate HTTP status header - set this to 0 or false if you don't want to send one at all |
135 | - if (!empty($status)) |
|
136 | - send_http_status($status); |
|
142 | + if (!empty($status)) { |
|
143 | + send_http_status($status); |
|
144 | + } |
|
137 | 145 | |
138 | 146 | // We don't have $txt yet, but that's okay... |
139 | - if (empty($txt)) |
|
140 | - die($error); |
|
147 | + if (empty($txt)) { |
|
148 | + die($error); |
|
149 | + } |
|
141 | 150 | |
142 | 151 | log_error_online($error, false); |
143 | 152 | setup_fatal_error_context($log ? log_error($error, $log) : $error); |
@@ -164,8 +173,9 @@ discard block |
||
164 | 173 | static $fatal_error_called = false; |
165 | 174 | |
166 | 175 | // Send the status header - set this to 0 or false if you don't want to send one at all |
167 | - if (!empty($status)) |
|
168 | - send_http_status($status); |
|
176 | + if (!empty($status)) { |
|
177 | + send_http_status($status); |
|
178 | + } |
|
169 | 179 | |
170 | 180 | // Try to load a theme if we don't have one. |
171 | 181 | if (empty($context['theme_loaded']) && empty($fatal_error_called)) |
@@ -175,8 +185,9 @@ discard block |
||
175 | 185 | } |
176 | 186 | |
177 | 187 | // If we have no theme stuff we can't have the language file... |
178 | - if (empty($context['theme_loaded'])) |
|
179 | - die($error); |
|
188 | + if (empty($context['theme_loaded'])) { |
|
189 | + die($error); |
|
190 | + } |
|
180 | 191 | |
181 | 192 | $reload_lang_file = true; |
182 | 193 | // Log the error in the forum's language, but don't waste the time if we aren't logging |
@@ -212,8 +223,9 @@ discard block |
||
212 | 223 | global $settings, $modSettings, $db_show_debug; |
213 | 224 | |
214 | 225 | // Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.) |
215 | - if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) |
|
216 | - return; |
|
226 | + if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && !empty($modSettings['enableErrorLogging']))) { |
|
227 | + return; |
|
228 | + } |
|
217 | 229 | |
218 | 230 | if (strpos($file, 'eval()') !== false && !empty($settings['current_include_filename'])) |
219 | 231 | { |
@@ -221,19 +233,22 @@ discard block |
||
221 | 233 | $count = count($array); |
222 | 234 | for ($i = 0; $i < $count; $i++) |
223 | 235 | { |
224 | - if ($array[$i]['function'] != 'loadSubTemplate') |
|
225 | - continue; |
|
236 | + if ($array[$i]['function'] != 'loadSubTemplate') { |
|
237 | + continue; |
|
238 | + } |
|
226 | 239 | |
227 | 240 | // This is a bug in PHP, with eval, it seems! |
228 | - if (empty($array[$i]['args'])) |
|
229 | - $i++; |
|
241 | + if (empty($array[$i]['args'])) { |
|
242 | + $i++; |
|
243 | + } |
|
230 | 244 | break; |
231 | 245 | } |
232 | 246 | |
233 | - if (isset($array[$i]) && !empty($array[$i]['args'])) |
|
234 | - $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
235 | - else |
|
236 | - $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
247 | + if (isset($array[$i]) && !empty($array[$i]['args'])) { |
|
248 | + $file = realpath($settings['current_include_filename']) . ' (' . $array[$i]['args'][0] . ' sub template - eval?)'; |
|
249 | + } else { |
|
250 | + $file = realpath($settings['current_include_filename']) . ' (eval?)'; |
|
251 | + } |
|
237 | 252 | } |
238 | 253 | |
239 | 254 | if (isset($db_show_debug) && $db_show_debug === true) |
@@ -242,8 +257,9 @@ discard block |
||
242 | 257 | if ($error_level % 255 != E_ERROR) |
243 | 258 | { |
244 | 259 | $temporary = ob_get_contents(); |
245 | - if (substr($temporary, -2) == '="') |
|
246 | - echo '"'; |
|
260 | + if (substr($temporary, -2) == '="') { |
|
261 | + echo '"'; |
|
262 | + } |
|
247 | 263 | } |
248 | 264 | |
249 | 265 | // Debugging! This should look like a PHP error message. |
@@ -259,23 +275,27 @@ discard block |
||
259 | 275 | call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); |
260 | 276 | |
261 | 277 | // Dying on these errors only causes MORE problems (blank pages!) |
262 | - if ($file == 'Unknown') |
|
263 | - return; |
|
278 | + if ($file == 'Unknown') { |
|
279 | + return; |
|
280 | + } |
|
264 | 281 | |
265 | 282 | // If this is an E_ERROR or E_USER_ERROR.... die. Violently so. |
266 | - if ($error_level % 255 == E_ERROR) |
|
267 | - obExit(false); |
|
268 | - else |
|
269 | - return; |
|
283 | + if ($error_level % 255 == E_ERROR) { |
|
284 | + obExit(false); |
|
285 | + } else { |
|
286 | + return; |
|
287 | + } |
|
270 | 288 | |
271 | 289 | // If this is an E_ERROR, E_USER_ERROR, E_WARNING, or E_USER_WARNING.... die. Violently so. |
272 | - if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) |
|
273 | - fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
290 | + if ($error_level % 255 == E_ERROR || $error_level % 255 == E_WARNING) { |
|
291 | + fatal_error(allowedTo('admin_forum') ? $message : $error_string, false); |
|
292 | + } |
|
274 | 293 | |
275 | 294 | // We should NEVER get to this point. Any fatal error MUST quit, or very bad things can happen. |
276 | - if ($error_level % 255 == E_ERROR) |
|
277 | - die('No direct access...'); |
|
278 | -} |
|
295 | + if ($error_level % 255 == E_ERROR) { |
|
296 | + die('No direct access...'); |
|
297 | + } |
|
298 | + } |
|
279 | 299 | |
280 | 300 | /** |
281 | 301 | * It is called by {@link fatal_error()} and {@link fatal_lang_error()}. |
@@ -291,24 +311,28 @@ discard block |
||
291 | 311 | |
292 | 312 | // Attempt to prevent a recursive loop. |
293 | 313 | ++$level; |
294 | - if ($level > 1) |
|
295 | - return false; |
|
314 | + if ($level > 1) { |
|
315 | + return false; |
|
316 | + } |
|
296 | 317 | |
297 | 318 | // Maybe they came from dlattach or similar? |
298 | - if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) |
|
299 | - loadTheme(); |
|
319 | + if (SMF != 'SSI' && SMF != 'BACKGROUND' && empty($context['theme_loaded'])) { |
|
320 | + loadTheme(); |
|
321 | + } |
|
300 | 322 | |
301 | 323 | // Don't bother indexing errors mate... |
302 | 324 | $context['robot_no_index'] = true; |
303 | 325 | |
304 | - if (!isset($context['error_title'])) |
|
305 | - $context['error_title'] = $txt['error_occured']; |
|
326 | + if (!isset($context['error_title'])) { |
|
327 | + $context['error_title'] = $txt['error_occured']; |
|
328 | + } |
|
306 | 329 | $context['error_message'] = isset($context['error_message']) ? $context['error_message'] : $error_message; |
307 | 330 | |
308 | 331 | $context['error_code'] = isset($error_code) ? 'id="' . $error_code . '" ' : ''; |
309 | 332 | |
310 | - if (empty($context['page_title'])) |
|
311 | - $context['page_title'] = $context['error_title']; |
|
333 | + if (empty($context['page_title'])) { |
|
334 | + $context['page_title'] = $context['error_title']; |
|
335 | + } |
|
312 | 336 | |
313 | 337 | loadTemplate('Errors'); |
314 | 338 | $context['sub_template'] = 'fatal_error'; |
@@ -316,23 +340,26 @@ discard block |
||
316 | 340 | // If this is SSI, what do they want us to do? |
317 | 341 | if (SMF == 'SSI') |
318 | 342 | { |
319 | - if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) |
|
320 | - $ssi_on_error_method(); |
|
321 | - elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
322 | - loadSubTemplate('fatal_error'); |
|
343 | + if (!empty($ssi_on_error_method) && $ssi_on_error_method !== true && is_callable($ssi_on_error_method)) { |
|
344 | + $ssi_on_error_method(); |
|
345 | + } elseif (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
346 | + loadSubTemplate('fatal_error'); |
|
347 | + } |
|
323 | 348 | |
324 | 349 | // No layers? |
325 | - if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) |
|
326 | - exit; |
|
350 | + if (empty($ssi_on_error_method) || $ssi_on_error_method !== true) { |
|
351 | + exit; |
|
352 | + } |
|
327 | 353 | } |
328 | 354 | // Alternatively from the cron call? |
329 | 355 | elseif (SMF == 'BACKGROUND') |
330 | 356 | { |
331 | 357 | // We can't rely on even having language files available. |
332 | - if (defined('FROM_CLI') && FROM_CLI) |
|
333 | - echo 'cron error: ', $context['error_message']; |
|
334 | - else |
|
335 | - echo 'An error occurred. More information may be available in your logs.'; |
|
358 | + if (defined('FROM_CLI') && FROM_CLI) { |
|
359 | + echo 'cron error: ', $context['error_message']; |
|
360 | + } else { |
|
361 | + echo 'An error occurred. More information may be available in your logs.'; |
|
362 | + } |
|
336 | 363 | exit; |
337 | 364 | } |
338 | 365 | |
@@ -360,8 +387,8 @@ discard block |
||
360 | 387 | |
361 | 388 | set_fatal_error_headers(); |
362 | 389 | |
363 | - if (!empty($maintenance)) |
|
364 | - echo '<!DOCTYPE html> |
|
390 | + if (!empty($maintenance)) { |
|
391 | + echo '<!DOCTYPE html> |
|
365 | 392 | <html> |
366 | 393 | <head> |
367 | 394 | <meta name="robots" content="noindex"> |
@@ -372,6 +399,7 @@ discard block |
||
372 | 399 | ', $mmessage, ' |
373 | 400 | </body> |
374 | 401 | </html>'; |
402 | + } |
|
375 | 403 | |
376 | 404 | die(); |
377 | 405 | } |
@@ -393,15 +421,17 @@ discard block |
||
393 | 421 | // For our purposes, we're gonna want this on if at all possible. |
394 | 422 | $modSettings['cache_enable'] = '1'; |
395 | 423 | |
396 | - if (($temp = cache_get_data('db_last_error', 600)) !== null) |
|
397 | - $db_last_error = max($db_last_error, $temp); |
|
424 | + if (($temp = cache_get_data('db_last_error', 600)) !== null) { |
|
425 | + $db_last_error = max($db_last_error, $temp); |
|
426 | + } |
|
398 | 427 | |
399 | 428 | if ($db_last_error < time() - 3600 * 24 * 3 && empty($maintenance) && !empty($db_error_send)) |
400 | 429 | { |
401 | 430 | // Avoid writing to the Settings.php file if at all possible; use shared memory instead. |
402 | 431 | cache_put_data('db_last_error', time(), 600); |
403 | - if (($temp = cache_get_data('db_last_error', 600)) === null) |
|
404 | - logLastDatabaseError(); |
|
432 | + if (($temp = cache_get_data('db_last_error', 600)) === null) { |
|
433 | + logLastDatabaseError(); |
|
434 | + } |
|
405 | 435 | |
406 | 436 | // Language files aren't loaded yet :(. |
407 | 437 | $db_error = @$smcFunc['db_error']($db_connection); |
@@ -482,12 +512,14 @@ discard block |
||
482 | 512 | global $smcFunc, $user_info, $modSettings; |
483 | 513 | |
484 | 514 | // Don't bother if Who's Online is disabled. |
485 | - if (empty($modSettings['who_enabled'])) |
|
486 | - return; |
|
515 | + if (empty($modSettings['who_enabled'])) { |
|
516 | + return; |
|
517 | + } |
|
487 | 518 | |
488 | 519 | // Maybe they came from SSI or similar where sessions are not recorded? |
489 | - if (SMF == 'SSI' || SMF == 'BACKGROUND') |
|
490 | - return; |
|
520 | + if (SMF == 'SSI' || SMF == 'BACKGROUND') { |
|
521 | + return; |
|
522 | + } |
|
491 | 523 | |
492 | 524 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
493 | 525 | |
@@ -506,8 +538,9 @@ discard block |
||
506 | 538 | $url = smf_json_decode($url, true); |
507 | 539 | $url['error'] = $error; |
508 | 540 | |
509 | - if (!empty($sprintf)) |
|
510 | - $url['error_params'] = $sprintf; |
|
541 | + if (!empty($sprintf)) { |
|
542 | + $url['error_params'] = $sprintf; |
|
543 | + } |
|
511 | 544 | |
512 | 545 | $smcFunc['db_query']('', ' |
513 | 546 | UPDATE {db_prefix}log_online |
@@ -538,10 +571,11 @@ discard block |
||
538 | 571 | |
539 | 572 | $protocol = preg_match('~HTTP/1\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'; |
540 | 573 | |
541 | - if (!isset($statuses[$code])) |
|
542 | - header($protocol . ' 500 Internal Server Error'); |
|
543 | - else |
|
544 | - header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
545 | -} |
|
574 | + if (!isset($statuses[$code])) { |
|
575 | + header($protocol . ' 500 Internal Server Error'); |
|
576 | + } else { |
|
577 | + header($protocol . ' ' . $code . ' ' . $statuses[$code]); |
|
578 | + } |
|
579 | + } |
|
546 | 580 | |
547 | 581 | ?> |
548 | 582 | \ No newline at end of file |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,14 +24,15 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => true, |
32 | 33 | ); |
33 | -} |
|
34 | + } |
|
35 | + } |
|
34 | 36 | |
35 | 37 | /** |
36 | 38 | * This function will tell you whether this database type supports this search type. |
@@ -54,12 +56,13 @@ discard block |
||
54 | 56 | { |
55 | 57 | global $smcFunc; |
56 | 58 | |
57 | - if ($size == 'small') |
|
58 | - $size = 'smallint(5)'; |
|
59 | - elseif ($size == 'medium') |
|
60 | - $size = 'mediumint(8)'; |
|
61 | - else |
|
62 | - $size = 'int(10)'; |
|
59 | + if ($size == 'small') { |
|
60 | + $size = 'smallint(5)'; |
|
61 | + } elseif ($size == 'medium') { |
|
62 | + $size = 'mediumint(8)'; |
|
63 | + } else { |
|
64 | + $size = 'int(10)'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | $smcFunc['db_query']('', ' |
65 | 68 | CREATE TABLE {db_prefix}log_search_words ( |
@@ -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 | * Turn off/on notification for a particular board. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | is_not_guest(); |
35 | 36 | |
36 | 37 | // You have to specify a board to turn notifications on! |
37 | - if (empty($board)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($board)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // No subaction: find out what to do. |
41 | 43 | if (isset($_GET['mode'])) |
@@ -48,16 +50,16 @@ discard block |
||
48 | 50 | require_once($sourcedir . '/Subs-Notify.php'); |
49 | 51 | setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref)); |
50 | 52 | |
51 | - if ($mode > 1) |
|
52 | - // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | + if ($mode > 1) { |
|
54 | + // Turn notification on. (note this just blows smoke if it's already on.) |
|
53 | 55 | $smcFunc['db_insert']('ignore', |
54 | 56 | '{db_prefix}log_notify', |
55 | 57 | array('id_member' => 'int', 'id_board' => 'int'), |
56 | 58 | array($user_info['id'], $board), |
57 | 59 | array('id_member', 'id_board') |
58 | 60 | ); |
59 | - else |
|
60 | - $smcFunc['db_query']('', ' |
|
61 | + } else { |
|
62 | + $smcFunc['db_query']('', ' |
|
61 | 63 | DELETE FROM {db_prefix}log_notify |
62 | 64 | WHERE id_member = {int:current_member} |
63 | 65 | AND id_board = {int:current_board}', |
@@ -66,6 +68,7 @@ discard block |
||
66 | 68 | 'current_member' => $user_info['id'], |
67 | 69 | ) |
68 | 70 | ); |
71 | + } |
|
69 | 72 | |
70 | 73 | } |
71 | 74 | |
@@ -81,10 +84,10 @@ discard block |
||
81 | 84 | ), |
82 | 85 | ); |
83 | 86 | $context['sub_template'] = 'generic_xml'; |
87 | + } else { |
|
88 | + redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
89 | + } |
|
84 | 90 | } |
85 | - else |
|
86 | - redirectexit('board=' . $board . '.' . $_REQUEST['start']); |
|
87 | -} |
|
88 | 91 | |
89 | 92 | /** |
90 | 93 | * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $mode = (int) $_GET['mode']; |
109 | 112 | $alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3); |
110 | 113 | |
111 | - if (empty($mode)) |
|
112 | - $mode = 1; |
|
114 | + if (empty($mode)) { |
|
115 | + $mode = 1; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | $request = $smcFunc['db_query']('', ' |
115 | 119 | SELECT id_member, id_topic, id_msg, unwatched |
@@ -132,8 +136,7 @@ discard block |
||
132 | 136 | 'id_msg' => 0, |
133 | 137 | 'unwatched' => empty($mode) ? 1 : 0, |
134 | 138 | ); |
135 | - } |
|
136 | - else |
|
139 | + } else |
|
137 | 140 | { |
138 | 141 | $insert = false; |
139 | 142 | $log['unwatched'] = empty($mode) ? 1 : 0; |
@@ -160,9 +163,8 @@ discard block |
||
160 | 163 | array($user_info['id'], $log['id_topic']), |
161 | 164 | array('id_member', 'id_board') |
162 | 165 | ); |
163 | - } |
|
164 | - else |
|
165 | - $smcFunc['db_query']('', ' |
|
166 | + } else { |
|
167 | + $smcFunc['db_query']('', ' |
|
166 | 168 | DELETE FROM {db_prefix}log_notify |
167 | 169 | WHERE id_topic = {int:topic} |
168 | 170 | AND id_member = {int:member}', |
@@ -170,6 +172,7 @@ discard block |
||
170 | 172 | 'topic' => $log['id_topic'], |
171 | 173 | 'member' => $user_info['id'], |
172 | 174 | )); |
175 | + } |
|
173 | 176 | |
174 | 177 | } |
175 | 178 | } |
@@ -186,9 +189,9 @@ discard block |
||
186 | 189 | ), |
187 | 190 | ); |
188 | 191 | $context['sub_template'] = 'generic_xml'; |
192 | + } else { |
|
193 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
194 | + } |
|
189 | 195 | } |
190 | - else |
|
191 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
192 | -} |
|
193 | 196 | |
194 | 197 | ?> |
195 | 198 | \ No newline at end of file |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
118 | 120 | |
119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
120 | 122 | |
121 | - if (empty($modSettings['search_force_index'])) |
|
122 | - $wordsSearch['words'][] = $word; |
|
123 | + if (empty($modSettings['search_force_index'])) { |
|
124 | + $wordsSearch['words'][] = $word; |
|
125 | + } |
|
123 | 126 | |
124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
125 | - if (count($subwords) > 1 && $isExcluded) |
|
126 | - return; |
|
127 | - else |
|
128 | + if (count($subwords) > 1 && $isExcluded) { |
|
129 | + return; |
|
130 | + } else |
|
128 | 131 | { |
129 | 132 | foreach ($subwords as $subword) |
130 | 133 | { |
131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
132 | 135 | { |
133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
134 | - if ($isExcluded) |
|
135 | - $wordsExclude[] = $subword; |
|
137 | + if ($isExcluded) { |
|
138 | + $wordsExclude[] = $subword; |
|
139 | + } |
|
136 | 140 | } |
137 | 141 | } |
138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | $query_where = array(); |
154 | 158 | $query_params = $search_data['params']; |
155 | 159 | |
156 | - if ($query_params['id_search']) |
|
157 | - $query_select['id_search'] = '{int:id_search}'; |
|
160 | + if ($query_params['id_search']) { |
|
161 | + $query_select['id_search'] = '{int:id_search}'; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | $count = 0; |
160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
164 | 169 | } |
165 | 170 | |
166 | - if ($query_params['user_query']) |
|
167 | - $query_where[] = '{raw:user_query}'; |
|
168 | - if ($query_params['board_query']) |
|
169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
171 | + if ($query_params['user_query']) { |
|
172 | + $query_where[] = '{raw:user_query}'; |
|
173 | + } |
|
174 | + if ($query_params['board_query']) { |
|
175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
176 | + } |
|
170 | 177 | |
171 | - if ($query_params['topic']) |
|
172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
173 | - if ($query_params['min_msg_id']) |
|
174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
175 | - if ($query_params['max_msg_id']) |
|
176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
178 | + if ($query_params['topic']) { |
|
179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
180 | + } |
|
181 | + if ($query_params['min_msg_id']) { |
|
182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
183 | + } |
|
184 | + if ($query_params['max_msg_id']) { |
|
185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
186 | + } |
|
177 | 187 | |
178 | 188 | $count = 0; |
179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
181 | 191 | { |
182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
193 | + } |
|
183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
184 | 195 | } |
185 | 196 | $count = 0; |
186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
188 | 199 | { |
189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
201 | + } |
|
190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
191 | 203 | } |
192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
199 | 211 | { |
200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
202 | - } |
|
203 | - else |
|
214 | + } else |
|
204 | 215 | { |
205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
237 | 248 | |
238 | 249 | $inserts = array(); |
239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
240 | - $inserts[] = array($word, $msgOptions['id']); |
|
250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
251 | + $inserts[] = array($word, $msgOptions['id']); |
|
252 | + } |
|
241 | 253 | |
242 | - if (!empty($inserts)) |
|
243 | - $smcFunc['db_insert']('ignore', |
|
254 | + if (!empty($inserts)) { |
|
255 | + $smcFunc['db_insert']('ignore', |
|
244 | 256 | '{db_prefix}log_search_words', |
245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
246 | 258 | $inserts, |
247 | 259 | array('id_word', 'id_msg') |
248 | 260 | ); |
261 | + } |
|
249 | 262 | } |
250 | 263 | |
251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
288 | 301 | if (!empty($inserted_words)) |
289 | 302 | { |
290 | 303 | $inserts = array(); |
291 | - foreach ($inserted_words as $word) |
|
292 | - $inserts[] = array($word, $msgOptions['id']); |
|
304 | + foreach ($inserted_words as $word) { |
|
305 | + $inserts[] = array($word, $msgOptions['id']); |
|
306 | + } |
|
293 | 307 | $smcFunc['db_insert']('insert', |
294 | 308 | '{db_prefix}log_search_words', |
295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |