@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | // This defines two version types for checking the API's are compatible with this version of SMF. |
20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
40 | 41 | |
41 | 42 | // Is the load average too high to allow searching just now? |
42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | loadLanguage('Search'); |
46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
89 | 91 | $context['search_params'][$k] = $v; |
90 | 92 | } |
91 | - if (isset($context['search_params']['brd'])) |
|
92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
93 | + if (isset($context['search_params']['brd'])) { |
|
94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | |
95 | - if (isset($_REQUEST['search'])) |
|
96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
98 | + if (isset($_REQUEST['search'])) { |
|
99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
100 | + } |
|
97 | 101 | |
98 | - if (isset($context['search_params']['search'])) |
|
99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
100 | - if (isset($context['search_params']['userspec'])) |
|
101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
102 | - if (!empty($context['search_params']['searchtype'])) |
|
103 | - $context['search_params']['searchtype'] = 2; |
|
104 | - if (!empty($context['search_params']['minage'])) |
|
105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
106 | - if (!empty($context['search_params']['maxage'])) |
|
107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
102 | + if (isset($context['search_params']['search'])) { |
|
103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
104 | + } |
|
105 | + if (isset($context['search_params']['userspec'])) { |
|
106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
107 | + } |
|
108 | + if (!empty($context['search_params']['searchtype'])) { |
|
109 | + $context['search_params']['searchtype'] = 2; |
|
110 | + } |
|
111 | + if (!empty($context['search_params']['minage'])) { |
|
112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
113 | + } |
|
114 | + if (!empty($context['search_params']['maxage'])) { |
|
115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
116 | + } |
|
108 | 117 | |
109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
116 | 125 | $context['search_errors']['messages'] = array(); |
117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
118 | 127 | { |
119 | - if ($search_error === 'messages') |
|
120 | - continue; |
|
128 | + if ($search_error === 'messages') { |
|
129 | + continue; |
|
130 | + } |
|
121 | 131 | |
122 | - if ($search_error == 'string_too_long') |
|
123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
132 | + if ($search_error == 'string_too_long') { |
|
133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
134 | + } |
|
124 | 135 | |
125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
144 | 155 | { |
145 | 156 | // This category hasn't been set up yet.. |
146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
147 | - $context['categories'][$row['id_cat']] = array( |
|
157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
158 | + $context['categories'][$row['id_cat']] = array( |
|
148 | 159 | 'id' => $row['id_cat'], |
149 | 160 | 'name' => $row['cat_name'], |
150 | 161 | 'boards' => array() |
151 | 162 | ); |
163 | + } |
|
152 | 164 | |
153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
159 | 171 | ); |
160 | 172 | |
161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
163 | - $context['boards_check_all'] = false; |
|
174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
175 | + $context['boards_check_all'] = false; |
|
176 | + } |
|
164 | 177 | } |
165 | 178 | $smcFunc['db_free_result']($request); |
166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
182 | 195 | } |
183 | 196 | |
184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
185 | - if ($max_boards == 1) |
|
186 | - $max_boards = 2; |
|
198 | + if ($max_boards == 1) { |
|
199 | + $max_boards = 2; |
|
200 | + } |
|
187 | 201 | |
188 | 202 | // Now, alternate them so they can be shown left and right ;). |
189 | 203 | $context['board_columns'] = array(); |
190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
191 | 205 | { |
192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
193 | - if (isset($temp_boards[$i + $max_boards])) |
|
194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
195 | - else |
|
196 | - $context['board_columns'][] = array(); |
|
207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
209 | + } else { |
|
210 | + $context['board_columns'][] = array(); |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | |
199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
225 | 240 | ) |
226 | 241 | ); |
227 | 242 | |
228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
229 | - fatal_lang_error('topic_gone', false); |
|
243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
244 | + fatal_lang_error('topic_gone', false); |
|
245 | + } |
|
230 | 246 | |
231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
256 | 272 | global $excludedWords, $participants, $smcFunc; |
257 | 273 | |
258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
277 | + } |
|
261 | 278 | |
262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
281 | + } |
|
264 | 282 | |
265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
307 | 325 | } |
308 | 326 | |
309 | 327 | // Zero weight. Weightless :P. |
310 | - if (empty($weight_total)) |
|
311 | - fatal_lang_error('search_invalid_weights'); |
|
328 | + if (empty($weight_total)) { |
|
329 | + fatal_lang_error('search_invalid_weights'); |
|
330 | + } |
|
312 | 331 | |
313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
326 | 345 | $context['search_string_limit'] = 100; |
327 | 346 | |
328 | 347 | loadLanguage('Search'); |
329 | - if (!isset($_REQUEST['xml'])) |
|
330 | - loadTemplate('Search'); |
|
348 | + if (!isset($_REQUEST['xml'])) { |
|
349 | + loadTemplate('Search'); |
|
350 | + } |
|
331 | 351 | //If we're doing XML we need to use the results template regardless really. |
332 | - else |
|
333 | - $context['sub_template'] = 'results'; |
|
352 | + else { |
|
353 | + $context['sub_template'] = 'results'; |
|
354 | + } |
|
334 | 355 | |
335 | 356 | // Are you allowed? |
336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
363 | 384 | $search_params[$k] = $v; |
364 | 385 | } |
365 | 386 | |
366 | - if (isset($search_params['brd'])) |
|
367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
387 | + if (isset($search_params['brd'])) { |
|
388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
389 | + } |
|
368 | 390 | } |
369 | 391 | |
370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
371 | - if (!isset($search_params['advanced'])) |
|
372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
393 | + if (!isset($search_params['advanced'])) { |
|
394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
395 | + } |
|
373 | 396 | |
374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
376 | - $search_params['searchtype'] = 2; |
|
398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
399 | + $search_params['searchtype'] = 2; |
|
400 | + } |
|
377 | 401 | |
378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
405 | + } |
|
381 | 406 | |
382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
410 | + } |
|
385 | 411 | |
386 | 412 | // Searching a specific topic? |
387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
388 | 414 | { |
389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
390 | 416 | $search_params['show_complete'] = true; |
417 | + } elseif (!empty($search_params['topic'])) { |
|
418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
391 | 419 | } |
392 | - elseif (!empty($search_params['topic'])) |
|
393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
394 | 420 | |
395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
408 | 434 | ) |
409 | 435 | ); |
410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
439 | + } |
|
413 | 440 | $smcFunc['db_free_result']($request); |
414 | 441 | } |
415 | 442 | |
416 | 443 | // Default the user name to a wildcard matching every user (*). |
417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
446 | + } |
|
419 | 447 | |
420 | 448 | // If there's no specific user, then don't mention it in the main query. |
421 | - if (empty($search_params['userspec'])) |
|
422 | - $userQuery = ''; |
|
423 | - else |
|
449 | + if (empty($search_params['userspec'])) { |
|
450 | + $userQuery = ''; |
|
451 | + } else |
|
424 | 452 | { |
425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
432 | 460 | { |
433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
434 | 462 | |
435 | - if (strlen($possible_users[$k]) == 0) |
|
436 | - unset($possible_users[$k]); |
|
463 | + if (strlen($possible_users[$k]) == 0) { |
|
464 | + unset($possible_users[$k]); |
|
465 | + } |
|
437 | 466 | } |
438 | 467 | |
439 | 468 | // Create a list of database-escaped search names. |
440 | 469 | $realNameMatches = array(); |
441 | - foreach ($possible_users as $possible_user) |
|
442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
470 | + foreach ($possible_users as $possible_user) { |
|
471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
443 | 472 | '{string:possible_user}', |
444 | 473 | array( |
445 | 474 | 'possible_user' => $possible_user |
446 | 475 | ) |
447 | 476 | ); |
477 | + } |
|
448 | 478 | |
449 | 479 | // Retrieve a list of possible members. |
450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
456 | 486 | ) |
457 | 487 | ); |
458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
460 | - $userQuery = ''; |
|
461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
490 | + $userQuery = ''; |
|
491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
462 | 492 | { |
463 | 493 | $userQuery = $smcFunc['db_quote']( |
464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
468 | 498 | ) |
469 | 499 | ); |
470 | - } |
|
471 | - else |
|
500 | + } else |
|
472 | 501 | { |
473 | 502 | $memberlist = array(); |
474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
475 | - $memberlist[] = $row['id_member']; |
|
503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
504 | + $memberlist[] = $row['id_member']; |
|
505 | + } |
|
476 | 506 | $userQuery = $smcFunc['db_quote']( |
477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
486 | 516 | } |
487 | 517 | |
488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
521 | + } |
|
491 | 522 | |
492 | 523 | // Ensure that brd is an array. |
493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
494 | 525 | { |
495 | - if (!empty($_REQUEST['brd'])) |
|
496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
497 | - else |
|
498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
526 | + if (!empty($_REQUEST['brd'])) { |
|
527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
528 | + } else { |
|
529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
530 | + } |
|
499 | 531 | } |
500 | 532 | |
501 | 533 | // Make sure all boards are integers. |
502 | - if (!empty($_REQUEST['brd'])) |
|
503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
534 | + if (!empty($_REQUEST['brd'])) { |
|
535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
537 | + } |
|
505 | 538 | |
506 | 539 | // Special case for boards: searching just one topic? |
507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
520 | 553 | ) |
521 | 554 | ); |
522 | 555 | |
523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
524 | - fatal_lang_error('topic_gone', false); |
|
556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
557 | + fatal_lang_error('topic_gone', false); |
|
558 | + } |
|
525 | 559 | |
526 | 560 | $search_params['brd'] = array(); |
527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
528 | 562 | $smcFunc['db_free_result']($request); |
529 | 563 | } |
530 | 564 | // Select all boards you've selected AND are allowed to see. |
531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
533 | - else |
|
565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
567 | + } else |
|
534 | 568 | { |
535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
548 | 582 | ) |
549 | 583 | ); |
550 | 584 | $search_params['brd'] = array(); |
551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
552 | - $search_params['brd'][] = $row['id_board']; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
586 | + $search_params['brd'][] = $row['id_board']; |
|
587 | + } |
|
553 | 588 | $smcFunc['db_free_result']($request); |
554 | 589 | |
555 | 590 | // This error should pro'bly only happen for hackers. |
556 | - if (empty($search_params['brd'])) |
|
557 | - $context['search_errors']['no_boards_selected'] = true; |
|
591 | + if (empty($search_params['brd'])) { |
|
592 | + $context['search_errors']['no_boards_selected'] = true; |
|
593 | + } |
|
558 | 594 | } |
559 | 595 | |
560 | 596 | if (count($search_params['brd']) != 0) |
561 | 597 | { |
562 | - foreach ($search_params['brd'] as $k => $v) |
|
563 | - $search_params['brd'][$k] = (int) $v; |
|
598 | + foreach ($search_params['brd'] as $k => $v) { |
|
599 | + $search_params['brd'][$k] = (int) $v; |
|
600 | + } |
|
564 | 601 | |
565 | 602 | // If we've selected all boards, this parameter can be left empty. |
566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
575 | 612 | $smcFunc['db_free_result']($request); |
576 | 613 | |
577 | - if (count($search_params['brd']) == $num_boards) |
|
614 | + if (count($search_params['brd']) == $num_boards) { |
|
615 | + $boardQuery = ''; |
|
616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
618 | + } else { |
|
619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
620 | + } |
|
621 | + } else { |
|
578 | 622 | $boardQuery = ''; |
579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
581 | - else |
|
582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
583 | 623 | } |
584 | - else |
|
585 | - $boardQuery = ''; |
|
586 | 624 | |
587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
596 | 634 | 'id_msg', |
597 | 635 | ); |
598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
639 | + } |
|
601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
603 | - $search_params['sort'] = 'id_msg'; |
|
641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
642 | + $search_params['sort'] = 'id_msg'; |
|
643 | + } |
|
604 | 644 | |
605 | 645 | // Sorting direction: descending unless stated otherwise. |
606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
624 | 664 | // What are we searching for? |
625 | 665 | if (empty($search_params['search'])) |
626 | 666 | { |
627 | - if (isset($_GET['search'])) |
|
628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
629 | - elseif (isset($_POST['search'])) |
|
630 | - $search_params['search'] = $_POST['search']; |
|
631 | - else |
|
632 | - $search_params['search'] = ''; |
|
667 | + if (isset($_GET['search'])) { |
|
668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
669 | + } elseif (isset($_POST['search'])) { |
|
670 | + $search_params['search'] = $_POST['search']; |
|
671 | + } else { |
|
672 | + $search_params['search'] = ''; |
|
673 | + } |
|
633 | 674 | } |
634 | 675 | |
635 | 676 | // Nothing?? |
636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
637 | - $context['search_errors']['invalid_search_string'] = true; |
|
677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
678 | + $context['search_errors']['invalid_search_string'] = true; |
|
679 | + } |
|
638 | 680 | // Too long? |
639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
649 | 691 | |
650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
695 | + } |
|
653 | 696 | |
654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
672 | 715 | { |
673 | 716 | if ($word === '-') |
674 | 717 | { |
675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
676 | - $excludedWords[] = $word; |
|
718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
719 | + $excludedWords[] = $word; |
|
720 | + } |
|
677 | 721 | unset($phraseArray[$index]); |
678 | 722 | } |
679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
683 | 727 | { |
684 | 728 | if (strpos(trim($word), '-') === 0) |
685 | 729 | { |
686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
687 | - $excludedWords[] = $word; |
|
730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
731 | + $excludedWords[] = $word; |
|
732 | + } |
|
688 | 733 | unset($wordArray[$index]); |
689 | 734 | } |
690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
697 | 742 | foreach ($searchArray as $index => $value) |
698 | 743 | { |
699 | 744 | // Skip anything practically empty. |
700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
701 | - unset($searchArray[$index]); |
|
745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
746 | + unset($searchArray[$index]); |
|
747 | + } |
|
702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
704 | 750 | { |
@@ -716,31 +762,37 @@ discard block |
||
716 | 762 | |
717 | 763 | // Create an array of replacements for highlighting. |
718 | 764 | $context['mark'] = array(); |
719 | - foreach ($searchArray as $word) |
|
720 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
765 | + foreach ($searchArray as $word) { |
|
766 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
767 | + } |
|
721 | 768 | |
722 | 769 | // Initialize two arrays storing the words that have to be searched for. |
723 | 770 | $orParts = array(); |
724 | 771 | $searchWords = array(); |
725 | 772 | |
726 | 773 | // Make sure at least one word is being searched for. |
727 | - if (empty($searchArray)) |
|
728 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
774 | + if (empty($searchArray)) { |
|
775 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
776 | + } |
|
729 | 777 | // All words/sentences must match. |
730 | - elseif (empty($search_params['searchtype'])) |
|
731 | - $orParts[0] = $searchArray; |
|
778 | + elseif (empty($search_params['searchtype'])) { |
|
779 | + $orParts[0] = $searchArray; |
|
780 | + } |
|
732 | 781 | // Any word/sentence must match. |
733 | - else |
|
734 | - foreach ($searchArray as $index => $value) |
|
782 | + else { |
|
783 | + foreach ($searchArray as $index => $value) |
|
735 | 784 | $orParts[$index] = array($value); |
785 | + } |
|
736 | 786 | |
737 | 787 | // Don't allow duplicate error messages if one string is too short. |
738 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
739 | - unset($context['search_errors']['invalid_search_string']); |
|
788 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
789 | + unset($context['search_errors']['invalid_search_string']); |
|
790 | + } |
|
740 | 791 | // Make sure the excluded words are in all or-branches. |
741 | - foreach ($orParts as $orIndex => $andParts) |
|
742 | - foreach ($excludedWords as $word) |
|
792 | + foreach ($orParts as $orIndex => $andParts) { |
|
793 | + foreach ($excludedWords as $word) |
|
743 | 794 | $orParts[$orIndex][] = $word; |
795 | + } |
|
744 | 796 | |
745 | 797 | // Determine the or-branches and the fulltext search words. |
746 | 798 | foreach ($orParts as $orIndex => $andParts) |
@@ -754,8 +806,9 @@ discard block |
||
754 | 806 | ); |
755 | 807 | |
756 | 808 | // Sort the indexed words (large words -> small words -> excluded words). |
757 | - if ($searchAPI->supportsMethod('searchSort')) |
|
758 | - usort($orParts[$orIndex], 'searchSort'); |
|
809 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
810 | + usort($orParts[$orIndex], 'searchSort'); |
|
811 | + } |
|
759 | 812 | |
760 | 813 | foreach ($orParts[$orIndex] as $word) |
761 | 814 | { |
@@ -767,15 +820,17 @@ discard block |
||
767 | 820 | if (!$is_excluded || count($subjectWords) === 1) |
768 | 821 | { |
769 | 822 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
770 | - if ($is_excluded) |
|
771 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
823 | + if ($is_excluded) { |
|
824 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
825 | + } |
|
826 | + } else { |
|
827 | + $excludedPhrases[] = $word; |
|
772 | 828 | } |
773 | - else |
|
774 | - $excludedPhrases[] = $word; |
|
775 | 829 | |
776 | 830 | // Have we got indexes to prepare? |
777 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
778 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
831 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
832 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
833 | + } |
|
779 | 834 | } |
780 | 835 | |
781 | 836 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -783,8 +838,7 @@ discard block |
||
783 | 838 | { |
784 | 839 | $context['search_errors']['query_not_specific_enough'] = true; |
785 | 840 | break; |
786 | - } |
|
787 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
841 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
788 | 842 | { |
789 | 843 | $context['search_errors']['query_not_specific_enough'] = true; |
790 | 844 | break; |
@@ -812,8 +866,9 @@ discard block |
||
812 | 866 | $found_misspelling = false; |
813 | 867 | foreach ($searchArray as $word) |
814 | 868 | { |
815 | - if (empty($link)) |
|
816 | - continue; |
|
869 | + if (empty($link)) { |
|
870 | + continue; |
|
871 | + } |
|
817 | 872 | |
818 | 873 | // Don't check phrases. |
819 | 874 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -828,8 +883,7 @@ discard block |
||
828 | 883 | $did_you_mean['search'][] = $word; |
829 | 884 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
830 | 885 | continue; |
831 | - } |
|
832 | - elseif (spell_check($link, $word)) |
|
886 | + } elseif (spell_check($link, $word)) |
|
833 | 887 | { |
834 | 888 | $did_you_mean['search'][] = $word; |
835 | 889 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -840,11 +894,13 @@ discard block |
||
840 | 894 | foreach ($suggestions as $i => $s) |
841 | 895 | { |
842 | 896 | // Search is case insensitive. |
843 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
844 | - unset($suggestions[$i]); |
|
897 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
898 | + unset($suggestions[$i]); |
|
899 | + } |
|
845 | 900 | // Plus, don't suggest something the user thinks is rude! |
846 | - elseif ($suggestions[$i] != censorText($s)) |
|
847 | - unset($suggestions[$i]); |
|
901 | + elseif ($suggestions[$i] != censorText($s)) { |
|
902 | + unset($suggestions[$i]); |
|
903 | + } |
|
848 | 904 | } |
849 | 905 | |
850 | 906 | // Anything found? If so, correct it! |
@@ -854,8 +910,7 @@ discard block |
||
854 | 910 | $did_you_mean['search'][] = $suggestions[0]; |
855 | 911 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
856 | 912 | $found_misspelling = true; |
857 | - } |
|
858 | - else |
|
913 | + } else |
|
859 | 914 | { |
860 | 915 | $did_you_mean['search'][] = $word; |
861 | 916 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -872,8 +927,7 @@ discard block |
||
872 | 927 | { |
873 | 928 | $temp_excluded['search'][] = '-"' . $word . '"'; |
874 | 929 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
875 | - } |
|
876 | - else |
|
930 | + } else |
|
877 | 931 | { |
878 | 932 | $temp_excluded['search'][] = '-' . $word; |
879 | 933 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -885,11 +939,13 @@ discard block |
||
885 | 939 | |
886 | 940 | $temp_params = $search_params; |
887 | 941 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
888 | - if (isset($temp_params['brd'])) |
|
889 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
942 | + if (isset($temp_params['brd'])) { |
|
943 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
944 | + } |
|
890 | 945 | $context['params'] = array(); |
891 | - foreach ($temp_params as $k => $v) |
|
892 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
946 | + foreach ($temp_params as $k => $v) { |
|
947 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
948 | + } |
|
893 | 949 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
894 | 950 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
895 | 951 | } |
@@ -897,18 +953,20 @@ discard block |
||
897 | 953 | |
898 | 954 | // Let the user adjust the search query, should they wish? |
899 | 955 | $context['search_params'] = $search_params; |
900 | - if (isset($context['search_params']['search'])) |
|
901 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
902 | - if (isset($context['search_params']['userspec'])) |
|
903 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
956 | + if (isset($context['search_params']['search'])) { |
|
957 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
958 | + } |
|
959 | + if (isset($context['search_params']['userspec'])) { |
|
960 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
961 | + } |
|
904 | 962 | |
905 | 963 | // Do we have captcha enabled? |
906 | 964 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
907 | 965 | { |
908 | 966 | // If we come from another search box tone down the error... |
909 | - if (!isset($_REQUEST['search_vv'])) |
|
910 | - $context['search_errors']['need_verification_code'] = true; |
|
911 | - else |
|
967 | + if (!isset($_REQUEST['search_vv'])) { |
|
968 | + $context['search_errors']['need_verification_code'] = true; |
|
969 | + } else |
|
912 | 970 | { |
913 | 971 | require_once($sourcedir . '/Subs-Editor.php'); |
914 | 972 | $verificationOptions = array( |
@@ -918,12 +976,14 @@ discard block |
||
918 | 976 | |
919 | 977 | if (is_array($context['require_verification'])) |
920 | 978 | { |
921 | - foreach ($context['require_verification'] as $error) |
|
922 | - $context['search_errors'][$error] = true; |
|
979 | + foreach ($context['require_verification'] as $error) { |
|
980 | + $context['search_errors'][$error] = true; |
|
981 | + } |
|
923 | 982 | } |
924 | 983 | // Don't keep asking for it - they've proven themselves worthy. |
925 | - else |
|
926 | - $_SESSION['ss_vv_passed'] = true; |
|
984 | + else { |
|
985 | + $_SESSION['ss_vv_passed'] = true; |
|
986 | + } |
|
927 | 987 | } |
928 | 988 | } |
929 | 989 | |
@@ -931,19 +991,22 @@ discard block |
||
931 | 991 | |
932 | 992 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
933 | 993 | $temp_params = $search_params; |
934 | - if (isset($temp_params['brd'])) |
|
935 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
994 | + if (isset($temp_params['brd'])) { |
|
995 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
996 | + } |
|
936 | 997 | $context['params'] = array(); |
937 | - foreach ($temp_params as $k => $v) |
|
938 | - $context['params'][] = $k . '|\'|' . $v; |
|
998 | + foreach ($temp_params as $k => $v) { |
|
999 | + $context['params'][] = $k . '|\'|' . $v; |
|
1000 | + } |
|
939 | 1001 | |
940 | 1002 | if (!empty($context['params'])) |
941 | 1003 | { |
942 | 1004 | // Due to old IE's 2083 character limit, we have to compress long search strings |
943 | 1005 | $params = @gzcompress(implode('|"|', $context['params'])); |
944 | 1006 | // Gzcompress failed, use try non-gz |
945 | - if (empty($params)) |
|
946 | - $params = implode('|"|', $context['params']); |
|
1007 | + if (empty($params)) { |
|
1008 | + $params = implode('|"|', $context['params']); |
|
1009 | + } |
|
947 | 1010 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
948 | 1011 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
949 | 1012 | } |
@@ -969,8 +1032,9 @@ discard block |
||
969 | 1032 | } |
970 | 1033 | |
971 | 1034 | // Spam me not, Spam-a-lot? |
972 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
973 | - spamProtection('search'); |
|
1035 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
1036 | + spamProtection('search'); |
|
1037 | + } |
|
974 | 1038 | // Store the last search string to allow pages of results to be browsed. |
975 | 1039 | $_SESSION['last_ss'] = $search_params['search']; |
976 | 1040 | |
@@ -1030,8 +1094,9 @@ discard block |
||
1030 | 1094 | 'where' => array(), |
1031 | 1095 | ); |
1032 | 1096 | |
1033 | - if ($modSettings['postmod_active']) |
|
1034 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1097 | + if ($modSettings['postmod_active']) { |
|
1098 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1099 | + } |
|
1035 | 1100 | |
1036 | 1101 | $numTables = 0; |
1037 | 1102 | $prev_join = 0; |
@@ -1043,8 +1108,7 @@ discard block |
||
1043 | 1108 | { |
1044 | 1109 | $subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)'; |
1045 | 1110 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1046 | - } |
|
1047 | - else |
|
1111 | + } else |
|
1048 | 1112 | { |
1049 | 1113 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1050 | 1114 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1062,14 +1126,18 @@ discard block |
||
1062 | 1126 | } |
1063 | 1127 | $subject_query['where'][] = $userQuery; |
1064 | 1128 | } |
1065 | - if (!empty($search_params['topic'])) |
|
1066 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1067 | - if (!empty($minMsgID)) |
|
1068 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1069 | - if (!empty($maxMsgID)) |
|
1070 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1071 | - if (!empty($boardQuery)) |
|
1072 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1129 | + if (!empty($search_params['topic'])) { |
|
1130 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1131 | + } |
|
1132 | + if (!empty($minMsgID)) { |
|
1133 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1134 | + } |
|
1135 | + if (!empty($maxMsgID)) { |
|
1136 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1137 | + } |
|
1138 | + if (!empty($boardQuery)) { |
|
1139 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1140 | + } |
|
1073 | 1141 | if (!empty($excludedPhrases)) |
1074 | 1142 | { |
1075 | 1143 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1089,8 +1157,9 @@ discard block |
||
1089 | 1157 | foreach ($weight_factors as $type => $value) |
1090 | 1158 | { |
1091 | 1159 | $relevance .= $weight[$type]; |
1092 | - if (!empty($value['results'])) |
|
1093 | - $relevance .= ' * ' . $value['results']; |
|
1160 | + if (!empty($value['results'])) { |
|
1161 | + $relevance .= ' * ' . $value['results']; |
|
1162 | + } |
|
1094 | 1163 | $relevance .= ' + '; |
1095 | 1164 | } |
1096 | 1165 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1128,20 +1197,23 @@ discard block |
||
1128 | 1197 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1129 | 1198 | { |
1130 | 1199 | // No duplicates! |
1131 | - if (isset($inserts[$row[1]])) |
|
1132 | - continue; |
|
1200 | + if (isset($inserts[$row[1]])) { |
|
1201 | + continue; |
|
1202 | + } |
|
1133 | 1203 | |
1134 | - foreach ($row as $key => $value) |
|
1135 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
1204 | + foreach ($row as $key => $value) { |
|
1205 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
1206 | + } |
|
1136 | 1207 | } |
1137 | 1208 | $smcFunc['db_free_result']($ignoreRequest); |
1138 | 1209 | $numSubjectResults = count($inserts); |
1210 | + } else { |
|
1211 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1139 | 1212 | } |
1140 | - else |
|
1141 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1142 | 1213 | |
1143 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1144 | - break; |
|
1214 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1215 | + break; |
|
1216 | + } |
|
1145 | 1217 | } |
1146 | 1218 | |
1147 | 1219 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1156,8 +1228,7 @@ discard block |
||
1156 | 1228 | } |
1157 | 1229 | |
1158 | 1230 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
1159 | - } |
|
1160 | - else |
|
1231 | + } else |
|
1161 | 1232 | { |
1162 | 1233 | $main_query = array( |
1163 | 1234 | 'select' => array( |
@@ -1189,8 +1260,7 @@ discard block |
||
1189 | 1260 | $main_query['weights'] = $weight_factors; |
1190 | 1261 | |
1191 | 1262 | $main_query['group_by'][] = 't.id_topic'; |
1192 | - } |
|
1193 | - else |
|
1263 | + } else |
|
1194 | 1264 | { |
1195 | 1265 | // This is outrageous! |
1196 | 1266 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1211,8 +1281,9 @@ discard block |
||
1211 | 1281 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
1212 | 1282 | $main_query['parameters']['topic'] = $search_params['topic']; |
1213 | 1283 | } |
1214 | - if (!empty($search_params['show_complete'])) |
|
1215 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1284 | + if (!empty($search_params['show_complete'])) { |
|
1285 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1286 | + } |
|
1216 | 1287 | } |
1217 | 1288 | |
1218 | 1289 | // *** Get the subject results. |
@@ -1237,14 +1308,15 @@ discard block |
||
1237 | 1308 | ) !== false; |
1238 | 1309 | |
1239 | 1310 | // Clean up some previous cache. |
1240 | - if (!$createTemporary) |
|
1241 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1311 | + if (!$createTemporary) { |
|
1312 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1242 | 1313 | DELETE FROM {db_prefix}log_search_topics |
1243 | 1314 | WHERE id_search = {int:search_id}', |
1244 | 1315 | array( |
1245 | 1316 | 'search_id' => $_SESSION['search_cache']['id_search'], |
1246 | 1317 | ) |
1247 | 1318 | ); |
1319 | + } |
|
1248 | 1320 | |
1249 | 1321 | foreach ($searchWords as $orIndex => $words) |
1250 | 1322 | { |
@@ -1276,8 +1348,7 @@ discard block |
||
1276 | 1348 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1277 | 1349 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
1278 | 1350 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
1279 | - } |
|
1280 | - else |
|
1351 | + } else |
|
1281 | 1352 | { |
1282 | 1353 | $subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)'; |
1283 | 1354 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1332,8 +1403,9 @@ discard block |
||
1332 | 1403 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
1333 | 1404 | |
1334 | 1405 | // Nothing to search for? |
1335 | - if (empty($subject_query['where'])) |
|
1336 | - continue; |
|
1406 | + if (empty($subject_query['where'])) { |
|
1407 | + continue; |
|
1408 | + } |
|
1337 | 1409 | |
1338 | 1410 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
1339 | 1411 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1356,19 +1428,21 @@ discard block |
||
1356 | 1428 | { |
1357 | 1429 | $ind = $createTemporary ? 0 : 1; |
1358 | 1430 | // No duplicates! |
1359 | - if (isset($inserts[$row[$ind]])) |
|
1360 | - continue; |
|
1431 | + if (isset($inserts[$row[$ind]])) { |
|
1432 | + continue; |
|
1433 | + } |
|
1361 | 1434 | |
1362 | 1435 | $inserts[$row[$ind]] = $row; |
1363 | 1436 | } |
1364 | 1437 | $smcFunc['db_free_result']($ignoreRequest); |
1365 | 1438 | $numSubjectResults = count($inserts); |
1439 | + } else { |
|
1440 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1366 | 1441 | } |
1367 | - else |
|
1368 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1369 | 1442 | |
1370 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1371 | - break; |
|
1443 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1444 | + break; |
|
1445 | + } |
|
1372 | 1446 | } |
1373 | 1447 | |
1374 | 1448 | // Got some non-MySQL data to plonk in? |
@@ -1386,8 +1460,9 @@ discard block |
||
1386 | 1460 | { |
1387 | 1461 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
1388 | 1462 | $main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)'; |
1389 | - if (!$createTemporary) |
|
1390 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1463 | + if (!$createTemporary) { |
|
1464 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1465 | + } |
|
1391 | 1466 | } |
1392 | 1467 | } |
1393 | 1468 | |
@@ -1413,14 +1488,15 @@ discard block |
||
1413 | 1488 | ) !== false; |
1414 | 1489 | |
1415 | 1490 | // Clear, all clear! |
1416 | - if (!$createTemporary) |
|
1417 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1491 | + if (!$createTemporary) { |
|
1492 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1418 | 1493 | DELETE FROM {db_prefix}log_search_messages |
1419 | 1494 | WHERE id_search = {int:id_search}', |
1420 | 1495 | array( |
1421 | 1496 | 'id_search' => $_SESSION['search_cache']['id_search'], |
1422 | 1497 | ) |
1423 | 1498 | ); |
1499 | + } |
|
1424 | 1500 | |
1425 | 1501 | foreach ($searchWords as $orIndex => $words) |
1426 | 1502 | { |
@@ -1454,19 +1530,21 @@ discard block |
||
1454 | 1530 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1455 | 1531 | { |
1456 | 1532 | // No duplicates! |
1457 | - if (isset($inserts[$row[0]])) |
|
1458 | - continue; |
|
1533 | + if (isset($inserts[$row[0]])) { |
|
1534 | + continue; |
|
1535 | + } |
|
1459 | 1536 | |
1460 | 1537 | $inserts[$row[0]] = $row; |
1461 | 1538 | } |
1462 | 1539 | $smcFunc['db_free_result']($ignoreRequest); |
1463 | 1540 | $indexedResults = count($inserts); |
1541 | + } else { |
|
1542 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
1464 | 1543 | } |
1465 | - else |
|
1466 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
1467 | 1544 | |
1468 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
1469 | - break; |
|
1545 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
1546 | + break; |
|
1547 | + } |
|
1470 | 1548 | } |
1471 | 1549 | } |
1472 | 1550 | |
@@ -1486,8 +1564,7 @@ discard block |
||
1486 | 1564 | $context['search_errors']['query_not_specific_enough'] = true; |
1487 | 1565 | $_REQUEST['params'] = $context['params']; |
1488 | 1566 | return PlushSearch1(); |
1489 | - } |
|
1490 | - elseif (!empty($indexedResults)) |
|
1567 | + } elseif (!empty($indexedResults)) |
|
1491 | 1568 | { |
1492 | 1569 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
1493 | 1570 | if (!$createTemporary) |
@@ -1509,15 +1586,18 @@ discard block |
||
1509 | 1586 | foreach ($words['all_words'] as $regularWord) |
1510 | 1587 | { |
1511 | 1588 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
1512 | - if (in_array($regularWord, $excludedWords)) |
|
1513 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1589 | + if (in_array($regularWord, $excludedWords)) { |
|
1590 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1591 | + } |
|
1514 | 1592 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
1515 | 1593 | } |
1516 | - if (!empty($where)) |
|
1517 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1594 | + if (!empty($where)) { |
|
1595 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1596 | + } |
|
1597 | + } |
|
1598 | + if (!empty($orWhere)) { |
|
1599 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1518 | 1600 | } |
1519 | - if (!empty($orWhere)) |
|
1520 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1521 | 1601 | |
1522 | 1602 | if (!empty($userQuery)) |
1523 | 1603 | { |
@@ -1555,8 +1635,9 @@ discard block |
||
1555 | 1635 | foreach ($main_query['weights'] as $type => $value) |
1556 | 1636 | { |
1557 | 1637 | $relevance .= $weight[$type]; |
1558 | - if (!empty($value['search'])) |
|
1559 | - $relevance .= ' * ' . $value['search']; |
|
1638 | + if (!empty($value['search'])) { |
|
1639 | + $relevance .= ' * ' . $value['search']; |
|
1640 | + } |
|
1560 | 1641 | $relevance .= ' + '; |
1561 | 1642 | $new_weight_total += $weight[$type]; |
1562 | 1643 | } |
@@ -1587,11 +1668,13 @@ discard block |
||
1587 | 1668 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1588 | 1669 | { |
1589 | 1670 | // No duplicates! |
1590 | - if (isset($inserts[$row[2]])) |
|
1591 | - continue; |
|
1671 | + if (isset($inserts[$row[2]])) { |
|
1672 | + continue; |
|
1673 | + } |
|
1592 | 1674 | |
1593 | - foreach ($row as $key => $value) |
|
1594 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
1675 | + foreach ($row as $key => $value) { |
|
1676 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
1677 | + } |
|
1595 | 1678 | } |
1596 | 1679 | $smcFunc['db_free_result']($ignoreRequest); |
1597 | 1680 | |
@@ -1599,8 +1682,9 @@ discard block |
||
1599 | 1682 | if (!empty($inserts)) |
1600 | 1683 | { |
1601 | 1684 | $query_columns = array(); |
1602 | - foreach ($main_query['select'] as $k => $v) |
|
1603 | - $query_columns[$k] = 'int'; |
|
1685 | + foreach ($main_query['select'] as $k => $v) { |
|
1686 | + $query_columns[$k] = 'int'; |
|
1687 | + } |
|
1604 | 1688 | |
1605 | 1689 | $smcFunc['db_insert']('', |
1606 | 1690 | '{db_prefix}log_search_results', |
@@ -1610,21 +1694,23 @@ discard block |
||
1610 | 1694 | ); |
1611 | 1695 | } |
1612 | 1696 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1697 | + } else { |
|
1698 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1613 | 1699 | } |
1614 | - else |
|
1615 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1616 | 1700 | } |
1617 | 1701 | |
1618 | 1702 | // Insert subject-only matches. |
1619 | 1703 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
1620 | 1704 | { |
1621 | 1705 | $relevance = '1000 * ('; |
1622 | - foreach ($weight_factors as $type => $value) |
|
1623 | - if (isset($value['results'])) |
|
1706 | + foreach ($weight_factors as $type => $value) { |
|
1707 | + if (isset($value['results'])) |
|
1624 | 1708 | { |
1625 | 1709 | $relevance .= $weight[$type]; |
1626 | - if (!empty($value['results'])) |
|
1627 | - $relevance .= ' * ' . $value['results']; |
|
1710 | + } |
|
1711 | + if (!empty($value['results'])) { |
|
1712 | + $relevance .= ' * ' . $value['results']; |
|
1713 | + } |
|
1628 | 1714 | $relevance .= ' + '; |
1629 | 1715 | } |
1630 | 1716 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1658,8 +1744,9 @@ discard block |
||
1658 | 1744 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1659 | 1745 | { |
1660 | 1746 | // No duplicates! |
1661 | - if (isset($usedIDs[$row[1]])) |
|
1662 | - continue; |
|
1747 | + if (isset($usedIDs[$row[1]])) { |
|
1748 | + continue; |
|
1749 | + } |
|
1663 | 1750 | |
1664 | 1751 | $usedIDs[$row[1]] = true; |
1665 | 1752 | $inserts[] = $row; |
@@ -1677,12 +1764,12 @@ discard block |
||
1677 | 1764 | ); |
1678 | 1765 | } |
1679 | 1766 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1767 | + } else { |
|
1768 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1680 | 1769 | } |
1681 | - else |
|
1682 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1770 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
1771 | + $_SESSION['search_cache']['num_results'] = 0; |
|
1683 | 1772 | } |
1684 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
1685 | - $_SESSION['search_cache']['num_results'] = 0; |
|
1686 | 1773 | } |
1687 | 1774 | } |
1688 | 1775 | |
@@ -1752,14 +1839,16 @@ discard block |
||
1752 | 1839 | ) |
1753 | 1840 | ); |
1754 | 1841 | $posters = array(); |
1755 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1756 | - $posters[] = $row['id_member']; |
|
1842 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1843 | + $posters[] = $row['id_member']; |
|
1844 | + } |
|
1757 | 1845 | $smcFunc['db_free_result']($request); |
1758 | 1846 | |
1759 | 1847 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
1760 | 1848 | |
1761 | - if (!empty($posters)) |
|
1762 | - loadMemberData(array_unique($posters)); |
|
1849 | + if (!empty($posters)) { |
|
1850 | + loadMemberData(array_unique($posters)); |
|
1851 | + } |
|
1763 | 1852 | |
1764 | 1853 | // PG optimization to evade FIND_IN_SET |
1765 | 1854 | if ($smcFunc['db_title'] == 'PostgreSQL') |
@@ -1768,8 +1857,9 @@ discard block |
||
1768 | 1857 | $msg_list_size = count($msg_list); |
1769 | 1858 | for ($i = 0; $i < $msg_list_size; $i++) |
1770 | 1859 | { |
1771 | - if ($i > 0) |
|
1772 | - $orderJoin .= ','; |
|
1860 | + if ($i > 0) { |
|
1861 | + $orderJoin .= ','; |
|
1862 | + } |
|
1773 | 1863 | $orderJoin .= '(' . $i . ',' . $msg_list[$i] . ')'; |
1774 | 1864 | } |
1775 | 1865 | |
@@ -1809,8 +1899,9 @@ discard block |
||
1809 | 1899 | ); |
1810 | 1900 | |
1811 | 1901 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
1812 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
1813 | - $context['topics'] = array(); |
|
1902 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
1903 | + $context['topics'] = array(); |
|
1904 | + } |
|
1814 | 1905 | |
1815 | 1906 | // If we want to know who participated in what then load this now. |
1816 | 1907 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1828,8 +1919,9 @@ discard block |
||
1828 | 1919 | 'limit' => count($participants), |
1829 | 1920 | ) |
1830 | 1921 | ); |
1831 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1832 | - $participants[$row['id_topic']] = true; |
|
1922 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1923 | + $participants[$row['id_topic']] = true; |
|
1924 | + } |
|
1833 | 1925 | $smcFunc['db_free_result']($result); |
1834 | 1926 | } |
1835 | 1927 | } |
@@ -1838,15 +1930,17 @@ discard block |
||
1838 | 1930 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
1839 | 1931 | |
1840 | 1932 | // Consider the search complete! |
1841 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1842 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1933 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1934 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1935 | + } |
|
1843 | 1936 | |
1844 | 1937 | $context['key_words'] = &$searchArray; |
1845 | 1938 | |
1846 | 1939 | // Setup the default topic icons... for checking they exist and the like! |
1847 | 1940 | $context['icon_sources'] = array(); |
1848 | - foreach ($context['stable_icons'] as $icon) |
|
1849 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1941 | + foreach ($context['stable_icons'] as $icon) { |
|
1942 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1943 | + } |
|
1850 | 1944 | |
1851 | 1945 | $context['sub_template'] = 'results'; |
1852 | 1946 | $context['page_title'] = $txt['search_results']; |
@@ -1877,26 +1971,31 @@ discard block |
||
1877 | 1971 | global $boards_can, $participants, $smcFunc; |
1878 | 1972 | static $recycle_board = null; |
1879 | 1973 | |
1880 | - if ($recycle_board === null) |
|
1881 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1974 | + if ($recycle_board === null) { |
|
1975 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1976 | + } |
|
1882 | 1977 | |
1883 | 1978 | // Remember which message this is. (ie. reply #83) |
1884 | 1979 | static $counter = null; |
1885 | - if ($counter == null || $reset) |
|
1886 | - $counter = $_REQUEST['start'] + 1; |
|
1980 | + if ($counter == null || $reset) { |
|
1981 | + $counter = $_REQUEST['start'] + 1; |
|
1982 | + } |
|
1887 | 1983 | |
1888 | 1984 | // If the query returned false, bail. |
1889 | - if ($messages_request == false) |
|
1890 | - return false; |
|
1985 | + if ($messages_request == false) { |
|
1986 | + return false; |
|
1987 | + } |
|
1891 | 1988 | |
1892 | 1989 | // Start from the beginning... |
1893 | - if ($reset) |
|
1894 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1990 | + if ($reset) { |
|
1991 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1992 | + } |
|
1895 | 1993 | |
1896 | 1994 | // Attempt to get the next message. |
1897 | 1995 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1898 | - if (!$message) |
|
1899 | - return false; |
|
1996 | + if (!$message) { |
|
1997 | + return false; |
|
1998 | + } |
|
1900 | 1999 | |
1901 | 2000 | // Can't have an empty subject can we? |
1902 | 2001 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1935,9 +2034,9 @@ discard block |
||
1935 | 2034 | |
1936 | 2035 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
1937 | 2036 | { |
1938 | - if (empty($context['key_words'])) |
|
1939 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
1940 | - else |
|
2037 | + if (empty($context['key_words'])) { |
|
2038 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
2039 | + } else |
|
1941 | 2040 | { |
1942 | 2041 | $matchString = ''; |
1943 | 2042 | $force_partial_word = false; |
@@ -1946,18 +2045,20 @@ discard block |
||
1946 | 2045 | $keyword = un_htmlspecialchars($keyword); |
1947 | 2046 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
1948 | 2047 | |
1949 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
1950 | - $force_partial_word = true; |
|
2048 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
2049 | + $force_partial_word = true; |
|
2050 | + } |
|
1951 | 2051 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
1952 | 2052 | } |
1953 | 2053 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
1954 | 2054 | |
1955 | 2055 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
1956 | 2056 | |
1957 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
1958 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
1959 | - else |
|
1960 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2057 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
2058 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2059 | + } else { |
|
2060 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2061 | + } |
|
1961 | 2062 | |
1962 | 2063 | $message['body'] = ''; |
1963 | 2064 | foreach ($matches[0] as $index => $match) |
@@ -1970,8 +2071,7 @@ discard block |
||
1970 | 2071 | // Re-fix the international characters. |
1971 | 2072 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
1972 | 2073 | } |
1973 | - } |
|
1974 | - else |
|
2074 | + } else |
|
1975 | 2075 | { |
1976 | 2076 | // Run BBC interpreter on the message. |
1977 | 2077 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1990,21 +2090,26 @@ discard block |
||
1990 | 2090 | // Sadly, we need to check the icon ain't broke. |
1991 | 2091 | if (!empty($modSettings['messageIconChecks_enable'])) |
1992 | 2092 | { |
1993 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1994 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1995 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1996 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1997 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1998 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1999 | - } |
|
2000 | - else |
|
2093 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2094 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2095 | + } |
|
2096 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2097 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2098 | + } |
|
2099 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2100 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2101 | + } |
|
2102 | + } else |
|
2001 | 2103 | { |
2002 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
2003 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2004 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
2005 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2006 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
2007 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2104 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2105 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2106 | + } |
|
2107 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2108 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2109 | + } |
|
2110 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2111 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2112 | + } |
|
2008 | 2113 | } |
2009 | 2114 | |
2010 | 2115 | // Do we have quote tag enabled? |
@@ -2014,12 +2119,14 @@ discard block |
||
2014 | 2119 | $colorClass = 'windowbg'; |
2015 | 2120 | |
2016 | 2121 | // Sticky topics should get a different color, too. |
2017 | - if ($message['is_sticky']) |
|
2018 | - $colorClass .= ' sticky'; |
|
2122 | + if ($message['is_sticky']) { |
|
2123 | + $colorClass .= ' sticky'; |
|
2124 | + } |
|
2019 | 2125 | |
2020 | 2126 | // Locked topics get special treatment as well. |
2021 | - if ($message['locked']) |
|
2022 | - $colorClass .= ' locked'; |
|
2127 | + if ($message['locked']) { |
|
2128 | + $colorClass .= ' locked'; |
|
2129 | + } |
|
2023 | 2130 | |
2024 | 2131 | $output = array_merge($context['topics'][$message['id_msg']], array( |
2025 | 2132 | 'id' => $message['id_topic'], |
@@ -2163,8 +2270,9 @@ discard block |
||
2163 | 2270 | |
2164 | 2271 | // Load up the search API we are going to use. |
2165 | 2272 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
2166 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
2167 | - fatal_lang_error('search_api_missing'); |
|
2273 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
2274 | + fatal_lang_error('search_api_missing'); |
|
2275 | + } |
|
2168 | 2276 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
2169 | 2277 | |
2170 | 2278 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -116,9 +116,10 @@ discard block |
||
116 | 116 | <h3 class="catbg">', $txt['attachment_transfer'], '</h3> |
117 | 117 | </div>'; |
118 | 118 | |
119 | - if (!empty($context['results'])) |
|
120 | - echo ' |
|
119 | + if (!empty($context['results'])) { |
|
120 | + echo ' |
|
121 | 121 | <div class="noticebox">', $context['results'], '</div>'; |
122 | + } |
|
122 | 123 | |
123 | 124 | echo ' |
124 | 125 | <div class="windowbg2 noup"> |
@@ -129,9 +130,10 @@ discard block |
||
129 | 130 | <dd><select name="from"> |
130 | 131 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
131 | 132 | |
132 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
133 | - echo ' |
|
133 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
134 | + echo ' |
|
134 | 135 | <option value="', $id, '">', $dir, '</option>'; |
136 | + } |
|
135 | 137 | echo ' |
136 | 138 | </select></dd> |
137 | 139 | <dt>', $txt['attachment_transfer_auto'], '</dt> |
@@ -139,13 +141,14 @@ discard block |
||
139 | 141 | <option value="0">', $txt['attachment_transfer_auto_select'], '</option> |
140 | 142 | <option value="-1">', $txt['attachment_transfer_forum_root'], '</option>'; |
141 | 143 | |
142 | - if (!empty($context['base_dirs'])) |
|
143 | - foreach ($context['base_dirs'] as $id => $dir) |
|
144 | + if (!empty($context['base_dirs'])) { |
|
145 | + foreach ($context['base_dirs'] as $id => $dir) |
|
144 | 146 | echo ' |
145 | 147 | <option value="', $id, '">', $dir, '</option>'; |
146 | - else |
|
147 | - echo ' |
|
148 | + } else { |
|
149 | + echo ' |
|
148 | 150 | <option value="0" disabled>', $txt['attachment_transfer_no_base'], '</option>'; |
151 | + } |
|
149 | 152 | |
150 | 153 | echo ' |
151 | 154 | </select></dd> |
@@ -153,16 +156,18 @@ discard block |
||
153 | 156 | <dd><select name="to"> |
154 | 157 | <option value="0">', $txt['attachment_transfer_select'], '</option>'; |
155 | 158 | |
156 | - foreach ($context['attach_dirs'] as $id => $dir) |
|
157 | - echo ' |
|
159 | + foreach ($context['attach_dirs'] as $id => $dir) { |
|
160 | + echo ' |
|
158 | 161 | <option value="', $id, '">', $dir, '</option>'; |
162 | + } |
|
159 | 163 | echo ' |
160 | 164 | </select></dd>'; |
161 | 165 | |
162 | - if (!empty($modSettings['attachmentDirFileLimit'])) |
|
163 | - echo ' |
|
166 | + if (!empty($modSettings['attachmentDirFileLimit'])) { |
|
167 | + echo ' |
|
164 | 168 | <dt>', $txt['attachment_transfer_empty'], '</dt> |
165 | 169 | <dd><input type="checkbox" name="empty_it"', $context['checked'] ? ' checked' : '', '></dd>'; |
170 | + } |
|
166 | 171 | echo ' |
167 | 172 | </dl> |
168 | 173 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -238,10 +243,11 @@ discard block |
||
238 | 243 | // Loop through each error reporting the status |
239 | 244 | foreach ($context['repair_errors'] as $error => $number) |
240 | 245 | { |
241 | - if (!empty($number)) |
|
242 | - echo ' |
|
246 | + if (!empty($number)) { |
|
247 | + echo ' |
|
243 | 248 | <input type="checkbox" name="to_fix[]" id="', $error, '" value="', $error, '"> |
244 | 249 | <label for="', $error, '">', sprintf($txt['attach_repair_' . $error], $number), '</label><br>'; |
250 | + } |
|
245 | 251 | } |
246 | 252 | |
247 | 253 | echo ' <br> |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl, $modSettings; |
19 | 19 | |
20 | 20 | // If maintenance has finished tell the user. |
21 | - if (!empty($context['maintenance_finished'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['maintenance_finished'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | echo ' |
28 | 29 | <div id="manage_maintenance"> |
@@ -107,11 +108,12 @@ discard block |
||
107 | 108 | <div id="manage_maintenance">'; |
108 | 109 | |
109 | 110 | // If maintenance has finished tell the user. |
110 | - if (!empty($context['maintenance_finished'])) |
|
111 | - echo ' |
|
111 | + if (!empty($context['maintenance_finished'])) { |
|
112 | + echo ' |
|
112 | 113 | <div class="infobox"> |
113 | 114 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
114 | 115 | </div>'; |
116 | + } |
|
115 | 117 | |
116 | 118 | echo ' |
117 | 119 | <div class="cat_bar"> |
@@ -238,11 +240,12 @@ discard block |
||
238 | 240 | <div id="manage_maintenance">'; |
239 | 241 | |
240 | 242 | // If maintenance has finished tell the user. |
241 | - if (!empty($context['maintenance_finished'])) |
|
242 | - echo ' |
|
243 | + if (!empty($context['maintenance_finished'])) { |
|
244 | + echo ' |
|
243 | 245 | <div class="infobox"> |
244 | 246 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
245 | 247 | </div>'; |
248 | + } |
|
246 | 249 | |
247 | 250 | echo ' |
248 | 251 | <div class="cat_bar"> |
@@ -300,9 +303,10 @@ discard block |
||
300 | 303 | <p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p> |
301 | 304 | <div style="display: none; padding: 3px" id="membersPanel">'; |
302 | 305 | |
303 | - foreach ($context['membergroups'] as $group) |
|
304 | - echo ' |
|
306 | + foreach ($context['membergroups'] as $group) { |
|
307 | + echo ' |
|
305 | 308 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
309 | + } |
|
306 | 310 | |
307 | 311 | echo ' |
308 | 312 | </div> |
@@ -346,11 +350,12 @@ discard block |
||
346 | 350 | global $scripturl, $txt, $context, $settings, $modSettings; |
347 | 351 | |
348 | 352 | // If maintenance has finished tell the user. |
349 | - if (!empty($context['maintenance_finished'])) |
|
350 | - echo ' |
|
353 | + if (!empty($context['maintenance_finished'])) { |
|
354 | + echo ' |
|
351 | 355 | <div class="infobox"> |
352 | 356 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
353 | 357 | </div>'; |
358 | + } |
|
354 | 359 | |
355 | 360 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
356 | 361 | echo ' |
@@ -418,19 +423,21 @@ discard block |
||
418 | 423 | <ul>'; |
419 | 424 | |
420 | 425 | // Display a checkbox with every board. |
421 | - foreach ($category['boards'] as $board) |
|
422 | - echo ' |
|
426 | + foreach ($category['boards'] as $board) { |
|
427 | + echo ' |
|
423 | 428 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label></li>'; |
429 | + } |
|
424 | 430 | |
425 | 431 | echo ' |
426 | 432 | </ul> |
427 | 433 | </fieldset>'; |
428 | 434 | |
429 | 435 | // Increase $i, and check if we're at the middle yet. |
430 | - if (++$i == $middle) |
|
431 | - echo ' |
|
436 | + if (++$i == $middle) { |
|
437 | + echo ' |
|
432 | 438 | </div> |
433 | 439 | <div class="floatright" style="width: 49%;">'; |
440 | + } |
|
434 | 441 | } |
435 | 442 | |
436 | 443 | echo ' |
@@ -469,9 +476,10 @@ discard block |
||
469 | 476 | echo ' |
470 | 477 | <optgroup label="', $category['name'], '">'; |
471 | 478 | |
472 | - foreach ($category['boards'] as $board) |
|
473 | - echo ' |
|
479 | + foreach ($category['boards'] as $board) { |
|
480 | + echo ' |
|
474 | 481 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
482 | + } |
|
475 | 483 | |
476 | 484 | echo ' |
477 | 485 | </optgroup>'; |
@@ -489,9 +497,10 @@ discard block |
||
489 | 497 | echo ' |
490 | 498 | <optgroup label="', $category['name'], '">'; |
491 | 499 | |
492 | - foreach ($category['boards'] as $board) |
|
493 | - echo ' |
|
500 | + foreach ($category['boards'] as $board) { |
|
501 | + echo ' |
|
494 | 502 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
503 | + } |
|
495 | 504 | |
496 | 505 | echo ' |
497 | 506 | </optgroup>'; |
@@ -531,9 +540,10 @@ discard block |
||
531 | 540 | ', $txt['database_optimize_attempt'], '<br>'; |
532 | 541 | |
533 | 542 | // List each table being optimized... |
534 | - foreach ($context['optimized_tables'] as $table) |
|
535 | - echo ' |
|
543 | + foreach ($context['optimized_tables'] as $table) { |
|
544 | + echo ' |
|
536 | 545 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
546 | + } |
|
537 | 547 | |
538 | 548 | // How did we go? |
539 | 549 | echo ' |
@@ -590,13 +600,14 @@ discard block |
||
590 | 600 | ', implode('</li><li>', $context['exceeding_messages']), ' |
591 | 601 | </li> |
592 | 602 | </ul>'; |
593 | - if (!empty($context['exceeding_messages_morethan'])) |
|
594 | - echo ' |
|
603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
604 | + echo ' |
|
595 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
596 | - } |
|
597 | - else |
|
598 | - echo ' |
|
606 | + } |
|
607 | + } else { |
|
608 | + echo ' |
|
599 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
610 | + } |
|
600 | 611 | |
601 | 612 | echo ' |
602 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
29 | 29 | // Go through each type of report they can run. |
30 | 30 | foreach ($context['report_types'] as $type) |
31 | 31 | { |
32 | - if (isset($type['description'])) |
|
33 | - echo ' |
|
32 | + if (isset($type['description'])) { |
|
33 | + echo ' |
|
34 | 34 | <dt>', $type['description'], '</dt>'; |
35 | + } |
|
35 | 36 | echo ' |
36 | 37 | <dd> |
37 | 38 | <input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', '> |
@@ -61,8 +62,9 @@ discard block |
||
61 | 62 | </div> |
62 | 63 | <div id="report_buttons">'; |
63 | 64 | |
64 | - if (!empty($context['report_buttons'])) |
|
65 | - template_button_strip($context['report_buttons'], 'right'); |
|
65 | + if (!empty($context['report_buttons'])) { |
|
66 | + template_button_strip($context['report_buttons'], 'right'); |
|
67 | + } |
|
66 | 68 | |
67 | 69 | echo ' |
68 | 70 | </div>'; |
@@ -73,25 +75,27 @@ discard block |
||
73 | 75 | echo ' |
74 | 76 | <table class="table_grid report_results">'; |
75 | 77 | |
76 | - if (!empty($table['title'])) |
|
77 | - echo ' |
|
78 | + if (!empty($table['title'])) { |
|
79 | + echo ' |
|
78 | 80 | <thead> |
79 | 81 | <tr class="title_bar"> |
80 | 82 | <th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th> |
81 | 83 | </tr> |
82 | 84 | </thead> |
83 | 85 | <tbody>'; |
86 | + } |
|
84 | 87 | |
85 | 88 | // Now do each row! |
86 | 89 | $row_number = 0; |
87 | 90 | foreach ($table['data'] as $row) |
88 | 91 | { |
89 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
90 | - echo ' |
|
92 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
93 | + echo ' |
|
91 | 94 | <tr class="windowbg table_caption">'; |
92 | - else |
|
93 | - echo ' |
|
95 | + } else { |
|
96 | + echo ' |
|
94 | 97 | <tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">'; |
98 | + } |
|
95 | 99 | |
96 | 100 | // Now do each column. |
97 | 101 | $column_number = 0; |
@@ -109,16 +113,17 @@ discard block |
||
109 | 113 | } |
110 | 114 | |
111 | 115 | // Shaded? |
112 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
113 | - echo ' |
|
116 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
117 | + echo ' |
|
114 | 118 | <td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
115 | 119 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
116 | 120 | </td>'; |
117 | - else |
|
118 | - echo ' |
|
121 | + } else { |
|
122 | + echo ' |
|
119 | 123 | <td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
120 | 124 | ', $data['v'], ' |
121 | 125 | </td>'; |
126 | + } |
|
122 | 127 | |
123 | 128 | $column_number++; |
124 | 129 | } |
@@ -167,24 +172,26 @@ discard block |
||
167 | 172 | <div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '"> |
168 | 173 | <table class="bordercolor">'; |
169 | 174 | |
170 | - if (!empty($table['title'])) |
|
171 | - echo ' |
|
175 | + if (!empty($table['title'])) { |
|
176 | + echo ' |
|
172 | 177 | <tr class="title_bar"> |
173 | 178 | <td colspan="', $table['column_count'], '"> |
174 | 179 | ', $table['title'], ' |
175 | 180 | </td> |
176 | 181 | </tr>'; |
182 | + } |
|
177 | 183 | |
178 | 184 | // Now do each row! |
179 | 185 | $row_number = 0; |
180 | 186 | foreach ($table['data'] as $row) |
181 | 187 | { |
182 | - if ($row_number == 0 && !empty($table['shading']['top'])) |
|
183 | - echo ' |
|
188 | + if ($row_number == 0 && !empty($table['shading']['top'])) { |
|
189 | + echo ' |
|
184 | 190 | <tr class="titlebg">'; |
185 | - else |
|
186 | - echo ' |
|
191 | + } else { |
|
192 | + echo ' |
|
187 | 193 | <tr class="windowbg">'; |
194 | + } |
|
188 | 195 | |
189 | 196 | // Now do each column!! |
190 | 197 | $column_number = 0; |
@@ -201,16 +208,17 @@ discard block |
||
201 | 208 | } |
202 | 209 | |
203 | 210 | // Shaded? |
204 | - if ($column_number == 0 && !empty($table['shading']['left'])) |
|
205 | - echo ' |
|
211 | + if ($column_number == 0 && !empty($table['shading']['left'])) { |
|
212 | + echo ' |
|
206 | 213 | <td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '> |
207 | 214 | ', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), ' |
208 | 215 | </td>'; |
209 | - else |
|
210 | - echo ' |
|
216 | + } else { |
|
217 | + echo ' |
|
211 | 218 | <td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '> |
212 | 219 | ', $data['v'], ' |
213 | 220 | </td>'; |
221 | + } |
|
214 | 222 | |
215 | 223 | $column_number++; |
216 | 224 | } |
@@ -26,9 +26,10 @@ discard block |
||
26 | 26 | </h3> |
27 | 27 | </div>'; |
28 | 28 | |
29 | - if ($context['ban']['is_new']) |
|
30 | - echo ' |
|
29 | + if ($context['ban']['is_new']) { |
|
30 | + echo ' |
|
31 | 31 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | // If there were errors creating the ban, show them. |
34 | 35 | if (!empty($context['error_messages'])) |
@@ -38,9 +39,10 @@ discard block |
||
38 | 39 | <strong>', $txt['ban_errors_detected'], '</strong> |
39 | 40 | <ul>'; |
40 | 41 | |
41 | - foreach ($context['error_messages'] as $error) |
|
42 | - echo ' |
|
42 | + foreach ($context['error_messages'] as $error) { |
|
43 | + echo ' |
|
43 | 44 | <li class="error">', $error, '</li>'; |
45 | + } |
|
44 | 46 | |
45 | 47 | echo ' |
46 | 48 | </ul> |
@@ -57,8 +59,8 @@ discard block |
||
57 | 59 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
58 | 60 | </dd>'; |
59 | 61 | |
60 | - if (isset($context['ban']['reason'])) |
|
61 | - echo ' |
|
62 | + if (isset($context['ban']['reason'])) { |
|
63 | + echo ' |
|
62 | 64 | <dt> |
63 | 65 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
64 | 66 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -66,9 +68,10 @@ discard block |
||
66 | 68 | <dd> |
67 | 69 | <textarea name="reason" id="reason" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['reason'], '</textarea> |
68 | 70 | </dd>'; |
71 | + } |
|
69 | 72 | |
70 | - if (isset($context['ban']['notes'])) |
|
71 | - echo ' |
|
73 | + if (isset($context['ban']['notes'])) { |
|
74 | + echo ' |
|
72 | 75 | <dt> |
73 | 76 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
74 | 77 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -76,6 +79,7 @@ discard block |
||
76 | 79 | <dd> |
77 | 80 | <textarea name="notes" id="ban_notes" cols="40" rows="3" style="min-height: 64px; max-height: 64px; min-width: 50%; max-width: 99%;">', $context['ban']['notes'], '</textarea> |
78 | 81 | </dd>'; |
82 | + } |
|
79 | 83 | |
80 | 84 | echo ' |
81 | 85 | </dl> |
@@ -115,8 +119,8 @@ discard block |
||
115 | 119 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
116 | 120 | </dd>'; |
117 | 121 | |
118 | - if (empty($modSettings['disableHostnameLookup'])) |
|
119 | - echo ' |
|
122 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
123 | + echo ' |
|
120 | 124 | <dt> |
121 | 125 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
122 | 126 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -124,6 +128,7 @@ discard block |
||
124 | 128 | <dd> |
125 | 129 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
126 | 130 | </dd>'; |
131 | + } |
|
127 | 132 | |
128 | 133 | echo ' |
129 | 134 | <dt> |
@@ -153,14 +158,15 @@ discard block |
||
153 | 158 | <dl class="settings">'; |
154 | 159 | |
155 | 160 | $count = 0; |
156 | - foreach ($ban_ips as $ip) |
|
157 | - echo ' |
|
161 | + foreach ($ban_ips as $ip) { |
|
162 | + echo ' |
|
158 | 163 | <dt> |
159 | 164 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
160 | 165 | </dt> |
161 | 166 | <dd> |
162 | 167 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
163 | 168 | </dd>'; |
169 | + } |
|
164 | 170 | |
165 | 171 | echo ' |
166 | 172 | </dl>'; |
@@ -202,8 +208,8 @@ discard block |
||
202 | 208 | addLoadEvent(fUpdateStatus);'; |
203 | 209 | |
204 | 210 | // Auto suggest only needed for adding new bans, not editing |
205 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
206 | - echo ' |
|
211 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
212 | + echo ' |
|
207 | 213 | var oAddMemberSuggest = new smc_AutoSuggest({ |
208 | 214 | sSelf: \'oAddMemberSuggest\', |
209 | 215 | sSessionId: smf_session_id, |
@@ -221,6 +227,7 @@ discard block |
||
221 | 227 | return true; |
222 | 228 | } |
223 | 229 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
230 | + } |
|
224 | 231 | |
225 | 232 | echo ' |
226 | 233 | function confirmBan(aForm) |
@@ -268,8 +275,8 @@ discard block |
||
268 | 275 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
269 | 276 | </dd>'; |
270 | 277 | |
271 | - if (empty($modSettings['disableHostnameLookup'])) |
|
272 | - echo ' |
|
278 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
279 | + echo ' |
|
273 | 280 | <dt> |
274 | 281 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
275 | 282 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -277,6 +284,7 @@ discard block |
||
277 | 284 | <dd> |
278 | 285 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
279 | 286 | </dd>'; |
287 | + } |
|
280 | 288 | |
281 | 289 | echo ' |
282 | 290 | <dt> |
@@ -18,9 +18,10 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl; |
19 | 19 | |
20 | 20 | // Are we done sending the newsletter? |
21 | - if (!empty($context['newsletter_sent'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['newsletter_sent'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox">', $txt['admin_news_newsletter_' . $context['newsletter_sent']], '</div>'; |
24 | + } |
|
24 | 25 | |
25 | 26 | echo ' |
26 | 27 | <div id="admincenter"> |
@@ -39,9 +40,10 @@ discard block |
||
39 | 40 | </dt> |
40 | 41 | <dd>'; |
41 | 42 | |
42 | - foreach ($context['groups'] as $group) |
|
43 | - echo ' |
|
43 | + foreach ($context['groups'] as $group) { |
|
44 | + echo ' |
|
44 | 45 | <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
46 | + } |
|
45 | 47 | |
46 | 48 | echo ' |
47 | 49 | <br> |
@@ -82,9 +84,10 @@ discard block |
||
82 | 84 | </dt> |
83 | 85 | <dd>'; |
84 | 86 | |
85 | - foreach ($context['groups'] as $group) |
|
86 | - echo ' |
|
87 | + foreach ($context['groups'] as $group) { |
|
88 | + echo ' |
|
87 | 89 | <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>'; |
90 | + } |
|
88 | 91 | |
89 | 92 | echo ' |
90 | 93 | <br> |
@@ -228,9 +231,10 @@ discard block |
||
228 | 231 | <div id="bbcBox_message"></div>'; |
229 | 232 | |
230 | 233 | // What about smileys? |
231 | - if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) |
|
232 | - echo ' |
|
234 | + if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) { |
|
235 | + echo ' |
|
233 | 236 | <div id="smileyBox_message"></div>'; |
237 | + } |
|
234 | 238 | |
235 | 239 | // Show BBC buttons, smileys and textbox. |
236 | 240 | echo ' |
@@ -251,9 +255,10 @@ discard block |
||
251 | 255 | <input type="hidden" name="email_force" value="', $context['email_force'], '"> |
252 | 256 | <input type="hidden" name="total_emails" value="', $context['total_emails'], '">'; |
253 | 257 | |
254 | - foreach ($context['recipients'] as $key => $values) |
|
255 | - echo ' |
|
258 | + foreach ($context['recipients'] as $key => $values) { |
|
259 | + echo ' |
|
256 | 260 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
261 | + } |
|
257 | 262 | |
258 | 263 | echo ' |
259 | 264 | <script>'; |
@@ -408,9 +413,10 @@ discard block |
||
408 | 413 | <input type="hidden" name="parse_html" value="', $context['parse_html'], '">'; |
409 | 414 | |
410 | 415 | // All the things we must remember! |
411 | - foreach ($context['recipients'] as $key => $values) |
|
412 | - echo ' |
|
416 | + foreach ($context['recipients'] as $key => $values) { |
|
417 | + echo ' |
|
413 | 418 | <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">'; |
419 | + } |
|
414 | 420 | |
415 | 421 | echo ' |
416 | 422 | </div> |
@@ -443,9 +449,10 @@ discard block |
||
443 | 449 | { |
444 | 450 | global $context, $txt; |
445 | 451 | |
446 | - if (!empty($context['saved_successful'])) |
|
447 | - echo ' |
|
452 | + if (!empty($context['saved_successful'])) { |
|
453 | + echo ' |
|
448 | 454 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
455 | + } |
|
449 | 456 | |
450 | 457 | template_show_list('news_lists'); |
451 | 458 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | </thead> |
149 | 149 | <tbody>'; |
150 | 150 | |
151 | - foreach ($context['membergroups'] as $membergroup) |
|
152 | - echo ' |
|
151 | + foreach ($context['membergroups'] as $membergroup) { |
|
152 | + echo ' |
|
153 | 153 | <tr class="windowbg"> |
154 | 154 | <td>', $membergroup['name'], '</td> |
155 | 155 | <td class="centercol"> |
@@ -159,6 +159,7 @@ discard block |
||
159 | 159 | ', $membergroup['can_be_additional'] ? '<input type="checkbox" name="membergroups[2][]" value="' . $membergroup['id'] . '" checked>' : '', ' |
160 | 160 | </td> |
161 | 161 | </tr>'; |
162 | + } |
|
162 | 163 | |
163 | 164 | echo ' |
164 | 165 | <tr class="windowbg"> |
@@ -185,8 +186,8 @@ discard block |
||
185 | 186 | </thead> |
186 | 187 | <tbody>'; |
187 | 188 | |
188 | - foreach ($context['postgroups'] as $postgroup) |
|
189 | - echo ' |
|
189 | + foreach ($context['postgroups'] as $postgroup) { |
|
190 | + echo ' |
|
190 | 191 | <tr class="windowbg"> |
191 | 192 | <td> |
192 | 193 | ', $postgroup['name'], ' |
@@ -195,6 +196,7 @@ discard block |
||
195 | 196 | <input type="checkbox" name="postgroups[]" value="', $postgroup['id'], '" checked> |
196 | 197 | </td> |
197 | 198 | </tr>'; |
199 | + } |
|
198 | 200 | |
199 | 201 | echo ' |
200 | 202 | <tr class="windowbg"> |
@@ -54,9 +54,10 @@ discard block |
||
54 | 54 | <dd> |
55 | 55 | <div id="known_themes_list">'; |
56 | 56 | |
57 | - foreach ($context['themes'] as $theme) |
|
58 | - echo ' |
|
57 | + foreach ($context['themes'] as $theme) { |
|
58 | + echo ' |
|
59 | 59 | <label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>'; |
60 | + } |
|
60 | 61 | |
61 | 62 | echo ' |
62 | 63 | </div> |
@@ -73,9 +74,10 @@ discard block |
||
73 | 74 | <select name="options[theme_guests]" id="theme_guests">'; |
74 | 75 | |
75 | 76 | // Put an option for each theme in the select box. |
76 | - foreach ($context['themes'] as $theme) |
|
77 | - echo ' |
|
77 | + foreach ($context['themes'] as $theme) { |
|
78 | + echo ' |
|
78 | 79 | <option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
80 | + } |
|
79 | 81 | |
80 | 82 | echo ' |
81 | 83 | </select> |
@@ -90,9 +92,10 @@ discard block |
||
90 | 92 | <option value="0">', $txt['theme_forum_default'], '</option>'; |
91 | 93 | |
92 | 94 | // Same thing, this time for changing the theme of everyone. |
93 | - foreach ($context['themes'] as $theme) |
|
94 | - echo ' |
|
95 | + foreach ($context['themes'] as $theme) { |
|
96 | + echo ' |
|
95 | 97 | <option value="', $theme['id'], '">', $theme['name'], '</option>'; |
98 | + } |
|
96 | 99 | |
97 | 100 | echo ' |
98 | 101 | </select> |
@@ -189,11 +192,12 @@ discard block |
||
189 | 192 | global $context, $scripturl, $txt; |
190 | 193 | |
191 | 194 | // Show a nice confirmation message. |
192 | - if (isset($_GET['done'])) |
|
193 | - echo ' |
|
195 | + if (isset($_GET['done'])) { |
|
196 | + echo ' |
|
194 | 197 | <div class="infobox"> |
195 | 198 | ', $txt['theme_confirmed_' . $_GET['done']], ' |
196 | 199 | </div>'; |
200 | + } |
|
197 | 201 | |
198 | 202 | echo ' |
199 | 203 | <div id="admincenter">'; |
@@ -357,11 +361,12 @@ discard block |
||
357 | 361 | if (empty($setting) || !is_array($setting)) |
358 | 362 | { |
359 | 363 | // Insert a separator (unless this is the first item in the list) |
360 | - if ($i !== $first_option_key) |
|
361 | - echo ' |
|
364 | + if ($i !== $first_option_key) { |
|
365 | + echo ' |
|
362 | 366 | </dl> |
363 | 367 | <hr> |
364 | 368 | <dl class="settings">'; |
369 | + } |
|
365 | 370 | |
366 | 371 | // Should we give a name to this section? |
367 | 372 | if (is_string($setting) && !empty($setting)) |
@@ -369,9 +374,9 @@ discard block |
||
369 | 374 | $titled_section = true; |
370 | 375 | echo ' |
371 | 376 | <dt><strong>' . $setting . '</strong></dt><dd></dd>'; |
377 | + } else { |
|
378 | + $titled_section = false; |
|
372 | 379 | } |
373 | - else |
|
374 | - $titled_section = false; |
|
375 | 380 | |
376 | 381 | continue; |
377 | 382 | } |
@@ -380,19 +385,21 @@ discard block |
||
380 | 385 | <dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>'; |
381 | 386 | |
382 | 387 | // Show the change option box ? |
383 | - if ($context['theme_options_reset']) |
|
384 | - echo ' |
|
388 | + if ($context['theme_options_reset']) { |
|
389 | + echo ' |
|
385 | 390 | <span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;"> |
386 | 391 | <option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option> |
387 | 392 | <option value="1">', $txt['themeadmin_reset_options_change'], '</option> |
388 | 393 | <option value="2">', $txt['themeadmin_reset_options_default'], '</option> |
389 | 394 | </select> </span>'; |
395 | + } |
|
390 | 396 | |
391 | 397 | echo ' |
392 | 398 | <label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>'; |
393 | - if (isset($setting['description'])) |
|
394 | - echo ' |
|
399 | + if (isset($setting['description'])) { |
|
400 | + echo ' |
|
395 | 401 | <br><span class="smalltext">', $setting['description'], '</span>'; |
402 | + } |
|
396 | 403 | echo ' |
397 | 404 | </dt>'; |
398 | 405 | |
@@ -434,13 +441,11 @@ discard block |
||
434 | 441 | |
435 | 442 | echo ' |
436 | 443 | <input type="number"', $min . $max . $step; |
437 | - } |
|
438 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
444 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
439 | 445 | { |
440 | 446 | echo' |
441 | 447 | <input type="url"'; |
442 | - } |
|
443 | - else |
|
448 | + } else |
|
444 | 449 | { |
445 | 450 | echo ' |
446 | 451 | <input type="text"'; |
@@ -484,8 +489,8 @@ discard block |
||
484 | 489 | <br>'; |
485 | 490 | |
486 | 491 | // @todo Why can't I edit the default theme popup. |
487 | - if ($context['theme_settings']['theme_id'] != 1) |
|
488 | - echo ' |
|
492 | + if ($context['theme_settings']['theme_id'] != 1) { |
|
493 | + echo ' |
|
489 | 494 | <div class="cat_bar"> |
490 | 495 | <h3 class="catbg config_hd"> |
491 | 496 | ', $txt['theme_edit'], ' |
@@ -501,6 +506,7 @@ discard block |
||
501 | 506 | </li> |
502 | 507 | </ul> |
503 | 508 | </div>'; |
509 | + } |
|
504 | 510 | |
505 | 511 | echo ' |
506 | 512 | <div class="cat_bar"> |
@@ -554,9 +560,10 @@ discard block |
||
554 | 560 | <dd> |
555 | 561 | <select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">'; |
556 | 562 | |
557 | - foreach ($context['theme_variants'] as $key => $variant) |
|
558 | - echo ' |
|
563 | + foreach ($context['theme_variants'] as $key => $variant) { |
|
564 | + echo ' |
|
559 | 565 | <option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>'; |
566 | + } |
|
560 | 567 | |
561 | 568 | echo ' |
562 | 569 | </select> |
@@ -592,11 +599,12 @@ discard block |
||
592 | 599 | if (empty($setting) || !is_array($setting)) |
593 | 600 | { |
594 | 601 | // We don't need a separator before the first list element |
595 | - if ($i !== $first_setting_key) |
|
596 | - echo ' |
|
602 | + if ($i !== $first_setting_key) { |
|
603 | + echo ' |
|
597 | 604 | </dl> |
598 | 605 | <hr> |
599 | 606 | <dl class="settings">'; |
607 | + } |
|
600 | 608 | |
601 | 609 | // Add a fake heading? |
602 | 610 | if (is_string($setting) && !empty($setting)) |
@@ -604,9 +612,9 @@ discard block |
||
604 | 612 | $titled_section = true; |
605 | 613 | echo ' |
606 | 614 | <dt><strong>' . $setting . '</strong></dt><dd></dd>'; |
615 | + } else { |
|
616 | + $titled_section = false; |
|
607 | 617 | } |
608 | - else |
|
609 | - $titled_section = false; |
|
610 | 618 | |
611 | 619 | continue; |
612 | 620 | } |
@@ -615,9 +623,10 @@ discard block |
||
615 | 623 | <dt> |
616 | 624 | <label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:'; |
617 | 625 | |
618 | - if (isset($setting['description'])) |
|
619 | - echo '<br> |
|
626 | + if (isset($setting['description'])) { |
|
627 | + echo '<br> |
|
620 | 628 | <span class="smalltext">', $setting['description'], '</span>'; |
629 | + } |
|
621 | 630 | |
622 | 631 | echo ' |
623 | 632 | </dt>'; |
@@ -638,9 +647,10 @@ discard block |
||
638 | 647 | <dd> |
639 | 648 | <select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">'; |
640 | 649 | |
641 | - foreach ($setting['options'] as $value => $label) |
|
642 | - echo ' |
|
650 | + foreach ($setting['options'] as $value => $label) { |
|
651 | + echo ' |
|
643 | 652 | <option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>'; |
653 | + } |
|
644 | 654 | |
645 | 655 | echo ' |
646 | 656 | </select> |
@@ -669,13 +679,11 @@ discard block |
||
669 | 679 | |
670 | 680 | echo ' |
671 | 681 | <input type="number"', $min . $max . $step; |
672 | - } |
|
673 | - else if (isset($setting['type']) && $setting['type'] == 'url') |
|
682 | + } else if (isset($setting['type']) && $setting['type'] == 'url') |
|
674 | 683 | { |
675 | 684 | echo' |
676 | 685 | <input type="url"'; |
677 | - } |
|
678 | - else |
|
686 | + } else |
|
679 | 687 | { |
680 | 688 | echo ' |
681 | 689 | <input type="text"'; |
@@ -828,21 +836,23 @@ discard block |
||
828 | 836 | <div class="windowbg">'; |
829 | 837 | |
830 | 838 | // Oops! there was an error :( |
831 | - if (!empty($context['error_message'])) |
|
832 | - echo ' |
|
839 | + if (!empty($context['error_message'])) { |
|
840 | + echo ' |
|
833 | 841 | <p> |
834 | 842 | ', $context['error_message'], ' |
835 | 843 | </p>'; |
844 | + } |
|
836 | 845 | |
837 | 846 | // Not much to show except a link back... |
838 | - else |
|
839 | - echo ' |
|
847 | + else { |
|
848 | + echo ' |
|
840 | 849 | <p> |
841 | 850 | <a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], ' |
842 | 851 | </p> |
843 | 852 | <p> |
844 | 853 | <a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a> |
845 | 854 | </p>'; |
855 | + } |
|
846 | 856 | |
847 | 857 | echo ' |
848 | 858 | </div> |
@@ -909,10 +919,11 @@ discard block |
||
909 | 919 | <span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span> |
910 | 920 | <span class="floatright">'; |
911 | 921 | |
912 | - if ($template['can_copy']) |
|
913 | - echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
914 | - else |
|
915 | - echo $txt['themeadmin_edit_no_copy']; |
|
922 | + if ($template['can_copy']) { |
|
923 | + echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>'; |
|
924 | + } else { |
|
925 | + echo $txt['themeadmin_edit_no_copy']; |
|
926 | + } |
|
916 | 927 | |
917 | 928 | echo ' |
918 | 929 | </span> |
@@ -935,11 +946,12 @@ discard block |
||
935 | 946 | echo ' |
936 | 947 | <div id="admincenter">'; |
937 | 948 | |
938 | - if (!empty($context['browse_title'])) |
|
939 | - echo ' |
|
949 | + if (!empty($context['browse_title'])) { |
|
950 | + echo ' |
|
940 | 951 | <div class="cat_bar"> |
941 | 952 | <h3 class="catbg">', $context['browse_title'], '</h3> |
942 | 953 | </div>'; |
954 | + } |
|
943 | 955 | |
944 | 956 | echo ' |
945 | 957 | <table class="table_grid tborder"> |
@@ -959,14 +971,13 @@ discard block |
||
959 | 971 | <tr class="windowbg"> |
960 | 972 | <td>'; |
961 | 973 | |
962 | - if ($file['is_editable']) |
|
963 | - echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
964 | - |
|
965 | - elseif ($file['is_directory']) |
|
966 | - echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
967 | - |
|
968 | - else |
|
969 | - echo $file['filename']; |
|
974 | + if ($file['is_editable']) { |
|
975 | + echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>'; |
|
976 | + } elseif ($file['is_directory']) { |
|
977 | + echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>'; |
|
978 | + } else { |
|
979 | + echo $file['filename']; |
|
980 | + } |
|
970 | 981 | |
971 | 982 | echo ' |
972 | 983 | </td> |
@@ -988,11 +999,12 @@ discard block |
||
988 | 999 | { |
989 | 1000 | global $context, $settings, $scripturl, $txt; |
990 | 1001 | |
991 | - if ($context['session_error']) |
|
992 | - echo ' |
|
1002 | + if ($context['session_error']) { |
|
1003 | + echo ' |
|
993 | 1004 | <div class="errorbox"> |
994 | 1005 | ', $txt['error_session_timeout'], ' |
995 | 1006 | </div>'; |
1007 | + } |
|
996 | 1008 | |
997 | 1009 | // From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com. |
998 | 1010 | echo ' |
@@ -1055,17 +1067,18 @@ discard block |
||
1055 | 1067 | try |
1056 | 1068 | { |
1057 | 1069 | '; |
1058 | - if (isBrowser('is_ie')) |
|
1059 | - echo ' |
|
1070 | + if (isBrowser('is_ie')) { |
|
1071 | + echo ' |
|
1060 | 1072 | var sheets = frames["css_preview_box"].document.styleSheets; |
1061 | 1073 | for (var j = 0; j < sheets.length; j++) |
1062 | 1074 | { |
1063 | 1075 | if (sheets[j].id == "css_preview_box") |
1064 | 1076 | sheets[j].cssText = document.forms.stylesheetForm.entire_file.value; |
1065 | 1077 | }'; |
1066 | - else |
|
1067 | - echo ' |
|
1078 | + } else { |
|
1079 | + echo ' |
|
1068 | 1080 | setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);'; |
1081 | + } |
|
1069 | 1082 | echo ' |
1070 | 1083 | } |
1071 | 1084 | catch (e) |
@@ -1117,9 +1130,10 @@ discard block |
||
1117 | 1130 | </div> |
1118 | 1131 | <div class="windowbg">'; |
1119 | 1132 | |
1120 | - if (!$context['allow_save']) |
|
1121 | - echo ' |
|
1133 | + if (!$context['allow_save']) { |
|
1134 | + echo ' |
|
1122 | 1135 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1136 | + } |
|
1123 | 1137 | |
1124 | 1138 | echo ' |
1125 | 1139 | <textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br> |
@@ -1132,9 +1146,10 @@ discard block |
||
1132 | 1146 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1133 | 1147 | |
1134 | 1148 | // Hopefully it exists. |
1135 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1136 | - echo ' |
|
1149 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1150 | + echo ' |
|
1137 | 1151 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1152 | + } |
|
1138 | 1153 | |
1139 | 1154 | echo ' |
1140 | 1155 | </form> |
@@ -1148,18 +1163,20 @@ discard block |
||
1148 | 1163 | { |
1149 | 1164 | global $context, $scripturl, $txt; |
1150 | 1165 | |
1151 | - if ($context['session_error']) |
|
1152 | - echo ' |
|
1166 | + if ($context['session_error']) { |
|
1167 | + echo ' |
|
1153 | 1168 | <div class="errorbox"> |
1154 | 1169 | ', $txt['error_session_timeout'], ' |
1155 | 1170 | </div>'; |
1171 | + } |
|
1156 | 1172 | |
1157 | - if (isset($context['parse_error'])) |
|
1158 | - echo ' |
|
1173 | + if (isset($context['parse_error'])) { |
|
1174 | + echo ' |
|
1159 | 1175 | <div class="errorbox"> |
1160 | 1176 | ', $txt['themeadmin_edit_error'], ' |
1161 | 1177 | <div><pre>', $context['parse_error'], '</pre></div> |
1162 | 1178 | </div>'; |
1179 | + } |
|
1163 | 1180 | |
1164 | 1181 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1165 | 1182 | echo ' |
@@ -1170,16 +1187,18 @@ discard block |
||
1170 | 1187 | </div> |
1171 | 1188 | <div class="windowbg">'; |
1172 | 1189 | |
1173 | - if (!$context['allow_save']) |
|
1174 | - echo ' |
|
1190 | + if (!$context['allow_save']) { |
|
1191 | + echo ' |
|
1175 | 1192 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>'; |
1193 | + } |
|
1176 | 1194 | |
1177 | - foreach ($context['file_parts'] as $part) |
|
1178 | - echo ' |
|
1195 | + foreach ($context['file_parts'] as $part) { |
|
1196 | + echo ' |
|
1179 | 1197 | <label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br> |
1180 | 1198 | <div class="centertext"> |
1181 | 1199 | <textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea> |
1182 | 1200 | </div>'; |
1201 | + } |
|
1183 | 1202 | |
1184 | 1203 | echo ' |
1185 | 1204 | <div class="padding righttext"> |
@@ -1188,9 +1207,10 @@ discard block |
||
1188 | 1207 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1189 | 1208 | |
1190 | 1209 | // Hopefully it exists. |
1191 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1192 | - echo ' |
|
1210 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1211 | + echo ' |
|
1193 | 1212 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1213 | + } |
|
1194 | 1214 | |
1195 | 1215 | echo ' |
1196 | 1216 | </div> |
@@ -1206,18 +1226,20 @@ discard block |
||
1206 | 1226 | { |
1207 | 1227 | global $context, $scripturl, $txt; |
1208 | 1228 | |
1209 | - if ($context['session_error']) |
|
1210 | - echo ' |
|
1229 | + if ($context['session_error']) { |
|
1230 | + echo ' |
|
1211 | 1231 | <div class="errorbox"> |
1212 | 1232 | ', $txt['error_session_timeout'], ' |
1213 | 1233 | </div>'; |
1234 | + } |
|
1214 | 1235 | |
1215 | 1236 | //Is this file writeable? |
1216 | - if (!$context['allow_save']) |
|
1217 | - echo ' |
|
1237 | + if (!$context['allow_save']) { |
|
1238 | + echo ' |
|
1218 | 1239 | <div class="errorbox"> |
1219 | 1240 | ', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], ' |
1220 | 1241 | </div>'; |
1242 | + } |
|
1221 | 1243 | |
1222 | 1244 | // Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.) |
1223 | 1245 | echo ' |
@@ -1233,9 +1255,10 @@ discard block |
||
1233 | 1255 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">'; |
1234 | 1256 | |
1235 | 1257 | // Hopefully it exists. |
1236 | - if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) |
|
1237 | - echo ' |
|
1258 | + if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) { |
|
1259 | + echo ' |
|
1238 | 1260 | <input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">'; |
1261 | + } |
|
1239 | 1262 | |
1240 | 1263 | echo ' |
1241 | 1264 | </div> |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | |
55 | 55 | // Prepare the comments... |
56 | 56 | $comments = array(); |
57 | - foreach ($report['comments'] as $comment) |
|
58 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
57 | + foreach ($report['comments'] as $comment) { |
|
58 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | echo ' |
61 | 62 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -69,18 +70,21 @@ discard block |
||
69 | 70 | <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
70 | 71 | |
71 | 72 | // Delete message button. |
72 | - if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) |
|
73 | - echo ' |
|
73 | + if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) { |
|
74 | + echo ' |
|
74 | 75 | <li><a href="', $scripturl, '?action=deletemsg;topic=', $report['topic']['id'], '.0;msg=', $report['topic']['id_msg'], ';modcenter;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['mc_reportedp_delete_confirm'], '" class="you_sure">', $delete_button, '</a></li>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | // Ban this user button. |
77 | - if (!$report['closed'] && !empty($context['report_manage_bans'])) |
|
78 | - echo ' |
|
79 | + if (!$report['closed'] && !empty($context['report_manage_bans'])) { |
|
80 | + echo ' |
|
79 | 81 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add', (!empty($report['author']['id']) ? ';u=' . $report['author']['id'] : ';msg=' . $report['topic']['id_msg']), ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
82 | + } |
|
80 | 83 | |
81 | - if (!$context['view_closed']) |
|
82 | - echo ' |
|
84 | + if (!$context['view_closed']) { |
|
85 | + echo ' |
|
83 | 86 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
87 | + } |
|
84 | 88 | |
85 | 89 | echo ' |
86 | 90 | </ul> |
@@ -88,11 +92,12 @@ discard block |
||
88 | 92 | } |
89 | 93 | |
90 | 94 | // Were none found? |
91 | - if (empty($context['reports'])) |
|
92 | - echo ' |
|
95 | + if (empty($context['reports'])) { |
|
96 | + echo ' |
|
93 | 97 | <div class="windowbg2"> |
94 | 98 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
95 | 99 | </div>'; |
100 | + } |
|
96 | 101 | |
97 | 102 | echo ' |
98 | 103 | <div class="pagesection"> |
@@ -125,18 +130,20 @@ discard block |
||
125 | 130 | <div class="modbox"> |
126 | 131 | <ul>'; |
127 | 132 | |
128 | - foreach ($context['reported_posts'] as $report) |
|
129 | - echo ' |
|
133 | + foreach ($context['reported_posts'] as $report) { |
|
134 | + echo ' |
|
130 | 135 | <li class="smalltext"> |
131 | 136 | <a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], ' |
132 | 137 | </li>'; |
138 | + } |
|
133 | 139 | |
134 | 140 | // Don't have any watched users right now? |
135 | - if (empty($context['reported_posts'])) |
|
136 | - echo ' |
|
141 | + if (empty($context['reported_posts'])) { |
|
142 | + echo ' |
|
137 | 143 | <li> |
138 | 144 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
139 | 145 | </li>'; |
146 | + } |
|
140 | 147 | |
141 | 148 | echo ' |
142 | 149 | </ul> |
@@ -226,12 +233,13 @@ discard block |
||
226 | 233 | <h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3> |
227 | 234 | </div>'; |
228 | 235 | |
229 | - foreach ($context['report']['comments'] as $comment) |
|
230 | - echo ' |
|
236 | + foreach ($context['report']['comments'] as $comment) { |
|
237 | + echo ' |
|
231 | 238 | <div class="windowbg"> |
232 | 239 | <p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p> |
233 | 240 | <p>', $comment['message'], '</p> |
234 | 241 | </div>'; |
242 | + } |
|
235 | 243 | |
236 | 244 | echo ' |
237 | 245 | <br> |
@@ -240,11 +248,12 @@ discard block |
||
240 | 248 | </div> |
241 | 249 | <div>'; |
242 | 250 | |
243 | - if (empty($context['report']['mod_comments'])) |
|
244 | - echo ' |
|
251 | + if (empty($context['report']['mod_comments'])) { |
|
252 | + echo ' |
|
245 | 253 | <div class="information"> |
246 | 254 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
247 | 255 | </div>'; |
256 | + } |
|
248 | 257 | |
249 | 258 | foreach ($context['report']['mod_comments'] as $comment) |
250 | 259 | { |
@@ -334,18 +343,20 @@ discard block |
||
334 | 343 | <div class="modbox"> |
335 | 344 | <ul>'; |
336 | 345 | |
337 | - foreach ($context['reported_members'] as $report) |
|
338 | - echo ' |
|
346 | + foreach ($context['reported_members'] as $report) { |
|
347 | + echo ' |
|
339 | 348 | <li class="smalltext"> |
340 | 349 | <a href="', $report['report_href'], '">', $report['user_name'], '</a> |
341 | 350 | </li>'; |
351 | + } |
|
342 | 352 | |
343 | 353 | // Don't have any reported members right now? |
344 | - if (empty($context['reported_members'])) |
|
345 | - echo ' |
|
354 | + if (empty($context['reported_members'])) { |
|
355 | + echo ' |
|
346 | 356 | <li> |
347 | 357 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
348 | 358 | </li>'; |
359 | + } |
|
349 | 360 | |
350 | 361 | echo ' |
351 | 362 | </ul> |
@@ -431,8 +442,9 @@ discard block |
||
431 | 442 | |
432 | 443 | // Prepare the comments... |
433 | 444 | $comments = array(); |
434 | - foreach ($report['comments'] as $comment) |
|
435 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
445 | + foreach ($report['comments'] as $comment) { |
|
446 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
447 | + } |
|
436 | 448 | |
437 | 449 | echo ' |
438 | 450 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -444,13 +456,15 @@ discard block |
||
444 | 456 | <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$report['closed'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '">', $close_button, '</a></li>'; |
445 | 457 | |
446 | 458 | // Ban this user button. |
447 | - if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
|
448 | - echo ' |
|
459 | + if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) { |
|
460 | + echo ' |
|
449 | 461 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
462 | + } |
|
450 | 463 | |
451 | - if (!$context['view_closed']) |
|
452 | - echo ' |
|
464 | + if (!$context['view_closed']) { |
|
465 | + echo ' |
|
453 | 466 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
467 | + } |
|
454 | 468 | |
455 | 469 | echo ' |
456 | 470 | </ul> |
@@ -458,11 +472,12 @@ discard block |
||
458 | 472 | } |
459 | 473 | |
460 | 474 | // Were none found? |
461 | - if (empty($context['reports'])) |
|
462 | - echo ' |
|
475 | + if (empty($context['reports'])) { |
|
476 | + echo ' |
|
463 | 477 | <div class="windowbg2"> |
464 | 478 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
465 | 479 | </div>'; |
480 | + } |
|
466 | 481 | |
467 | 482 | echo ' |
468 | 483 | <div class="pagesection"> |
@@ -522,12 +537,13 @@ discard block |
||
522 | 537 | <h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3> |
523 | 538 | </div>'; |
524 | 539 | |
525 | - foreach ($context['report']['comments'] as $comment) |
|
526 | - echo ' |
|
540 | + foreach ($context['report']['comments'] as $comment) { |
|
541 | + echo ' |
|
527 | 542 | <div class="windowbg"> |
528 | 543 | <p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p> |
529 | 544 | <p>', $comment['message'], '</p> |
530 | 545 | </div>'; |
546 | + } |
|
531 | 547 | |
532 | 548 | echo ' |
533 | 549 | <br> |
@@ -536,11 +552,12 @@ discard block |
||
536 | 552 | </div> |
537 | 553 | <div>'; |
538 | 554 | |
539 | - if (empty($context['report']['mod_comments'])) |
|
540 | - echo ' |
|
555 | + if (empty($context['report']['mod_comments'])) { |
|
556 | + echo ' |
|
541 | 557 | <div class="information"> |
542 | 558 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
543 | 559 | </div>'; |
560 | + } |
|
544 | 561 | |
545 | 562 | foreach ($context['report']['mod_comments'] as $comment) |
546 | 563 | { |