@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | * @version 2.1 Beta 4 |
18 | 18 | */ |
19 | 19 | |
20 | -if (!defined('SMF')) |
|
20 | +if (!defined('SMF')) { |
|
21 | 21 | die('No direct access...'); |
22 | +} |
|
22 | 23 | |
23 | 24 | /** |
24 | 25 | * Attempt to start the session, unless it already has been. |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | { |
39 | 40 | $parsed_url = parse_url($boardurl); |
40 | 41 | |
41 | - if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) |
|
42 | - @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
42 | + if (preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) == 0 && preg_match('~(?:[^\.]+\.)?([^\.]{2,}\..+)\z~i', $parsed_url['host'], $parts) == 1) { |
|
43 | + @ini_set('session.cookie_domain', '.' . $parts[1]); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | // @todo Set the session cookie path? |
45 | 47 | |
@@ -47,8 +49,9 @@ discard block |
||
47 | 49 | if ((ini_get('session.auto_start') == 1 && !empty($modSettings['databaseSession_enable'])) || session_id() == '') |
48 | 50 | { |
49 | 51 | // Attempt to end the already-started session. |
50 | - if (ini_get('session.auto_start') == 1) |
|
51 | - session_write_close(); |
|
52 | + if (ini_get('session.auto_start') == 1) { |
|
53 | + session_write_close(); |
|
54 | + } |
|
52 | 55 | |
53 | 56 | // This is here to stop people from using bad junky PHPSESSIDs. |
54 | 57 | if (isset($_REQUEST[session_name()]) && preg_match('~^[A-Za-z0-9,-]{16,64}$~', $_REQUEST[session_name()]) == 0 && !isset($_COOKIE[session_name()])) |
@@ -63,23 +66,26 @@ discard block |
||
63 | 66 | if (!empty($modSettings['databaseSession_enable'])) |
64 | 67 | { |
65 | 68 | @ini_set('session.serialize_handler', 'php_serialize'); |
66 | - if (ini_get('session.serialize_handler') != 'php_serialize') |
|
67 | - @ini_set('session.serialize_handler', 'php'); |
|
69 | + if (ini_get('session.serialize_handler') != 'php_serialize') { |
|
70 | + @ini_set('session.serialize_handler', 'php'); |
|
71 | + } |
|
68 | 72 | session_set_save_handler('sessionOpen', 'sessionClose', 'sessionRead', 'sessionWrite', 'sessionDestroy', 'sessionGC'); |
69 | 73 | @ini_set('session.gc_probability', '1'); |
74 | + } elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) { |
|
75 | + @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
70 | 76 | } |
71 | - elseif (ini_get('session.gc_maxlifetime') <= 1440 && !empty($modSettings['databaseSession_lifetime'])) |
|
72 | - @ini_set('session.gc_maxlifetime', max($modSettings['databaseSession_lifetime'], 60)); |
|
73 | 77 | |
74 | 78 | // Use cache setting sessions? |
75 | - if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') |
|
76 | - call_integration_hook('integrate_session_handlers'); |
|
79 | + if (empty($modSettings['databaseSession_enable']) && !empty($modSettings['cache_enable']) && php_sapi_name() != 'cli') { |
|
80 | + call_integration_hook('integrate_session_handlers'); |
|
81 | + } |
|
77 | 82 | |
78 | 83 | session_start(); |
79 | 84 | |
80 | 85 | // Change it so the cache settings are a little looser than default. |
81 | - if (!empty($modSettings['databaseSession_loose'])) |
|
82 | - header('cache-control: private'); |
|
86 | + if (!empty($modSettings['databaseSession_loose'])) { |
|
87 | + header('cache-control: private'); |
|
88 | + } |
|
83 | 89 | } |
84 | 90 | |
85 | 91 | // Set the randomly generated code. |
@@ -125,8 +131,9 @@ discard block |
||
125 | 131 | { |
126 | 132 | global $smcFunc; |
127 | 133 | |
128 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
129 | - return ''; |
|
134 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
135 | + return ''; |
|
136 | + } |
|
130 | 137 | |
131 | 138 | // Look for it in the database. |
132 | 139 | $result = $smcFunc['db_query']('', ' |
@@ -156,8 +163,9 @@ discard block |
||
156 | 163 | global $smcFunc, $db_connection, $db_server, $db_name, $db_user, $db_passwd; |
157 | 164 | global $db_prefix, $db_persist, $db_port, $db_mb4; |
158 | 165 | |
159 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
160 | - return false; |
|
166 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
167 | + return false; |
|
168 | + } |
|
161 | 169 | |
162 | 170 | // php < 7.0 need this |
163 | 171 | if (empty($db_connection)) |
@@ -165,11 +173,13 @@ discard block |
||
165 | 173 | $db_options = array(); |
166 | 174 | |
167 | 175 | // Add in the port if needed |
168 | - if (!empty($db_port)) |
|
169 | - $db_options['port'] = $db_port; |
|
176 | + if (!empty($db_port)) { |
|
177 | + $db_options['port'] = $db_port; |
|
178 | + } |
|
170 | 179 | |
171 | - if (!empty($db_mb4)) |
|
172 | - $db_options['db_mb4'] = $db_mb4; |
|
180 | + if (!empty($db_mb4)) { |
|
181 | + $db_options['db_mb4'] = $db_mb4; |
|
182 | + } |
|
173 | 183 | |
174 | 184 | $options = array_merge($db_options, array('persist' => $db_persist, 'dont_select_db' => SMF == 'SSI')); |
175 | 185 | |
@@ -189,13 +199,14 @@ discard block |
||
189 | 199 | ); |
190 | 200 | |
191 | 201 | // If that didn't work, try inserting a new one. |
192 | - if ($smcFunc['db_affected_rows']() == 0) |
|
193 | - $smcFunc['db_insert']('ignore', |
|
202 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
203 | + $smcFunc['db_insert']('ignore', |
|
194 | 204 | '{db_prefix}sessions', |
195 | 205 | array('session_id' => 'string', 'data' => 'string', 'last_update' => 'int'), |
196 | 206 | array($session_id, $data, time()), |
197 | 207 | array('session_id') |
198 | 208 | ); |
209 | + } |
|
199 | 210 | |
200 | 211 | return ($smcFunc['db_affected_rows']() == 0 ? false : true); |
201 | 212 | } |
@@ -210,8 +221,9 @@ discard block |
||
210 | 221 | { |
211 | 222 | global $smcFunc; |
212 | 223 | |
213 | - if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) |
|
214 | - return false; |
|
224 | + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { |
|
225 | + return false; |
|
226 | + } |
|
215 | 227 | |
216 | 228 | // Just delete the row... |
217 | 229 | $smcFunc['db_query']('', ' |
@@ -237,8 +249,9 @@ discard block |
||
237 | 249 | global $modSettings, $smcFunc; |
238 | 250 | |
239 | 251 | // Just set to the default or lower? Ignore it for a higher value. (hopefully) |
240 | - if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) |
|
241 | - $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
252 | + if (!empty($modSettings['databaseSession_lifetime']) && ($max_lifetime <= 1440 || $modSettings['databaseSession_lifetime'] > $max_lifetime)) { |
|
253 | + $max_lifetime = max($modSettings['databaseSession_lifetime'], 60); |
|
254 | + } |
|
242 | 255 | |
243 | 256 | // Clean up after yerself ;). |
244 | 257 | $smcFunc['db_query']('', ' |
@@ -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(); |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | // Are the result fresh? |
998 | 998 | if (!$update_cache && !empty($_SESSION['search_cache']['id_search'])) |
999 | 999 | { |
1000 | - $request = $smcFunc['db_query']('',' |
|
1000 | + $request = $smcFunc['db_query']('', ' |
|
1001 | 1001 | SELECT id_search |
1002 | 1002 | FROM {db_prefix}log_search_results |
1003 | 1003 | WHERE id_search = {int:search_id} |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | SELECT |
1120 | 1120 | {int:id_search}, |
1121 | 1121 | t.id_topic, |
1122 | - ' . $relevance. ', |
|
1122 | + ' . $relevance . ', |
|
1123 | 1123 | ' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ', |
1124 | 1124 | 1 |
1125 | 1125 | FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : ' |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | if (empty($subject_query['where'])) |
1353 | 1353 | continue; |
1354 | 1354 | |
1355 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
|
1355 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? (' |
|
1356 | 1356 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
1357 | 1357 | (' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . ' |
1358 | 1358 | SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | } |
1580 | 1580 | $main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance'; |
1581 | 1581 | |
1582 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( ' |
|
1582 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? (' |
|
1583 | 1583 | INSERT IGNORE INTO ' . '{db_prefix}log_search_results |
1584 | 1584 | (' . implode(', ', array_keys($main_query['select'])) . ')') : '') . ' |
1585 | 1585 | SELECT |
@@ -1647,7 +1647,7 @@ discard block |
||
1647 | 1647 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
1648 | 1648 | |
1649 | 1649 | $usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts)); |
1650 | - $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( ' |
|
1650 | + $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? (' |
|
1651 | 1651 | INSERT IGNORE INTO {db_prefix}log_search_results |
1652 | 1652 | (id_search, id_topic, relevance, id_msg, num_matches)') : '') . ' |
1653 | 1653 | SELECT |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | if (strlen($query) == 0) |
2117 | 2117 | continue; |
2118 | 2118 | |
2119 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
|
2119 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m) |
|
2120 | 2120 | { |
2121 | 2121 | return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>"; |
2122 | 2122 | }, $body_highlighted); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | // This defines two version types for checking the API's are compatible with this version of SMF. |
20 | 21 | $GLOBALS['search_versions'] = array( |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir; |
40 | 41 | |
41 | 42 | // Is the load average too high to allow searching just now? |
42 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
43 | - fatal_lang_error('loadavg_search_disabled', false); |
|
43 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
44 | + fatal_lang_error('loadavg_search_disabled', false); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | loadLanguage('Search'); |
46 | 48 | // Don't load this in XML mode. |
@@ -88,23 +90,30 @@ discard block |
||
88 | 90 | @list ($k, $v) = explode('|\'|', $data); |
89 | 91 | $context['search_params'][$k] = $v; |
90 | 92 | } |
91 | - if (isset($context['search_params']['brd'])) |
|
92 | - $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
93 | + if (isset($context['search_params']['brd'])) { |
|
94 | + $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']); |
|
95 | + } |
|
93 | 96 | } |
94 | 97 | |
95 | - if (isset($_REQUEST['search'])) |
|
96 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
98 | + if (isset($_REQUEST['search'])) { |
|
99 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
100 | + } |
|
97 | 101 | |
98 | - if (isset($context['search_params']['search'])) |
|
99 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
100 | - if (isset($context['search_params']['userspec'])) |
|
101 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
102 | - if (!empty($context['search_params']['searchtype'])) |
|
103 | - $context['search_params']['searchtype'] = 2; |
|
104 | - if (!empty($context['search_params']['minage'])) |
|
105 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
106 | - if (!empty($context['search_params']['maxage'])) |
|
107 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
102 | + if (isset($context['search_params']['search'])) { |
|
103 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
104 | + } |
|
105 | + if (isset($context['search_params']['userspec'])) { |
|
106 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
107 | + } |
|
108 | + if (!empty($context['search_params']['searchtype'])) { |
|
109 | + $context['search_params']['searchtype'] = 2; |
|
110 | + } |
|
111 | + if (!empty($context['search_params']['minage'])) { |
|
112 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
113 | + } |
|
114 | + if (!empty($context['search_params']['maxage'])) { |
|
115 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
116 | + } |
|
108 | 117 | |
109 | 118 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
110 | 119 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -116,11 +125,13 @@ discard block |
||
116 | 125 | $context['search_errors']['messages'] = array(); |
117 | 126 | foreach ($context['search_errors'] as $search_error => $dummy) |
118 | 127 | { |
119 | - if ($search_error === 'messages') |
|
120 | - continue; |
|
128 | + if ($search_error === 'messages') { |
|
129 | + continue; |
|
130 | + } |
|
121 | 131 | |
122 | - if ($search_error == 'string_too_long') |
|
123 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
132 | + if ($search_error == 'string_too_long') { |
|
133 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
134 | + } |
|
124 | 135 | |
125 | 136 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
126 | 137 | } |
@@ -143,12 +154,13 @@ discard block |
||
143 | 154 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
144 | 155 | { |
145 | 156 | // This category hasn't been set up yet.. |
146 | - if (!isset($context['categories'][$row['id_cat']])) |
|
147 | - $context['categories'][$row['id_cat']] = array( |
|
157 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
158 | + $context['categories'][$row['id_cat']] = array( |
|
148 | 159 | 'id' => $row['id_cat'], |
149 | 160 | 'name' => $row['cat_name'], |
150 | 161 | 'boards' => array() |
151 | 162 | ); |
163 | + } |
|
152 | 164 | |
153 | 165 | // Set this board up, and let the template know when it's a child. (indent them..) |
154 | 166 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -159,8 +171,9 @@ discard block |
||
159 | 171 | ); |
160 | 172 | |
161 | 173 | // If a board wasn't checked that probably should have been ensure the board selection is selected, yo! |
162 | - if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) |
|
163 | - $context['boards_check_all'] = false; |
|
174 | + if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) { |
|
175 | + $context['boards_check_all'] = false; |
|
176 | + } |
|
164 | 177 | } |
165 | 178 | $smcFunc['db_free_result']($request); |
166 | 179 | |
@@ -182,18 +195,20 @@ discard block |
||
182 | 195 | } |
183 | 196 | |
184 | 197 | $max_boards = ceil(count($temp_boards) / 2); |
185 | - if ($max_boards == 1) |
|
186 | - $max_boards = 2; |
|
198 | + if ($max_boards == 1) { |
|
199 | + $max_boards = 2; |
|
200 | + } |
|
187 | 201 | |
188 | 202 | // Now, alternate them so they can be shown left and right ;). |
189 | 203 | $context['board_columns'] = array(); |
190 | 204 | for ($i = 0; $i < $max_boards; $i++) |
191 | 205 | { |
192 | 206 | $context['board_columns'][] = $temp_boards[$i]; |
193 | - if (isset($temp_boards[$i + $max_boards])) |
|
194 | - $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
195 | - else |
|
196 | - $context['board_columns'][] = array(); |
|
207 | + if (isset($temp_boards[$i + $max_boards])) { |
|
208 | + $context['board_columns'][] = $temp_boards[$i + $max_boards]; |
|
209 | + } else { |
|
210 | + $context['board_columns'][] = array(); |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | |
199 | 214 | if (!empty($_REQUEST['topic'])) |
@@ -225,8 +240,9 @@ discard block |
||
225 | 240 | ) |
226 | 241 | ); |
227 | 242 | |
228 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
229 | - fatal_lang_error('topic_gone', false); |
|
243 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
244 | + fatal_lang_error('topic_gone', false); |
|
245 | + } |
|
230 | 246 | |
231 | 247 | list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request); |
232 | 248 | $smcFunc['db_free_result']($request); |
@@ -256,11 +272,13 @@ discard block |
||
256 | 272 | global $excludedWords, $participants, $smcFunc; |
257 | 273 | |
258 | 274 | // if comming from the quick search box, and we want to search on members, well we need to do that ;) |
259 | - if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') |
|
260 | - redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
275 | + if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') { |
|
276 | + redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search'])); |
|
277 | + } |
|
261 | 278 | |
262 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
263 | - fatal_lang_error('loadavg_search_disabled', false); |
|
279 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
280 | + fatal_lang_error('loadavg_search_disabled', false); |
|
281 | + } |
|
264 | 282 | |
265 | 283 | // No, no, no... this is a bit hard on the server, so don't you go prefetching it! |
266 | 284 | if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch') |
@@ -307,8 +325,9 @@ discard block |
||
307 | 325 | } |
308 | 326 | |
309 | 327 | // Zero weight. Weightless :P. |
310 | - if (empty($weight_total)) |
|
311 | - fatal_lang_error('search_invalid_weights'); |
|
328 | + if (empty($weight_total)) { |
|
329 | + fatal_lang_error('search_invalid_weights'); |
|
330 | + } |
|
312 | 331 | |
313 | 332 | // These vars don't require an interface, they're just here for tweaking. |
314 | 333 | $recentPercentage = 0.30; |
@@ -326,11 +345,13 @@ discard block |
||
326 | 345 | $context['search_string_limit'] = 100; |
327 | 346 | |
328 | 347 | loadLanguage('Search'); |
329 | - if (!isset($_REQUEST['xml'])) |
|
330 | - loadTemplate('Search'); |
|
348 | + if (!isset($_REQUEST['xml'])) { |
|
349 | + loadTemplate('Search'); |
|
350 | + } |
|
331 | 351 | //If we're doing XML we need to use the results template regardless really. |
332 | - else |
|
333 | - $context['sub_template'] = 'results'; |
|
352 | + else { |
|
353 | + $context['sub_template'] = 'results'; |
|
354 | + } |
|
334 | 355 | |
335 | 356 | // Are you allowed? |
336 | 357 | isAllowedTo('search_posts'); |
@@ -363,34 +384,39 @@ discard block |
||
363 | 384 | $search_params[$k] = $v; |
364 | 385 | } |
365 | 386 | |
366 | - if (isset($search_params['brd'])) |
|
367 | - $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
387 | + if (isset($search_params['brd'])) { |
|
388 | + $search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']); |
|
389 | + } |
|
368 | 390 | } |
369 | 391 | |
370 | 392 | // Store whether simple search was used (needed if the user wants to do another query). |
371 | - if (!isset($search_params['advanced'])) |
|
372 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
393 | + if (!isset($search_params['advanced'])) { |
|
394 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
395 | + } |
|
373 | 396 | |
374 | 397 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
375 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
376 | - $search_params['searchtype'] = 2; |
|
398 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
399 | + $search_params['searchtype'] = 2; |
|
400 | + } |
|
377 | 401 | |
378 | 402 | // Minimum age of messages. Default to zero (don't set param in that case). |
379 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
380 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
403 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
404 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
405 | + } |
|
381 | 406 | |
382 | 407 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
383 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) |
|
384 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
408 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) { |
|
409 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
410 | + } |
|
385 | 411 | |
386 | 412 | // Searching a specific topic? |
387 | 413 | if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic')) |
388 | 414 | { |
389 | 415 | $search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : ''); |
390 | 416 | $search_params['show_complete'] = true; |
417 | + } elseif (!empty($search_params['topic'])) { |
|
418 | + $search_params['topic'] = (int) $search_params['topic']; |
|
391 | 419 | } |
392 | - elseif (!empty($search_params['topic'])) |
|
393 | - $search_params['topic'] = (int) $search_params['topic']; |
|
394 | 420 | |
395 | 421 | if (!empty($search_params['minage']) || !empty($search_params['maxage'])) |
396 | 422 | { |
@@ -408,19 +434,21 @@ discard block |
||
408 | 434 | ) |
409 | 435 | ); |
410 | 436 | list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request); |
411 | - if ($minMsgID < 0 || $maxMsgID < 0) |
|
412 | - $context['search_errors']['no_messages_in_time_frame'] = true; |
|
437 | + if ($minMsgID < 0 || $maxMsgID < 0) { |
|
438 | + $context['search_errors']['no_messages_in_time_frame'] = true; |
|
439 | + } |
|
413 | 440 | $smcFunc['db_free_result']($request); |
414 | 441 | } |
415 | 442 | |
416 | 443 | // Default the user name to a wildcard matching every user (*). |
417 | - if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
418 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
444 | + if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
445 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
446 | + } |
|
419 | 447 | |
420 | 448 | // If there's no specific user, then don't mention it in the main query. |
421 | - if (empty($search_params['userspec'])) |
|
422 | - $userQuery = ''; |
|
423 | - else |
|
449 | + if (empty($search_params['userspec'])) { |
|
450 | + $userQuery = ''; |
|
451 | + } else |
|
424 | 452 | { |
425 | 453 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
426 | 454 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -432,19 +460,21 @@ discard block |
||
432 | 460 | { |
433 | 461 | $possible_users[$k] = trim($possible_users[$k]); |
434 | 462 | |
435 | - if (strlen($possible_users[$k]) == 0) |
|
436 | - unset($possible_users[$k]); |
|
463 | + if (strlen($possible_users[$k]) == 0) { |
|
464 | + unset($possible_users[$k]); |
|
465 | + } |
|
437 | 466 | } |
438 | 467 | |
439 | 468 | // Create a list of database-escaped search names. |
440 | 469 | $realNameMatches = array(); |
441 | - foreach ($possible_users as $possible_user) |
|
442 | - $realNameMatches[] = $smcFunc['db_quote']( |
|
470 | + foreach ($possible_users as $possible_user) { |
|
471 | + $realNameMatches[] = $smcFunc['db_quote']( |
|
443 | 472 | '{string:possible_user}', |
444 | 473 | array( |
445 | 474 | 'possible_user' => $possible_user |
446 | 475 | ) |
447 | 476 | ); |
477 | + } |
|
448 | 478 | |
449 | 479 | // Retrieve a list of possible members. |
450 | 480 | $request = $smcFunc['db_query']('', ' |
@@ -456,9 +486,9 @@ discard block |
||
456 | 486 | ) |
457 | 487 | ); |
458 | 488 | // Simply do nothing if there're too many members matching the criteria. |
459 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
460 | - $userQuery = ''; |
|
461 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
489 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
490 | + $userQuery = ''; |
|
491 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
462 | 492 | { |
463 | 493 | $userQuery = $smcFunc['db_quote']( |
464 | 494 | 'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})', |
@@ -467,12 +497,12 @@ discard block |
||
467 | 497 | 'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches), |
468 | 498 | ) |
469 | 499 | ); |
470 | - } |
|
471 | - else |
|
500 | + } else |
|
472 | 501 | { |
473 | 502 | $memberlist = array(); |
474 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
475 | - $memberlist[] = $row['id_member']; |
|
503 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
504 | + $memberlist[] = $row['id_member']; |
|
505 | + } |
|
476 | 506 | $userQuery = $smcFunc['db_quote']( |
477 | 507 | '(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))', |
478 | 508 | array( |
@@ -486,22 +516,25 @@ discard block |
||
486 | 516 | } |
487 | 517 | |
488 | 518 | // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST. |
489 | - if (!empty($search_params['brd']) && is_array($search_params['brd'])) |
|
490 | - $_REQUEST['brd'] = $search_params['brd']; |
|
519 | + if (!empty($search_params['brd']) && is_array($search_params['brd'])) { |
|
520 | + $_REQUEST['brd'] = $search_params['brd']; |
|
521 | + } |
|
491 | 522 | |
492 | 523 | // Ensure that brd is an array. |
493 | 524 | if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board')) |
494 | 525 | { |
495 | - if (!empty($_REQUEST['brd'])) |
|
496 | - $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
497 | - else |
|
498 | - $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
526 | + if (!empty($_REQUEST['brd'])) { |
|
527 | + $_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']); |
|
528 | + } else { |
|
529 | + $_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array(); |
|
530 | + } |
|
499 | 531 | } |
500 | 532 | |
501 | 533 | // Make sure all boards are integers. |
502 | - if (!empty($_REQUEST['brd'])) |
|
503 | - foreach ($_REQUEST['brd'] as $id => $brd) |
|
534 | + if (!empty($_REQUEST['brd'])) { |
|
535 | + foreach ($_REQUEST['brd'] as $id => $brd) |
|
504 | 536 | $_REQUEST['brd'][$id] = (int) $brd; |
537 | + } |
|
505 | 538 | |
506 | 539 | // Special case for boards: searching just one topic? |
507 | 540 | if (!empty($search_params['topic'])) |
@@ -520,17 +553,18 @@ discard block |
||
520 | 553 | ) |
521 | 554 | ); |
522 | 555 | |
523 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
524 | - fatal_lang_error('topic_gone', false); |
|
556 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
557 | + fatal_lang_error('topic_gone', false); |
|
558 | + } |
|
525 | 559 | |
526 | 560 | $search_params['brd'] = array(); |
527 | 561 | list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request); |
528 | 562 | $smcFunc['db_free_result']($request); |
529 | 563 | } |
530 | 564 | // Select all boards you've selected AND are allowed to see. |
531 | - elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) |
|
532 | - $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
533 | - else |
|
565 | + elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) { |
|
566 | + $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd']; |
|
567 | + } else |
|
534 | 568 | { |
535 | 569 | $see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board'; |
536 | 570 | $request = $smcFunc['db_query']('', ' |
@@ -548,19 +582,22 @@ discard block |
||
548 | 582 | ) |
549 | 583 | ); |
550 | 584 | $search_params['brd'] = array(); |
551 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
552 | - $search_params['brd'][] = $row['id_board']; |
|
585 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
586 | + $search_params['brd'][] = $row['id_board']; |
|
587 | + } |
|
553 | 588 | $smcFunc['db_free_result']($request); |
554 | 589 | |
555 | 590 | // This error should pro'bly only happen for hackers. |
556 | - if (empty($search_params['brd'])) |
|
557 | - $context['search_errors']['no_boards_selected'] = true; |
|
591 | + if (empty($search_params['brd'])) { |
|
592 | + $context['search_errors']['no_boards_selected'] = true; |
|
593 | + } |
|
558 | 594 | } |
559 | 595 | |
560 | 596 | if (count($search_params['brd']) != 0) |
561 | 597 | { |
562 | - foreach ($search_params['brd'] as $k => $v) |
|
563 | - $search_params['brd'][$k] = (int) $v; |
|
598 | + foreach ($search_params['brd'] as $k => $v) { |
|
599 | + $search_params['brd'][$k] = (int) $v; |
|
600 | + } |
|
564 | 601 | |
565 | 602 | // If we've selected all boards, this parameter can be left empty. |
566 | 603 | $request = $smcFunc['db_query']('', ' |
@@ -574,15 +611,16 @@ discard block |
||
574 | 611 | list ($num_boards) = $smcFunc['db_fetch_row']($request); |
575 | 612 | $smcFunc['db_free_result']($request); |
576 | 613 | |
577 | - if (count($search_params['brd']) == $num_boards) |
|
614 | + if (count($search_params['brd']) == $num_boards) { |
|
615 | + $boardQuery = ''; |
|
616 | + } elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) { |
|
617 | + $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
618 | + } else { |
|
619 | + $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
620 | + } |
|
621 | + } else { |
|
578 | 622 | $boardQuery = ''; |
579 | - elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) |
|
580 | - $boardQuery = '!= ' . $modSettings['recycle_board']; |
|
581 | - else |
|
582 | - $boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')'; |
|
583 | 623 | } |
584 | - else |
|
585 | - $boardQuery = ''; |
|
586 | 624 | |
587 | 625 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
588 | 626 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
@@ -596,11 +634,13 @@ discard block |
||
596 | 634 | 'id_msg', |
597 | 635 | ); |
598 | 636 | call_integration_hook('integrate_search_sort_columns', array(&$sort_columns)); |
599 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
600 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
637 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
638 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
639 | + } |
|
601 | 640 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance'; |
602 | - if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') |
|
603 | - $search_params['sort'] = 'id_msg'; |
|
641 | + if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') { |
|
642 | + $search_params['sort'] = 'id_msg'; |
|
643 | + } |
|
604 | 644 | |
605 | 645 | // Sorting direction: descending unless stated otherwise. |
606 | 646 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
@@ -624,17 +664,19 @@ discard block |
||
624 | 664 | // What are we searching for? |
625 | 665 | if (empty($search_params['search'])) |
626 | 666 | { |
627 | - if (isset($_GET['search'])) |
|
628 | - $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
629 | - elseif (isset($_POST['search'])) |
|
630 | - $search_params['search'] = $_POST['search']; |
|
631 | - else |
|
632 | - $search_params['search'] = ''; |
|
667 | + if (isset($_GET['search'])) { |
|
668 | + $search_params['search'] = un_htmlspecialchars($_GET['search']); |
|
669 | + } elseif (isset($_POST['search'])) { |
|
670 | + $search_params['search'] = $_POST['search']; |
|
671 | + } else { |
|
672 | + $search_params['search'] = ''; |
|
673 | + } |
|
633 | 674 | } |
634 | 675 | |
635 | 676 | // Nothing?? |
636 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
637 | - $context['search_errors']['invalid_search_string'] = true; |
|
677 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
678 | + $context['search_errors']['invalid_search_string'] = true; |
|
679 | + } |
|
638 | 680 | // Too long? |
639 | 681 | elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit']) |
640 | 682 | { |
@@ -648,8 +690,9 @@ discard block |
||
648 | 690 | $stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query)); |
649 | 691 | |
650 | 692 | // This (hidden) setting will do fulltext searching in the most basic way. |
651 | - if (!empty($modSettings['search_simple_fulltext'])) |
|
652 | - $stripped_query = strtr($stripped_query, array('"' => '')); |
|
693 | + if (!empty($modSettings['search_simple_fulltext'])) { |
|
694 | + $stripped_query = strtr($stripped_query, array('"' => '')); |
|
695 | + } |
|
653 | 696 | |
654 | 697 | $no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1; |
655 | 698 | |
@@ -672,8 +715,9 @@ discard block |
||
672 | 715 | { |
673 | 716 | if ($word === '-') |
674 | 717 | { |
675 | - if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
676 | - $excludedWords[] = $word; |
|
718 | + if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
719 | + $excludedWords[] = $word; |
|
720 | + } |
|
677 | 721 | unset($phraseArray[$index]); |
678 | 722 | } |
679 | 723 | } |
@@ -683,8 +727,9 @@ discard block |
||
683 | 727 | { |
684 | 728 | if (strpos(trim($word), '-') === 0) |
685 | 729 | { |
686 | - if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) |
|
687 | - $excludedWords[] = $word; |
|
730 | + if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) { |
|
731 | + $excludedWords[] = $word; |
|
732 | + } |
|
688 | 733 | unset($wordArray[$index]); |
689 | 734 | } |
690 | 735 | } |
@@ -697,8 +742,9 @@ discard block |
||
697 | 742 | foreach ($searchArray as $index => $value) |
698 | 743 | { |
699 | 744 | // Skip anything practically empty. |
700 | - if (($searchArray[$index] = trim($value, '-_\' ')) === '') |
|
701 | - unset($searchArray[$index]); |
|
745 | + if (($searchArray[$index] = trim($value, '-_\' ')) === '') { |
|
746 | + unset($searchArray[$index]); |
|
747 | + } |
|
702 | 748 | // Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing. |
703 | 749 | elseif (in_array($searchArray[$index], $blacklisted_words)) |
704 | 750 | { |
@@ -716,31 +762,37 @@ discard block |
||
716 | 762 | |
717 | 763 | // Create an array of replacements for highlighting. |
718 | 764 | $context['mark'] = array(); |
719 | - foreach ($searchArray as $word) |
|
720 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
765 | + foreach ($searchArray as $word) { |
|
766 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
767 | + } |
|
721 | 768 | |
722 | 769 | // Initialize two arrays storing the words that have to be searched for. |
723 | 770 | $orParts = array(); |
724 | 771 | $searchWords = array(); |
725 | 772 | |
726 | 773 | // Make sure at least one word is being searched for. |
727 | - if (empty($searchArray)) |
|
728 | - $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
774 | + if (empty($searchArray)) { |
|
775 | + $context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true; |
|
776 | + } |
|
729 | 777 | // All words/sentences must match. |
730 | - elseif (empty($search_params['searchtype'])) |
|
731 | - $orParts[0] = $searchArray; |
|
778 | + elseif (empty($search_params['searchtype'])) { |
|
779 | + $orParts[0] = $searchArray; |
|
780 | + } |
|
732 | 781 | // Any word/sentence must match. |
733 | - else |
|
734 | - foreach ($searchArray as $index => $value) |
|
782 | + else { |
|
783 | + foreach ($searchArray as $index => $value) |
|
735 | 784 | $orParts[$index] = array($value); |
785 | + } |
|
736 | 786 | |
737 | 787 | // Don't allow duplicate error messages if one string is too short. |
738 | - if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
|
739 | - unset($context['search_errors']['invalid_search_string']); |
|
788 | + if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) { |
|
789 | + unset($context['search_errors']['invalid_search_string']); |
|
790 | + } |
|
740 | 791 | // Make sure the excluded words are in all or-branches. |
741 | - foreach ($orParts as $orIndex => $andParts) |
|
742 | - foreach ($excludedWords as $word) |
|
792 | + foreach ($orParts as $orIndex => $andParts) { |
|
793 | + foreach ($excludedWords as $word) |
|
743 | 794 | $orParts[$orIndex][] = $word; |
795 | + } |
|
744 | 796 | |
745 | 797 | // Determine the or-branches and the fulltext search words. |
746 | 798 | foreach ($orParts as $orIndex => $andParts) |
@@ -754,8 +806,9 @@ discard block |
||
754 | 806 | ); |
755 | 807 | |
756 | 808 | // Sort the indexed words (large words -> small words -> excluded words). |
757 | - if ($searchAPI->supportsMethod('searchSort')) |
|
758 | - usort($orParts[$orIndex], 'searchSort'); |
|
809 | + if ($searchAPI->supportsMethod('searchSort')) { |
|
810 | + usort($orParts[$orIndex], 'searchSort'); |
|
811 | + } |
|
759 | 812 | |
760 | 813 | foreach ($orParts[$orIndex] as $word) |
761 | 814 | { |
@@ -767,15 +820,17 @@ discard block |
||
767 | 820 | if (!$is_excluded || count($subjectWords) === 1) |
768 | 821 | { |
769 | 822 | $searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords); |
770 | - if ($is_excluded) |
|
771 | - $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
823 | + if ($is_excluded) { |
|
824 | + $excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords); |
|
825 | + } |
|
826 | + } else { |
|
827 | + $excludedPhrases[] = $word; |
|
772 | 828 | } |
773 | - else |
|
774 | - $excludedPhrases[] = $word; |
|
775 | 829 | |
776 | 830 | // Have we got indexes to prepare? |
777 | - if ($searchAPI->supportsMethod('prepareIndexes')) |
|
778 | - $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
831 | + if ($searchAPI->supportsMethod('prepareIndexes')) { |
|
832 | + $searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded); |
|
833 | + } |
|
779 | 834 | } |
780 | 835 | |
781 | 836 | // Search_force_index requires all AND parts to have at least one fulltext word. |
@@ -783,8 +838,7 @@ discard block |
||
783 | 838 | { |
784 | 839 | $context['search_errors']['query_not_specific_enough'] = true; |
785 | 840 | break; |
786 | - } |
|
787 | - elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
841 | + } elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) |
|
788 | 842 | { |
789 | 843 | $context['search_errors']['query_not_specific_enough'] = true; |
790 | 844 | break; |
@@ -812,8 +866,9 @@ discard block |
||
812 | 866 | $found_misspelling = false; |
813 | 867 | foreach ($searchArray as $word) |
814 | 868 | { |
815 | - if (empty($link)) |
|
816 | - continue; |
|
869 | + if (empty($link)) { |
|
870 | + continue; |
|
871 | + } |
|
817 | 872 | |
818 | 873 | // Don't check phrases. |
819 | 874 | if (preg_match('~^\w+$~', $word) === 0) |
@@ -828,8 +883,7 @@ discard block |
||
828 | 883 | $did_you_mean['search'][] = $word; |
829 | 884 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
830 | 885 | continue; |
831 | - } |
|
832 | - elseif (spell_check($link, $word)) |
|
886 | + } elseif (spell_check($link, $word)) |
|
833 | 887 | { |
834 | 888 | $did_you_mean['search'][] = $word; |
835 | 889 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -840,11 +894,13 @@ discard block |
||
840 | 894 | foreach ($suggestions as $i => $s) |
841 | 895 | { |
842 | 896 | // Search is case insensitive. |
843 | - if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) |
|
844 | - unset($suggestions[$i]); |
|
897 | + if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) { |
|
898 | + unset($suggestions[$i]); |
|
899 | + } |
|
845 | 900 | // Plus, don't suggest something the user thinks is rude! |
846 | - elseif ($suggestions[$i] != censorText($s)) |
|
847 | - unset($suggestions[$i]); |
|
901 | + elseif ($suggestions[$i] != censorText($s)) { |
|
902 | + unset($suggestions[$i]); |
|
903 | + } |
|
848 | 904 | } |
849 | 905 | |
850 | 906 | // Anything found? If so, correct it! |
@@ -854,8 +910,7 @@ discard block |
||
854 | 910 | $did_you_mean['search'][] = $suggestions[0]; |
855 | 911 | $did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>'; |
856 | 912 | $found_misspelling = true; |
857 | - } |
|
858 | - else |
|
913 | + } else |
|
859 | 914 | { |
860 | 915 | $did_you_mean['search'][] = $word; |
861 | 916 | $did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word); |
@@ -872,8 +927,7 @@ discard block |
||
872 | 927 | { |
873 | 928 | $temp_excluded['search'][] = '-"' . $word . '"'; |
874 | 929 | $temp_excluded['display'][] = '-"' . $smcFunc['htmlspecialchars']($word) . '"'; |
875 | - } |
|
876 | - else |
|
930 | + } else |
|
877 | 931 | { |
878 | 932 | $temp_excluded['search'][] = '-' . $word; |
879 | 933 | $temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word); |
@@ -885,11 +939,13 @@ discard block |
||
885 | 939 | |
886 | 940 | $temp_params = $search_params; |
887 | 941 | $temp_params['search'] = implode(' ', $did_you_mean['search']); |
888 | - if (isset($temp_params['brd'])) |
|
889 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
942 | + if (isset($temp_params['brd'])) { |
|
943 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
944 | + } |
|
890 | 945 | $context['params'] = array(); |
891 | - foreach ($temp_params as $k => $v) |
|
892 | - $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
946 | + foreach ($temp_params as $k => $v) { |
|
947 | + $context['did_you_mean_params'][] = $k . '|\'|' . $v; |
|
948 | + } |
|
893 | 949 | $context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params'])); |
894 | 950 | $context['did_you_mean'] = implode(' ', $did_you_mean['display']); |
895 | 951 | } |
@@ -897,18 +953,20 @@ discard block |
||
897 | 953 | |
898 | 954 | // Let the user adjust the search query, should they wish? |
899 | 955 | $context['search_params'] = $search_params; |
900 | - if (isset($context['search_params']['search'])) |
|
901 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
902 | - if (isset($context['search_params']['userspec'])) |
|
903 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
956 | + if (isset($context['search_params']['search'])) { |
|
957 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
958 | + } |
|
959 | + if (isset($context['search_params']['userspec'])) { |
|
960 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
961 | + } |
|
904 | 962 | |
905 | 963 | // Do we have captcha enabled? |
906 | 964 | if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])) |
907 | 965 | { |
908 | 966 | // If we come from another search box tone down the error... |
909 | - if (!isset($_REQUEST['search_vv'])) |
|
910 | - $context['search_errors']['need_verification_code'] = true; |
|
911 | - else |
|
967 | + if (!isset($_REQUEST['search_vv'])) { |
|
968 | + $context['search_errors']['need_verification_code'] = true; |
|
969 | + } else |
|
912 | 970 | { |
913 | 971 | require_once($sourcedir . '/Subs-Editor.php'); |
914 | 972 | $verificationOptions = array( |
@@ -918,12 +976,14 @@ discard block |
||
918 | 976 | |
919 | 977 | if (is_array($context['require_verification'])) |
920 | 978 | { |
921 | - foreach ($context['require_verification'] as $error) |
|
922 | - $context['search_errors'][$error] = true; |
|
979 | + foreach ($context['require_verification'] as $error) { |
|
980 | + $context['search_errors'][$error] = true; |
|
981 | + } |
|
923 | 982 | } |
924 | 983 | // Don't keep asking for it - they've proven themselves worthy. |
925 | - else |
|
926 | - $_SESSION['ss_vv_passed'] = true; |
|
984 | + else { |
|
985 | + $_SESSION['ss_vv_passed'] = true; |
|
986 | + } |
|
927 | 987 | } |
928 | 988 | } |
929 | 989 | |
@@ -931,19 +991,22 @@ discard block |
||
931 | 991 | |
932 | 992 | // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below. |
933 | 993 | $temp_params = $search_params; |
934 | - if (isset($temp_params['brd'])) |
|
935 | - $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
994 | + if (isset($temp_params['brd'])) { |
|
995 | + $temp_params['brd'] = implode(',', $temp_params['brd']); |
|
996 | + } |
|
936 | 997 | $context['params'] = array(); |
937 | - foreach ($temp_params as $k => $v) |
|
938 | - $context['params'][] = $k . '|\'|' . $v; |
|
998 | + foreach ($temp_params as $k => $v) { |
|
999 | + $context['params'][] = $k . '|\'|' . $v; |
|
1000 | + } |
|
939 | 1001 | |
940 | 1002 | if (!empty($context['params'])) |
941 | 1003 | { |
942 | 1004 | // Due to old IE's 2083 character limit, we have to compress long search strings |
943 | 1005 | $params = @gzcompress(implode('|"|', $context['params'])); |
944 | 1006 | // Gzcompress failed, use try non-gz |
945 | - if (empty($params)) |
|
946 | - $params = implode('|"|', $context['params']); |
|
1007 | + if (empty($params)) { |
|
1008 | + $params = implode('|"|', $context['params']); |
|
1009 | + } |
|
947 | 1010 | // Base64 encode, then replace +/= with uri safe ones that can be reverted |
948 | 1011 | $context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params)); |
949 | 1012 | } |
@@ -969,8 +1032,9 @@ discard block |
||
969 | 1032 | } |
970 | 1033 | |
971 | 1034 | // Spam me not, Spam-a-lot? |
972 | - if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) |
|
973 | - spamProtection('search'); |
|
1035 | + if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) { |
|
1036 | + spamProtection('search'); |
|
1037 | + } |
|
974 | 1038 | // Store the last search string to allow pages of results to be browsed. |
975 | 1039 | $_SESSION['last_ss'] = $search_params['search']; |
976 | 1040 | |
@@ -1007,8 +1071,9 @@ discard block |
||
1007 | 1071 | ) |
1008 | 1072 | ); |
1009 | 1073 | |
1010 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1011 | - $update_cache = true; |
|
1074 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1075 | + $update_cache = true; |
|
1076 | + } |
|
1012 | 1077 | } |
1013 | 1078 | |
1014 | 1079 | if ($update_cache) |
@@ -1047,8 +1112,9 @@ discard block |
||
1047 | 1112 | 'where' => array(), |
1048 | 1113 | ); |
1049 | 1114 | |
1050 | - if ($modSettings['postmod_active']) |
|
1051 | - $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1115 | + if ($modSettings['postmod_active']) { |
|
1116 | + $subject_query['where'][] = 't.approved = {int:is_approved}'; |
|
1117 | + } |
|
1052 | 1118 | |
1053 | 1119 | $numTables = 0; |
1054 | 1120 | $prev_join = 0; |
@@ -1060,8 +1126,7 @@ discard block |
||
1060 | 1126 | { |
1061 | 1127 | $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)'; |
1062 | 1128 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1063 | - } |
|
1064 | - else |
|
1129 | + } else |
|
1065 | 1130 | { |
1066 | 1131 | $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)'; |
1067 | 1132 | $subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}'); |
@@ -1079,14 +1144,18 @@ discard block |
||
1079 | 1144 | } |
1080 | 1145 | $subject_query['where'][] = $userQuery; |
1081 | 1146 | } |
1082 | - if (!empty($search_params['topic'])) |
|
1083 | - $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1084 | - if (!empty($minMsgID)) |
|
1085 | - $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1086 | - if (!empty($maxMsgID)) |
|
1087 | - $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1088 | - if (!empty($boardQuery)) |
|
1089 | - $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1147 | + if (!empty($search_params['topic'])) { |
|
1148 | + $subject_query['where'][] = 't.id_topic = ' . $search_params['topic']; |
|
1149 | + } |
|
1150 | + if (!empty($minMsgID)) { |
|
1151 | + $subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID; |
|
1152 | + } |
|
1153 | + if (!empty($maxMsgID)) { |
|
1154 | + $subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID; |
|
1155 | + } |
|
1156 | + if (!empty($boardQuery)) { |
|
1157 | + $subject_query['where'][] = 't.id_board ' . $boardQuery; |
|
1158 | + } |
|
1090 | 1159 | if (!empty($excludedPhrases)) |
1091 | 1160 | { |
1092 | 1161 | if ($subject_query['from'] != '{db_prefix}messages AS m') |
@@ -1106,8 +1175,9 @@ discard block |
||
1106 | 1175 | foreach ($weight_factors as $type => $value) |
1107 | 1176 | { |
1108 | 1177 | $relevance .= $weight[$type]; |
1109 | - if (!empty($value['results'])) |
|
1110 | - $relevance .= ' * ' . $value['results']; |
|
1178 | + if (!empty($value['results'])) { |
|
1179 | + $relevance .= ' * ' . $value['results']; |
|
1180 | + } |
|
1111 | 1181 | $relevance .= ' + '; |
1112 | 1182 | } |
1113 | 1183 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1145,20 +1215,23 @@ discard block |
||
1145 | 1215 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1146 | 1216 | { |
1147 | 1217 | // No duplicates! |
1148 | - if (isset($inserts[$row[1]])) |
|
1149 | - continue; |
|
1218 | + if (isset($inserts[$row[1]])) { |
|
1219 | + continue; |
|
1220 | + } |
|
1150 | 1221 | |
1151 | - foreach ($row as $key => $value) |
|
1152 | - $inserts[$row[1]][] = (int) $row[$key]; |
|
1222 | + foreach ($row as $key => $value) { |
|
1223 | + $inserts[$row[1]][] = (int) $row[$key]; |
|
1224 | + } |
|
1153 | 1225 | } |
1154 | 1226 | $smcFunc['db_free_result']($ignoreRequest); |
1155 | 1227 | $numSubjectResults = count($inserts); |
1228 | + } else { |
|
1229 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1156 | 1230 | } |
1157 | - else |
|
1158 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1159 | 1231 | |
1160 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1161 | - break; |
|
1232 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1233 | + break; |
|
1234 | + } |
|
1162 | 1235 | } |
1163 | 1236 | |
1164 | 1237 | // If there's data to be inserted for non-IGNORE databases do it here! |
@@ -1173,8 +1246,7 @@ discard block |
||
1173 | 1246 | } |
1174 | 1247 | |
1175 | 1248 | $_SESSION['search_cache']['num_results'] = $numSubjectResults; |
1176 | - } |
|
1177 | - else |
|
1249 | + } else |
|
1178 | 1250 | { |
1179 | 1251 | $main_query = array( |
1180 | 1252 | 'select' => array( |
@@ -1206,8 +1278,7 @@ discard block |
||
1206 | 1278 | $main_query['weights'] = $weight_factors; |
1207 | 1279 | |
1208 | 1280 | $main_query['group_by'][] = 't.id_topic'; |
1209 | - } |
|
1210 | - else |
|
1281 | + } else |
|
1211 | 1282 | { |
1212 | 1283 | // This is outrageous! |
1213 | 1284 | $main_query['select']['id_topic'] = 'm.id_msg AS id_topic'; |
@@ -1228,8 +1299,9 @@ discard block |
||
1228 | 1299 | $main_query['where'][] = 't.id_topic = {int:topic}'; |
1229 | 1300 | $main_query['parameters']['topic'] = $search_params['topic']; |
1230 | 1301 | } |
1231 | - if (!empty($search_params['show_complete'])) |
|
1232 | - $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1302 | + if (!empty($search_params['show_complete'])) { |
|
1303 | + $main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg'; |
|
1304 | + } |
|
1233 | 1305 | } |
1234 | 1306 | |
1235 | 1307 | // *** Get the subject results. |
@@ -1254,14 +1326,15 @@ discard block |
||
1254 | 1326 | ) !== false; |
1255 | 1327 | |
1256 | 1328 | // Clean up some previous cache. |
1257 | - if (!$createTemporary) |
|
1258 | - $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1329 | + if (!$createTemporary) { |
|
1330 | + $smcFunc['db_search_query']('delete_log_search_topics', ' |
|
1259 | 1331 | DELETE FROM {db_prefix}log_search_topics |
1260 | 1332 | WHERE id_search = {int:search_id}', |
1261 | 1333 | array( |
1262 | 1334 | 'search_id' => $_SESSION['search_cache']['id_search'], |
1263 | 1335 | ) |
1264 | 1336 | ); |
1337 | + } |
|
1265 | 1338 | |
1266 | 1339 | foreach ($searchWords as $orIndex => $words) |
1267 | 1340 | { |
@@ -1293,8 +1366,7 @@ discard block |
||
1293 | 1366 | $subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)'; |
1294 | 1367 | $subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}'; |
1295 | 1368 | $subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]'; |
1296 | - } |
|
1297 | - else |
|
1369 | + } else |
|
1298 | 1370 | { |
1299 | 1371 | $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)'; |
1300 | 1372 | $subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}'; |
@@ -1349,8 +1421,9 @@ discard block |
||
1349 | 1421 | call_integration_hook('integrate_subject_search_query', array(&$subject_query)); |
1350 | 1422 | |
1351 | 1423 | // Nothing to search for? |
1352 | - if (empty($subject_query['where'])) |
|
1353 | - continue; |
|
1424 | + if (empty($subject_query['where'])) { |
|
1425 | + continue; |
|
1426 | + } |
|
1354 | 1427 | |
1355 | 1428 | $ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( ' |
1356 | 1429 | INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics |
@@ -1373,19 +1446,21 @@ discard block |
||
1373 | 1446 | { |
1374 | 1447 | $ind = $createTemporary ? 0 : 1; |
1375 | 1448 | // No duplicates! |
1376 | - if (isset($inserts[$row[$ind]])) |
|
1377 | - continue; |
|
1449 | + if (isset($inserts[$row[$ind]])) { |
|
1450 | + continue; |
|
1451 | + } |
|
1378 | 1452 | |
1379 | 1453 | $inserts[$row[$ind]] = $row; |
1380 | 1454 | } |
1381 | 1455 | $smcFunc['db_free_result']($ignoreRequest); |
1382 | 1456 | $numSubjectResults = count($inserts); |
1457 | + } else { |
|
1458 | + $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1383 | 1459 | } |
1384 | - else |
|
1385 | - $numSubjectResults += $smcFunc['db_affected_rows'](); |
|
1386 | 1460 | |
1387 | - if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) |
|
1388 | - break; |
|
1461 | + if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) { |
|
1462 | + break; |
|
1463 | + } |
|
1389 | 1464 | } |
1390 | 1465 | |
1391 | 1466 | // Got some non-MySQL data to plonk in? |
@@ -1403,8 +1478,9 @@ discard block |
||
1403 | 1478 | { |
1404 | 1479 | $main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END'; |
1405 | 1480 | $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)'; |
1406 | - if (!$createTemporary) |
|
1407 | - $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1481 | + if (!$createTemporary) { |
|
1482 | + $main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search']; |
|
1483 | + } |
|
1408 | 1484 | } |
1409 | 1485 | } |
1410 | 1486 | |
@@ -1430,14 +1506,15 @@ discard block |
||
1430 | 1506 | ) !== false; |
1431 | 1507 | |
1432 | 1508 | // Clear, all clear! |
1433 | - if (!$createTemporary) |
|
1434 | - $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1509 | + if (!$createTemporary) { |
|
1510 | + $smcFunc['db_search_query']('delete_log_search_messages', ' |
|
1435 | 1511 | DELETE FROM {db_prefix}log_search_messages |
1436 | 1512 | WHERE id_search = {int:id_search}', |
1437 | 1513 | array( |
1438 | 1514 | 'id_search' => $_SESSION['search_cache']['id_search'], |
1439 | 1515 | ) |
1440 | 1516 | ); |
1517 | + } |
|
1441 | 1518 | |
1442 | 1519 | foreach ($searchWords as $orIndex => $words) |
1443 | 1520 | { |
@@ -1471,19 +1548,21 @@ discard block |
||
1471 | 1548 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1472 | 1549 | { |
1473 | 1550 | // No duplicates! |
1474 | - if (isset($inserts[$row[0]])) |
|
1475 | - continue; |
|
1551 | + if (isset($inserts[$row[0]])) { |
|
1552 | + continue; |
|
1553 | + } |
|
1476 | 1554 | |
1477 | 1555 | $inserts[$row[0]] = $row; |
1478 | 1556 | } |
1479 | 1557 | $smcFunc['db_free_result']($ignoreRequest); |
1480 | 1558 | $indexedResults = count($inserts); |
1559 | + } else { |
|
1560 | + $indexedResults += $smcFunc['db_affected_rows'](); |
|
1481 | 1561 | } |
1482 | - else |
|
1483 | - $indexedResults += $smcFunc['db_affected_rows'](); |
|
1484 | 1562 | |
1485 | - if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) |
|
1486 | - break; |
|
1563 | + if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) { |
|
1564 | + break; |
|
1565 | + } |
|
1487 | 1566 | } |
1488 | 1567 | } |
1489 | 1568 | |
@@ -1503,8 +1582,7 @@ discard block |
||
1503 | 1582 | $context['search_errors']['query_not_specific_enough'] = true; |
1504 | 1583 | $_REQUEST['params'] = $context['params']; |
1505 | 1584 | return PlushSearch1(); |
1506 | - } |
|
1507 | - elseif (!empty($indexedResults)) |
|
1585 | + } elseif (!empty($indexedResults)) |
|
1508 | 1586 | { |
1509 | 1587 | $main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)'; |
1510 | 1588 | if (!$createTemporary) |
@@ -1526,15 +1604,18 @@ discard block |
||
1526 | 1604 | foreach ($words['all_words'] as $regularWord) |
1527 | 1605 | { |
1528 | 1606 | $where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
1529 | - if (in_array($regularWord, $excludedWords)) |
|
1530 | - $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1607 | + if (in_array($regularWord, $excludedWords)) { |
|
1608 | + $where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}'; |
|
1609 | + } |
|
1531 | 1610 | $main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
1532 | 1611 | } |
1533 | - if (!empty($where)) |
|
1534 | - $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1612 | + if (!empty($where)) { |
|
1613 | + $orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0]; |
|
1614 | + } |
|
1615 | + } |
|
1616 | + if (!empty($orWhere)) { |
|
1617 | + $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1535 | 1618 | } |
1536 | - if (!empty($orWhere)) |
|
1537 | - $main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0]; |
|
1538 | 1619 | |
1539 | 1620 | if (!empty($userQuery)) |
1540 | 1621 | { |
@@ -1572,8 +1653,9 @@ discard block |
||
1572 | 1653 | foreach ($main_query['weights'] as $type => $value) |
1573 | 1654 | { |
1574 | 1655 | $relevance .= $weight[$type]; |
1575 | - if (!empty($value['search'])) |
|
1576 | - $relevance .= ' * ' . $value['search']; |
|
1656 | + if (!empty($value['search'])) { |
|
1657 | + $relevance .= ' * ' . $value['search']; |
|
1658 | + } |
|
1577 | 1659 | $relevance .= ' + '; |
1578 | 1660 | $new_weight_total += $weight[$type]; |
1579 | 1661 | } |
@@ -1604,11 +1686,13 @@ discard block |
||
1604 | 1686 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1605 | 1687 | { |
1606 | 1688 | // No duplicates! |
1607 | - if (isset($inserts[$row[2]])) |
|
1608 | - continue; |
|
1689 | + if (isset($inserts[$row[2]])) { |
|
1690 | + continue; |
|
1691 | + } |
|
1609 | 1692 | |
1610 | - foreach ($row as $key => $value) |
|
1611 | - $inserts[$row[2]][] = (int) $row[$key]; |
|
1693 | + foreach ($row as $key => $value) { |
|
1694 | + $inserts[$row[2]][] = (int) $row[$key]; |
|
1695 | + } |
|
1612 | 1696 | } |
1613 | 1697 | $smcFunc['db_free_result']($ignoreRequest); |
1614 | 1698 | |
@@ -1616,8 +1700,9 @@ discard block |
||
1616 | 1700 | if (!empty($inserts)) |
1617 | 1701 | { |
1618 | 1702 | $query_columns = array(); |
1619 | - foreach ($main_query['select'] as $k => $v) |
|
1620 | - $query_columns[$k] = 'int'; |
|
1703 | + foreach ($main_query['select'] as $k => $v) { |
|
1704 | + $query_columns[$k] = 'int'; |
|
1705 | + } |
|
1621 | 1706 | |
1622 | 1707 | $smcFunc['db_insert']('', |
1623 | 1708 | '{db_prefix}log_search_results', |
@@ -1627,21 +1712,23 @@ discard block |
||
1627 | 1712 | ); |
1628 | 1713 | } |
1629 | 1714 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1715 | + } else { |
|
1716 | + $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1630 | 1717 | } |
1631 | - else |
|
1632 | - $_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows'](); |
|
1633 | 1718 | } |
1634 | 1719 | |
1635 | 1720 | // Insert subject-only matches. |
1636 | 1721 | if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0) |
1637 | 1722 | { |
1638 | 1723 | $relevance = '1000 * ('; |
1639 | - foreach ($weight_factors as $type => $value) |
|
1640 | - if (isset($value['results'])) |
|
1724 | + foreach ($weight_factors as $type => $value) { |
|
1725 | + if (isset($value['results'])) |
|
1641 | 1726 | { |
1642 | 1727 | $relevance .= $weight[$type]; |
1643 | - if (!empty($value['results'])) |
|
1644 | - $relevance .= ' * ' . $value['results']; |
|
1728 | + } |
|
1729 | + if (!empty($value['results'])) { |
|
1730 | + $relevance .= ' * ' . $value['results']; |
|
1731 | + } |
|
1645 | 1732 | $relevance .= ' + '; |
1646 | 1733 | } |
1647 | 1734 | $relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance'; |
@@ -1675,8 +1762,9 @@ discard block |
||
1675 | 1762 | while ($row = $smcFunc['db_fetch_row']($ignoreRequest)) |
1676 | 1763 | { |
1677 | 1764 | // No duplicates! |
1678 | - if (isset($usedIDs[$row[1]])) |
|
1679 | - continue; |
|
1765 | + if (isset($usedIDs[$row[1]])) { |
|
1766 | + continue; |
|
1767 | + } |
|
1680 | 1768 | |
1681 | 1769 | $usedIDs[$row[1]] = true; |
1682 | 1770 | $inserts[] = $row; |
@@ -1694,12 +1782,12 @@ discard block |
||
1694 | 1782 | ); |
1695 | 1783 | } |
1696 | 1784 | $_SESSION['search_cache']['num_results'] += count($inserts); |
1785 | + } else { |
|
1786 | + $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1697 | 1787 | } |
1698 | - else |
|
1699 | - $_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows'](); |
|
1788 | + } elseif ($_SESSION['search_cache']['num_results'] == -1) { |
|
1789 | + $_SESSION['search_cache']['num_results'] = 0; |
|
1700 | 1790 | } |
1701 | - elseif ($_SESSION['search_cache']['num_results'] == -1) |
|
1702 | - $_SESSION['search_cache']['num_results'] = 0; |
|
1703 | 1791 | } |
1704 | 1792 | } |
1705 | 1793 | |
@@ -1769,14 +1857,16 @@ discard block |
||
1769 | 1857 | ) |
1770 | 1858 | ); |
1771 | 1859 | $posters = array(); |
1772 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1773 | - $posters[] = $row['id_member']; |
|
1860 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1861 | + $posters[] = $row['id_member']; |
|
1862 | + } |
|
1774 | 1863 | $smcFunc['db_free_result']($request); |
1775 | 1864 | |
1776 | 1865 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
1777 | 1866 | |
1778 | - if (!empty($posters)) |
|
1779 | - loadMemberData(array_unique($posters)); |
|
1867 | + if (!empty($posters)) { |
|
1868 | + loadMemberData(array_unique($posters)); |
|
1869 | + } |
|
1780 | 1870 | |
1781 | 1871 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
1782 | 1872 | $messages_request = $smcFunc['db_query']('', ' |
@@ -1809,8 +1899,9 @@ discard block |
||
1809 | 1899 | ); |
1810 | 1900 | |
1811 | 1901 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
1812 | - if ($smcFunc['db_num_rows']($messages_request) == 0) |
|
1813 | - $context['topics'] = array(); |
|
1902 | + if ($smcFunc['db_num_rows']($messages_request) == 0) { |
|
1903 | + $context['topics'] = array(); |
|
1904 | + } |
|
1814 | 1905 | |
1815 | 1906 | // If we want to know who participated in what then load this now. |
1816 | 1907 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -1828,8 +1919,9 @@ discard block |
||
1828 | 1919 | 'limit' => count($participants), |
1829 | 1920 | ) |
1830 | 1921 | ); |
1831 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
1832 | - $participants[$row['id_topic']] = true; |
|
1922 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
1923 | + $participants[$row['id_topic']] = true; |
|
1924 | + } |
|
1833 | 1925 | $smcFunc['db_free_result']($result); |
1834 | 1926 | } |
1835 | 1927 | } |
@@ -1838,15 +1930,17 @@ discard block |
||
1838 | 1930 | $context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false); |
1839 | 1931 | |
1840 | 1932 | // Consider the search complete! |
1841 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
1842 | - cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1933 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
1934 | + cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90); |
|
1935 | + } |
|
1843 | 1936 | |
1844 | 1937 | $context['key_words'] = &$searchArray; |
1845 | 1938 | |
1846 | 1939 | // Setup the default topic icons... for checking they exist and the like! |
1847 | 1940 | $context['icon_sources'] = array(); |
1848 | - foreach ($context['stable_icons'] as $icon) |
|
1849 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1941 | + foreach ($context['stable_icons'] as $icon) { |
|
1942 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1943 | + } |
|
1850 | 1944 | |
1851 | 1945 | $context['sub_template'] = 'results'; |
1852 | 1946 | $context['page_title'] = $txt['search_results']; |
@@ -1877,26 +1971,31 @@ discard block |
||
1877 | 1971 | global $boards_can, $participants, $smcFunc; |
1878 | 1972 | static $recycle_board = null; |
1879 | 1973 | |
1880 | - if ($recycle_board === null) |
|
1881 | - $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1974 | + if ($recycle_board === null) { |
|
1975 | + $recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0; |
|
1976 | + } |
|
1882 | 1977 | |
1883 | 1978 | // Remember which message this is. (ie. reply #83) |
1884 | 1979 | static $counter = null; |
1885 | - if ($counter == null || $reset) |
|
1886 | - $counter = $_REQUEST['start'] + 1; |
|
1980 | + if ($counter == null || $reset) { |
|
1981 | + $counter = $_REQUEST['start'] + 1; |
|
1982 | + } |
|
1887 | 1983 | |
1888 | 1984 | // If the query returned false, bail. |
1889 | - if ($messages_request == false) |
|
1890 | - return false; |
|
1985 | + if ($messages_request == false) { |
|
1986 | + return false; |
|
1987 | + } |
|
1891 | 1988 | |
1892 | 1989 | // Start from the beginning... |
1893 | - if ($reset) |
|
1894 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1990 | + if ($reset) { |
|
1991 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1992 | + } |
|
1895 | 1993 | |
1896 | 1994 | // Attempt to get the next message. |
1897 | 1995 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1898 | - if (!$message) |
|
1899 | - return false; |
|
1996 | + if (!$message) { |
|
1997 | + return false; |
|
1998 | + } |
|
1900 | 1999 | |
1901 | 2000 | // Can't have an empty subject can we? |
1902 | 2001 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1935,9 +2034,9 @@ discard block |
||
1935 | 2034 | |
1936 | 2035 | if ($smcFunc['strlen']($message['body']) > $charLimit) |
1937 | 2036 | { |
1938 | - if (empty($context['key_words'])) |
|
1939 | - $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
1940 | - else |
|
2037 | + if (empty($context['key_words'])) { |
|
2038 | + $message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
2039 | + } else |
|
1941 | 2040 | { |
1942 | 2041 | $matchString = ''; |
1943 | 2042 | $force_partial_word = false; |
@@ -1946,18 +2045,20 @@ discard block |
||
1946 | 2045 | $keyword = un_htmlspecialchars($keyword); |
1947 | 2046 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
1948 | 2047 | |
1949 | - if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
|
1950 | - $force_partial_word = true; |
|
2048 | + if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) { |
|
2049 | + $force_partial_word = true; |
|
2050 | + } |
|
1951 | 2051 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
1952 | 2052 | } |
1953 | 2053 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
1954 | 2054 | |
1955 | 2055 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br>' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
1956 | 2056 | |
1957 | - if (empty($modSettings['search_method']) || $force_partial_word) |
|
1958 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
1959 | - else |
|
1960 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2057 | + if (empty($modSettings['search_method']) || $force_partial_word) { |
|
2058 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2059 | + } else { |
|
2060 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches); |
|
2061 | + } |
|
1961 | 2062 | |
1962 | 2063 | $message['body'] = ''; |
1963 | 2064 | foreach ($matches[0] as $index => $match) |
@@ -1970,8 +2071,7 @@ discard block |
||
1970 | 2071 | // Re-fix the international characters. |
1971 | 2072 | $message['body'] = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']); |
1972 | 2073 | } |
1973 | - } |
|
1974 | - else |
|
2074 | + } else |
|
1975 | 2075 | { |
1976 | 2076 | // Run BBC interpreter on the message. |
1977 | 2077 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
@@ -1990,21 +2090,26 @@ discard block |
||
1990 | 2090 | // Sadly, we need to check the icon ain't broke. |
1991 | 2091 | if (!empty($modSettings['messageIconChecks_enable'])) |
1992 | 2092 | { |
1993 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
1994 | - $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1995 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
1996 | - $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1997 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1998 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1999 | - } |
|
2000 | - else |
|
2093 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2094 | + $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2095 | + } |
|
2096 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2097 | + $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2098 | + } |
|
2099 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2100 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
2101 | + } |
|
2102 | + } else |
|
2001 | 2103 | { |
2002 | - if (!isset($context['icon_sources'][$message['first_icon']])) |
|
2003 | - $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2004 | - if (!isset($context['icon_sources'][$message['last_icon']])) |
|
2005 | - $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2006 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
2007 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2104 | + if (!isset($context['icon_sources'][$message['first_icon']])) { |
|
2105 | + $context['icon_sources'][$message['first_icon']] = 'images_url'; |
|
2106 | + } |
|
2107 | + if (!isset($context['icon_sources'][$message['last_icon']])) { |
|
2108 | + $context['icon_sources'][$message['last_icon']] = 'images_url'; |
|
2109 | + } |
|
2110 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
2111 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
2112 | + } |
|
2008 | 2113 | } |
2009 | 2114 | |
2010 | 2115 | // Do we have quote tag enabled? |
@@ -2014,12 +2119,14 @@ discard block |
||
2014 | 2119 | $colorClass = 'windowbg'; |
2015 | 2120 | |
2016 | 2121 | // Sticky topics should get a different color, too. |
2017 | - if ($message['is_sticky']) |
|
2018 | - $colorClass .= ' sticky'; |
|
2122 | + if ($message['is_sticky']) { |
|
2123 | + $colorClass .= ' sticky'; |
|
2124 | + } |
|
2019 | 2125 | |
2020 | 2126 | // Locked topics get special treatment as well. |
2021 | - if ($message['locked']) |
|
2022 | - $colorClass .= ' locked'; |
|
2127 | + if ($message['locked']) { |
|
2128 | + $colorClass .= ' locked'; |
|
2129 | + } |
|
2023 | 2130 | |
2024 | 2131 | $output = array_merge($context['topics'][$message['id_msg']], array( |
2025 | 2132 | 'id' => $message['id_topic'], |
@@ -2113,8 +2220,9 @@ discard block |
||
2113 | 2220 | $query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\'')); |
2114 | 2221 | |
2115 | 2222 | // Highlighting empty strings would make a terrible mess... |
2116 | - if (strlen($query) == 0) |
|
2117 | - continue; |
|
2223 | + if (strlen($query) == 0) { |
|
2224 | + continue; |
|
2225 | + } |
|
2118 | 2226 | |
2119 | 2227 | $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m) |
2120 | 2228 | { |
@@ -2167,8 +2275,9 @@ discard block |
||
2167 | 2275 | |
2168 | 2276 | // Load up the search API we are going to use. |
2169 | 2277 | $modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index']; |
2170 | - if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) |
|
2171 | - fatal_lang_error('search_api_missing'); |
|
2278 | + if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) { |
|
2279 | + fatal_lang_error('search_api_missing'); |
|
2280 | + } |
|
2172 | 2281 | require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'); |
2173 | 2282 | |
2174 | 2283 | // Create an instance of the search API and check it is valid for this version of SMF. |
@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $txt, $scripturl; |
19 | 19 | |
20 | 20 | // Let them know the action was a success. |
21 | - if (!empty($context['report_post_action'])) |
|
22 | - echo ' |
|
21 | + if (!empty($context['report_post_action'])) { |
|
22 | + echo ' |
|
23 | 23 | <div class="infobox"> |
24 | 24 | ', $txt['report_action_' . $context['report_post_action']], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | echo ' |
28 | 29 | <form id="reported_posts" action="', $scripturl, '?action=moderate;area=reportedposts;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | |
53 | 54 | // Prepare the comments... |
54 | 55 | $comments = array(); |
55 | - foreach ($report['comments'] as $comment) |
|
56 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
56 | + foreach ($report['comments'] as $comment) { |
|
57 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
58 | + } |
|
57 | 59 | |
58 | 60 | echo ' |
59 | 61 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -69,18 +71,21 @@ discard block |
||
69 | 71 | <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 | 72 | |
71 | 73 | // 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 ' |
|
74 | + if (!$report['closed'] && (is_array($context['report_remove_any_boards']) && in_array($report['topic']['id_board'], $context['report_remove_any_boards']))) { |
|
75 | + echo ' |
|
74 | 76 | <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>'; |
77 | + } |
|
75 | 78 | |
76 | 79 | // Ban this user button. |
77 | - if (!$report['closed'] && !empty($context['report_manage_bans'])) |
|
78 | - echo ' |
|
80 | + if (!$report['closed'] && !empty($context['report_manage_bans'])) { |
|
81 | + echo ' |
|
79 | 82 | <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>'; |
83 | + } |
|
80 | 84 | |
81 | - if (!$context['view_closed']) |
|
82 | - echo ' |
|
85 | + if (!$context['view_closed']) { |
|
86 | + echo ' |
|
83 | 87 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
88 | + } |
|
84 | 89 | |
85 | 90 | echo ' |
86 | 91 | </ul> |
@@ -88,18 +93,20 @@ discard block |
||
88 | 93 | } |
89 | 94 | |
90 | 95 | // Were none found? |
91 | - if (empty($context['reports'])) |
|
92 | - echo ' |
|
96 | + if (empty($context['reports'])) { |
|
97 | + echo ' |
|
93 | 98 | <div class="windowbg"> |
94 | 99 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
95 | 100 | </div>'; |
101 | + } |
|
96 | 102 | |
97 | 103 | echo ' |
98 | 104 | <div class="pagesection">'; |
99 | 105 | |
100 | - if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) |
|
101 | - echo ' |
|
106 | + if (!empty($context['total_reports']) && $context['total_reports'] >= $context['reports_how_many']) { |
|
107 | + echo ' |
|
102 | 108 | <div class="pagelinks floatleft">' . $context['page_index'] . '</div>'; |
109 | + } |
|
103 | 110 | |
104 | 111 | echo ' |
105 | 112 | <div class="floatright">', !$context['view_closed'] ? ' |
@@ -130,18 +137,20 @@ discard block |
||
130 | 137 | <div class="modbox"> |
131 | 138 | <ul>'; |
132 | 139 | |
133 | - foreach ($context['reported_posts'] as $report) |
|
134 | - echo ' |
|
140 | + foreach ($context['reported_posts'] as $report) { |
|
141 | + echo ' |
|
135 | 142 | <li class="smalltext"> |
136 | 143 | <a href="', $report['report_href'], '">', $report['subject'], '</a> ', $txt['mc_reportedp_by'], ' ', $report['author']['link'], ' |
137 | 144 | </li>'; |
145 | + } |
|
138 | 146 | |
139 | 147 | // Don't have any watched users right now? |
140 | - if (empty($context['reported_posts'])) |
|
141 | - echo ' |
|
148 | + if (empty($context['reported_posts'])) { |
|
149 | + echo ' |
|
142 | 150 | <li> |
143 | 151 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
144 | 152 | </li>'; |
153 | + } |
|
145 | 154 | |
146 | 155 | echo ' |
147 | 156 | </ul> |
@@ -189,11 +198,12 @@ discard block |
||
189 | 198 | global $context, $scripturl, $txt; |
190 | 199 | |
191 | 200 | // Let them know the action was a success. |
192 | - if (!empty($context['report_post_action'])) |
|
193 | - echo ' |
|
201 | + if (!empty($context['report_post_action'])) { |
|
202 | + echo ' |
|
194 | 203 | <div class="infobox"> |
195 | 204 | ', $txt['report_action_' . $context['report_post_action']], ' |
196 | 205 | </div>'; |
206 | + } |
|
197 | 207 | |
198 | 208 | echo ' |
199 | 209 | <div id="modcenter"> |
@@ -229,14 +239,15 @@ discard block |
||
229 | 239 | <h3 class="catbg">', $txt['mc_modreport_whoreported_title'], '</h3> |
230 | 240 | </div>'; |
231 | 241 | |
232 | - foreach ($context['report']['comments'] as $comment) |
|
233 | - echo ' |
|
242 | + foreach ($context['report']['comments'] as $comment) { |
|
243 | + echo ' |
|
234 | 244 | <div class="windowbg"> |
235 | 245 | <p class="smalltext"> |
236 | 246 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
237 | 247 | </p> |
238 | 248 | <p>', $comment['message'], '</p> |
239 | 249 | </div>'; |
250 | + } |
|
240 | 251 | |
241 | 252 | echo ' |
242 | 253 | <br> |
@@ -245,11 +256,12 @@ discard block |
||
245 | 256 | </div> |
246 | 257 | <div>'; |
247 | 258 | |
248 | - if (empty($context['report']['mod_comments'])) |
|
249 | - echo ' |
|
259 | + if (empty($context['report']['mod_comments'])) { |
|
260 | + echo ' |
|
250 | 261 | <div class="information"> |
251 | 262 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
252 | 263 | </div>'; |
264 | + } |
|
253 | 265 | |
254 | 266 | foreach ($context['report']['mod_comments'] as $comment) |
255 | 267 | { |
@@ -335,18 +347,20 @@ discard block |
||
335 | 347 | <div class="modbox"> |
336 | 348 | <ul>'; |
337 | 349 | |
338 | - foreach ($context['reported_members'] as $report) |
|
339 | - echo ' |
|
350 | + foreach ($context['reported_members'] as $report) { |
|
351 | + echo ' |
|
340 | 352 | <li class="smalltext"> |
341 | 353 | <a href="', $report['report_href'], '">', $report['user_name'], '</a> |
342 | 354 | </li>'; |
355 | + } |
|
343 | 356 | |
344 | 357 | // Don't have any reported members right now? |
345 | - if (empty($context['reported_members'])) |
|
346 | - echo ' |
|
358 | + if (empty($context['reported_members'])) { |
|
359 | + echo ' |
|
347 | 360 | <li> |
348 | 361 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
349 | 362 | </li>'; |
363 | + } |
|
350 | 364 | |
351 | 365 | echo ' |
352 | 366 | </ul> |
@@ -394,11 +408,12 @@ discard block |
||
394 | 408 | global $context, $txt, $scripturl; |
395 | 409 | |
396 | 410 | // Let them know the action was a success. |
397 | - if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) |
|
398 | - echo ' |
|
411 | + if (!empty($context['report_post_action']) && !empty($txt['report_action_' . $context['report_post_action']])) { |
|
412 | + echo ' |
|
399 | 413 | <div class="infobox"> |
400 | 414 | ', $txt['report_action_' . $context['report_post_action']], ' |
401 | 415 | </div>'; |
416 | + } |
|
402 | 417 | |
403 | 418 | echo ' |
404 | 419 | <form id="reported_members" action="', $scripturl, '?action=moderate;area=reportedmembers;sa=show', $context['view_closed'] ? ';closed' : '', ';start=', $context['start'], '" method="post" accept-charset="', $context['character_set'], '"> |
@@ -430,8 +445,9 @@ discard block |
||
430 | 445 | |
431 | 446 | // Prepare the comments... |
432 | 447 | $comments = array(); |
433 | - foreach ($report['comments'] as $comment) |
|
434 | - $comments[$comment['member']['id']] = $comment['member']['link']; |
|
448 | + foreach ($report['comments'] as $comment) { |
|
449 | + $comments[$comment['member']['id']] = $comment['member']['link']; |
|
450 | + } |
|
435 | 451 | |
436 | 452 | echo ' |
437 | 453 | ', $txt['mc_reportedp_reported_by'], ': ', implode(', ', $comments), ' |
@@ -443,13 +459,15 @@ discard block |
||
443 | 459 | <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>'; |
444 | 460 | |
445 | 461 | // Ban this user button. |
446 | - if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) |
|
447 | - echo ' |
|
462 | + if (!$report['closed'] && !empty($context['report_manage_bans']) && !empty($report['user']['id'])) { |
|
463 | + echo ' |
|
448 | 464 | <li><a href="', $scripturl, '?action=admin;area=ban;sa=add;u=', $report['user']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $ban_button, '</a></li>'; |
465 | + } |
|
449 | 466 | |
450 | - if (!$context['view_closed']) |
|
451 | - echo ' |
|
467 | + if (!$context['view_closed']) { |
|
468 | + echo ' |
|
452 | 469 | <li><input type="checkbox" name="close[]" value="' . $report['id'] . '"></li>'; |
470 | + } |
|
453 | 471 | |
454 | 472 | echo ' |
455 | 473 | </ul> |
@@ -457,11 +475,12 @@ discard block |
||
457 | 475 | } |
458 | 476 | |
459 | 477 | // Were none found? |
460 | - if (empty($context['reports'])) |
|
461 | - echo ' |
|
478 | + if (empty($context['reports'])) { |
|
479 | + echo ' |
|
462 | 480 | <div class="windowbg"> |
463 | 481 | <p class="centertext">', $txt['mc_reportedp_none_found'], '</p> |
464 | 482 | </div>'; |
483 | + } |
|
465 | 484 | |
466 | 485 | echo ' |
467 | 486 | <div class="pagesection"> |
@@ -482,11 +501,12 @@ discard block |
||
482 | 501 | global $context, $scripturl, $txt; |
483 | 502 | |
484 | 503 | // Let them know the action was a success. |
485 | - if (!empty($context['report_post_action'])) |
|
486 | - echo ' |
|
504 | + if (!empty($context['report_post_action'])) { |
|
505 | + echo ' |
|
487 | 506 | <div class="infobox"> |
488 | 507 | ', $txt['report_action_' . $context['report_post_action']], ' |
489 | 508 | </div>'; |
509 | + } |
|
490 | 510 | |
491 | 511 | echo ' |
492 | 512 | <div id="modcenter"> |
@@ -519,14 +539,15 @@ discard block |
||
519 | 539 | <h3 class="catbg">', $txt['mc_memberreport_whoreported_title'], '</h3> |
520 | 540 | </div>'; |
521 | 541 | |
522 | - foreach ($context['report']['comments'] as $comment) |
|
523 | - echo ' |
|
542 | + foreach ($context['report']['comments'] as $comment) { |
|
543 | + echo ' |
|
524 | 544 | <div class="windowbg"> |
525 | 545 | <p class="smalltext"> |
526 | 546 | ', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), ' |
527 | 547 | </p> |
528 | 548 | <p>', $comment['message'], '</p> |
529 | 549 | </div>'; |
550 | + } |
|
530 | 551 | |
531 | 552 | echo ' |
532 | 553 | <br> |
@@ -535,11 +556,12 @@ discard block |
||
535 | 556 | </div> |
536 | 557 | <div>'; |
537 | 558 | |
538 | - if (empty($context['report']['mod_comments'])) |
|
539 | - echo ' |
|
559 | + if (empty($context['report']['mod_comments'])) { |
|
560 | + echo ' |
|
540 | 561 | <div class="information"> |
541 | 562 | <p class="centertext">', $txt['mc_modreport_no_mod_comment'], '</p> |
542 | 563 | </div>'; |
564 | + } |
|
543 | 565 | |
544 | 566 | foreach ($context['report']['mod_comments'] as $comment) |
545 | 567 | { |
@@ -40,9 +40,10 @@ discard block |
||
40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
41 | 41 | |
42 | 42 | // Show a list of all the years we allow... |
43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
44 | - echo ' |
|
43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
44 | + echo ' |
|
45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
46 | + } |
|
46 | 47 | |
47 | 48 | echo ' |
48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
51 | 52 | |
52 | 53 | // There are 12 months per year - ensure that they all get listed. |
53 | - for ($month = 1; $month <= 12; $month++) |
|
54 | - echo ' |
|
54 | + for ($month = 1; $month <= 12; $month++) { |
|
55 | + echo ' |
|
55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | echo ' |
58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
61 | 63 | |
62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
64 | - echo ' |
|
65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
66 | + echo ' |
|
65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
68 | + } |
|
66 | 69 | |
67 | 70 | echo ' |
68 | 71 | </select> |
69 | 72 | </dd> |
70 | 73 | </dl>'; |
71 | 74 | |
72 | - if ($context['is_new']) |
|
73 | - echo ' |
|
75 | + if ($context['is_new']) { |
|
76 | + echo ' |
|
74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
75 | - else |
|
76 | - echo ' |
|
78 | + } else { |
|
79 | + echo ' |
|
77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
83 | + } |
|
80 | 84 | echo ' |
81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
82 | 86 | </div><!-- .windowbg --> |
@@ -106,7 +106,7 @@ |
||
106 | 106 | if (!empty($context['custom_profile_fields']['columns'])) |
107 | 107 | foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
108 | 108 | echo ' |
109 | - <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
|
109 | + <td class="' , $key, ' centertext">', $member['options'][$key], '</td>'; |
|
110 | 110 | |
111 | 111 | echo ' |
112 | 112 | </tr>'; |
@@ -27,9 +27,10 @@ discard block |
||
27 | 27 | <h3 class="catbg"> |
28 | 28 | <span class="floatleft">', $txt['members_list'], '</span>'; |
29 | 29 | |
30 | - if (!isset($context['old_search'])) |
|
31 | - echo ' |
|
30 | + if (!isset($context['old_search'])) { |
|
31 | + echo ' |
|
32 | 32 | <span class="floatright">', $context['letter_links'], '</span>'; |
33 | + } |
|
33 | 34 | echo ' |
34 | 35 | </h3> |
35 | 36 | </div>'; |
@@ -44,20 +45,23 @@ discard block |
||
44 | 45 | foreach ($context['columns'] as $key => $column) |
45 | 46 | { |
46 | 47 | // @TODO maybe find something nicer? |
47 | - if ($key == 'email_address' && !$context['can_send_email']) |
|
48 | - continue; |
|
48 | + if ($key == 'email_address' && !$context['can_send_email']) { |
|
49 | + continue; |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // This is a selected column, so underline it or some such. |
51 | - if ($column['selected']) |
|
52 | - echo ' |
|
53 | + if ($column['selected']) { |
|
54 | + echo ' |
|
53 | 55 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '> |
54 | 56 | <a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>'; |
57 | + } |
|
55 | 58 | |
56 | 59 | // This is just some column... show the link and be done with it. |
57 | - else |
|
58 | - echo ' |
|
60 | + else { |
|
61 | + echo ' |
|
59 | 62 | <th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '> |
60 | 63 | ', $column['link'], '</th>'; |
64 | + } |
|
61 | 65 | } |
62 | 66 | |
63 | 67 | echo ' |
@@ -77,9 +81,10 @@ discard block |
||
77 | 81 | </td> |
78 | 82 | <td class="real_name lefttext">', $member['link'], '</td>'; |
79 | 83 | |
80 | - if (!isset($context['disabled_fields']['website'])) |
|
81 | - echo ' |
|
84 | + if (!isset($context['disabled_fields']['website'])) { |
|
85 | + echo ' |
|
82 | 86 | <td class="website_url centertext">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" rel="noopener"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>'; |
87 | + } |
|
83 | 88 | |
84 | 89 | // Group and date. |
85 | 90 | echo ' |
@@ -92,32 +97,35 @@ discard block |
||
92 | 97 | <td class="post_count centertext">', $member['posts'], '</td> |
93 | 98 | <td class="statsbar">'; |
94 | 99 | |
95 | - if (!empty($member['post_percent'])) |
|
96 | - echo ' |
|
100 | + if (!empty($member['post_percent'])) { |
|
101 | + echo ' |
|
97 | 102 | <div class="generic_bar"> |
98 | 103 | <div class="bar" style="width: ', $member['post_percent'], '%;"></div> |
99 | 104 | </div>'; |
105 | + } |
|
100 | 106 | |
101 | 107 | echo ' |
102 | 108 | </td>'; |
103 | 109 | } |
104 | 110 | |
105 | 111 | // Show custom fields marked to be shown here |
106 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
107 | - foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
112 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
113 | + foreach ($context['custom_profile_fields']['columns'] as $key => $column) |
|
108 | 114 | echo ' |
109 | 115 | <td class="' , $key , ' centertext">', $member['options'][$key], '</td>'; |
116 | + } |
|
110 | 117 | |
111 | 118 | echo ' |
112 | 119 | </tr>'; |
113 | 120 | } |
114 | 121 | } |
115 | 122 | // No members? |
116 | - else |
|
117 | - echo ' |
|
123 | + else { |
|
124 | + echo ' |
|
118 | 125 | <tr> |
119 | 126 | <td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td> |
120 | 127 | </tr>'; |
128 | + } |
|
121 | 129 | |
122 | 130 | echo ' |
123 | 131 | </tbody> |
@@ -130,11 +138,12 @@ discard block |
||
130 | 138 | <div class="pagelinks floatleft">', $context['page_index'], '</div>'; |
131 | 139 | |
132 | 140 | // If it is displaying the result of a search show a "search again" link to edit their criteria. |
133 | - if (isset($context['old_search'])) |
|
134 | - echo ' |
|
141 | + if (isset($context['old_search'])) { |
|
142 | + echo ' |
|
135 | 143 | <div class="buttonlist floatright"> |
136 | 144 | <a class="button" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a> |
137 | 145 | </div>'; |
146 | + } |
|
138 | 147 | echo ' |
139 | 148 | </div> |
140 | 149 | </div><!-- #memberlist -->'; |
@@ -174,12 +183,13 @@ discard block |
||
174 | 183 | <dd> |
175 | 184 | <ul>'; |
176 | 185 | |
177 | - foreach ($context['search_fields'] as $id => $title) |
|
178 | - echo ' |
|
186 | + foreach ($context['search_fields'] as $id => $title) { |
|
187 | + echo ' |
|
179 | 188 | <li> |
180 | 189 | <input type="checkbox" name="fields[]" id="fields-', $id, '" value="', $id, '"', in_array($id, $context['search_defaults']) ? ' checked' : '', '> |
181 | 190 | <label for="fields-', $id, '">', $title, '</label> |
182 | 191 | </li>'; |
192 | + } |
|
183 | 193 | |
184 | 194 | echo ' |
185 | 195 | </ul> |
@@ -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"> |
@@ -39,8 +40,8 @@ discard block |
||
39 | 40 | </div>'; |
40 | 41 | |
41 | 42 | // Show an option to convert the body column of the post table to MEDIUMTEXT or TEXT |
42 | - if (isset($context['convert_to'])) |
|
43 | - echo ' |
|
43 | + if (isset($context['convert_to'])) { |
|
44 | + echo ' |
|
44 | 45 | <div class="cat_bar"> |
45 | 46 | <h3 class="catbg">', $txt[$context['convert_to'] . '_title'], '</h3> |
46 | 47 | </div> |
@@ -53,10 +54,11 @@ discard block |
||
53 | 54 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
54 | 55 | </form> |
55 | 56 | </div>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | // We might want to convert entities if we're on UTF-8. |
58 | - if ($context['convert_entities']) |
|
59 | - echo ' |
|
60 | + if ($context['convert_entities']) { |
|
61 | + echo ' |
|
60 | 62 | <div class="cat_bar"> |
61 | 63 | <h3 class="catbg">', $txt['entity_convert_title'], '</h3> |
62 | 64 | </div> |
@@ -68,6 +70,7 @@ discard block |
||
68 | 70 | <input type="hidden" name="', $context['admin-maint_token_var'], '" value="', $context['admin-maint_token'], '"> |
69 | 71 | </form> |
70 | 72 | </div>'; |
73 | + } |
|
71 | 74 | |
72 | 75 | echo ' |
73 | 76 | </div><!-- #manage_maintenance -->'; |
@@ -85,11 +88,12 @@ discard block |
||
85 | 88 | <div id="manage_maintenance">'; |
86 | 89 | |
87 | 90 | // If maintenance has finished tell the user. |
88 | - if (!empty($context['maintenance_finished'])) |
|
89 | - echo ' |
|
91 | + if (!empty($context['maintenance_finished'])) { |
|
92 | + echo ' |
|
90 | 93 | <div class="infobox"> |
91 | 94 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
92 | 95 | </div>'; |
96 | + } |
|
93 | 97 | |
94 | 98 | echo ' |
95 | 99 | <div class="cat_bar"> |
@@ -221,11 +225,12 @@ discard block |
||
221 | 225 | <div id="manage_maintenance">'; |
222 | 226 | |
223 | 227 | // If maintenance has finished, tell the user. |
224 | - if (!empty($context['maintenance_finished'])) |
|
225 | - echo ' |
|
228 | + if (!empty($context['maintenance_finished'])) { |
|
229 | + echo ' |
|
226 | 230 | <div class="infobox"> |
227 | 231 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
228 | 232 | </div>'; |
233 | + } |
|
229 | 234 | |
230 | 235 | echo ' |
231 | 236 | <div class="cat_bar"> |
@@ -287,9 +292,10 @@ discard block |
||
287 | 292 | </p> |
288 | 293 | <div style="display: none;" id="membersPanel">'; |
289 | 294 | |
290 | - foreach ($context['membergroups'] as $group) |
|
291 | - echo ' |
|
295 | + foreach ($context['membergroups'] as $group) { |
|
296 | + echo ' |
|
292 | 297 | <label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked> ', $group['name'], '</label><br>'; |
298 | + } |
|
293 | 299 | |
294 | 300 | echo ' |
295 | 301 | </div> |
@@ -333,11 +339,12 @@ discard block |
||
333 | 339 | global $scripturl, $txt, $context, $settings, $modSettings; |
334 | 340 | |
335 | 341 | // If maintenance has finished tell the user. |
336 | - if (!empty($context['maintenance_finished'])) |
|
337 | - echo ' |
|
342 | + if (!empty($context['maintenance_finished'])) { |
|
343 | + echo ' |
|
338 | 344 | <div class="infobox"> |
339 | 345 | ', sprintf($txt['maintain_done'], $context['maintenance_finished']), ' |
340 | 346 | </div>'; |
347 | + } |
|
341 | 348 | |
342 | 349 | // Bit of javascript for showing which boards to prune in an otherwise hidden list. |
343 | 350 | echo ' |
@@ -405,21 +412,23 @@ discard block |
||
405 | 412 | <ul>'; |
406 | 413 | |
407 | 414 | // Display a checkbox with every board. |
408 | - foreach ($category['boards'] as $board) |
|
409 | - echo ' |
|
415 | + foreach ($category['boards'] as $board) { |
|
416 | + echo ' |
|
410 | 417 | <li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"> |
411 | 418 | <label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked>', $board['name'], '</label> |
412 | 419 | </li>'; |
420 | + } |
|
413 | 421 | |
414 | 422 | echo ' |
415 | 423 | </ul> |
416 | 424 | </fieldset>'; |
417 | 425 | |
418 | 426 | // Increase $i, and check if we're at the middle yet. |
419 | - if (++$i == $middle) |
|
420 | - echo ' |
|
427 | + if (++$i == $middle) { |
|
428 | + echo ' |
|
421 | 429 | </div><!-- .floatleft --> |
422 | 430 | <div class="floatright" style="width: 49%;">'; |
431 | + } |
|
423 | 432 | } |
424 | 433 | |
425 | 434 | echo ' |
@@ -461,9 +470,10 @@ discard block |
||
461 | 470 | echo ' |
462 | 471 | <optgroup label="', $category['name'], '">'; |
463 | 472 | |
464 | - foreach ($category['boards'] as $board) |
|
465 | - echo ' |
|
473 | + foreach ($category['boards'] as $board) { |
|
474 | + echo ' |
|
466 | 475 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
476 | + } |
|
467 | 477 | |
468 | 478 | echo ' |
469 | 479 | </optgroup>'; |
@@ -481,9 +491,10 @@ discard block |
||
481 | 491 | echo ' |
482 | 492 | <optgroup label="', $category['name'], '">'; |
483 | 493 | |
484 | - foreach ($category['boards'] as $board) |
|
485 | - echo ' |
|
494 | + foreach ($category['boards'] as $board) { |
|
495 | + echo ' |
|
486 | 496 | <option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>'; |
497 | + } |
|
487 | 498 | |
488 | 499 | echo ' |
489 | 500 | </optgroup>'; |
@@ -526,9 +537,10 @@ discard block |
||
526 | 537 | ', $txt['database_optimize_attempt'], '<br>'; |
527 | 538 | |
528 | 539 | // List each table being optimized... |
529 | - foreach ($context['optimized_tables'] as $table) |
|
530 | - echo ' |
|
540 | + foreach ($context['optimized_tables'] as $table) { |
|
541 | + echo ' |
|
531 | 542 | ', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>'; |
543 | + } |
|
532 | 544 | |
533 | 545 | // How did we go? |
534 | 546 | echo ' |
@@ -588,13 +600,14 @@ discard block |
||
588 | 600 | </li> |
589 | 601 | </ul>'; |
590 | 602 | |
591 | - if (!empty($context['exceeding_messages_morethan'])) |
|
592 | - echo ' |
|
603 | + if (!empty($context['exceeding_messages_morethan'])) { |
|
604 | + echo ' |
|
593 | 605 | <p>', $context['exceeding_messages_morethan'], '</p>'; |
594 | - } |
|
595 | - else |
|
596 | - echo ' |
|
606 | + } |
|
607 | + } else { |
|
608 | + echo ' |
|
597 | 609 | <p class="infobox">', $txt['convert_to_text'], '</p>'; |
610 | + } |
|
598 | 611 | |
599 | 612 | echo ' |
600 | 613 | <form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '"> |
@@ -25,18 +25,20 @@ discard block |
||
25 | 25 | </div> |
26 | 26 | <div class="windowbg">'; |
27 | 27 | |
28 | - if (!empty($context['move_board'])) |
|
29 | - echo ' |
|
28 | + if (!empty($context['move_board'])) { |
|
29 | + echo ' |
|
30 | 30 | <div class="noticebox"> |
31 | 31 | ', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', ' |
32 | 32 | </div>'; |
33 | + } |
|
33 | 34 | |
34 | 35 | // No categories so show a label. |
35 | - if (empty($context['categories'])) |
|
36 | - echo ' |
|
36 | + if (empty($context['categories'])) { |
|
37 | + echo ' |
|
37 | 38 | <div class="windowbg centertext"> |
38 | 39 | ', $txt['mboards_no_cats'], ' |
39 | 40 | </div>'; |
41 | + } |
|
40 | 42 | |
41 | 43 | // Loop through every category, listing the boards in each as we go. |
42 | 44 | foreach ($context['categories'] as $category) |
@@ -54,9 +56,10 @@ discard block |
||
54 | 56 | <form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '"> |
55 | 57 | <ul id="category_', $category['id'], '" class="nolist">'; |
56 | 58 | |
57 | - if (!empty($category['move_link'])) |
|
58 | - echo ' |
|
59 | + if (!empty($category['move_link'])) { |
|
60 | + echo ' |
|
59 | 61 | <li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | $recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>'; |
62 | 65 | $redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">'; |
@@ -79,9 +82,10 @@ discard block |
||
79 | 82 | echo ' |
80 | 83 | <li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">'; |
81 | 84 | |
82 | - foreach ($board['move_links'] as $link) |
|
83 | - echo ' |
|
85 | + foreach ($board['move_links'] as $link) { |
|
86 | + echo ' |
|
84 | 87 | <a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>'; |
88 | + } |
|
85 | 89 | |
86 | 90 | echo ' |
87 | 91 | </li>'; |
@@ -130,9 +134,10 @@ discard block |
||
130 | 134 | <select name="cat_order">'; |
131 | 135 | |
132 | 136 | // Print every existing category into a select box. |
133 | - foreach ($context['category_order'] as $order) |
|
134 | - echo ' |
|
137 | + foreach ($context['category_order'] as $order) { |
|
138 | + echo ' |
|
135 | 139 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
140 | + } |
|
136 | 141 | echo ' |
137 | 142 | </select> |
138 | 143 | </dd>'; |
@@ -167,14 +172,15 @@ discard block |
||
167 | 172 | { |
168 | 173 | foreach ($context['custom_category_settings'] as $catset_id => $catset) |
169 | 174 | { |
170 | - if (!empty($catset['dt']) && !empty($catset['dd'])) |
|
171 | - echo ' |
|
175 | + if (!empty($catset['dt']) && !empty($catset['dd'])) { |
|
176 | + echo ' |
|
172 | 177 | <dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '"> |
173 | 178 | ', $catset['dt'], ' |
174 | 179 | </dt> |
175 | 180 | <dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '> |
176 | 181 | ', $catset['dd'], ' |
177 | 182 | </dd>'; |
183 | + } |
|
178 | 184 | } |
179 | 185 | } |
180 | 186 | |
@@ -182,21 +188,23 @@ discard block |
||
182 | 188 | echo ' |
183 | 189 | </dl>'; |
184 | 190 | |
185 | - if (isset($context['category']['is_new'])) |
|
186 | - echo ' |
|
191 | + if (isset($context['category']['is_new'])) { |
|
192 | + echo ' |
|
187 | 193 | <input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">'; |
188 | - else |
|
189 | - echo ' |
|
194 | + } else { |
|
195 | + echo ' |
|
190 | 196 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button"> |
191 | 197 | <input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">'; |
198 | + } |
|
192 | 199 | echo ' |
193 | 200 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
194 | 201 | <input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">'; |
195 | 202 | |
196 | 203 | // If this category is empty we don't bother with the next confirmation screen. |
197 | - if ($context['category']['is_empty']) |
|
198 | - echo ' |
|
204 | + if ($context['category']['is_empty']) { |
|
205 | + echo ' |
|
199 | 206 | <input type="hidden" name="empty" value="1">'; |
207 | + } |
|
200 | 208 | |
201 | 209 | echo ' |
202 | 210 | </div><!-- .windowbg --> |
@@ -223,9 +231,10 @@ discard block |
||
223 | 231 | <p>', $txt['mboards_delete_cat_contains'], ':</p> |
224 | 232 | <ul>'; |
225 | 233 | |
226 | - foreach ($context['category']['children'] as $child) |
|
227 | - echo ' |
|
234 | + foreach ($context['category']['children'] as $child) { |
|
235 | + echo ' |
|
228 | 236 | <li>', $child, '</li>'; |
237 | + } |
|
229 | 238 | |
230 | 239 | echo ' |
231 | 240 | </ul> |
@@ -239,10 +248,11 @@ discard block |
||
239 | 248 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>: |
240 | 249 | <select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>'; |
241 | 250 | |
242 | - foreach ($context['category_order'] as $cat) |
|
243 | - if ($cat['id'] != 0) |
|
251 | + foreach ($context['category_order'] as $cat) { |
|
252 | + if ($cat['id'] != 0) |
|
244 | 253 | echo ' |
245 | 254 | <option value="', $cat['id'], '">', $cat['true_name'], '</option>'; |
255 | + } |
|
246 | 256 | |
247 | 257 | echo ' |
248 | 258 | </select> |
@@ -285,9 +295,10 @@ discard block |
||
285 | 295 | <dd> |
286 | 296 | <select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">'; |
287 | 297 | |
288 | - foreach ($context['categories'] as $category) |
|
289 | - echo ' |
|
298 | + foreach ($context['categories'] as $category) { |
|
299 | + echo ' |
|
290 | 300 | <option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>'; |
301 | + } |
|
291 | 302 | echo ' |
292 | 303 | </select> |
293 | 304 | </dd>'; |
@@ -315,9 +326,10 @@ discard block |
||
315 | 326 | <select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '> |
316 | 327 | ', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : ''; |
317 | 328 | |
318 | - foreach ($context['board_order'] as $order) |
|
319 | - echo ' |
|
329 | + foreach ($context['board_order'] as $order) { |
|
330 | + echo ' |
|
320 | 331 | <option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>'; |
332 | + } |
|
321 | 333 | echo ' |
322 | 334 | </select> |
323 | 335 | </dd>'; |
@@ -346,13 +358,15 @@ discard block |
||
346 | 358 | <dd> |
347 | 359 | <select name="profile">'; |
348 | 360 | |
349 | - if (isset($context['board']['is_new'])) |
|
350 | - echo ' |
|
361 | + if (isset($context['board']['is_new'])) { |
|
362 | + echo ' |
|
351 | 363 | <option value="-1">[', $txt['permission_profile_inherit'], ']</option>'; |
364 | + } |
|
352 | 365 | |
353 | - foreach ($context['profiles'] as $id => $profile) |
|
354 | - echo ' |
|
366 | + foreach ($context['profiles'] as $id => $profile) { |
|
367 | + echo ' |
|
355 | 368 | <option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>'; |
369 | + } |
|
356 | 370 | |
357 | 371 | echo ' |
358 | 372 | </select> |
@@ -365,8 +379,8 @@ discard block |
||
365 | 379 | </dt> |
366 | 380 | <dd>'; |
367 | 381 | |
368 | - if (!empty($modSettings['deny_boards_access'])) |
|
369 | - echo ' |
|
382 | + if (!empty($modSettings['deny_boards_access'])) { |
|
383 | + echo ' |
|
370 | 384 | <table> |
371 | 385 | <tr> |
372 | 386 | <td></td> |
@@ -374,10 +388,11 @@ discard block |
||
374 | 388 | <th>', $txt['permissions_option_off'], '</th> |
375 | 389 | <th>', $txt['permissions_option_deny'], '</th> |
376 | 390 | </tr>'; |
391 | + } |
|
377 | 392 | |
378 | 393 | // List all the membergroups so the user can choose who may access this board. |
379 | - foreach ($context['groups'] as $group) |
|
380 | - if (empty($modSettings['deny_boards_access'])) |
|
394 | + foreach ($context['groups'] as $group) { |
|
395 | + if (empty($modSettings['deny_boards_access'])) |
|
381 | 396 | echo ' |
382 | 397 | <label for="groups_', $group['id'], '"> |
383 | 398 | <input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '> |
@@ -385,8 +400,9 @@ discard block |
||
385 | 400 | ', $group['name'], ' |
386 | 401 | </span> |
387 | 402 | </label><br>'; |
388 | - else |
|
389 | - echo ' |
|
403 | + } |
|
404 | + else { |
|
405 | + echo ' |
|
390 | 406 | <tr> |
391 | 407 | <td> |
392 | 408 | <label for="groups_', $group['id'], '_a"> |
@@ -406,16 +422,17 @@ discard block |
||
406 | 422 | </td> |
407 | 423 | <td></td> |
408 | 424 | </tr>'; |
425 | + } |
|
409 | 426 | |
410 | - if (empty($modSettings['deny_boards_access'])) |
|
411 | - echo ' |
|
427 | + if (empty($modSettings['deny_boards_access'])) { |
|
428 | + echo ' |
|
412 | 429 | <span class="select_all_box"> |
413 | 430 | <em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');"> |
414 | 431 | </span> |
415 | 432 | <br><br> |
416 | 433 | </dd>'; |
417 | - else |
|
418 | - echo ' |
|
434 | + } else { |
|
435 | + echo ' |
|
419 | 436 | <tr class="select_all_box"> |
420 | 437 | <td> |
421 | 438 | </td> |
@@ -434,6 +451,7 @@ discard block |
||
434 | 451 | </tr> |
435 | 452 | </table> |
436 | 453 | </dd>'; |
454 | + } |
|
437 | 455 | |
438 | 456 | // Options to choose moderators, specify as announcement board and choose whether to count posts here. |
439 | 457 | echo ' |
@@ -488,8 +506,8 @@ discard block |
||
488 | 506 | </dl> |
489 | 507 | </div>'; |
490 | 508 | |
491 | - if ($context['board']['redirect']) |
|
492 | - echo ' |
|
509 | + if ($context['board']['redirect']) { |
|
510 | + echo ' |
|
493 | 511 | <div id="reset_redirect_div"> |
494 | 512 | <dl class="settings"> |
495 | 513 | <dt> |
@@ -502,6 +520,7 @@ discard block |
||
502 | 520 | </dd> |
503 | 521 | </dl> |
504 | 522 | </div>'; |
523 | + } |
|
505 | 524 | } |
506 | 525 | |
507 | 526 | echo ' |
@@ -529,9 +548,10 @@ discard block |
||
529 | 548 | <select name="boardtheme" id="boardtheme" onchange="refreshOptions();"> |
530 | 549 | <option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>'; |
531 | 550 | |
532 | - foreach ($context['themes'] as $theme) |
|
533 | - echo ' |
|
551 | + foreach ($context['themes'] as $theme) { |
|
552 | + echo ' |
|
534 | 553 | <option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>'; |
554 | + } |
|
535 | 555 | |
536 | 556 | echo ' |
537 | 557 | </select> |
@@ -560,14 +580,15 @@ discard block |
||
560 | 580 | |
561 | 581 | foreach ($context['custom_board_settings'] as $cbs_id => $cbs) |
562 | 582 | { |
563 | - if (!empty($cbs['dt']) && !empty($cbs['dd'])) |
|
564 | - echo ' |
|
583 | + if (!empty($cbs['dt']) && !empty($cbs['dd'])) { |
|
584 | + echo ' |
|
565 | 585 | <dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '"> |
566 | 586 | ', $cbs['dt'], ' |
567 | 587 | </dt> |
568 | 588 | <dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '> |
569 | 589 | ', $cbs['dd'], ' |
570 | 590 | </dd>'; |
591 | + } |
|
571 | 592 | } |
572 | 593 | |
573 | 594 | echo ' |
@@ -575,9 +596,10 @@ discard block |
||
575 | 596 | </div>'; |
576 | 597 | } |
577 | 598 | |
578 | - if (!empty($context['board']['is_recycle'])) |
|
579 | - echo ' |
|
599 | + if (!empty($context['board']['is_recycle'])) { |
|
600 | + echo ' |
|
580 | 601 | <div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>'; |
602 | + } |
|
581 | 603 | |
582 | 604 | echo ' |
583 | 605 | <input type="hidden" name="rid" value="', $context['redirect_location'], '"> |
@@ -585,21 +607,24 @@ discard block |
||
585 | 607 | <input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">'; |
586 | 608 | |
587 | 609 | // If this board has no children don't bother with the next confirmation screen. |
588 | - if ($context['board']['no_children']) |
|
589 | - echo ' |
|
610 | + if ($context['board']['no_children']) { |
|
611 | + echo ' |
|
590 | 612 | <input type="hidden" name="no_children" value="1">'; |
613 | + } |
|
591 | 614 | |
592 | - if (isset($context['board']['is_new'])) |
|
593 | - echo ' |
|
615 | + if (isset($context['board']['is_new'])) { |
|
616 | + echo ' |
|
594 | 617 | <input type="hidden" name="cur_cat" value="', $context['board']['category'], '"> |
595 | 618 | <input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
596 | - else |
|
597 | - echo ' |
|
619 | + } else { |
|
620 | + echo ' |
|
598 | 621 | <input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">'; |
622 | + } |
|
599 | 623 | |
600 | - if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) |
|
601 | - echo ' |
|
624 | + if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) { |
|
625 | + echo ' |
|
602 | 626 | <input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">'; |
627 | + } |
|
603 | 628 | echo ' |
604 | 629 | </div><!-- .windowbg --> |
605 | 630 | </form> |
@@ -620,12 +645,13 @@ discard block |
||
620 | 645 | sItemListContainerId: \'moderator_container\', |
621 | 646 | aListItems: ['; |
622 | 647 | |
623 | - foreach ($context['board']['moderators'] as $id_member => $member_name) |
|
624 | - echo ' |
|
648 | + foreach ($context['board']['moderators'] as $id_member => $member_name) { |
|
649 | + echo ' |
|
625 | 650 | { |
626 | 651 | sItemId: ', JavaScriptEscape($id_member), ', |
627 | 652 | sItemName: ', JavaScriptEscape($member_name), ' |
628 | 653 | }', $id_member == $context['board']['last_moderator_id'] ? '' : ','; |
654 | + } |
|
629 | 655 | |
630 | 656 | echo ' |
631 | 657 | ] |
@@ -645,12 +671,13 @@ discard block |
||
645 | 671 | sItemListContainerId: \'moderator_group_container\', |
646 | 672 | aListItems: ['; |
647 | 673 | |
648 | - foreach ($context['board']['moderator_groups'] as $id_group => $group_name) |
|
649 | - echo ' |
|
674 | + foreach ($context['board']['moderator_groups'] as $id_group => $group_name) { |
|
675 | + echo ' |
|
650 | 676 | { |
651 | 677 | sItemId: ', JavaScriptEscape($id_group), ', |
652 | 678 | sItemName: ', JavaScriptEscape($group_name), ' |
653 | 679 | }', $id_group == $context['board']['last_moderator_group_id'] ? '' : ','; |
680 | + } |
|
654 | 681 | |
655 | 682 | echo ' |
656 | 683 | ] |
@@ -676,17 +703,19 @@ discard block |
||
676 | 703 | echo ' |
677 | 704 | document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";'; |
678 | 705 | |
679 | - if ($context['board']['redirect']) |
|
680 | - echo ' |
|
706 | + if ($context['board']['redirect']) { |
|
707 | + echo ' |
|
681 | 708 | document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";'; |
709 | + } |
|
682 | 710 | } |
683 | 711 | |
684 | 712 | // Include any JavaScript added by mods using the 'integrate_edit_board' hook. |
685 | 713 | if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions'])) |
686 | 714 | { |
687 | - foreach ($context['custom_refreshOptions'] as $refreshOption) |
|
688 | - echo ' |
|
715 | + foreach ($context['custom_refreshOptions'] as $refreshOption) { |
|
716 | + echo ' |
|
689 | 717 | ', $refreshOption; |
718 | + } |
|
690 | 719 | } |
691 | 720 | |
692 | 721 | echo ' |
@@ -715,9 +744,10 @@ discard block |
||
715 | 744 | <p>', $txt['mboards_delete_board_contains'], '</p> |
716 | 745 | <ul>'; |
717 | 746 | |
718 | - foreach ($context['children'] as $child) |
|
719 | - echo ' |
|
747 | + foreach ($context['children'] as $child) { |
|
748 | + echo ' |
|
720 | 749 | <li>', $child['node']['name'], '</li>'; |
750 | + } |
|
721 | 751 | |
722 | 752 | echo ' |
723 | 753 | </ul> |
@@ -731,10 +761,11 @@ discard block |
||
731 | 761 | <label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>: |
732 | 762 | <select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>'; |
733 | 763 | |
734 | - foreach ($context['board_order'] as $board) |
|
735 | - if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
764 | + foreach ($context['board_order'] as $board) { |
|
765 | + if ($board['id'] != $context['board']['id'] && empty($board['is_child'])) |
|
736 | 766 | echo ' |
737 | 767 | <option value="', $board['id'], '">', $board['name'], '</option>'; |
768 | + } |
|
738 | 769 | |
739 | 770 | echo ' |
740 | 771 | </select> |
@@ -28,14 +28,15 @@ discard block |
||
28 | 28 | <div id="confirm_buttons">'; |
29 | 29 | |
30 | 30 | // Age restriction in effect? |
31 | - if ($context['show_coppa']) |
|
32 | - echo ' |
|
31 | + if ($context['show_coppa']) { |
|
32 | + echo ' |
|
33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
34 | 34 | <br> |
35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
36 | - else |
|
37 | - echo ' |
|
36 | + } else { |
|
37 | + echo ' |
|
38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo ' |
41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
78 | 79 | <ul>'; |
79 | 80 | |
80 | 81 | // Cycle through each error and display an error message. |
81 | - foreach ($context['registration_errors'] as $error) |
|
82 | - echo ' |
|
82 | + foreach ($context['registration_errors'] as $error) { |
|
83 | + echo ' |
|
83 | 84 | <li>', $error, '</li>'; |
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
149 | 151 | echo ' |
150 | 152 | <dl class="register_form">'; |
151 | 153 | |
152 | - foreach ($context['custom_fields'] as $field) |
|
153 | - if ($field['show_reg'] > 1) |
|
154 | + foreach ($context['custom_fields'] as $field) { |
|
155 | + if ($field['show_reg'] > 1) |
|
154 | 156 | echo ' |
155 | 157 | <dt> |
156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
158 | 160 | </dt> |
159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
162 | + } |
|
160 | 163 | |
161 | 164 | echo ' |
162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
167 | 170 | </div><!-- .roundframe -->'; |
168 | 171 | |
169 | 172 | // If we have either of these, show the extra group. |
170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
171 | - echo ' |
|
173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
174 | + echo ' |
|
172 | 175 | <div class="title_bar"> |
173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
174 | 177 | </div> |
175 | 178 | <div class="roundframe noup"> |
176 | 179 | <fieldset> |
177 | 180 | <dl class="register_form" id="custom_group">'; |
181 | + } |
|
178 | 182 | |
179 | 183 | if (!empty($context['profile_fields'])) |
180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
189 | 193 | $callback_func(); |
190 | 194 | } |
191 | - } |
|
192 | - else |
|
195 | + } else |
|
193 | 196 | { |
194 | 197 | echo ' |
195 | 198 | <dt> |
196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
197 | 200 | |
198 | 201 | // Does it have any subtext to show? |
199 | - if (!empty($field['subtext'])) |
|
200 | - echo ' |
|
202 | + if (!empty($field['subtext'])) { |
|
203 | + echo ' |
|
201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
205 | + } |
|
202 | 206 | |
203 | 207 | echo ' |
204 | 208 | </dt> |
205 | 209 | <dd>'; |
206 | 210 | |
207 | 211 | // Want to put something infront of the box? |
208 | - if (!empty($field['preinput'])) |
|
209 | - echo ' |
|
212 | + if (!empty($field['preinput'])) { |
|
213 | + echo ' |
|
210 | 214 | ', $field['preinput']; |
215 | + } |
|
211 | 216 | |
212 | 217 | // What type of data are we showing? |
213 | - if ($field['type'] == 'label') |
|
214 | - echo ' |
|
218 | + if ($field['type'] == 'label') { |
|
219 | + echo ' |
|
215 | 220 | ', $field['value']; |
221 | + } |
|
216 | 222 | |
217 | 223 | // Maybe it's a text box - very likely! |
218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
219 | - echo ' |
|
224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
225 | + echo ' |
|
220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
227 | + } |
|
221 | 228 | |
222 | 229 | // You "checking" me out? ;) |
223 | - elseif ($field['type'] == 'check') |
|
224 | - echo ' |
|
230 | + elseif ($field['type'] == 'check') { |
|
231 | + echo ' |
|
225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
233 | + } |
|
226 | 234 | |
227 | 235 | // Always fun - select boxes! |
228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
233 | 241 | if (isset($field['options'])) |
234 | 242 | { |
235 | 243 | // Is this some code to generate the options? |
236 | - if (!is_array($field['options'])) |
|
237 | - $field['options'] = eval($field['options']); |
|
244 | + if (!is_array($field['options'])) { |
|
245 | + $field['options'] = eval($field['options']); |
|
246 | + } |
|
238 | 247 | |
239 | 248 | // Assuming we now have some! |
240 | - if (is_array($field['options'])) |
|
241 | - foreach ($field['options'] as $value => $name) |
|
249 | + if (is_array($field['options'])) { |
|
250 | + foreach ($field['options'] as $value => $name) |
|
242 | 251 | echo ' |
243 | 252 | <option', is_numeric($value) ? ' value="" disabled' : ' value="' . $value . '"', $value === $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
248 | 258 | } |
249 | 259 | |
250 | 260 | // Something to end with? |
251 | - if (!empty($field['postinput'])) |
|
252 | - echo ' |
|
261 | + if (!empty($field['postinput'])) { |
|
262 | + echo ' |
|
253 | 263 | ', $field['postinput']; |
264 | + } |
|
254 | 265 | |
255 | 266 | echo ' |
256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
261 | 272 | // Are there any custom fields? |
262 | 273 | if (!empty($context['custom_fields'])) |
263 | 274 | { |
264 | - foreach ($context['custom_fields'] as $field) |
|
265 | - if ($field['show_reg'] < 2) |
|
275 | + foreach ($context['custom_fields'] as $field) { |
|
276 | + if ($field['show_reg'] < 2) |
|
266 | 277 | echo ' |
267 | 278 | <dt> |
268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
270 | 281 | </dt> |
271 | 282 | <dd>', $field['input_html'], '</dd>'; |
283 | + } |
|
272 | 284 | } |
273 | 285 | |
274 | 286 | // If we have either of these, close the list like a proper gent. |
275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
276 | - echo ' |
|
287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
288 | + echo ' |
|
277 | 289 | </dl> |
278 | 290 | </fieldset> |
279 | 291 | </div><!-- .roundframe -->'; |
292 | + } |
|
280 | 293 | |
281 | - if ($context['visual_verification']) |
|
282 | - echo ' |
|
294 | + if ($context['visual_verification']) { |
|
295 | + echo ' |
|
283 | 296 | <div class="title_bar"> |
284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
289 | 302 | </fieldset> |
290 | 303 | </div>'; |
304 | + } |
|
291 | 305 | |
292 | 306 | echo ' |
293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
294 | 308 | |
295 | 309 | // Age restriction in effect? |
296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
297 | - echo ' |
|
310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
311 | + echo ' |
|
298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
299 | 313 | <br> |
300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
301 | - else |
|
302 | - echo ' |
|
315 | + } else { |
|
316 | + echo ' |
|
303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
318 | + } |
|
304 | 319 | |
305 | 320 | echo ' |
306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
363 | 378 | |
364 | 379 | // Can they send by post? |
365 | - if (!empty($context['coppa']['post'])) |
|
366 | - echo ' |
|
380 | + if (!empty($context['coppa']['post'])) { |
|
381 | + echo ' |
|
367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
368 | 383 | <div class="coppa_contact"> |
369 | 384 | ', $context['coppa']['post'], ' |
370 | 385 | </div>'; |
386 | + } |
|
371 | 387 | |
372 | 388 | // Can they send by fax?? |
373 | - if (!empty($context['coppa']['fax'])) |
|
374 | - echo ' |
|
389 | + if (!empty($context['coppa']['fax'])) { |
|
390 | + echo ' |
|
375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
376 | 392 | <div class="coppa_contact"> |
377 | 393 | ', $context['coppa']['fax'], ' |
378 | 394 | </div>'; |
395 | + } |
|
379 | 396 | |
380 | 397 | // Offer an alternative Phone Number? |
381 | - if ($context['coppa']['phone']) |
|
382 | - echo ' |
|
398 | + if ($context['coppa']['phone']) { |
|
399 | + echo ' |
|
383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
401 | + } |
|
384 | 402 | |
385 | 403 | echo ' |
386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
445 | 463 | <body style="margin: 1ex;"> |
446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
447 | 465 | |
448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
449 | - echo ' |
|
466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
467 | + echo ' |
|
450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
451 | 469 | <param name="AutoStart" value="1"> |
452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
453 | 471 | </object>'; |
454 | - else |
|
455 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
459 | 477 | </object> |
460 | 478 | </audio>'; |
479 | + } |
|
461 | 480 | |
462 | 481 | echo ' |
463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
485 | 504 | </div> |
486 | 505 | <div id="register_screen" class="windowbg">'; |
487 | 506 | |
488 | - if (!empty($context['registration_done'])) |
|
489 | - echo ' |
|
507 | + if (!empty($context['registration_done'])) { |
|
508 | + echo ' |
|
490 | 509 | <div class="infobox"> |
491 | 510 | ', $context['registration_done'], ' |
492 | 511 | </div>'; |
512 | + } |
|
493 | 513 | |
494 | 514 | echo ' |
495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
525 | 545 | <dd> |
526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
527 | 547 | |
528 | - foreach ($context['member_groups'] as $id => $name) |
|
529 | - echo ' |
|
548 | + foreach ($context['member_groups'] as $id => $name) { |
|
549 | + echo ' |
|
530 | 550 | <option value="', $id, '">', $name, '</option>'; |
551 | + } |
|
531 | 552 | |
532 | 553 | echo ' |
533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
535 | 556 | } |
536 | 557 | |
537 | 558 | // If there is any field marked as required, show it here! |
538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
539 | - foreach ($context['custom_fields'] as $field) |
|
559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
560 | + foreach ($context['custom_fields'] as $field) |
|
540 | 561 | if ($field['show_reg'] > 1) |
541 | 562 | echo ' |
542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
546 | 567 | <dd> |
547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
548 | 569 | </dd>'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | <dt> |
@@ -582,18 +604,19 @@ discard block |
||
582 | 604 | { |
583 | 605 | global $context, $scripturl, $txt; |
584 | 606 | |
585 | - if (!empty($context['saved_successful'])) |
|
586 | - echo ' |
|
607 | + if (!empty($context['saved_successful'])) { |
|
608 | + echo ' |
|
587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
588 | - |
|
589 | - elseif (!empty($context['could_not_save'])) |
|
590 | - echo ' |
|
610 | + } elseif (!empty($context['could_not_save'])) { |
|
611 | + echo ' |
|
591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
613 | + } |
|
592 | 614 | |
593 | 615 | // Warning for if the file isn't writable. |
594 | - if (!empty($context['warning'])) |
|
595 | - echo ' |
|
616 | + if (!empty($context['warning'])) { |
|
617 | + echo ' |
|
596 | 618 | <div class="errorbox">', $context['warning'], '</div>'; |
619 | + } |
|
597 | 620 | |
598 | 621 | // Just a big box to edit the text file ;) |
599 | 622 | echo ' |
@@ -615,9 +638,10 @@ discard block |
||
615 | 638 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
616 | 639 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
617 | 640 | |
618 | - foreach ($context['editable_agreements'] as $file => $name) |
|
619 | - echo ' |
|
641 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
642 | + echo ' |
|
620 | 643 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
644 | + } |
|
621 | 645 | |
622 | 646 | echo ' |
623 | 647 | </select> |
@@ -657,9 +681,10 @@ discard block |
||
657 | 681 | { |
658 | 682 | global $context, $scripturl, $txt; |
659 | 683 | |
660 | - if (!empty($context['saved_successful'])) |
|
661 | - echo ' |
|
684 | + if (!empty($context['saved_successful'])) { |
|
685 | + echo ' |
|
662 | 686 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
687 | + } |
|
663 | 688 | |
664 | 689 | echo ' |
665 | 690 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -29,9 +29,10 @@ discard block |
||
29 | 29 | <strong>', $txt['ban_errors_detected'], '</strong> |
30 | 30 | <ul>'; |
31 | 31 | |
32 | - foreach ($context['error_messages'] as $error) |
|
33 | - echo ' |
|
32 | + foreach ($context['error_messages'] as $error) { |
|
33 | + echo ' |
|
34 | 34 | <li class="error">', $error, '</li>'; |
35 | + } |
|
35 | 36 | |
36 | 37 | echo ' |
37 | 38 | </ul> |
@@ -45,9 +46,10 @@ discard block |
||
45 | 46 | </h3> |
46 | 47 | </div>'; |
47 | 48 | |
48 | - if ($context['ban']['is_new']) |
|
49 | - echo ' |
|
49 | + if ($context['ban']['is_new']) { |
|
50 | + echo ' |
|
50 | 51 | <div class="information noup">', $txt['ban_add_notes'], '</div>'; |
52 | + } |
|
51 | 53 | |
52 | 54 | echo ' |
53 | 55 | <div class="windowbg noup"> |
@@ -59,8 +61,8 @@ discard block |
||
59 | 61 | <input type="text" id="ban_name" name="ban_name" value="', $context['ban']['name'], '" size="45" maxlength="60"> |
60 | 62 | </dd>'; |
61 | 63 | |
62 | - if (isset($context['ban']['reason'])) |
|
63 | - echo ' |
|
64 | + if (isset($context['ban']['reason'])) { |
|
65 | + echo ' |
|
64 | 66 | <dt> |
65 | 67 | <strong><label for="reason">', $txt['ban_reason'], ':</label></strong><br> |
66 | 68 | <span class="smalltext">', $txt['ban_reason_desc'], '</span> |
@@ -68,9 +70,10 @@ discard block |
||
68 | 70 | <dd> |
69 | 71 | <textarea name="reason" id="reason" cols="40" rows="3">', $context['ban']['reason'], '</textarea> |
70 | 72 | </dd>'; |
73 | + } |
|
71 | 74 | |
72 | - if (isset($context['ban']['notes'])) |
|
73 | - echo ' |
|
75 | + if (isset($context['ban']['notes'])) { |
|
76 | + echo ' |
|
74 | 77 | <dt> |
75 | 78 | <strong><label for="ban_notes">', $txt['ban_notes'], ':</label></strong><br> |
76 | 79 | <span class="smalltext">', $txt['ban_notes_desc'], '</span> |
@@ -78,6 +81,7 @@ discard block |
||
78 | 81 | <dd> |
79 | 82 | <textarea name="notes" id="ban_notes" cols="40" rows="3">', $context['ban']['notes'], '</textarea> |
80 | 83 | </dd>'; |
84 | + } |
|
81 | 85 | |
82 | 86 | echo ' |
83 | 87 | </dl> |
@@ -117,8 +121,8 @@ discard block |
||
117 | 121 | <input type="text" name="main_ip" value="', $context['ban_suggestions']['main_ip'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
118 | 122 | </dd>'; |
119 | 123 | |
120 | - if (empty($modSettings['disableHostnameLookup'])) |
|
121 | - echo ' |
|
124 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
125 | + echo ' |
|
122 | 126 | <dt> |
123 | 127 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', !empty($context['ban_suggestions']['hostname']) ? ' checked' : '', '> |
124 | 128 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -126,6 +130,7 @@ discard block |
||
126 | 130 | <dd> |
127 | 131 | <input type="text" name="hostname" value="', $context['ban_suggestions']['hostname'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
128 | 132 | </dd>'; |
133 | + } |
|
129 | 134 | |
130 | 135 | echo ' |
131 | 136 | <dt> |
@@ -155,14 +160,15 @@ discard block |
||
155 | 160 | <dl class="settings">'; |
156 | 161 | |
157 | 162 | $count = 0; |
158 | - foreach ($ban_ips as $ip) |
|
159 | - echo ' |
|
163 | + foreach ($ban_ips as $ip) { |
|
164 | + echo ' |
|
160 | 165 | <dt> |
161 | 166 | <input type="checkbox" id="suggestions_', $key, '_', $count, '" name="ban_suggestions[', $key, '][]"', !empty($context['ban_suggestions']['saved_triggers'][$key]) && in_array($ip, $context['ban_suggestions']['saved_triggers'][$key]) ? ' checked' : '', ' value="', $ip, '"> |
162 | 167 | </dt> |
163 | 168 | <dd> |
164 | 169 | <label for="suggestions_', $key, '_', $count++, '">', $ip, '</label> |
165 | 170 | </dd>'; |
171 | + } |
|
166 | 172 | |
167 | 173 | echo ' |
168 | 174 | </dl>'; |
@@ -204,8 +210,8 @@ discard block |
||
204 | 210 | addLoadEvent(fUpdateStatus);'; |
205 | 211 | |
206 | 212 | // Auto suggest only needed for adding new bans, not editing |
207 | - if ($context['ban']['is_new'] && empty($_REQUEST['u'])) |
|
208 | - echo ' |
|
213 | + if ($context['ban']['is_new'] && empty($_REQUEST['u'])) { |
|
214 | + echo ' |
|
209 | 215 | var oAddMemberSuggest = new smc_AutoSuggest({ |
210 | 216 | sSelf: \'oAddMemberSuggest\', |
211 | 217 | sSessionId: smf_session_id, |
@@ -223,6 +229,7 @@ discard block |
||
223 | 229 | return true; |
224 | 230 | } |
225 | 231 | oAddMemberSuggest.registerCallback(\'onBeforeUpdate\', \'onUpdateName\');'; |
232 | + } |
|
226 | 233 | |
227 | 234 | echo ' |
228 | 235 | function confirmBan(aForm) |
@@ -271,8 +278,8 @@ discard block |
||
271 | 278 | <input type="text" name="main_ip" value="', $context['ban_trigger']['ip']['value'], '" size="44" onfocus="document.getElementById(\'main_ip_check\').checked = true;"> |
272 | 279 | </dd>'; |
273 | 280 | |
274 | - if (empty($modSettings['disableHostnameLookup'])) |
|
275 | - echo ' |
|
281 | + if (empty($modSettings['disableHostnameLookup'])) { |
|
282 | + echo ' |
|
276 | 283 | <dt> |
277 | 284 | <input type="checkbox" name="ban_suggestions[]" id="hostname_check" value="hostname"', $context['ban_trigger']['hostname']['selected'] ? ' checked' : '', '> |
278 | 285 | <label for="hostname_check">', $txt['ban_on_hostname'], '</label> |
@@ -280,6 +287,7 @@ discard block |
||
280 | 287 | <dd> |
281 | 288 | <input type="text" name="hostname" value="', $context['ban_trigger']['hostname']['value'], '" size="44" onfocus="document.getElementById(\'hostname_check\').checked = true;"> |
282 | 289 | </dd>'; |
290 | + } |
|
283 | 291 | |
284 | 292 | echo ' |
285 | 293 | <dt> |