@@ -42,42 +42,42 @@ discard block |
||
42 | 42 | |
43 | 43 | // You can filter by any of the following columns: |
44 | 44 | $filters = array( |
45 | - 'id_member' => array ( |
|
45 | + 'id_member' => array( |
|
46 | 46 | 'txt' => $txt['username'], |
47 | 47 | 'operator' => '=', |
48 | 48 | 'datatype' => 'int', |
49 | 49 | ), |
50 | - 'ip' => array ( |
|
50 | + 'ip' => array( |
|
51 | 51 | 'txt' => $txt['ip_address'], |
52 | 52 | 'operator' => '=', |
53 | 53 | 'datatype' => 'inet', |
54 | 54 | ), |
55 | - 'session' => array ( |
|
55 | + 'session' => array( |
|
56 | 56 | 'txt' => $txt['session'], |
57 | 57 | 'operator' => 'LIKE', |
58 | 58 | 'datatype' => 'string', |
59 | 59 | ), |
60 | - 'url' => array ( |
|
60 | + 'url' => array( |
|
61 | 61 | 'txt' => $txt['error_url'], |
62 | 62 | 'operator' => 'LIKE', |
63 | 63 | 'datatype' => 'string', |
64 | 64 | ), |
65 | - 'message' => array ( |
|
65 | + 'message' => array( |
|
66 | 66 | 'txt' => $txt['error_message'], |
67 | 67 | 'operator' => 'LIKE', |
68 | 68 | 'datatype' => 'string', |
69 | 69 | ), |
70 | - 'error_type' => array ( |
|
70 | + 'error_type' => array( |
|
71 | 71 | 'txt' => $txt['error_type'], |
72 | 72 | 'operator' => 'LIKE', |
73 | 73 | 'datatype' => 'string', |
74 | 74 | ), |
75 | - 'file' => array ( |
|
75 | + 'file' => array( |
|
76 | 76 | 'txt' => $txt['file'], |
77 | 77 | 'operator' => 'LIKE', |
78 | 78 | 'datatype' => 'string', |
79 | 79 | ), |
80 | - 'line' => array ( |
|
80 | + 'line' => array( |
|
81 | 81 | 'txt' => $txt['line'], |
82 | 82 | 'operator' => '=', |
83 | 83 | 'datatype' => 'int', |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $result = $smcFunc['db_query']('', ' |
104 | 104 | SELECT COUNT(*) |
105 | 105 | FROM {db_prefix}log_errors' . (isset($filter) ? ' |
106 | - WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : ''), |
|
106 | + WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : ''), |
|
107 | 107 | array( |
108 | 108 | 'filter' => isset($filter) ? $filter['value']['sql'] : '', |
109 | 109 | ) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $request = $smcFunc['db_query']('', ' |
147 | 147 | SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line |
148 | 148 | FROM {db_prefix}log_errors' . (isset($filter) ? ' |
149 | - WHERE ' . $filter['variable'] . ' '.$filters[$_GET['filter']]['operator'].' {'.$filters[$_GET['filter']]['datatype'].':filter}' : '') . ' |
|
149 | + WHERE ' . $filter['variable'] . ' ' . $filters[$_GET['filter']]['operator'] . ' {' . $filters[$_GET['filter']]['datatype'] . ':filter}' : '') . ' |
|
150 | 150 | ORDER BY id_error ' . ($context['sort_direction'] == 'down' ? 'DESC' : '') . ' |
151 | 151 | LIMIT {int:start}, {int:max}', |
152 | 152 | array( |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $context['errors'] = array(); |
159 | 159 | $members = array(); |
160 | 160 | |
161 | - for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
|
161 | + for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
|
162 | 162 | { |
163 | 163 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | 164 | if ($search_message == $filter['value']['sql']) |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'id' => $row['id_error'], |
185 | 185 | 'error_type' => array( |
186 | 186 | 'type' => $row['error_type'], |
187 | - 'name' => isset($txt['errortype_'.$row['error_type']]) ? $txt['errortype_'.$row['error_type']] : $row['error_type'], |
|
187 | + 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type'], |
|
188 | 188 | ), |
189 | 189 | 'file' => array(), |
190 | 190 | ); |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | // We don't want to slice off too many so lets make sure we stop at the last one |
413 | 413 | $max = min($max, max(array_keys($file_data))); |
414 | 414 | |
415 | - $file_data = array_slice($file_data, $min-1, $max - $min); |
|
415 | + $file_data = array_slice($file_data, $min - 1, $max - $min); |
|
416 | 416 | |
417 | 417 | $context['file_data'] = array( |
418 | 418 | 'contents' => $file_data, |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * View the forum's error log. |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Check for the administrative permission to do this. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -85,8 +87,8 @@ discard block |
||
85 | 87 | ); |
86 | 88 | |
87 | 89 | // Set up the filtering... |
88 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
89 | - $filter = array( |
|
90 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
91 | + $filter = array( |
|
90 | 92 | 'variable' => $_GET['filter'], |
91 | 93 | 'value' => array( |
92 | 94 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -94,10 +96,12 @@ discard block |
||
94 | 96 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
95 | 97 | 'entity' => $filters[$_GET['filter']]['txt'] |
96 | 98 | ); |
99 | + } |
|
97 | 100 | |
98 | 101 | // Deleting, are we? |
99 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
100 | - deleteErrors(); |
|
102 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
103 | + deleteErrors(); |
|
104 | + } |
|
101 | 105 | |
102 | 106 | // Just how many errors are there? |
103 | 107 | $result = $smcFunc['db_query']('', ' |
@@ -112,12 +116,14 @@ discard block |
||
112 | 116 | $smcFunc['db_free_result']($result); |
113 | 117 | |
114 | 118 | // If this filter is empty... |
115 | - if ($num_errors == 0 && isset($filter)) |
|
116 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
119 | + if ($num_errors == 0 && isset($filter)) { |
|
120 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
121 | + } |
|
117 | 122 | |
118 | 123 | // Clean up start. |
119 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
120 | - $_GET['start'] = 0; |
|
124 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
125 | + $_GET['start'] = 0; |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Do we want to reverse error listing? |
123 | 129 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -127,9 +133,9 @@ discard block |
||
127 | 133 | $context['start'] = $_GET['start']; |
128 | 134 | |
129 | 135 | // Update the error count |
130 | - if (!isset($filter)) |
|
131 | - $context['num_errors'] = $num_errors; |
|
132 | - else |
|
136 | + if (!isset($filter)) { |
|
137 | + $context['num_errors'] = $num_errors; |
|
138 | + } else |
|
133 | 139 | { |
134 | 140 | // We want all errors, not just the number of filtered messages... |
135 | 141 | $query = $smcFunc['db_query']('', ' |
@@ -161,8 +167,9 @@ discard block |
||
161 | 167 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i ++) |
162 | 168 | { |
163 | 169 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
164 | - if ($search_message == $filter['value']['sql']) |
|
165 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
170 | + if ($search_message == $filter['value']['sql']) { |
|
171 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
172 | + } |
|
166 | 173 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
167 | 174 | |
168 | 175 | $context['errors'][$row['id_error']] = array( |
@@ -221,8 +228,9 @@ discard block |
||
221 | 228 | 'members' => count($members), |
222 | 229 | ) |
223 | 230 | ); |
224 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
225 | - $members[$row['id_member']] = $row; |
|
231 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
232 | + $members[$row['id_member']] = $row; |
|
233 | + } |
|
226 | 234 | $smcFunc['db_free_result']($request); |
227 | 235 | |
228 | 236 | // This is a guest... |
@@ -254,20 +262,18 @@ discard block |
||
254 | 262 | $id = $filter['value']['sql']; |
255 | 263 | loadMemberData($id, false, 'minimal'); |
256 | 264 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
257 | - } |
|
258 | - elseif ($filter['variable'] == 'url') |
|
259 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
260 | - elseif ($filter['variable'] == 'message') |
|
265 | + } elseif ($filter['variable'] == 'url') { |
|
266 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
267 | + } elseif ($filter['variable'] == 'message') |
|
261 | 268 | { |
262 | 269 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
263 | 270 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
264 | - } |
|
265 | - elseif ($filter['variable'] == 'error_type') |
|
271 | + } elseif ($filter['variable'] == 'error_type') |
|
266 | 272 | { |
267 | 273 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
274 | + } else { |
|
275 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
268 | 276 | } |
269 | - else |
|
270 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
271 | 277 | } |
272 | 278 | |
273 | 279 | $context['error_types'] = array(); |
@@ -308,10 +314,11 @@ discard block |
||
308 | 314 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
309 | 315 | |
310 | 316 | // Finally, work out what is the last tab! |
311 | - if (isset($context['error_types'][$sum])) |
|
312 | - $context['error_types'][$sum]['is_last'] = true; |
|
313 | - else |
|
314 | - $context['error_types']['all']['is_last'] = true; |
|
317 | + if (isset($context['error_types'][$sum])) { |
|
318 | + $context['error_types'][$sum]['is_last'] = true; |
|
319 | + } else { |
|
320 | + $context['error_types']['all']['is_last'] = true; |
|
321 | + } |
|
315 | 322 | |
316 | 323 | // And this is pretty basic ;). |
317 | 324 | $context['page_title'] = $txt['errlog']; |
@@ -337,21 +344,23 @@ discard block |
||
337 | 344 | validateToken('admin-el'); |
338 | 345 | |
339 | 346 | // Delete all or just some? |
340 | - if (isset($_POST['delall']) && !isset($filter)) |
|
341 | - $smcFunc['db_query']('truncate_table', ' |
|
347 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
348 | + $smcFunc['db_query']('truncate_table', ' |
|
342 | 349 | TRUNCATE {db_prefix}log_errors', |
343 | 350 | array( |
344 | 351 | ) |
345 | 352 | ); |
353 | + } |
|
346 | 354 | // Deleting all with a filter? |
347 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
348 | - $smcFunc['db_query']('', ' |
|
355 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
356 | + $smcFunc['db_query']('', ' |
|
349 | 357 | DELETE FROM {db_prefix}log_errors |
350 | 358 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
351 | 359 | array( |
352 | 360 | 'filter' => $filter['value']['sql'], |
353 | 361 | ) |
354 | 362 | ); |
363 | + } |
|
355 | 364 | // Just specific errors? |
356 | 365 | elseif (!empty($_POST['delete'])) |
357 | 366 | { |
@@ -397,15 +406,17 @@ discard block |
||
397 | 406 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
398 | 407 | |
399 | 408 | // Make sure the file we are looking for is one they are allowed to look at |
400 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
401 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
409 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
410 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
411 | + } |
|
402 | 412 | |
403 | 413 | // get the min and max lines |
404 | 414 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
405 | 415 | $max = $line + 21; // One additional line to make everything work out correctly |
406 | 416 | |
407 | - if ($max <= 0 || $min >= $max) |
|
408 | - fatal_lang_error('error_bad_line'); |
|
417 | + if ($max <= 0 || $min >= $max) { |
|
418 | + fatal_lang_error('error_bad_line'); |
|
419 | + } |
|
409 | 420 | |
410 | 421 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
411 | 422 |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | |
660 | 660 | // Remove the phrase parts and extract the words. |
661 | 661 | $wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']); |
662 | - $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
662 | + $wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES)); |
|
663 | 663 | |
664 | 664 | // A minus sign in front of a word excludes the word.... so... |
665 | 665 | $excludedWords = array(); |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | SELECT |
1105 | 1105 | {int:id_search}, |
1106 | 1106 | t.id_topic, |
1107 | - ' . $relevance. ', |
|
1107 | + ' . $relevance . ', |
|
1108 | 1108 | ' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ', |
1109 | 1109 | 1 |
1110 | 1110 | FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : ' |
@@ -1339,7 +1339,7 @@ discard block |
||
1339 | 1339 | if (empty($subject_query['where'])) |
1340 | 1340 | continue; |
1341 | 1341 | |
1342 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
|
1342 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? (' |
|
1343 | 1343 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
1344 | 1344 | (' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . ' |
1345 | 1345 | SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | $main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance'; |
1570 | 1570 | |
1571 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( ' |
|
1571 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? (' |
|
1572 | 1572 | INSERT IGNORE INTO ' . '{db_prefix}log_search_results |
1573 | 1573 | (' . implode(', ', array_keys($main_query['select'])) . ')') : '') . ' |
1574 | 1574 | SELECT |
@@ -1636,7 +1636,7 @@ discard block |
||
1636 | 1636 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
1637 | 1637 | |
1638 | 1638 | $usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts)); |
1639 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( ' |
|
1639 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? (' |
|
1640 | 1640 | INSERT IGNORE INTO {db_prefix}log_search_results |
1641 | 1641 | (id_search, id_topic, relevance, id_msg, num_matches)') : '') . ' |
1642 | 1642 | SELECT |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | $query = trim($query, "\*+"); |
2103 | 2103 | $query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\'')); |
2104 | 2104 | |
2105 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
|
2105 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m) |
|
2106 | 2106 | { |
2107 | 2107 | return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>"; |
2108 | 2108 | }, $body_highlighted); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | // 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 | { |
@@ -710,39 +756,45 @@ discard block |
||
710 | 756 | { |
711 | 757 | $context['search_ignored'][] = $value; |
712 | 758 | unset($searchArray[$index]); |
759 | + } else { |
|
760 | + $searchArray[$index] = $searchArray[$index]; |
|
713 | 761 | } |
714 | - else |
|
715 | - $searchArray[$index] = $searchArray[$index]; |
|
716 | 762 | } |
717 | 763 | $searchArray = array_slice(array_unique($searchArray), 0, 10); |
718 | 764 | |
719 | 765 | // Create an array of replacements for highlighting. |
720 | 766 | $context['mark'] = array(); |
721 | - foreach ($searchArray as $word) |
|
722 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
767 | + foreach ($searchArray as $word) { |
|
768 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
769 | + } |
|
723 | 770 | |
724 | 771 | // Initialize two arrays storing the words that have to be searched for. |
725 | 772 | $orParts = array(); |
726 | 773 | $searchWords = array(); |
727 | 774 | |
728 | 775 | // Make sure at least one word is being searched for. |
729 | - if (empty($searchArray)) |
|
730 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
776 | + if (empty($searchArray)) { |
|
777 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
778 | + } |
|
731 | 779 | // All words/sentences must match. |
732 | - elseif (empty($search_params['searchtype'])) |
|
733 | - $orParts[0] = $searchArray; |
|
780 | + elseif (empty($search_params['searchtype'])) { |
|
781 | + $orParts[0] = $searchArray; |
|
782 | + } |
|
734 | 783 | // Any word/sentence must match. |
735 | - else |
|
736 | - foreach ($searchArray as $index => $value) |
|
784 | + else { |
|
785 | + foreach ($searchArray as $index => $value) |
|
737 | 786 | $orParts[$index] = array($value); |
787 | + } |
|
738 | 788 | |
739 | 789 | // Don't allow duplicate error messages if one string is too short. |
740 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
741 | - unset($context['search_errors']['invalid_search_string']); |
|
790 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
791 | + unset($context['search_errors']['invalid_search_string']); |
|
792 | + } |
|
742 | 793 | // Make sure the excluded words are in all or-branches. |
743 | - foreach ($orParts as $orIndex => $andParts) |
|
744 | - foreach ($excludedWords as $word) |
|
794 | + foreach ($orParts as $orIndex => $andParts) { |
|
795 | + foreach ($excludedWords as $word) |
|
745 | 796 | $orParts[$orIndex][] = $word; |
797 | + } |
|
746 | 798 | |
747 | 799 | // Determine the or-branches and the fulltext search words. |
748 | 800 | foreach ($orParts as $orIndex => $andParts) |
@@ -756,8 +808,9 @@ discard block |
||
756 | 808 | ); |
757 | 809 | |
758 | 810 | // Sort the indexed words (large words -> small words -> excluded words). |
759 | - if ($searchAPI->supportsMethod('searchSort')) |
|
760 | - usort($orParts[$orIndex], 'searchSort'); |
|
811 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
812 | + usort($orParts[$orIndex], 'searchSort'); |
|
813 | + } |
|
761 | 814 | |
762 | 815 | foreach ($orParts[$orIndex] as $word) |
763 | 816 | { |
@@ -769,15 +822,17 @@ discard block |
||
769 | 822 | if (!$is_excluded || count($subjectWords) === 1) |
770 | 823 | { |
771 | 824 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
772 | - if ($is_excluded) |
|
773 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
825 | + if ($is_excluded) { |
|
826 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
827 | + } |
|
828 | + } else { |
|
829 | + $excludedPhrases[] = $word; |
|
774 | 830 | } |
775 | - else |
|
776 | - $excludedPhrases[] = $word; |
|
777 | 831 | |
778 | 832 | // Have we got indexes to prepare? |
779 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
780 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
833 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
834 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
835 | + } |
|
781 | 836 | } |
782 | 837 | |
783 | 838 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -785,8 +840,7 @@ discard block |
||
785 | 840 | { |
786 | 841 | $context['search_errors']['query_not_specific_enough'] = true; |
787 | 842 | break; |
788 | - } |
|
789 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
843 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
790 | 844 | { |
791 | 845 | $context['search_errors']['query_not_specific_enough'] = true; |
792 | 846 | break; |
@@ -814,8 +868,9 @@ discard block |
||
814 | 868 | $found_misspelling = false; |
815 | 869 | foreach ($searchArray as $word) |
816 | 870 | { |
817 | - if (empty($link)) |
|
818 | - continue; |
|
871 | + if (empty($link)) { |
|
872 | + continue; |
|
873 | + } |
|
819 | 874 | |
820 | 875 | // Don't check phrases. |
821 | 876 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -830,8 +885,7 @@ discard block |
||
830 | 885 | $did_you_mean['search'][] = $word; |
831 | 886 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
832 | 887 | continue; |
833 | - } |
|
834 | - elseif (spell_check($link, $word)) |
|
888 | + } elseif (spell_check($link, $word)) |
|
835 | 889 | { |
836 | 890 | $did_you_mean['search'][] = $word; |
837 | 891 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -842,11 +896,13 @@ discard block |
||
842 | 896 | foreach ($suggestions as $i => $s) |
843 | 897 | { |
844 | 898 | // Search is case insensitive. |
845 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
846 | - unset($suggestions[$i]); |
|
899 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
900 | + unset($suggestions[$i]); |
|
901 | + } |
|
847 | 902 | // Plus, don't suggest something the user thinks is rude! |
848 | - elseif ($suggestions[$i] != censorText($s)) |
|
849 | - unset($suggestions[$i]); |
|
903 | + elseif ($suggestions[$i] != censorText($s)) { |
|
904 | + unset($suggestions[$i]); |
|
905 | + } |
|
850 | 906 | } |
851 | 907 | |
852 | 908 | // Anything found? If so, correct it! |
@@ -856,8 +912,7 @@ discard block |
||
856 | 912 | $did_you_mean['search'][] = $suggestions[0]; |
857 | 913 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
858 | 914 | $found_misspelling = true; |
859 | - } |
|
860 | - else |
|
915 | + } else |
|
861 | 916 | { |
862 | 917 | $did_you_mean['search'][] = $word; |
863 | 918 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -874,8 +929,7 @@ discard block |
||
874 | 929 | { |
875 | 930 | $temp_excluded['search'][] = '-"' . $word . '"'; |
876 | 931 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
877 | - } |
|
878 | - else |
|
932 | + } else |
|
879 | 933 | { |
880 | 934 | $temp_excluded['search'][] = '-' . $word; |
881 | 935 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -887,11 +941,13 @@ discard block |
||
887 | 941 | |
888 | 942 | $temp_params = $search_params; |
889 | 943 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
890 | - if (isset($temp_params['brd'])) |
|
891 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
944 | + if (isset($temp_params['brd'])) { |
|
945 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
946 | + } |
|
892 | 947 | $context['params'] = array(); |
893 | - foreach ($temp_params as $k => $v) |
|
894 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
948 | + foreach ($temp_params as $k => $v) { |
|
949 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
950 | + } |
|
895 | 951 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
896 | 952 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
897 | 953 | } |
@@ -899,18 +955,20 @@ discard block |
||
899 | 955 | |
900 | 956 | // Let the user adjust the search query, should they wish? |
901 | 957 | $context['search_params'] = $search_params; |
902 | - if (isset($context['search_params']['search'])) |
|
903 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
904 | - if (isset($context['search_params']['userspec'])) |
|
905 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
958 | + if (isset($context['search_params']['search'])) { |
|
959 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
960 | + } |
|
961 | + if (isset($context['search_params']['userspec'])) { |
|
962 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
963 | + } |
|
906 | 964 | |
907 | 965 | // Do we have captcha enabled? |
908 | 966 | 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'])) |
909 | 967 | { |
910 | 968 | // If we come from another search box tone down the error... |
911 | - if (!isset($_REQUEST['search_vv'])) |
|
912 | - $context['search_errors']['need_verification_code'] = true; |
|
913 | - else |
|
969 | + if (!isset($_REQUEST['search_vv'])) { |
|
970 | + $context['search_errors']['need_verification_code'] = true; |
|
971 | + } else |
|
914 | 972 | { |
915 | 973 | require_once($sourcedir . '/Subs-Editor.php'); |
916 | 974 | $verificationOptions = array( |
@@ -920,12 +978,14 @@ discard block |
||
920 | 978 | |
921 | 979 | if (is_array($context['require_verification'])) |
922 | 980 | { |
923 | - foreach ($context['require_verification'] as $error) |
|
924 | - $context['search_errors'][$error] = true; |
|
981 | + foreach ($context['require_verification'] as $error) { |
|
982 | + $context['search_errors'][$error] = true; |
|
983 | + } |
|
925 | 984 | } |
926 | 985 | // Don't keep asking for it - they've proven themselves worthy. |
927 | - else |
|
928 | - $_SESSION['ss_vv_passed'] = true; |
|
986 | + else { |
|
987 | + $_SESSION['ss_vv_passed'] = true; |
|
988 | + } |
|
929 | 989 | } |
930 | 990 | } |
931 | 991 | |
@@ -933,19 +993,22 @@ discard block |
||
933 | 993 | |
934 | 994 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
935 | 995 | $temp_params = $search_params; |
936 | - if (isset($temp_params['brd'])) |
|
937 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
996 | + if (isset($temp_params['brd'])) { |
|
997 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
998 | + } |
|
938 | 999 | $context['params'] = array(); |
939 | - foreach ($temp_params as $k => $v) |
|
940 | - $context['params'][] = $k . '|\'|' . $v; |
|
1000 | + foreach ($temp_params as $k => $v) { |
|
1001 | + $context['params'][] = $k . '|\'|' . $v; |
|
1002 | + } |
|
941 | 1003 | |
942 | 1004 | if (!empty($context['params'])) |
943 | 1005 | { |
944 | 1006 | // Due to old IE's 2083 character limit, we have to compress long search strings |
945 | 1007 | $params = @gzcompress(implode('|"|', $context['params'])); |
946 | 1008 | // Gzcompress failed, use try non-gz |
947 | - if (empty($params)) |
|
948 | - $params = implode('|"|', $context['params']); |
|
1009 | + if (empty($params)) { |
|
1010 | + $params = implode('|"|', $context['params']); |
|
1011 | + } |
|
949 | 1012 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
950 | 1013 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
951 | 1014 | } |
@@ -971,8 +1034,9 @@ discard block |
||
971 | 1034 | } |
972 | 1035 | |
973 | 1036 | // Spam me not, Spam-a-lot? |
974 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
975 | - spamProtection('search'); |
|
1037 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
1038 | + spamProtection('search'); |
|
1039 | + } |
|
976 | 1040 | // Store the last search string to allow pages of results to be browsed. |
977 | 1041 | $_SESSION['last_ss'] = $search_params['search']; |
978 | 1042 | |
@@ -1032,8 +1096,9 @@ discard block |
||
1032 | 1096 | 'where' => array(), |
1033 | 1097 | ); |
1034 | 1098 | |
1035 | - if ($modSettings['postmod_active']) |
|
1036 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1099 | + if ($modSettings['postmod_active']) { |
|
1100 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1101 | + } |
|
1037 | 1102 | |
1038 | 1103 | $numTables = 0; |
1039 | 1104 | $prev_join = 0; |
@@ -1045,8 +1110,7 @@ discard block |
||
1045 | 1110 | { |
1046 | 1111 | $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)'; |
1047 | 1112 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1048 | - } |
|
1049 | - else |
|
1113 | + } else |
|
1050 | 1114 | { |
1051 | 1115 | $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)'; |
1052 | 1116 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1064,14 +1128,18 @@ discard block |
||
1064 | 1128 | } |
1065 | 1129 | $subject_query['where'][] = $userQuery; |
1066 | 1130 | } |
1067 | - if (!empty($search_params['topic'])) |
|
1068 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1069 | - if (!empty($minMsgID)) |
|
1070 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1071 | - if (!empty($maxMsgID)) |
|
1072 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1073 | - if (!empty($boardQuery)) |
|
1074 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1131 | + if (!empty($search_params['topic'])) { |
|
1132 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1133 | + } |
|
1134 | + if (!empty($minMsgID)) { |
|
1135 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1136 | + } |
|
1137 | + if (!empty($maxMsgID)) { |
|
1138 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1139 | + } |
|
1140 | + if (!empty($boardQuery)) { |
|
1141 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1142 | + } |
|
1075 | 1143 | if (!empty($excludedPhrases)) |
1076 | 1144 | { |
1077 | 1145 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1091,8 +1159,9 @@ discard block |
||
1091 | 1159 | foreach ($weight_factors as $type => $value) |
1092 | 1160 | { |
1093 | 1161 | $relevance .= $weight[$type]; |
1094 | - if (!empty($value['results'])) |
|
1095 | - $relevance .= ' * ' . $value['results']; |
|
1162 | + if (!empty($value['results'])) { |
|
1163 | + $relevance .= ' * ' . $value['results']; |
|
1164 | + } |
|
1096 | 1165 | $relevance .= ' + '; |
1097 | 1166 | } |
1098 | 1167 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1130,20 +1199,23 @@ discard block |
||
1130 | 1199 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1131 | 1200 | { |
1132 | 1201 | // No duplicates! |
1133 | - if (isset($inserts[$row[1]])) |
|
1134 | - continue; |
|
1202 | + if (isset($inserts[$row[1]])) { |
|
1203 | + continue; |
|
1204 | + } |
|
1135 | 1205 | |
1136 | - foreach ($row as $key => $value) |
|
1137 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
1206 | + foreach ($row as $key => $value) { |
|
1207 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
1208 | + } |
|
1138 | 1209 | } |
1139 | 1210 | $smcFunc['db_free_result']($ignoreRequest); |
1140 | 1211 | $numSubjectResults = count($inserts); |
1212 | + } else { |
|
1213 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1141 | 1214 | } |
1142 | - else |
|
1143 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1144 | 1215 | |
1145 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1146 | - break; |
|
1216 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1217 | + break; |
|
1218 | + } |
|
1147 | 1219 | } |
1148 | 1220 | |
1149 | 1221 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1158,8 +1230,7 @@ discard block |
||
1158 | 1230 | } |
1159 | 1231 | |
1160 | 1232 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
1161 | - } |
|
1162 | - else |
|
1233 | + } else |
|
1163 | 1234 | { |
1164 | 1235 | $main_query = array( |
1165 | 1236 | 'select' => array( |
@@ -1191,8 +1262,7 @@ discard block |
||
1191 | 1262 | $main_query['weights'] = $weight_factors; |
1192 | 1263 | |
1193 | 1264 | $main_query['group_by'][] = 't.id_topic'; |
1194 | - } |
|
1195 | - else |
|
1265 | + } else |
|
1196 | 1266 | { |
1197 | 1267 | // This is outrageous! |
1198 | 1268 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1213,8 +1283,9 @@ discard block |
||
1213 | 1283 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
1214 | 1284 | $main_query['parameters']['topic'] = $search_params['topic']; |
1215 | 1285 | } |
1216 | - if (!empty($search_params['show_complete'])) |
|
1217 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1286 | + if (!empty($search_params['show_complete'])) { |
|
1287 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1288 | + } |
|
1218 | 1289 | } |
1219 | 1290 | |
1220 | 1291 | // *** Get the subject results. |
@@ -1241,14 +1312,15 @@ discard block |
||
1241 | 1312 | ) !== false; |
1242 | 1313 | |
1243 | 1314 | // Clean up some previous cache. |
1244 | - if (!$createTemporary) |
|
1245 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1315 | + if (!$createTemporary) { |
|
1316 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1246 | 1317 | DELETE FROM {db_prefix}log_search_topics |
1247 | 1318 | WHERE id_search = {int:search_id}', |
1248 | 1319 | array( |
1249 | 1320 | 'search_id' => $_SESSION['search_cache']['id_search'], |
1250 | 1321 | ) |
1251 | 1322 | ); |
1323 | + } |
|
1252 | 1324 | |
1253 | 1325 | foreach ($searchWords as $orIndex => $words) |
1254 | 1326 | { |
@@ -1280,8 +1352,7 @@ discard block |
||
1280 | 1352 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1281 | 1353 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
1282 | 1354 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
1283 | - } |
|
1284 | - else |
|
1355 | + } else |
|
1285 | 1356 | { |
1286 | 1357 | $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)'; |
1287 | 1358 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1336,8 +1407,9 @@ discard block |
||
1336 | 1407 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
1337 | 1408 | |
1338 | 1409 | // Nothing to search for? |
1339 | - if (empty($subject_query['where'])) |
|
1340 | - continue; |
|
1410 | + if (empty($subject_query['where'])) { |
|
1411 | + continue; |
|
1412 | + } |
|
1341 | 1413 | |
1342 | 1414 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
1343 | 1415 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1360,19 +1432,21 @@ discard block |
||
1360 | 1432 | { |
1361 | 1433 | $ind = $createTemporary ? 0 : 1; |
1362 | 1434 | // No duplicates! |
1363 | - if (isset($inserts[$row[$ind]])) |
|
1364 | - continue; |
|
1435 | + if (isset($inserts[$row[$ind]])) { |
|
1436 | + continue; |
|
1437 | + } |
|
1365 | 1438 | |
1366 | 1439 | $inserts[$row[$ind]] = $row; |
1367 | 1440 | } |
1368 | 1441 | $smcFunc['db_free_result']($ignoreRequest); |
1369 | 1442 | $numSubjectResults = count($inserts); |
1443 | + } else { |
|
1444 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1370 | 1445 | } |
1371 | - else |
|
1372 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1373 | 1446 | |
1374 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1375 | - break; |
|
1447 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1448 | + break; |
|
1449 | + } |
|
1376 | 1450 | } |
1377 | 1451 | |
1378 | 1452 | // Got some non-MySQL data to plonk in? |
@@ -1390,8 +1464,9 @@ discard block |
||
1390 | 1464 | { |
1391 | 1465 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
1392 | 1466 | $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)'; |
1393 | - if (!$createTemporary) |
|
1394 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1467 | + if (!$createTemporary) { |
|
1468 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1469 | + } |
|
1395 | 1470 | } |
1396 | 1471 | } |
1397 | 1472 | |
@@ -1419,14 +1494,15 @@ discard block |
||
1419 | 1494 | ) !== false; |
1420 | 1495 | |
1421 | 1496 | // Clear, all clear! |
1422 | - if (!$createTemporary) |
|
1423 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1497 | + if (!$createTemporary) { |
|
1498 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1424 | 1499 | DELETE FROM {db_prefix}log_search_messages |
1425 | 1500 | WHERE id_search = {int:id_search}', |
1426 | 1501 | array( |
1427 | 1502 | 'id_search' => $_SESSION['search_cache']['id_search'], |
1428 | 1503 | ) |
1429 | 1504 | ); |
1505 | + } |
|
1430 | 1506 | |
1431 | 1507 | foreach ($searchWords as $orIndex => $words) |
1432 | 1508 | { |
@@ -1460,19 +1536,21 @@ discard block |
||
1460 | 1536 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1461 | 1537 | { |
1462 | 1538 | // No duplicates! |
1463 | - if (isset($inserts[$row[0]])) |
|
1464 | - continue; |
|
1539 | + if (isset($inserts[$row[0]])) { |
|
1540 | + continue; |
|
1541 | + } |
|
1465 | 1542 | |
1466 | 1543 | $inserts[$row[0]] = $row; |
1467 | 1544 | } |
1468 | 1545 | $smcFunc['db_free_result']($ignoreRequest); |
1469 | 1546 | $indexedResults = count($inserts); |
1547 | + } else { |
|
1548 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
1470 | 1549 | } |
1471 | - else |
|
1472 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
1473 | 1550 | |
1474 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
1475 | - break; |
|
1551 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
1552 | + break; |
|
1553 | + } |
|
1476 | 1554 | } |
1477 | 1555 | } |
1478 | 1556 | |
@@ -1492,8 +1570,7 @@ discard block |
||
1492 | 1570 | $context['search_errors']['query_not_specific_enough'] = true; |
1493 | 1571 | $_REQUEST['params'] = $context['params']; |
1494 | 1572 | return PlushSearch1(); |
1495 | - } |
|
1496 | - elseif (!empty($indexedResults)) |
|
1573 | + } elseif (!empty($indexedResults)) |
|
1497 | 1574 | { |
1498 | 1575 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
1499 | 1576 | if (!$createTemporary) |
@@ -1515,15 +1592,18 @@ discard block |
||
1515 | 1592 | foreach ($words['all_words'] as $regularWord) |
1516 | 1593 | { |
1517 | 1594 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
1518 | - if (in_array($regularWord, $excludedWords)) |
|
1519 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1595 | + if (in_array($regularWord, $excludedWords)) { |
|
1596 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1597 | + } |
|
1520 | 1598 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
1521 | 1599 | } |
1522 | - if (!empty($where)) |
|
1523 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1600 | + if (!empty($where)) { |
|
1601 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1602 | + } |
|
1603 | + } |
|
1604 | + if (!empty($orWhere)) { |
|
1605 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1524 | 1606 | } |
1525 | - if (!empty($orWhere)) |
|
1526 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1527 | 1607 | |
1528 | 1608 | if (!empty($userQuery)) |
1529 | 1609 | { |
@@ -1561,8 +1641,9 @@ discard block |
||
1561 | 1641 | foreach ($main_query['weights'] as $type => $value) |
1562 | 1642 | { |
1563 | 1643 | $relevance .= $weight[$type]; |
1564 | - if (!empty($value['search'])) |
|
1565 | - $relevance .= ' * ' . $value['search']; |
|
1644 | + if (!empty($value['search'])) { |
|
1645 | + $relevance .= ' * ' . $value['search']; |
|
1646 | + } |
|
1566 | 1647 | $relevance .= ' + '; |
1567 | 1648 | $new_weight_total += $weight[$type]; |
1568 | 1649 | } |
@@ -1593,11 +1674,13 @@ discard block |
||
1593 | 1674 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1594 | 1675 | { |
1595 | 1676 | // No duplicates! |
1596 | - if (isset($inserts[$row[2]])) |
|
1597 | - continue; |
|
1677 | + if (isset($inserts[$row[2]])) { |
|
1678 | + continue; |
|
1679 | + } |
|
1598 | 1680 | |
1599 | - foreach ($row as $key => $value) |
|
1600 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
1681 | + foreach ($row as $key => $value) { |
|
1682 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
1683 | + } |
|
1601 | 1684 | } |
1602 | 1685 | $smcFunc['db_free_result']($ignoreRequest); |
1603 | 1686 | |
@@ -1605,8 +1688,9 @@ discard block |
||
1605 | 1688 | if (!empty($inserts)) |
1606 | 1689 | { |
1607 | 1690 | $query_columns = array(); |
1608 | - foreach ($main_query['select'] as $k => $v) |
|
1609 | - $query_columns[$k] = 'int'; |
|
1691 | + foreach ($main_query['select'] as $k => $v) { |
|
1692 | + $query_columns[$k] = 'int'; |
|
1693 | + } |
|
1610 | 1694 | |
1611 | 1695 | $smcFunc['db_insert']('', |
1612 | 1696 | '{db_prefix}log_search_results', |
@@ -1616,21 +1700,23 @@ discard block |
||
1616 | 1700 | ); |
1617 | 1701 | } |
1618 | 1702 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1703 | + } else { |
|
1704 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1619 | 1705 | } |
1620 | - else |
|
1621 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1622 | 1706 | } |
1623 | 1707 | |
1624 | 1708 | // Insert subject-only matches. |
1625 | 1709 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
1626 | 1710 | { |
1627 | 1711 | $relevance = '1000 * ('; |
1628 | - foreach ($weight_factors as $type => $value) |
|
1629 | - if (isset($value['results'])) |
|
1712 | + foreach ($weight_factors as $type => $value) { |
|
1713 | + if (isset($value['results'])) |
|
1630 | 1714 | { |
1631 | 1715 | $relevance .= $weight[$type]; |
1632 | - if (!empty($value['results'])) |
|
1633 | - $relevance .= ' * ' . $value['results']; |
|
1716 | + } |
|
1717 | + if (!empty($value['results'])) { |
|
1718 | + $relevance .= ' * ' . $value['results']; |
|
1719 | + } |
|
1634 | 1720 | $relevance .= ' + '; |
1635 | 1721 | } |
1636 | 1722 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1664,8 +1750,9 @@ discard block |
||
1664 | 1750 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1665 | 1751 | { |
1666 | 1752 | // No duplicates! |
1667 | - if (isset($usedIDs[$row[1]])) |
|
1668 | - continue; |
|
1753 | + if (isset($usedIDs[$row[1]])) { |
|
1754 | + continue; |
|
1755 | + } |
|
1669 | 1756 | |
1670 | 1757 | $usedIDs[$row[1]] = true; |
1671 | 1758 | $inserts[] = $row; |
@@ -1683,12 +1770,12 @@ discard block |
||
1683 | 1770 | ); |
1684 | 1771 | } |
1685 | 1772 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1773 | + } else { |
|
1774 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1686 | 1775 | } |
1687 | - else |
|
1688 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1776 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
1777 | + $_SESSION['search_cache']['num_results'] = 0; |
|
1689 | 1778 | } |
1690 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
1691 | - $_SESSION['search_cache']['num_results'] = 0; |
|
1692 | 1779 | } |
1693 | 1780 | } |
1694 | 1781 | |
@@ -1758,14 +1845,16 @@ discard block |
||
1758 | 1845 | ) |
1759 | 1846 | ); |
1760 | 1847 | $posters = array(); |
1761 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1762 | - $posters[] = $row['id_member']; |
|
1848 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1849 | + $posters[] = $row['id_member']; |
|
1850 | + } |
|
1763 | 1851 | $smcFunc['db_free_result']($request); |
1764 | 1852 | |
1765 | 1853 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
1766 | 1854 | |
1767 | - if (!empty($posters)) |
|
1768 | - loadMemberData(array_unique($posters)); |
|
1855 | + if (!empty($posters)) { |
|
1856 | + loadMemberData(array_unique($posters)); |
|
1857 | + } |
|
1769 | 1858 | |
1770 | 1859 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
1771 | 1860 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1799,8 +1888,9 @@ discard block |
||
1799 | 1888 | ); |
1800 | 1889 | |
1801 | 1890 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
1802 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
1803 | - $context['topics'] = array(); |
|
1891 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
1892 | + $context['topics'] = array(); |
|
1893 | + } |
|
1804 | 1894 | |
1805 | 1895 | // If we want to know who participated in what then load this now. |
1806 | 1896 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1818,8 +1908,9 @@ discard block |
||
1818 | 1908 | 'limit' => count($participants), |
1819 | 1909 | ) |
1820 | 1910 | ); |
1821 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1822 | - $participants[$row['id_topic']] = true; |
|
1911 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1912 | + $participants[$row['id_topic']] = true; |
|
1913 | + } |
|
1823 | 1914 | $smcFunc['db_free_result']($result); |
1824 | 1915 | } |
1825 | 1916 | } |
@@ -1828,15 +1919,17 @@ discard block |
||
1828 | 1919 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
1829 | 1920 | |
1830 | 1921 | // Consider the search complete! |
1831 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1832 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1922 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1923 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1924 | + } |
|
1833 | 1925 | |
1834 | 1926 | $context['key_words'] = &$searchArray; |
1835 | 1927 | |
1836 | 1928 | // Setup the default topic icons... for checking they exist and the like! |
1837 | 1929 | $context['icon_sources'] = array(); |
1838 | - foreach ($context['stable_icons'] as $icon) |
|
1839 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1930 | + foreach ($context['stable_icons'] as $icon) { |
|
1931 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1932 | + } |
|
1840 | 1933 | |
1841 | 1934 | $context['sub_template'] = 'results'; |
1842 | 1935 | $context['page_title'] = $txt['search_results']; |
@@ -1867,26 +1960,31 @@ discard block |
||
1867 | 1960 | global $boards_can, $participants, $smcFunc; |
1868 | 1961 | static $recycle_board = null; |
1869 | 1962 | |
1870 | - if ($recycle_board === null) |
|
1871 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1963 | + if ($recycle_board === null) { |
|
1964 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1965 | + } |
|
1872 | 1966 | |
1873 | 1967 | // Remember which message this is. (ie. reply #83) |
1874 | 1968 | static $counter = null; |
1875 | - if ($counter == null || $reset) |
|
1876 | - $counter = $_REQUEST['start'] + 1; |
|
1969 | + if ($counter == null || $reset) { |
|
1970 | + $counter = $_REQUEST['start'] + 1; |
|
1971 | + } |
|
1877 | 1972 | |
1878 | 1973 | // If the query returned false, bail. |
1879 | - if ($messages_request == false) |
|
1880 | - return false; |
|
1974 | + if ($messages_request == false) { |
|
1975 | + return false; |
|
1976 | + } |
|
1881 | 1977 | |
1882 | 1978 | // Start from the beginning... |
1883 | - if ($reset) |
|
1884 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1979 | + if ($reset) { |
|
1980 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1981 | + } |
|
1885 | 1982 | |
1886 | 1983 | // Attempt to get the next message. |
1887 | 1984 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1888 | - if (!$message) |
|
1889 | - return false; |
|
1985 | + if (!$message) { |
|
1986 | + return false; |
|
1987 | + } |
|
1890 | 1988 | |
1891 | 1989 | // Can't have an empty subject can we? |
1892 | 1990 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1925,9 +2023,9 @@ discard block |
||
1925 | 2023 | |
1926 | 2024 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
1927 | 2025 | { |
1928 | - if (empty($context['key_words'])) |
|
1929 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
1930 | - else |
|
2026 | + if (empty($context['key_words'])) { |
|
2027 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
2028 | + } else |
|
1931 | 2029 | { |
1932 | 2030 | $matchString = ''; |
1933 | 2031 | $force_partial_word = false; |
@@ -1936,18 +2034,20 @@ discard block |
||
1936 | 2034 | $keyword = un_htmlspecialchars($keyword); |
1937 | 2035 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
1938 | 2036 | |
1939 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
1940 | - $force_partial_word = true; |
|
2037 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
2038 | + $force_partial_word = true; |
|
2039 | + } |
|
1941 | 2040 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
1942 | 2041 | } |
1943 | 2042 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
1944 | 2043 | |
1945 | 2044 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
1946 | 2045 | |
1947 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
1948 | - 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); |
|
1949 | - else |
|
1950 | - 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); |
|
2046 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
2047 | + 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); |
|
2048 | + } else { |
|
2049 | + 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); |
|
2050 | + } |
|
1951 | 2051 | |
1952 | 2052 | $message['body'] = ''; |
1953 | 2053 | foreach ($matches[0] as $index => $match) |
@@ -1960,8 +2060,7 @@ discard block |
||
1960 | 2060 | // Re-fix the international characters. |
1961 | 2061 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
1962 | 2062 | } |
1963 | - } |
|
1964 | - else |
|
2063 | + } else |
|
1965 | 2064 | { |
1966 | 2065 | // Run BBC interpreter on the message. |
1967 | 2066 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1980,21 +2079,26 @@ discard block |
||
1980 | 2079 | // Sadly, we need to check the icon ain't broke. |
1981 | 2080 | if (!empty($modSettings['messageIconChecks_enable'])) |
1982 | 2081 | { |
1983 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1984 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1985 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1986 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1987 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1988 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1989 | - } |
|
1990 | - else |
|
2082 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2083 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2084 | + } |
|
2085 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2086 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2087 | + } |
|
2088 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2089 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2090 | + } |
|
2091 | + } else |
|
1991 | 2092 | { |
1992 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1993 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
1994 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1995 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
1996 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1997 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2093 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2094 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2095 | + } |
|
2096 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2097 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2098 | + } |
|
2099 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2100 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2101 | + } |
|
1998 | 2102 | } |
1999 | 2103 | |
2000 | 2104 | // Do we have quote tag enabled? |
@@ -2004,12 +2108,14 @@ discard block |
||
2004 | 2108 | $colorClass = 'windowbg'; |
2005 | 2109 | |
2006 | 2110 | // Sticky topics should get a different color, too. |
2007 | - if ($message['is_sticky']) |
|
2008 | - $colorClass .= ' sticky'; |
|
2111 | + if ($message['is_sticky']) { |
|
2112 | + $colorClass .= ' sticky'; |
|
2113 | + } |
|
2009 | 2114 | |
2010 | 2115 | // Locked topics get special treatment as well. |
2011 | - if ($message['locked']) |
|
2012 | - $colorClass .= ' locked'; |
|
2116 | + if ($message['locked']) { |
|
2117 | + $colorClass .= ' locked'; |
|
2118 | + } |
|
2013 | 2119 | |
2014 | 2120 | $output = array_merge($context['topics'][$message['id_msg']], array( |
2015 | 2121 | 'id' => $message['id_topic'], |
@@ -2153,8 +2259,9 @@ discard block |
||
2153 | 2259 | |
2154 | 2260 | // Load up the search API we are going to use. |
2155 | 2261 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
2156 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
2157 | - fatal_lang_error('search_api_missing'); |
|
2262 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
2263 | + fatal_lang_error('search_api_missing'); |
|
2264 | + } |
|
2158 | 2265 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
2159 | 2266 | |
2160 | 2267 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function get($property = '') |
168 | 168 | { |
169 | 169 | // All properties inside Likes are protected, thus, an underscore is used. |
170 | - $property = '_'. $property; |
|
170 | + $property = '_' . $property; |
|
171 | 171 | return property_exists($this, $property) ? $this->$property : false; |
172 | 172 | } |
173 | 173 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | // Nope? then just do a redirect to whatever URL was provided. |
573 | 573 | else |
574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : ''); |
|
574 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] . ';error=' . $this->_error : ''); |
|
575 | 575 | |
576 | 576 | return; |
577 | 577 | } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | if (in_array($this->_sa, $generic)) |
589 | 589 | { |
590 | 590 | $context['sub_template'] = 'generic'; |
591 | - $context['data'] = isset($txt['like_'. $this->_data]) ? $txt['like_'. $this->_data] : $this->_data; |
|
591 | + $context['data'] = isset($txt['like_' . $this->_data]) ? $txt['like_' . $this->_data] : $this->_data; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | // Directly pass the current called sub-action and the data generated by its associated Method. |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Class Likes |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | $this->_extra = isset($_GET['extra']) ? $_GET['extra'] : false; |
109 | 110 | |
110 | 111 | // We do not want to output debug information here. |
111 | - if ($this->_js) |
|
112 | - $db_show_debug = false; |
|
112 | + if ($this->_js) { |
|
113 | + $db_show_debug = false; |
|
114 | + } |
|
113 | 115 | } |
114 | 116 | |
115 | 117 | /** |
@@ -143,8 +145,9 @@ discard block |
||
143 | 145 | $call = $this->_sa; |
144 | 146 | |
145 | 147 | // Guest can only view likes. |
146 | - if ($call != 'view') |
|
147 | - is_not_guest(); |
|
148 | + if ($call != 'view') { |
|
149 | + is_not_guest(); |
|
150 | + } |
|
148 | 151 | |
149 | 152 | checkSession('get'); |
150 | 153 | |
@@ -182,15 +185,17 @@ discard block |
||
182 | 185 | global $smcFunc, $modSettings; |
183 | 186 | |
184 | 187 | // This feature is currently disable. |
185 | - if (empty($modSettings['enable_likes'])) |
|
186 | - return $this->_error = 'like_disable'; |
|
188 | + if (empty($modSettings['enable_likes'])) { |
|
189 | + return $this->_error = 'like_disable'; |
|
190 | + } |
|
187 | 191 | |
188 | 192 | // Zerothly, they did indicate some kind of content to like, right? |
189 | 193 | preg_match('~^([a-z0-9\-\_]{1,6})~i', $this->_type, $matches); |
190 | 194 | $this->_type = isset($matches[1]) ? $matches[1] : ''; |
191 | 195 | |
192 | - if ($this->_type == '' || $this->_content <= 0) |
|
193 | - return $this->_error = 'cannot_'; |
|
196 | + if ($this->_type == '' || $this->_content <= 0) { |
|
197 | + return $this->_error = 'cannot_'; |
|
198 | + } |
|
194 | 199 | |
195 | 200 | // First we need to verify if the user can see the type of content or not. This is set up to be extensible, |
196 | 201 | // so we'll check for the one type we do know about, and if it's not that, we'll defer to any hooks. |
@@ -209,12 +214,14 @@ discard block |
||
209 | 214 | 'msg' => $this->_content, |
210 | 215 | ) |
211 | 216 | ); |
212 | - if ($smcFunc['db_num_rows']($request) == 1) |
|
213 | - list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
217 | + if ($smcFunc['db_num_rows']($request) == 1) { |
|
218 | + list ($this->_idTopic, $topicOwner) = $smcFunc['db_fetch_row']($request); |
|
219 | + } |
|
214 | 220 | |
215 | 221 | $smcFunc['db_free_result']($request); |
216 | - if (empty($this->_idTopic)) |
|
217 | - return $this->_error = 'cannot_'; |
|
222 | + if (empty($this->_idTopic)) { |
|
223 | + return $this->_error = 'cannot_'; |
|
224 | + } |
|
218 | 225 | |
219 | 226 | // So we know what topic it's in and more importantly we know the user can see it. |
220 | 227 | // If we're not viewing, we need some info set up. |
@@ -224,9 +231,7 @@ discard block |
||
224 | 231 | $this->_validLikes['can_see'] = allowedTo('likes_view') ? true : 'cannot_view_likes'; |
225 | 232 | |
226 | 233 | $this->_validLikes['can_like'] = ($this->_user['id'] == $topicOwner ? 'cannot_like_content' : (allowedTo('likes_like') ? true : 'cannot_like_content')); |
227 | - } |
|
228 | - |
|
229 | - else |
|
234 | + } else |
|
230 | 235 | { |
231 | 236 | // Modders: This will give you whatever the user offers up in terms of liking, e.g. $this->_type=msg, $this->_content=1 |
232 | 237 | // When you hook this, check $this->_type first. If it is not something your mod worries about, return false. |
@@ -244,8 +249,9 @@ discard block |
||
244 | 249 | if ($result !== false) |
245 | 250 | { |
246 | 251 | // Match the type with what we already have. |
247 | - if (!isset($result['type']) || $result['type'] != $this->_type) |
|
248 | - return $this->_error = 'not_valid_like_type'; |
|
252 | + if (!isset($result['type']) || $result['type'] != $this->_type) { |
|
253 | + return $this->_error = 'not_valid_like_type'; |
|
254 | + } |
|
249 | 255 | |
250 | 256 | // Fill out the rest. |
251 | 257 | $this->_type = $result['type']; |
@@ -256,17 +262,20 @@ discard block |
||
256 | 262 | } |
257 | 263 | } |
258 | 264 | |
259 | - if (!$found) |
|
260 | - return $this->_error = 'cannot_'; |
|
265 | + if (!$found) { |
|
266 | + return $this->_error = 'cannot_'; |
|
267 | + } |
|
261 | 268 | } |
262 | 269 | |
263 | 270 | // Does the user can see this? |
264 | - if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) |
|
265 | - return $this->_error = $this->_validLikes['can_see']; |
|
271 | + if (isset($this->_validLikes['can_see']) && is_string($this->_validLikes['can_see'])) { |
|
272 | + return $this->_error = $this->_validLikes['can_see']; |
|
273 | + } |
|
266 | 274 | |
267 | 275 | // Does the user can like this? Viewing a list of likes doesn't require this permission. |
268 | - if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) |
|
269 | - return $this->_error = $this->_validLikes['can_like']; |
|
276 | + if ($this->_sa != 'view' && isset($this->_validLikes['can_like']) && is_string($this->_validLikes['can_like'])) { |
|
277 | + return $this->_error = $this->_validLikes['can_like']; |
|
278 | + } |
|
270 | 279 | } |
271 | 280 | |
272 | 281 | /** |
@@ -291,8 +300,9 @@ discard block |
||
291 | 300 | ); |
292 | 301 | |
293 | 302 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
294 | - if ($this->_sa == __FUNCTION__) |
|
295 | - $this->_data = __FUNCTION__; |
|
303 | + if ($this->_sa == __FUNCTION__) { |
|
304 | + $this->_data = __FUNCTION__; |
|
305 | + } |
|
296 | 306 | } |
297 | 307 | |
298 | 308 | /** |
@@ -322,8 +332,8 @@ discard block |
||
322 | 332 | |
323 | 333 | // Add a background task to process sending alerts. |
324 | 334 | // Mod author, you can add your own background task for your own custom like event using the "integrate_issue_like" hook or your callback, both are immediately called after this. |
325 | - if ($this->_type == 'msg') |
|
326 | - $smcFunc['db_insert']('insert', |
|
335 | + if ($this->_type == 'msg') { |
|
336 | + $smcFunc['db_insert']('insert', |
|
327 | 337 | '{db_prefix}background_tasks', |
328 | 338 | array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'), |
329 | 339 | array('$sourcedir/tasks/Likes-Notify.php', 'Likes_Notify_Background', json_encode(array( |
@@ -335,10 +345,12 @@ discard block |
||
335 | 345 | )), 0), |
336 | 346 | array('id_task') |
337 | 347 | ); |
348 | + } |
|
338 | 349 | |
339 | 350 | // Are we calling this directly? if so, set a proper data for the response. Do note that __METHOD__ returns both the class name and the function name. |
340 | - if ($this->_sa == __FUNCTION__) |
|
341 | - $this->_data = __FUNCTION__; |
|
351 | + if ($this->_sa == __FUNCTION__) { |
|
352 | + $this->_data = __FUNCTION__; |
|
353 | + } |
|
342 | 354 | } |
343 | 355 | |
344 | 356 | /** |
@@ -364,8 +376,9 @@ discard block |
||
364 | 376 | $smcFunc['db_free_result']($request); |
365 | 377 | |
366 | 378 | // If you want to call this directly, fill out _data property too. |
367 | - if ($this->_sa == __FUNCTION__) |
|
368 | - $this->_data = $this->_numLikes; |
|
379 | + if ($this->_sa == __FUNCTION__) { |
|
380 | + $this->_data = $this->_numLikes; |
|
381 | + } |
|
369 | 382 | } |
370 | 383 | |
371 | 384 | /** |
@@ -378,8 +391,9 @@ discard block |
||
378 | 391 | global $smcFunc; |
379 | 392 | |
380 | 393 | // Safety first! |
381 | - if (empty($this->_type) || empty($this->_content)) |
|
382 | - return $this->_error = 'cannot_'; |
|
394 | + if (empty($this->_type) || empty($this->_content)) { |
|
395 | + return $this->_error = 'cannot_'; |
|
396 | + } |
|
383 | 397 | |
384 | 398 | // Do we already like this? |
385 | 399 | $request = $smcFunc['db_query']('', ' |
@@ -397,26 +411,28 @@ discard block |
||
397 | 411 | $this->_alreadyLiked = (bool) $smcFunc['db_num_rows']($request) != 0; |
398 | 412 | $smcFunc['db_free_result']($request); |
399 | 413 | |
400 | - if ($this->_alreadyLiked) |
|
401 | - $this->delete(); |
|
402 | - |
|
403 | - else |
|
404 | - $this->insert(); |
|
414 | + if ($this->_alreadyLiked) { |
|
415 | + $this->delete(); |
|
416 | + } else { |
|
417 | + $this->insert(); |
|
418 | + } |
|
405 | 419 | |
406 | 420 | // Now, how many people like this content now? We *could* just +1 / -1 the relevant container but that has proven to become unstable. |
407 | 421 | $this->_count(); |
408 | 422 | |
409 | 423 | // Update the likes count for messages. |
410 | - if ($this->_type == 'msg') |
|
411 | - $this->msgIssueLike(); |
|
424 | + if ($this->_type == 'msg') { |
|
425 | + $this->msgIssueLike(); |
|
426 | + } |
|
412 | 427 | |
413 | 428 | // Any callbacks? |
414 | 429 | elseif (!empty($this->_validLikes['callback'])) |
415 | 430 | { |
416 | 431 | $call = call_helper($this->_validLikes['callback'], true); |
417 | 432 | |
418 | - if (!empty($call)) |
|
419 | - call_user_func_array($call, array($this)); |
|
433 | + if (!empty($call)) { |
|
434 | + call_user_func_array($call, array($this)); |
|
435 | + } |
|
420 | 436 | } |
421 | 437 | |
422 | 438 | // Sometimes there might be other things that need updating after we do this like. |
@@ -425,8 +441,9 @@ discard block |
||
425 | 441 | // Now some clean up. This is provided here for any like handlers that want to do any cache flushing. |
426 | 442 | // This way a like handler doesn't need to explicitly declare anything in integrate_issue_like, but do so |
427 | 443 | // in integrate_valid_likes where it absolutely has to exist. |
428 | - if (!empty($this->_validLikes['flush_cache'])) |
|
429 | - cache_put_data($this->_validLikes['flush_cache'], null); |
|
444 | + if (!empty($this->_validLikes['flush_cache'])) { |
|
445 | + cache_put_data($this->_validLikes['flush_cache'], null); |
|
446 | + } |
|
430 | 447 | |
431 | 448 | // All done, start building the data to pass as response. |
432 | 449 | $this->_data = array( |
@@ -450,8 +467,9 @@ discard block |
||
450 | 467 | { |
451 | 468 | global $smcFunc; |
452 | 469 | |
453 | - if ($this->_type !== 'msg') |
|
454 | - return; |
|
470 | + if ($this->_type !== 'msg') { |
|
471 | + return; |
|
472 | + } |
|
455 | 473 | |
456 | 474 | $smcFunc['db_query']('', ' |
457 | 475 | UPDATE {db_prefix}messages |
@@ -492,8 +510,9 @@ discard block |
||
492 | 510 | 'like_type' => $this->_type, |
493 | 511 | ) |
494 | 512 | ); |
495 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
496 | - $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
513 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
514 | + $context['likers'][$row['id_member']] = array('timestamp' => $row['like_time']); |
|
515 | + } |
|
497 | 516 | |
498 | 517 | // Now to get member data, including avatars and so on. |
499 | 518 | $members = array_keys($context['likers']); |
@@ -501,8 +520,9 @@ discard block |
||
501 | 520 | if (count($loaded) != count($members)) |
502 | 521 | { |
503 | 522 | $members = array_diff($members, $loaded); |
504 | - foreach ($members as $not_loaded) |
|
505 | - unset ($context['likers'][$not_loaded]); |
|
523 | + foreach ($members as $not_loaded) { |
|
524 | + unset ($context['likers'][$not_loaded]); |
|
525 | + } |
|
506 | 526 | } |
507 | 527 | |
508 | 528 | foreach ($context['likers'] as $liker => $dummy) |
@@ -544,12 +564,14 @@ discard block |
||
544 | 564 | global $context, $txt; |
545 | 565 | |
546 | 566 | // Don't do anything if someone else has already take care of the response. |
547 | - if (!$this->_setResponse) |
|
548 | - return; |
|
567 | + if (!$this->_setResponse) { |
|
568 | + return; |
|
569 | + } |
|
549 | 570 | |
550 | 571 | // Want a json response huh? |
551 | - if ($this->_validLikes['json']) |
|
552 | - return $this->jsonResponse(); |
|
572 | + if ($this->_validLikes['json']) { |
|
573 | + return $this->jsonResponse(); |
|
574 | + } |
|
553 | 575 | |
554 | 576 | // Set everything up for display. |
555 | 577 | loadTemplate('Likes'); |
@@ -559,8 +581,9 @@ discard block |
||
559 | 581 | if ($this->_error) |
560 | 582 | { |
561 | 583 | // If this is a generic error, set it up good. |
562 | - if ($this->_error == 'cannot_') |
|
563 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
584 | + if ($this->_error == 'cannot_') { |
|
585 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
586 | + } |
|
564 | 587 | |
565 | 588 | // Is this request coming from an ajax call? |
566 | 589 | if ($this->_js) |
@@ -570,8 +593,9 @@ discard block |
||
570 | 593 | } |
571 | 594 | |
572 | 595 | // Nope? then just do a redirect to whatever URL was provided. |
573 | - else |
|
574 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : ''); |
|
596 | + else { |
|
597 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] .';error='. $this->_error : ''); |
|
598 | + } |
|
575 | 599 | |
576 | 600 | return; |
577 | 601 | } |
@@ -580,8 +604,9 @@ discard block |
||
580 | 604 | else |
581 | 605 | { |
582 | 606 | // Not an ajax request so send the user back to the previous location or the main page. |
583 | - if (!$this->_js) |
|
584 | - redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
607 | + if (!$this->_js) { |
|
608 | + redirectexit(!empty($this->_validLikes['redirect']) ? $this->_validLikes['redirect'] : ''); |
|
609 | + } |
|
585 | 610 | |
586 | 611 | // These fine gentlemen all share the same template. |
587 | 612 | $generic = array('delete', 'insert', '_count'); |
@@ -612,8 +637,9 @@ discard block |
||
612 | 637 | // If there is an error, send it. |
613 | 638 | if ($this->_error) |
614 | 639 | { |
615 | - if ($this->_error == 'cannot_') |
|
616 | - $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
640 | + if ($this->_error == 'cannot_') { |
|
641 | + $this->_error = $this->_sa == 'view' ? 'cannot_view_likes' : 'cannot_like_content'; |
|
642 | + } |
|
617 | 643 | |
618 | 644 | $print['error'] = $this->_error; |
619 | 645 | } |
@@ -649,33 +675,36 @@ discard block |
||
649 | 675 | <body style="background-color: #444455; color: white; font-style: italic; font-family: serif;"> |
650 | 676 | <div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">'; |
651 | 677 | |
652 | - if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) |
|
653 | - $_GET['verse'] = '4:16'; |
|
678 | + if (!isset($_GET['verse']) || ($_GET['verse'] != '2:18' && $_GET['verse'] != '22:1-2')) { |
|
679 | + $_GET['verse'] = '4:16'; |
|
680 | + } |
|
654 | 681 | |
655 | - if ($_GET['verse'] == '2:18') |
|
656 | - echo ' |
|
682 | + if ($_GET['verse'] == '2:18') { |
|
683 | + echo ' |
|
657 | 684 | Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none. And it became to be in those days <em>something</em>. Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind. And thus what was to be known the <em>secret project</em> began into its existence. Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.'; |
658 | - elseif ($_GET['verse'] == '4:16') |
|
659 | - echo ' |
|
685 | + } elseif ($_GET['verse'] == '4:16') { |
|
686 | + echo ' |
|
660 | 687 | And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together. Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.'; |
661 | - elseif ($_GET['verse'] == '22:1-2') |
|
662 | - echo ' |
|
688 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
689 | + echo ' |
|
663 | 690 | <p>Now <em>behold</em>, that which was once the secret project was <em id="unknown" name="[Unknown]">unknown</em> no longer. Alas, it needed more than <em>only one</em>, but yet even thought otherwise. It became that the opposition <em>rumored</em> and lied, but still to no avail. Their match, though not <em>perfect</em>, had them outdone.</p> |
664 | 691 | <p style="margin: 2ex 1ex 0 1ex; font-size: 1.05em; line-height: 1.5; text-align: center;">Let it continue. <em>The end</em>.</p>'; |
692 | + } |
|
665 | 693 | |
666 | 694 | echo ' |
667 | 695 | </div> |
668 | 696 | <div style="margin-top: 2ex; font-size: 2em; text-align: right;">'; |
669 | 697 | |
670 | - if ($_GET['verse'] == '2:18') |
|
671 | - echo ' |
|
698 | + if ($_GET['verse'] == '2:18') { |
|
699 | + echo ' |
|
672 | 700 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=4:16" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>'; |
673 | - elseif ($_GET['verse'] == '4:16') |
|
674 | - echo ' |
|
701 | + } elseif ($_GET['verse'] == '4:16') { |
|
702 | + echo ' |
|
675 | 703 | from <span style="font-family: Georgia, serif;"><strong><a href="', $scripturl, '?action=about:unknown;verse=22:1-2" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>'; |
676 | - elseif ($_GET['verse'] == '22:1-2') |
|
677 | - echo ' |
|
704 | + } elseif ($_GET['verse'] == '22:1-2') { |
|
705 | + echo ' |
|
678 | 706 | from <span style="font-family: Georgia, serif;"><strong>The Book of Unknown</strong>, 22:1-2</span>'; |
707 | + } |
|
679 | 708 | |
680 | 709 | echo ' |
681 | 710 | </div> |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | COALESCE(mem.real_name, ms.poster_name) AS topic_started_name, ms.poster_time AS topic_started_time, |
160 | 160 | ' . ($user_info['is_guest'] ? 't.id_last_msg + 1' : 'COALESCE(lt.id_msg, lmr.id_msg, -1) + 1') . ' AS new_from |
161 | 161 | ' . (!empty($board_info['recycle']) ? ', id_previous_board, id_previous_topic' : '') . ' |
162 | - ' . (!empty($topic_selects) ? (', '. implode(', ', $topic_selects)) : '') . ' |
|
162 | + ' . (!empty($topic_selects) ? (', ' . implode(', ', $topic_selects)) : '') . ' |
|
163 | 163 | ' . (!$user_info['is_guest'] ? ', COALESCE(lt.unwatched, 0) as unwatched' : '') . ' |
164 | 164 | FROM {db_prefix}topics AS t |
165 | 165 | INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg) |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | WHERE INSTR(lo.url, {string:in_url_string}) > 0 OR lo.session = {string:session}', |
389 | 389 | array( |
390 | 390 | 'reg_id_group' => 0, |
391 | - 'in_url_string' => '"topic":'.$topic, |
|
391 | + 'in_url_string' => '"topic":' . $topic, |
|
392 | 392 | 'session' => $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(), |
393 | 393 | ) |
394 | 394 | ); |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | $context['links'] = array( |
458 | 458 | 'first' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.0' : '', |
459 | 459 | 'prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '', |
460 | - 'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '', |
|
461 | - 'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic. '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '', |
|
460 | + 'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '', |
|
461 | + 'last' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . (floor($context['total_visible_posts'] / $context['messages_per_page']) * $context['messages_per_page']) : '', |
|
462 | 462 | 'up' => $scripturl . '?board=' . $board . '.0' |
463 | 463 | ); |
464 | 464 | } |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | id_msg, icon, subject, poster_time, poster_ip, id_member, modified_time, modified_name, modified_reason, body, |
1038 | 1038 | smileys_enabled, poster_name, poster_email, approved, likes, |
1039 | 1039 | id_msg_modified < {int:new_from} AS is_read |
1040 | - ' . (!empty($msg_selects) ? (', '. implode(', ', $msg_selects)) : '') . ' |
|
1040 | + ' . (!empty($msg_selects) ? (', ' . implode(', ', $msg_selects)) : '') . ' |
|
1041 | 1041 | FROM {db_prefix}messages |
1042 | 1042 | ' . (!empty($msg_tables) ? implode("\n\t", $msg_tables) : '') . ' |
1043 | 1043 | WHERE id_msg IN ({array_int:message_list}) |
@@ -1681,17 +1681,17 @@ discard block |
||
1681 | 1681 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
1682 | 1682 | { |
1683 | 1683 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
1684 | - $callback = function ($buffer) |
|
1684 | + $callback = function($buffer) |
|
1685 | 1685 | { |
1686 | 1686 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
1687 | 1687 | }; |
1688 | 1688 | elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
1689 | - $callback = function ($buffer) |
|
1689 | + $callback = function($buffer) |
|
1690 | 1690 | { |
1691 | 1691 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
1692 | 1692 | }; |
1693 | 1693 | else |
1694 | - $callback = function ($buffer) |
|
1694 | + $callback = function($buffer) |
|
1695 | 1695 | { |
1696 | 1696 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
1697 | 1697 | }; |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | list($subname) = $smcFunc['db_fetch_row']($request); |
1773 | 1773 | $smcFunc['db_free_result']($request); |
1774 | 1774 | $_SESSION['split_selection'][$topic] = $messages; |
1775 | - redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' .urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1775 | + redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' . urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1776 | 1776 | } |
1777 | 1777 | |
1778 | 1778 | // Allowed to delete any message? |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $attachments, $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -394,21 +399,25 @@ discard block |
||
394 | 399 | ); |
395 | 400 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
396 | 401 | { |
397 | - if (empty($row['id_member'])) |
|
398 | - continue; |
|
402 | + if (empty($row['id_member'])) { |
|
403 | + continue; |
|
404 | + } |
|
399 | 405 | |
400 | - if (!empty($row['online_color'])) |
|
401 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
402 | - else |
|
403 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
406 | + if (!empty($row['online_color'])) { |
|
407 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
408 | + } else { |
|
409 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
410 | + } |
|
404 | 411 | |
405 | 412 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
406 | - if ($is_buddy) |
|
407 | - $link = '<strong>' . $link . '</strong>'; |
|
413 | + if ($is_buddy) { |
|
414 | + $link = '<strong>' . $link . '</strong>'; |
|
415 | + } |
|
408 | 416 | |
409 | 417 | // Add them both to the list and to the more detailed list. |
410 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
411 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
418 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
419 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
420 | + } |
|
412 | 421 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
413 | 422 | 'id' => $row['id_member'], |
414 | 423 | 'username' => $row['member_name'], |
@@ -420,8 +429,9 @@ discard block |
||
420 | 429 | 'hidden' => empty($row['show_online']), |
421 | 430 | ); |
422 | 431 | |
423 | - if (empty($row['show_online'])) |
|
424 | - $context['view_num_hidden']++; |
|
432 | + if (empty($row['show_online'])) { |
|
433 | + $context['view_num_hidden']++; |
|
434 | + } |
|
425 | 435 | } |
426 | 436 | |
427 | 437 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -435,11 +445,13 @@ discard block |
||
435 | 445 | |
436 | 446 | // If all is set, but not allowed... just unset it. |
437 | 447 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
438 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
439 | - unset($_REQUEST['all']); |
|
448 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
449 | + unset($_REQUEST['all']); |
|
450 | + } |
|
440 | 451 | // Otherwise, it must be allowed... so pretend start was -1. |
441 | - elseif (isset($_REQUEST['all'])) |
|
442 | - $_REQUEST['start'] = -1; |
|
452 | + elseif (isset($_REQUEST['all'])) { |
|
453 | + $_REQUEST['start'] = -1; |
|
454 | + } |
|
443 | 455 | |
444 | 456 | // Construct the page index, allowing for the .START method... |
445 | 457 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -476,8 +488,9 @@ discard block |
||
476 | 488 | $_REQUEST['start'] = 0; |
477 | 489 | } |
478 | 490 | // They aren't using it, but the *option* is there, at least. |
479 | - else |
|
480 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
491 | + else { |
|
492 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
493 | + } |
|
481 | 494 | } |
482 | 495 | |
483 | 496 | // Build the link tree. |
@@ -493,14 +506,16 @@ discard block |
||
493 | 506 | if (!empty($board_info['moderators'])) |
494 | 507 | { |
495 | 508 | // Add a link for each moderator... |
496 | - foreach ($board_info['moderators'] as $mod) |
|
497 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
509 | + foreach ($board_info['moderators'] as $mod) { |
|
510 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
511 | + } |
|
498 | 512 | } |
499 | 513 | if (!empty($board_info['moderator_groups'])) |
500 | 514 | { |
501 | 515 | // Add a link for each moderator group as well... |
502 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
503 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
516 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
517 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
518 | + } |
|
504 | 519 | } |
505 | 520 | |
506 | 521 | if (!empty($context['link_moderators'])) |
@@ -531,9 +546,9 @@ discard block |
||
531 | 546 | // For quick reply we need a response prefix in the default forum language. |
532 | 547 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
533 | 548 | { |
534 | - if ($language === $user_info['language']) |
|
535 | - $context['response_prefix'] = $txt['response_prefix']; |
|
536 | - else |
|
549 | + if ($language === $user_info['language']) { |
|
550 | + $context['response_prefix'] = $txt['response_prefix']; |
|
551 | + } else |
|
537 | 552 | { |
538 | 553 | loadLanguage('index', $language, false); |
539 | 554 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -546,10 +561,11 @@ discard block |
||
546 | 561 | if (allowedTo('calendar_view') && !empty($modSettings['cal_showInTopic']) && !empty($modSettings['cal_enabled'])) |
547 | 562 | { |
548 | 563 | // First, try create a better time format, ignoring the "time" elements. |
549 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
550 | - $date_string = $user_info['time_format']; |
|
551 | - else |
|
552 | - $date_string = $matches[0]; |
|
564 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
565 | + $date_string = $user_info['time_format']; |
|
566 | + } else { |
|
567 | + $date_string = $matches[0]; |
|
568 | + } |
|
553 | 569 | |
554 | 570 | // Any calendar information for this topic? |
555 | 571 | $request = $smcFunc['db_query']('', ' |
@@ -587,8 +603,9 @@ discard block |
||
587 | 603 | } |
588 | 604 | $smcFunc['db_free_result']($request); |
589 | 605 | |
590 | - if (!empty($context['linked_calendar_events'])) |
|
591 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
606 | + if (!empty($context['linked_calendar_events'])) { |
|
607 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
608 | + } |
|
592 | 609 | } |
593 | 610 | |
594 | 611 | // Create the poll info if it exists. |
@@ -661,20 +678,21 @@ discard block |
||
661 | 678 | foreach ($guestinfo as $i => $guestvoted) |
662 | 679 | { |
663 | 680 | $guestvoted = explode(',', $guestvoted); |
664 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
665 | - break; |
|
681 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
682 | + break; |
|
683 | + } |
|
666 | 684 | } |
667 | 685 | // Has the poll been reset since guest voted? |
668 | 686 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
669 | 687 | { |
670 | 688 | // Remove the poll info from the cookie to allow guest to vote again |
671 | 689 | unset($guestinfo[$i]); |
672 | - if (!empty($guestinfo)) |
|
673 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
674 | - else |
|
675 | - unset($_COOKIE['guest_poll_vote']); |
|
676 | - } |
|
677 | - else |
|
690 | + if (!empty($guestinfo)) { |
|
691 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
692 | + } else { |
|
693 | + unset($_COOKIE['guest_poll_vote']); |
|
694 | + } |
|
695 | + } else |
|
678 | 696 | { |
679 | 697 | // What did they vote for? |
680 | 698 | unset($guestvoted[0], $guestvoted[1]); |
@@ -788,23 +806,29 @@ discard block |
||
788 | 806 | // Build the poll moderation button array. |
789 | 807 | $context['poll_buttons'] = array(); |
790 | 808 | |
791 | - if ($context['allow_return_vote']) |
|
792 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
809 | + if ($context['allow_return_vote']) { |
|
810 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
811 | + } |
|
793 | 812 | |
794 | - if ($context['show_view_results_button']) |
|
795 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
813 | + if ($context['show_view_results_button']) { |
|
814 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
815 | + } |
|
796 | 816 | |
797 | - if ($context['allow_change_vote']) |
|
798 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
817 | + if ($context['allow_change_vote']) { |
|
818 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
819 | + } |
|
799 | 820 | |
800 | - if ($context['allow_lock_poll']) |
|
801 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
821 | + if ($context['allow_lock_poll']) { |
|
822 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
823 | + } |
|
802 | 824 | |
803 | - if ($context['allow_edit_poll']) |
|
804 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
825 | + if ($context['allow_edit_poll']) { |
|
826 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
827 | + } |
|
805 | 828 | |
806 | - if ($context['can_remove_poll']) |
|
807 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
829 | + if ($context['can_remove_poll']) { |
|
830 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
831 | + } |
|
808 | 832 | |
809 | 833 | // Allow mods to add additional buttons here |
810 | 834 | call_integration_hook('integrate_poll_buttons'); |
@@ -845,8 +869,9 @@ discard block |
||
845 | 869 | $all_posters = array(); |
846 | 870 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
847 | 871 | { |
848 | - if (!empty($row['id_member'])) |
|
849 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
872 | + if (!empty($row['id_member'])) { |
|
873 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
874 | + } |
|
850 | 875 | $messages[] = $row['id_msg']; |
851 | 876 | } |
852 | 877 | $smcFunc['db_free_result']($request); |
@@ -858,8 +883,9 @@ discard block |
||
858 | 883 | if (!$user_info['is_guest'] && !empty($messages)) |
859 | 884 | { |
860 | 885 | $mark_at_msg = max($messages); |
861 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
862 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
886 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
887 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
888 | + } |
|
863 | 889 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
864 | 890 | { |
865 | 891 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -891,8 +917,9 @@ discard block |
||
891 | 917 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
892 | 918 | { |
893 | 919 | // Find if this topic is marked for notification... |
894 | - if (!empty($row['id_topic'])) |
|
895 | - $context['is_marked_notify'] = true; |
|
920 | + if (!empty($row['id_topic'])) { |
|
921 | + $context['is_marked_notify'] = true; |
|
922 | + } |
|
896 | 923 | |
897 | 924 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
898 | 925 | if (!empty($row['sent']) && $do_once) |
@@ -914,8 +941,9 @@ discard block |
||
914 | 941 | } |
915 | 942 | |
916 | 943 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
917 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
918 | - $_SESSION['topicseen_cache'][$board]--; |
|
944 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
945 | + $_SESSION['topicseen_cache'][$board]--; |
|
946 | + } |
|
919 | 947 | // Mark board as seen if this is the only new topic. |
920 | 948 | elseif (isset($_REQUEST['topicseen'])) |
921 | 949 | { |
@@ -939,14 +967,16 @@ discard block |
||
939 | 967 | $smcFunc['db_free_result']($request); |
940 | 968 | |
941 | 969 | // If there're no real new topics in this board, mark the board as seen. |
942 | - if (empty($numNewTopics)) |
|
943 | - $_REQUEST['boardseen'] = true; |
|
944 | - else |
|
945 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
970 | + if (empty($numNewTopics)) { |
|
971 | + $_REQUEST['boardseen'] = true; |
|
972 | + } else { |
|
973 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
974 | + } |
|
946 | 975 | } |
947 | 976 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
948 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
949 | - $_SESSION['topicseen_cache'][$board]--; |
|
977 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
978 | + $_SESSION['topicseen_cache'][$board]--; |
|
979 | + } |
|
950 | 980 | |
951 | 981 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
952 | 982 | if (isset($_REQUEST['boardseen'])) |
@@ -1003,23 +1033,26 @@ discard block |
||
1003 | 1033 | $temp = array(); |
1004 | 1034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1005 | 1035 | { |
1006 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1007 | - continue; |
|
1036 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1037 | + continue; |
|
1038 | + } |
|
1008 | 1039 | |
1009 | 1040 | $temp[$row['id_attach']] = $row; |
1010 | 1041 | $temp[$row['id_attach']]['topic'] = $topic; |
1011 | 1042 | $temp[$row['id_attach']]['board'] = $board; |
1012 | 1043 | |
1013 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1014 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1044 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1045 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1046 | + } |
|
1015 | 1047 | } |
1016 | 1048 | $smcFunc['db_free_result']($request); |
1017 | 1049 | |
1018 | 1050 | // This is better than sorting it with the query... |
1019 | 1051 | ksort($temp); |
1020 | 1052 | |
1021 | - foreach ($temp as $row) |
|
1022 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1053 | + foreach ($temp as $row) { |
|
1054 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1055 | + } |
|
1023 | 1056 | } |
1024 | 1057 | |
1025 | 1058 | $msg_parameters = array( |
@@ -1046,21 +1079,23 @@ discard block |
||
1046 | 1079 | ); |
1047 | 1080 | |
1048 | 1081 | // And the likes |
1049 | - if (!empty($modSettings['enable_likes'])) |
|
1050 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1082 | + if (!empty($modSettings['enable_likes'])) { |
|
1083 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1084 | + } |
|
1051 | 1085 | |
1052 | 1086 | // Go to the last message if the given time is beyond the time of the last message. |
1053 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1054 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1087 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1088 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1089 | + } |
|
1055 | 1090 | |
1056 | 1091 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1057 | 1092 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1058 | - if (empty($options['view_newest_first'])) |
|
1059 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1060 | - else |
|
1061 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1062 | - } |
|
1063 | - else |
|
1093 | + if (empty($options['view_newest_first'])) { |
|
1094 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1095 | + } else { |
|
1096 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1097 | + } |
|
1098 | + } else |
|
1064 | 1099 | { |
1065 | 1100 | $messages_request = false; |
1066 | 1101 | $context['first_message'] = 0; |
@@ -1096,8 +1131,9 @@ discard block |
||
1096 | 1131 | 'can_see_likes' => 'likes_view', |
1097 | 1132 | 'can_like' => 'likes_like', |
1098 | 1133 | ); |
1099 | - foreach ($common_permissions as $contextual => $perm) |
|
1100 | - $context[$contextual] = allowedTo($perm); |
|
1134 | + foreach ($common_permissions as $contextual => $perm) { |
|
1135 | + $context[$contextual] = allowedTo($perm); |
|
1136 | + } |
|
1101 | 1137 | |
1102 | 1138 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1103 | 1139 | $anyown_permissions = array( |
@@ -1110,8 +1146,9 @@ discard block |
||
1110 | 1146 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1111 | 1147 | 'can_view_warning' => 'profile_warning', |
1112 | 1148 | ); |
1113 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1114 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1149 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1150 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1151 | + } |
|
1115 | 1152 | |
1116 | 1153 | if (!$user_info['is_admin'] && !$modSettings['topic_move_any']) |
1117 | 1154 | { |
@@ -1157,8 +1194,9 @@ discard block |
||
1157 | 1194 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1158 | 1195 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1159 | 1196 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1160 | - if (!empty($context['drafts_save'])) |
|
1161 | - loadLanguage('Drafts'); |
|
1197 | + if (!empty($context['drafts_save'])) { |
|
1198 | + loadLanguage('Drafts'); |
|
1199 | + } |
|
1162 | 1200 | |
1163 | 1201 | // When was the last time this topic was replied to? Should we warn them about it? |
1164 | 1202 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1219,26 +1257,31 @@ discard block |
||
1219 | 1257 | // Message icons - customized icons are off? |
1220 | 1258 | $context['icons'] = getMessageIcons($board); |
1221 | 1259 | |
1222 | - if (!empty($context['icons'])) |
|
1223 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1260 | + if (!empty($context['icons'])) { |
|
1261 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1262 | + } |
|
1224 | 1263 | |
1225 | 1264 | // Build the normal button array. |
1226 | 1265 | $context['normal_buttons'] = array(); |
1227 | 1266 | |
1228 | - if ($context['can_reply']) |
|
1229 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1267 | + if ($context['can_reply']) { |
|
1268 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1269 | + } |
|
1230 | 1270 | |
1231 | - if ($context['can_add_poll']) |
|
1232 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1271 | + if ($context['can_add_poll']) { |
|
1272 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1273 | + } |
|
1233 | 1274 | |
1234 | - if ($context['can_mark_unread']) |
|
1235 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1275 | + if ($context['can_mark_unread']) { |
|
1276 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1277 | + } |
|
1236 | 1278 | |
1237 | - if ($context['can_print']) |
|
1238 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1279 | + if ($context['can_print']) { |
|
1280 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1281 | + } |
|
1239 | 1282 | |
1240 | - if ($context['can_set_notify']) |
|
1241 | - $context['normal_buttons']['notify'] = array( |
|
1283 | + if ($context['can_set_notify']) { |
|
1284 | + $context['normal_buttons']['notify'] = array( |
|
1242 | 1285 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1243 | 1286 | 'sub_buttons' => array( |
1244 | 1287 | array( |
@@ -1260,38 +1303,47 @@ discard block |
||
1260 | 1303 | ), |
1261 | 1304 | ), |
1262 | 1305 | ); |
1306 | + } |
|
1263 | 1307 | |
1264 | 1308 | // Build the mod button array |
1265 | 1309 | $context['mod_buttons'] = array(); |
1266 | 1310 | |
1267 | - if ($context['can_move']) |
|
1268 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1311 | + if ($context['can_move']) { |
|
1312 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1313 | + } |
|
1269 | 1314 | |
1270 | - if ($context['can_delete']) |
|
1271 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1315 | + if ($context['can_delete']) { |
|
1316 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1317 | + } |
|
1272 | 1318 | |
1273 | - if ($context['can_lock']) |
|
1274 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1319 | + if ($context['can_lock']) { |
|
1320 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1321 | + } |
|
1275 | 1322 | |
1276 | - if ($context['can_sticky']) |
|
1277 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1323 | + if ($context['can_sticky']) { |
|
1324 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1325 | + } |
|
1278 | 1326 | |
1279 | - if ($context['can_merge']) |
|
1280 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1327 | + if ($context['can_merge']) { |
|
1328 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1329 | + } |
|
1281 | 1330 | |
1282 | - if ($context['calendar_post']) |
|
1283 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1331 | + if ($context['calendar_post']) { |
|
1332 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1333 | + } |
|
1284 | 1334 | |
1285 | 1335 | // Restore topic. eh? No monkey business. |
1286 | - if ($context['can_restore_topic']) |
|
1287 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1336 | + if ($context['can_restore_topic']) { |
|
1337 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1338 | + } |
|
1288 | 1339 | |
1289 | 1340 | // Show a message in case a recently posted message became unapproved. |
1290 | 1341 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1291 | 1342 | |
1292 | 1343 | // Don't want to show this forever... |
1293 | - if ($context['becomesUnapproved']) |
|
1294 | - unset($_SESSION['becomesUnapproved']); |
|
1344 | + if ($context['becomesUnapproved']) { |
|
1345 | + unset($_SESSION['becomesUnapproved']); |
|
1346 | + } |
|
1295 | 1347 | |
1296 | 1348 | // Allow adding new mod buttons easily. |
1297 | 1349 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1300,12 +1352,14 @@ discard block |
||
1300 | 1352 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1301 | 1353 | |
1302 | 1354 | // Load the drafts js file |
1303 | - if ($context['drafts_autosave']) |
|
1304 | - loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1355 | + if ($context['drafts_autosave']) { |
|
1356 | + loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts'); |
|
1357 | + } |
|
1305 | 1358 | |
1306 | 1359 | // Spellcheck |
1307 | - if ($context['show_spellchecking']) |
|
1308 | - loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1360 | + if ($context['show_spellchecking']) { |
|
1361 | + loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck'); |
|
1362 | + } |
|
1309 | 1363 | |
1310 | 1364 | // topic.js |
1311 | 1365 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -1339,16 +1393,19 @@ discard block |
||
1339 | 1393 | static $counter = null; |
1340 | 1394 | |
1341 | 1395 | // If the query returned false, bail. |
1342 | - if ($messages_request == false) |
|
1343 | - return false; |
|
1396 | + if ($messages_request == false) { |
|
1397 | + return false; |
|
1398 | + } |
|
1344 | 1399 | |
1345 | 1400 | // Remember which message this is. (ie. reply #83) |
1346 | - if ($counter === null || $reset) |
|
1347 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1401 | + if ($counter === null || $reset) { |
|
1402 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1403 | + } |
|
1348 | 1404 | |
1349 | 1405 | // Start from the beginning... |
1350 | - if ($reset) |
|
1351 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1406 | + if ($reset) { |
|
1407 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1408 | + } |
|
1352 | 1409 | |
1353 | 1410 | // Attempt to get the next message. |
1354 | 1411 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1362,19 +1419,21 @@ discard block |
||
1362 | 1419 | if (empty($context['icon_sources'])) |
1363 | 1420 | { |
1364 | 1421 | $context['icon_sources'] = array(); |
1365 | - foreach ($context['stable_icons'] as $icon) |
|
1366 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1422 | + foreach ($context['stable_icons'] as $icon) { |
|
1423 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1424 | + } |
|
1367 | 1425 | } |
1368 | 1426 | |
1369 | 1427 | // Message Icon Management... check the images exist. |
1370 | 1428 | if (empty($modSettings['messageIconChecks_disable'])) |
1371 | 1429 | { |
1372 | 1430 | // If the current icon isn't known, then we need to do something... |
1373 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1374 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1431 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1432 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1433 | + } |
|
1434 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1435 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1375 | 1436 | } |
1376 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1377 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1378 | 1437 | |
1379 | 1438 | // If you're a lazy bum, you probably didn't give a subject... |
1380 | 1439 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1399,8 +1458,7 @@ discard block |
||
1399 | 1458 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1400 | 1459 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1401 | 1460 | $memberContext[$message['id_member']]['is_guest'] = true; |
1402 | - } |
|
1403 | - else |
|
1461 | + } else |
|
1404 | 1462 | { |
1405 | 1463 | // Define this here to make things a bit more readable |
1406 | 1464 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1423,8 +1481,9 @@ discard block |
||
1423 | 1481 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1424 | 1482 | |
1425 | 1483 | // If it's in the recycle bin we need to override whatever icon we did have. |
1426 | - if (!empty($board_info['recycle'])) |
|
1427 | - $message['icon'] = 'recycled'; |
|
1484 | + if (!empty($board_info['recycle'])) { |
|
1485 | + $message['icon'] = 'recycled'; |
|
1486 | + } |
|
1428 | 1487 | |
1429 | 1488 | require_once($sourcedir . '/Subs-Attachments.php'); |
1430 | 1489 | |
@@ -1468,32 +1527,36 @@ discard block |
||
1468 | 1527 | } |
1469 | 1528 | |
1470 | 1529 | // Are likes enable? |
1471 | - if (!empty($modSettings['enable_likes'])) |
|
1472 | - $output['likes'] = array( |
|
1530 | + if (!empty($modSettings['enable_likes'])) { |
|
1531 | + $output['likes'] = array( |
|
1473 | 1532 | 'count' => $message['likes'], |
1474 | 1533 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1475 | 1534 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1476 | 1535 | ); |
1536 | + } |
|
1477 | 1537 | |
1478 | 1538 | // Is this user the message author? |
1479 | 1539 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1480 | - if (!empty($output['modified']['name'])) |
|
1481 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1540 | + if (!empty($output['modified']['name'])) { |
|
1541 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1542 | + } |
|
1482 | 1543 | |
1483 | 1544 | // Did they give a reason for editing? |
1484 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1485 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1545 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1546 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1547 | + } |
|
1486 | 1548 | |
1487 | 1549 | // Any custom profile fields? |
1488 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1489 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1550 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1551 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1490 | 1552 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1553 | + } |
|
1491 | 1554 | |
1492 | - if (empty($options['view_newest_first'])) |
|
1493 | - $counter++; |
|
1494 | - |
|
1495 | - else |
|
1496 | - $counter--; |
|
1555 | + if (empty($options['view_newest_first'])) { |
|
1556 | + $counter++; |
|
1557 | + } else { |
|
1558 | + $counter--; |
|
1559 | + } |
|
1497 | 1560 | |
1498 | 1561 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1499 | 1562 | |
@@ -1519,21 +1582,23 @@ discard block |
||
1519 | 1582 | $context['no_last_modified'] = true; |
1520 | 1583 | |
1521 | 1584 | // Prevent a preview image from being displayed twice. |
1522 | - if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) |
|
1523 | - return; |
|
1585 | + if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) { |
|
1586 | + return; |
|
1587 | + } |
|
1524 | 1588 | |
1525 | 1589 | // Make sure some attachment was requested! |
1526 | - if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) |
|
1527 | - fatal_lang_error('no_access', false); |
|
1590 | + if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) { |
|
1591 | + fatal_lang_error('no_access', false); |
|
1592 | + } |
|
1528 | 1593 | |
1529 | 1594 | $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id']; |
1530 | 1595 | |
1531 | 1596 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
1532 | 1597 | $attachRequest = null; |
1533 | 1598 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
1534 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
1535 | - $request = $attachRequest; |
|
1536 | - else |
|
1599 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
1600 | + $request = $attachRequest; |
|
1601 | + } else |
|
1537 | 1602 | { |
1538 | 1603 | // This checks only the current board for $board/$topic's permissions. |
1539 | 1604 | isAllowedTo('view_attachments'); |
@@ -1554,19 +1619,21 @@ discard block |
||
1554 | 1619 | ); |
1555 | 1620 | } |
1556 | 1621 | |
1557 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1558 | - fatal_lang_error('no_access', false); |
|
1622 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1623 | + fatal_lang_error('no_access', false); |
|
1624 | + } |
|
1559 | 1625 | |
1560 | 1626 | list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request); |
1561 | 1627 | $smcFunc['db_free_result']($request); |
1562 | 1628 | |
1563 | 1629 | // If it isn't yet approved, do they have permission to view it? |
1564 | - if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) |
|
1565 | - isAllowedTo('approve_posts'); |
|
1630 | + if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) { |
|
1631 | + isAllowedTo('approve_posts'); |
|
1632 | + } |
|
1566 | 1633 | |
1567 | 1634 | // Update the download counter (unless it's a thumbnail). |
1568 | - if ($attachment_type != 3) |
|
1569 | - $smcFunc['db_query']('attach_download_increase', ' |
|
1635 | + if ($attachment_type != 3) { |
|
1636 | + $smcFunc['db_query']('attach_download_increase', ' |
|
1570 | 1637 | UPDATE LOW_PRIORITY {db_prefix}attachments |
1571 | 1638 | SET downloads = downloads + 1 |
1572 | 1639 | WHERE id_attach = {int:id_attach}', |
@@ -1574,15 +1641,15 @@ discard block |
||
1574 | 1641 | 'id_attach' => $id_attach, |
1575 | 1642 | ) |
1576 | 1643 | ); |
1644 | + } |
|
1577 | 1645 | |
1578 | 1646 | $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash); |
1579 | 1647 | |
1580 | 1648 | // This is done to clear any output that was made before now. |
1581 | 1649 | ob_end_clean(); |
1582 | - if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) |
|
1583 | - @ob_start('ob_gzhandler'); |
|
1584 | - |
|
1585 | - else |
|
1650 | + if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) { |
|
1651 | + @ob_start('ob_gzhandler'); |
|
1652 | + } else |
|
1586 | 1653 | { |
1587 | 1654 | ob_start(); |
1588 | 1655 | header('Content-Encoding: none'); |
@@ -1625,8 +1692,9 @@ discard block |
||
1625 | 1692 | // Send the attachment headers. |
1626 | 1693 | header('Pragma: '); |
1627 | 1694 | |
1628 | - if (!isBrowser('gecko')) |
|
1629 | - header('Content-Transfer-Encoding: binary'); |
|
1695 | + if (!isBrowser('gecko')) { |
|
1696 | + header('Content-Transfer-Encoding: binary'); |
|
1697 | + } |
|
1630 | 1698 | |
1631 | 1699 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
1632 | 1700 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT'); |
@@ -1635,18 +1703,19 @@ discard block |
||
1635 | 1703 | header('ETag: ' . $eTag); |
1636 | 1704 | |
1637 | 1705 | // Make sure the mime type warrants an inline display. |
1638 | - if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) |
|
1639 | - unset($_REQUEST['image']); |
|
1706 | + if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) { |
|
1707 | + unset($_REQUEST['image']); |
|
1708 | + } |
|
1640 | 1709 | |
1641 | 1710 | // Does this have a mime type? |
1642 | - elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
1643 | - header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1644 | - |
|
1645 | - else |
|
1711 | + elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
1712 | + header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp'))); |
|
1713 | + } else |
|
1646 | 1714 | { |
1647 | 1715 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
1648 | - if (isset($_REQUEST['image'])) |
|
1649 | - unset($_REQUEST['image']); |
|
1716 | + if (isset($_REQUEST['image'])) { |
|
1717 | + unset($_REQUEST['image']); |
|
1718 | + } |
|
1650 | 1719 | } |
1651 | 1720 | |
1652 | 1721 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -1654,23 +1723,22 @@ discard block |
||
1654 | 1723 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
1655 | 1724 | |
1656 | 1725 | // Different browsers like different standards... |
1657 | - if (isBrowser('firefox')) |
|
1658 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1659 | - |
|
1660 | - elseif (isBrowser('opera')) |
|
1661 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1662 | - |
|
1663 | - elseif (isBrowser('ie')) |
|
1664 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1665 | - |
|
1666 | - else |
|
1667 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1726 | + if (isBrowser('firefox')) { |
|
1727 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
1728 | + } elseif (isBrowser('opera')) { |
|
1729 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
1730 | + } elseif (isBrowser('ie')) { |
|
1731 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
1732 | + } else { |
|
1733 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
1734 | + } |
|
1668 | 1735 | |
1669 | 1736 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
1670 | - if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
1671 | - header('Cache-Control: no-cache'); |
|
1672 | - else |
|
1673 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1737 | + if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
1738 | + header('Cache-Control: no-cache'); |
|
1739 | + } else { |
|
1740 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
1741 | + } |
|
1674 | 1742 | |
1675 | 1743 | header('Content-Length: ' . filesize($filename)); |
1676 | 1744 | |
@@ -1680,20 +1748,23 @@ discard block |
||
1680 | 1748 | // Recode line endings for text files, if enabled. |
1681 | 1749 | if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) |
1682 | 1750 | { |
1683 | - if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) |
|
1684 | - $callback = function ($buffer) |
|
1751 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) { |
|
1752 | + $callback = function ($buffer) |
|
1685 | 1753 | { |
1686 | 1754 | return preg_replace('~[\r]?\n~', "\r\n", $buffer); |
1755 | + } |
|
1687 | 1756 | }; |
1688 | - elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) |
|
1689 | - $callback = function ($buffer) |
|
1757 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { |
|
1758 | + $callback = function ($buffer) |
|
1690 | 1759 | { |
1691 | 1760 | return preg_replace('~[\r]?\n~', "\r", $buffer); |
1761 | + } |
|
1692 | 1762 | }; |
1693 | - else |
|
1694 | - $callback = function ($buffer) |
|
1763 | + else { |
|
1764 | + $callback = function ($buffer) |
|
1695 | 1765 | { |
1696 | 1766 | return preg_replace('~[\r]?\n~', "\n", $buffer); |
1767 | + } |
|
1697 | 1768 | }; |
1698 | 1769 | } |
1699 | 1770 | |
@@ -1701,23 +1772,26 @@ discard block |
||
1701 | 1772 | if (filesize($filename) > 4194304) |
1702 | 1773 | { |
1703 | 1774 | // Forcibly end any output buffering going on. |
1704 | - while (@ob_get_level() > 0) |
|
1705 | - @ob_end_clean(); |
|
1775 | + while (@ob_get_level() > 0) { |
|
1776 | + @ob_end_clean(); |
|
1777 | + } |
|
1706 | 1778 | |
1707 | 1779 | $fp = fopen($filename, 'rb'); |
1708 | 1780 | while (!feof($fp)) |
1709 | 1781 | { |
1710 | - if (isset($callback)) |
|
1711 | - echo $callback(fread($fp, 8192)); |
|
1712 | - else |
|
1713 | - echo fread($fp, 8192); |
|
1782 | + if (isset($callback)) { |
|
1783 | + echo $callback(fread($fp, 8192)); |
|
1784 | + } else { |
|
1785 | + echo fread($fp, 8192); |
|
1786 | + } |
|
1714 | 1787 | flush(); |
1715 | 1788 | } |
1716 | 1789 | fclose($fp); |
1717 | 1790 | } |
1718 | 1791 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
1719 | - elseif (isset($callback) || @readfile($filename) === null) |
|
1720 | - echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1792 | + elseif (isset($callback) || @readfile($filename) === null) { |
|
1793 | + echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename); |
|
1794 | + } |
|
1721 | 1795 | |
1722 | 1796 | obExit(false); |
1723 | 1797 | } |
@@ -1730,8 +1804,9 @@ discard block |
||
1730 | 1804 | */ |
1731 | 1805 | function approved_attach_sort($a, $b) |
1732 | 1806 | { |
1733 | - if ($a['is_approved'] == $b['is_approved']) |
|
1734 | - return 0; |
|
1807 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1808 | + return 0; |
|
1809 | + } |
|
1735 | 1810 | |
1736 | 1811 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1737 | 1812 | } |
@@ -1748,16 +1823,19 @@ discard block |
||
1748 | 1823 | |
1749 | 1824 | require_once($sourcedir . '/RemoveTopic.php'); |
1750 | 1825 | |
1751 | - if (empty($_REQUEST['msgs'])) |
|
1752 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1826 | + if (empty($_REQUEST['msgs'])) { |
|
1827 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1828 | + } |
|
1753 | 1829 | |
1754 | 1830 | $messages = array(); |
1755 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1756 | - $messages[] = (int) $dummy; |
|
1831 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1832 | + $messages[] = (int) $dummy; |
|
1833 | + } |
|
1757 | 1834 | |
1758 | 1835 | // We are restoring messages. We handle this in another place. |
1759 | - if (isset($_REQUEST['restore_selected'])) |
|
1760 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1836 | + if (isset($_REQUEST['restore_selected'])) { |
|
1837 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1838 | + } |
|
1761 | 1839 | if (isset($_REQUEST['split_selection'])) |
1762 | 1840 | { |
1763 | 1841 | $request = $smcFunc['db_query']('', ' |
@@ -1776,8 +1854,9 @@ discard block |
||
1776 | 1854 | } |
1777 | 1855 | |
1778 | 1856 | // Allowed to delete any message? |
1779 | - if (allowedTo('delete_any')) |
|
1780 | - $allowed_all = true; |
|
1857 | + if (allowedTo('delete_any')) { |
|
1858 | + $allowed_all = true; |
|
1859 | + } |
|
1781 | 1860 | // Allowed to delete replies to their messages? |
1782 | 1861 | elseif (allowedTo('delete_replies')) |
1783 | 1862 | { |
@@ -1794,13 +1873,14 @@ discard block |
||
1794 | 1873 | $smcFunc['db_free_result']($request); |
1795 | 1874 | |
1796 | 1875 | $allowed_all = $starter == $user_info['id']; |
1876 | + } else { |
|
1877 | + $allowed_all = false; |
|
1797 | 1878 | } |
1798 | - else |
|
1799 | - $allowed_all = false; |
|
1800 | 1879 | |
1801 | 1880 | // Make sure they're allowed to delete their own messages, if not any. |
1802 | - if (!$allowed_all) |
|
1803 | - isAllowedTo('delete_own'); |
|
1881 | + if (!$allowed_all) { |
|
1882 | + isAllowedTo('delete_own'); |
|
1883 | + } |
|
1804 | 1884 | |
1805 | 1885 | // Allowed to remove which messages? |
1806 | 1886 | $request = $smcFunc['db_query']('', ' |
@@ -1820,8 +1900,9 @@ discard block |
||
1820 | 1900 | $messages = array(); |
1821 | 1901 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1822 | 1902 | { |
1823 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1824 | - continue; |
|
1903 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
1904 | + continue; |
|
1905 | + } |
|
1825 | 1906 | |
1826 | 1907 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1827 | 1908 | } |
@@ -1844,17 +1925,20 @@ discard block |
||
1844 | 1925 | foreach ($messages as $message => $info) |
1845 | 1926 | { |
1846 | 1927 | // Just skip the first message - if it's not the last. |
1847 | - if ($message == $first_message && $message != $last_message) |
|
1848 | - continue; |
|
1928 | + if ($message == $first_message && $message != $last_message) { |
|
1929 | + continue; |
|
1930 | + } |
|
1849 | 1931 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
1850 | - elseif ($message == $first_message) |
|
1851 | - $topicGone = true; |
|
1932 | + elseif ($message == $first_message) { |
|
1933 | + $topicGone = true; |
|
1934 | + } |
|
1852 | 1935 | |
1853 | 1936 | removeMessage($message); |
1854 | 1937 | |
1855 | 1938 | // Log this moderation action ;). |
1856 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1857 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1939 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
1940 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1941 | + } |
|
1858 | 1942 | } |
1859 | 1943 | |
1860 | 1944 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | </div> |
286 | 286 | <div class="cat_bar"> |
287 | 287 | <h3 class="catbg"> |
288 | - <a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'],'"></span></a> ', $txt['maintain_members'], ' |
|
288 | + <a href="', $scripturl, '?action=helpadmin;help=maintenance_members" onclick="return reqOverlayDiv(this.href);" class="help"><span class="generic_icons help" title="', $txt['help'], '"></span></a> ', $txt['maintain_members'], ' |
|
289 | 289 | </h3> |
290 | 290 | </div> |
291 | 291 | <div class="windowbg2 noup"> |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | echo ' |
437 | 437 | </div> |
438 | 438 | </div> |
439 | - <input type="submit" value="', $txt['maintain_old_remove'] ,'" data-confirm="', $txt['maintain_old_confirm'] ,'" class="button_submit you_sure"> |
|
439 | + <input type="submit" value="', $txt['maintain_old_remove'], '" data-confirm="', $txt['maintain_old_confirm'], '" class="button_submit you_sure"> |
|
440 | 440 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
441 | 441 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
442 | 442 | </form> |
@@ -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 class="input_check"> ', $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 class="input_check">', $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'], '"> |
@@ -148,7 +148,7 @@ |
||
148 | 148 | <head> |
149 | 149 | <meta charset="', $context['character_set'], '"> |
150 | 150 | <title>', $context['page_title'], '</title> |
151 | - <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/report.css', $modSettings['browser_cache'] ,'"> |
|
151 | + <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/report.css', $modSettings['browser_cache'], '"> |
|
152 | 152 | </head> |
153 | 153 | <body>'; |
154 | 154 | } |
@@ -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' : '', ' class="input_radio"> |
@@ -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 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | { |
23 | 23 | echo ' |
24 | 24 | <div class="infobox"> |
25 | - ', $txt['report_action_'. $context['report_post_action']], ' |
|
25 | + ', $txt['report_action_' . $context['report_post_action']], ' |
|
26 | 26 | </div>'; |
27 | 27 | } |
28 | 28 | |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | <br> |
66 | 66 | <ul class="quickbuttons"> |
67 | 67 | <li><a href="', $report['report_href'], '">', $details_button, '</a></li> |
68 | - <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;ignore=', (int) !$report['ignore'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" ', (!$report['ignore'] ? ' class="you_sure" data-confirm="'. $txt['mc_reportedp_ignore_confirm'] .'"' : '') ,'>', $report['ignore'] ? $unignore_button : $ignore_button, '</a></li> |
|
68 | + <li><a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;ignore=', (int) !$report['ignore'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" ', (!$report['ignore'] ? ' class="you_sure" data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : ''), '>', $report['ignore'] ? $unignore_button : $ignore_button, '</a></li> |
|
69 | 69 | <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 | 70 | |
71 | 71 | // Delete message button. |
72 | 72 | if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) |
73 | 73 | echo ' |
74 | - <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>'; |
|
74 | + <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>'; |
|
75 | 75 | |
76 | 76 | // Ban this user button. |
77 | 77 | if (!$report['closed'] && !empty($context['report_manage_bans'])) |
78 | 78 | echo ' |
79 | - <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>'; |
|
79 | + <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>'; |
|
80 | 80 | |
81 | 81 | if (!$context['view_closed']) |
82 | 82 | echo ' |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | |
97 | 97 | echo ' |
98 | 98 | <div class="pagesection"> |
99 | - ', !empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many'] ? '<div class="pagelinks floatleft">'. $context['page_index']. '</div>' : '' ,' |
|
99 | + ', !empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many'] ? '<div class="pagelinks floatleft">' . $context['page_index'] . '</div>' : '', ' |
|
100 | 100 | <div class="floatright">', !$context['view_closed'] ? ' |
101 | - <input type="hidden" name="'. $context['mod-report-close-all_token_var'] .'" value="'. $context['mod-report-close-all_token'] .'"> |
|
101 | + <input type="hidden" name="'. $context['mod-report-close-all_token_var'] . '" value="' . $context['mod-report-close-all_token'] . '"> |
|
102 | 102 | <input type="submit" name="close_selected" value="' . $txt['mc_reportedp_close_selected'] . '" class="button_submit">' : '', ' |
103 | 103 | </div> |
104 | 104 | </div> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | { |
189 | 189 | echo ' |
190 | 190 | <div class="infobox"> |
191 | - ', $txt['report_action_'. $context['report_post_action']], ' |
|
191 | + ', $txt['report_action_' . $context['report_post_action']], ' |
|
192 | 192 | </div>'; |
193 | 193 | } |
194 | 194 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $unignore_button = create_button('ignore', 'mc_reportedp_unignore', 'mc_reportedp_unignore'); |
214 | 214 | |
215 | 215 | echo ' |
216 | - <a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;ignore=', (int) !$context['report']['ignore'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" class="button', (!$context['report']['ignore'] ? ' you_sure' : '') ,'"', (!$context['report']['ignore'] ? ' data-confirm="'. $txt['mc_reportedp_ignore_confirm'] .'"' : '') ,'>', $context['report']['ignore'] ? $unignore_button : $ignore_button, '</a> |
|
216 | + <a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;ignore=', (int) !$context['report']['ignore'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" class="button', (!$context['report']['ignore'] ? ' you_sure' : ''), '"', (!$context['report']['ignore'] ? ' data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : ''), '>', $context['report']['ignore'] ? $unignore_button : $ignore_button, '</a> |
|
217 | 217 | <a href="', $scripturl, '?action=moderate;area=reportedposts;sa=handle;closed=', (int) !$context['report']['closed'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '" class="button">', $close_button, '</a> |
218 | 218 | </span> |
219 | 219 | </h3> |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | { |
251 | 251 | echo ' |
252 | 252 | <div class="title_bar"> |
253 | - <h3 class="titlebg">', $comment['member']['link'], ': <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=editcomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';'. $context['session_var'] .'='. $context['session_id'] .'" class="button">'. $txt['mc_reportedp_comment_edit'] .'</a><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=handlecomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';delete;'. $context['session_var'] .'='. $context['session_id']. ';'. $context['mod-reportC-delete_token_var'] .'='. $context['mod-reportC-delete_token'] .'" class="button">'. $txt['mc_reportedp_comment_delete'] .'</a></span>' : '') ,'</h3> |
|
253 | + <h3 class="titlebg">', $comment['member']['link'], ': <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=editcomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" class="button">' . $txt['mc_reportedp_comment_edit'] . '</a><a href="' . $scripturl . '?action=moderate;area=reportedposts;sa=handlecomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';delete;' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context['mod-reportC-delete_token_var'] . '=' . $context['mod-reportC-delete_token'] . '" class="button">' . $txt['mc_reportedp_comment_delete'] . '</a></span>' : ''), '</h3> |
|
254 | 254 | </div>'; |
255 | 255 | |
256 | 256 | echo ' |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | |
293 | 293 | echo ' |
294 | 294 | <div id="modcenter"> |
295 | - <form action="', $scripturl, '?action=moderate;area=reported', $context['report_type'], ';sa=editcomment;mid=', $context['comment_id'], ';rid=', $context['report_id'] ,';save" method="post" accept-charset="', $context['character_set'], '">'; |
|
295 | + <form action="', $scripturl, '?action=moderate;area=reported', $context['report_type'], ';sa=editcomment;mid=', $context['comment_id'], ';rid=', $context['report_id'], ';save" method="post" accept-charset="', $context['character_set'], '">'; |
|
296 | 296 | |
297 | 297 | echo ' |
298 | 298 | <br> |
299 | 299 | <div class="cat_bar"> |
300 | - <h3 class="catbg">', $txt['mc_modreport_edit_mod_comment'] ,'</h3> |
|
300 | + <h3 class="catbg">', $txt['mc_modreport_edit_mod_comment'], '</h3> |
|
301 | 301 | </div> |
302 | 302 | <div class="windowbg2">'; |
303 | 303 | |
304 | 304 | echo ' |
305 | - <textarea rows="6" cols="60" style="width: 60%;" name="mod_comment">', $context['comment']['body'] ,'</textarea> |
|
305 | + <textarea rows="6" cols="60" style="width: 60%;" name="mod_comment">', $context['comment']['body'], '</textarea> |
|
306 | 306 | <div> |
307 | 307 | <input type="submit" name="edit_comment" value="', $txt['mc_modreport_edit_mod_comment'], '" class="button_submit"> |
308 | 308 | </div> |
@@ -393,11 +393,11 @@ discard block |
||
393 | 393 | global $context, $txt, $scripturl; |
394 | 394 | |
395 | 395 | // Let them know the action was a success. |
396 | - if (!empty($context['report_post_action']) && !empty($txt['report_action_'. $context['report_post_action']])) |
|
396 | + if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) |
|
397 | 397 | { |
398 | 398 | echo ' |
399 | 399 | <div class="infobox"> |
400 | - ', $txt['report_action_'. $context['report_post_action']], ' |
|
400 | + ', $txt['report_action_' . $context['report_post_action']], ' |
|
401 | 401 | </div>'; |
402 | 402 | } |
403 | 403 | |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | <hr> |
441 | 441 | <ul class="quickbuttons"> |
442 | 442 | <li><a href="', $report['report_href'], '">', $details_button, '</a></li> |
443 | - <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;ignore=', (int) !$report['ignore'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" ', (!$report['ignore'] ? ' class="you_sure" data-confirm="'. $txt['mc_reportedp_ignore_confirm'] .'"' : '') ,'>', $report['ignore'] ? $unignore_button : $ignore_button, '</a></li> |
|
443 | + <li><a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;ignore=', (int) !$report['ignore'], ';rid=', $report['id'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" ', (!$report['ignore'] ? ' class="you_sure" data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : ''), '>', $report['ignore'] ? $unignore_button : $ignore_button, '</a></li> |
|
444 | 444 | <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 | 445 | |
446 | 446 | // Ban this user button. |
447 | 447 | if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
448 | 448 | echo ' |
449 | - <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'] ,';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
|
449 | + <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
|
450 | 450 | |
451 | 451 | if (!$context['view_closed']) |
452 | 452 | echo ' |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | { |
488 | 488 | echo ' |
489 | 489 | <div class="infobox"> |
490 | - ', $txt['report_action_'. $context['report_post_action']], ' |
|
490 | + ', $txt['report_action_' . $context['report_post_action']], ' |
|
491 | 491 | </div>'; |
492 | 492 | } |
493 | 493 | |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | $unignore_button = create_button('ignore', 'mc_reportedp_unignore', 'mc_reportedp_unignore'); |
513 | 513 | |
514 | 514 | echo ' |
515 | - <a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;ignore=', (int) !$context['report']['ignore'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" class="button', (!$context['report']['ignore'] ? ' you_sure' : '') ,'"', (!$context['report']['ignore'] ? ' data-confirm="'. $txt['mc_reportedp_ignore_confirm'] .'"' : '') ,'>', $context['report']['ignore'] ? $unignore_button : $ignore_button, '</a> |
|
515 | + <a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;ignore=', (int) !$context['report']['ignore'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-ignore_token_var'], '=', $context['mod-report-ignore_token'], '" class="button', (!$context['report']['ignore'] ? ' you_sure' : ''), '"', (!$context['report']['ignore'] ? ' data-confirm="' . $txt['mc_reportedp_ignore_confirm'] . '"' : ''), '>', $context['report']['ignore'] ? $unignore_button : $ignore_button, '</a> |
|
516 | 516 | <a href="', $scripturl, '?action=moderate;area=reportedmembers;sa=handle;closed=', (int) !$context['report']['closed'], ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], ';', $context['mod-report-closed_token_var'], '=', $context['mod-report-closed_token'], '" class="button">', $close_button, '</a> |
517 | 517 | </span> |
518 | 518 | </h3> |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | { |
547 | 547 | echo ' |
548 | 548 | <div class="title_bar"> |
549 | - <h3 class="titlebg">', $comment['member']['link'], ': <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=editcomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';'. $context['session_var'] .'='. $context['session_id'] .'" class="button">'. $txt['mc_reportedp_comment_edit'] .'</a> <a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=handlecomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';delete;'. $context['session_var'] .'='. $context['session_id']. ';'. $context['mod-reportC-delete_token_var'] .'='. $context['mod-reportC-delete_token'] .'" class="button you_sure" data-confirm="'. $txt['mc_reportedp_delete_confirm'] .'">'. $txt['mc_reportedp_comment_delete'] .'</a></span>' : '') ,'</h3> |
|
549 | + <h3 class="titlebg">', $comment['member']['link'], ': <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=editcomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" class="button">' . $txt['mc_reportedp_comment_edit'] . '</a> <a href="' . $scripturl . '?action=moderate;area=reportedmembers;sa=handlecomment;rid=' . $context['report']['id'] . ';mid=' . $comment['id'] . ';delete;' . $context['session_var'] . '=' . $context['session_id'] . ';' . $context['mod-reportC-delete_token_var'] . '=' . $context['mod-reportC-delete_token'] . '" class="button you_sure" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '">' . $txt['mc_reportedp_comment_delete'] . '</a></span>' : ''), '</h3> |
|
550 | 550 | </div>'; |
551 | 551 | |
552 | 552 | echo ' |
@@ -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'] . '" class="input_check"></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'] . '" class="input_check"></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 | { |
@@ -26,9 +26,10 @@ discard block |
||
26 | 26 | <div class="cat_bar"> |
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
29 | - if (!isset($context['old_search'])) |
|
30 | - echo ' |
|
29 | + if (!isset($context['old_search'])) { |
|
30 | + echo ' |
|
31 | 31 | <span class="floatright">', $context['letter_links'], '</span>'; |
32 | + } |
|
32 | 33 | echo ' |
33 | 34 | </h3> |
34 | 35 | </div>'; |
@@ -43,19 +44,22 @@ discard block |
||
43 | 44 | foreach ($context['columns'] as $key => $column) |
44 | 45 | { |
45 | 46 | // @TODO maybe find something nicer? |
46 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
47 | - continue; |
|
47 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
48 | + continue; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | // This is a selected column, so underline it or some such. |
50 | - if ($column['selected']) |
|
51 | - echo ' |
|
52 | + if ($column['selected']) { |
|
53 | + echo ' |
|
52 | 54 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
53 | 55 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
56 | + } |
|
54 | 57 | // This is just some column... show the link and be done with it. |
55 | - else |
|
56 | - echo ' |
|
58 | + else { |
|
59 | + echo ' |
|
57 | 60 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
58 | 61 | ', $column['link'], '</th>'; |
62 | + } |
|
59 | 63 | } |
60 | 64 | echo ' |
61 | 65 | </tr> |
@@ -74,9 +78,10 @@ discard block |
||
74 | 78 | </td> |
75 | 79 | <td class="lefttext">', $member['link'], '</td>'; |
76 | 80 | |
77 | - if (!isset($context['disabled_fields']['website'])) |
|
78 | - echo ' |
|
81 | + if (!isset($context['disabled_fields']['website'])) { |
|
82 | + echo ' |
|
79 | 83 | <td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" class="new_win"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
84 | + } |
|
80 | 85 | |
81 | 86 | // Group and date. |
82 | 87 | echo ' |
@@ -89,11 +94,12 @@ discard block |
||
89 | 94 | <td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td> |
90 | 95 | <td class="centertext statsbar" style="width: 120px">'; |
91 | 96 | |
92 | - if (!empty($member['post_percent'])) |
|
93 | - echo ' |
|
97 | + if (!empty($member['post_percent'])) { |
|
98 | + echo ' |
|
94 | 99 | <div class="bar" style="width: ', $member['post_percent'] + 4, 'px;"> |
95 | 100 | <div style="width: ', $member['post_percent'], 'px;"></div> |
96 | 101 | </div>'; |
102 | + } |
|
97 | 103 | |
98 | 104 | echo ' |
99 | 105 | </td>'; |
@@ -102,9 +108,10 @@ discard block |
||
102 | 108 | // Show custom fields marked to be shown here |
103 | 109 | if (!empty($context['custom_profile_fields']['columns'])) |
104 | 110 | { |
105 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
106 | - echo ' |
|
111 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) { |
|
112 | + echo ' |
|
107 | 113 | <td class="righttext">', $member['options'][$key], '</td>'; |
114 | + } |
|
108 | 115 | } |
109 | 116 | |
110 | 117 | echo ' |
@@ -112,11 +119,12 @@ discard block |
||
112 | 119 | } |
113 | 120 | } |
114 | 121 | // No members? |
115 | - else |
|
116 | - echo ' |
|
122 | + else { |
|
123 | + echo ' |
|
117 | 124 | <tr> |
118 | 125 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
119 | 126 | </tr>'; |
127 | + } |
|
120 | 128 | |
121 | 129 | echo ' |
122 | 130 | </tbody> |
@@ -129,9 +137,10 @@ discard block |
||
129 | 137 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
130 | 138 | |
131 | 139 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
132 | - if (isset($context['old_search'])) |
|
133 | - echo ' |
|
140 | + if (isset($context['old_search'])) { |
|
141 | + echo ' |
|
134 | 142 | <a class="button_link" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>'; |
143 | + } |
|
135 | 144 | echo ' |
136 | 145 | </div> |
137 | 146 | </div>'; |
@@ -90,7 +90,7 @@ |
||
90 | 90 | |
91 | 91 | echo ' |
92 | 92 | </dl> |
93 | - <input type="submit" name="preview" value="', $txt['preview'] , '" class="button_submit"> |
|
93 | + <input type="submit" name="preview" value="', $txt['preview'], '" class="button_submit"> |
|
94 | 94 | <input type="submit" name="save" value="', $txt['rtm10'], '" style="margin-left: 1ex;" class="button_submit"> |
95 | 95 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
96 | 96 | </div> |
@@ -62,16 +62,17 @@ |
||
62 | 62 | <div id="error_box" class="errorbox"> |
63 | 63 | <ul id="error_list">'; |
64 | 64 | |
65 | - foreach ($context['post_errors'] as $key => $error) |
|
66 | - echo ' |
|
65 | + foreach ($context['post_errors'] as $key => $error) { |
|
66 | + echo ' |
|
67 | 67 | <li id="error_', $key, '" class="error">', $error, '</li>'; |
68 | + } |
|
68 | 69 | |
69 | 70 | echo ' |
70 | 71 | </ul>'; |
71 | - } |
|
72 | - else |
|
73 | - echo ' |
|
72 | + } else { |
|
73 | + echo ' |
|
74 | 74 | <div style="display:none" id="error_box" class="errorbox">'; |
75 | + } |
|
75 | 76 | |
76 | 77 | echo ' |
77 | 78 | </div>'; |