@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Shows an avatar based on $_GET['attach'] |
@@ -35,11 +36,11 @@ discard block |
||
35 | 36 | |
36 | 37 | if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0) |
37 | 38 | { |
38 | - if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') |
|
39 | - $modSettings['enableCompressedOutput'] = 0; |
|
40 | - |
|
41 | - else |
|
42 | - ob_start('ob_gzhandler'); |
|
39 | + if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') { |
|
40 | + $modSettings['enableCompressedOutput'] = 0; |
|
41 | + } else { |
|
42 | + ob_start('ob_gzhandler'); |
|
43 | + } |
|
43 | 44 | } |
44 | 45 | |
45 | 46 | if (empty($modSettings['enableCompressedOutput'])) |
@@ -71,8 +72,9 @@ discard block |
||
71 | 72 | } |
72 | 73 | |
73 | 74 | // Use cache when possible. |
74 | - if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) |
|
75 | - list($file, $thumbFile) = $cache; |
|
75 | + if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) { |
|
76 | + list($file, $thumbFile) = $cache; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | // Get the info from the DB. |
78 | 80 | if (empty($file) || empty($thumbFile) && !empty($file['id_thumb'])) |
@@ -80,10 +82,9 @@ discard block |
||
80 | 82 | // Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request. |
81 | 83 | $attachRequest = null; |
82 | 84 | call_integration_hook('integrate_download_request', array(&$attachRequest)); |
83 | - if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) |
|
84 | - $request = $attachRequest; |
|
85 | - |
|
86 | - else |
|
85 | + if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) { |
|
86 | + $request = $attachRequest; |
|
87 | + } else |
|
87 | 88 | { |
88 | 89 | // Make sure this attachment is on this board and load its info while we are at it. |
89 | 90 | $request = $smcFunc['db_query']('', ' |
@@ -176,13 +177,15 @@ discard block |
||
176 | 177 | } |
177 | 178 | |
178 | 179 | // Cache it. |
179 | - if (!empty($file) || !empty($thumbFile)) |
|
180 | - cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
180 | + if (!empty($file) || !empty($thumbFile)) { |
|
181 | + cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900)); |
|
182 | + } |
|
181 | 183 | } |
182 | 184 | |
183 | 185 | // Replace the normal file with its thumbnail if it has one! |
184 | - if (!empty($showThumb) && !empty($thumbFile)) |
|
185 | - $file = $thumbFile; |
|
186 | + if (!empty($showThumb) && !empty($thumbFile)) { |
|
187 | + $file = $thumbFile; |
|
188 | + } |
|
186 | 189 | |
187 | 190 | // No point in a nicer message, because this is supposed to be an attachment anyway... |
188 | 191 | if (!file_exists($file['filePath'])) |
@@ -232,8 +235,8 @@ discard block |
||
232 | 235 | } |
233 | 236 | |
234 | 237 | // Update the download counter (unless it's a thumbnail or resuming an incomplete download). |
235 | - if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) |
|
236 | - $smcFunc['db_query']('attach_download_increase', ' |
|
238 | + if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) { |
|
239 | + $smcFunc['db_query']('attach_download_increase', ' |
|
237 | 240 | UPDATE LOW_PRIORITY {db_prefix}attachments |
238 | 241 | SET downloads = downloads + 1 |
239 | 242 | WHERE id_attach = {int:id_attach}', |
@@ -241,12 +244,14 @@ discard block |
||
241 | 244 | 'id_attach' => $attachId, |
242 | 245 | ) |
243 | 246 | ); |
247 | + } |
|
244 | 248 | |
245 | 249 | // Send the attachment headers. |
246 | 250 | header('Pragma: '); |
247 | 251 | |
248 | - if (!isBrowser('gecko')) |
|
249 | - header('Content-Transfer-Encoding: binary'); |
|
252 | + if (!isBrowser('gecko')) { |
|
253 | + header('Content-Transfer-Encoding: binary'); |
|
254 | + } |
|
250 | 255 | |
251 | 256 | header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
252 | 257 | header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT'); |
@@ -255,18 +260,19 @@ discard block |
||
255 | 260 | header('ETag: ' . $eTag); |
256 | 261 | |
257 | 262 | // Make sure the mime type warrants an inline display. |
258 | - if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) |
|
259 | - unset($_REQUEST['image']); |
|
263 | + if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) { |
|
264 | + unset($_REQUEST['image']); |
|
265 | + } |
|
260 | 266 | |
261 | 267 | // Does this have a mime type? |
262 | - elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) |
|
263 | - header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
264 | - |
|
265 | - else |
|
268 | + elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) { |
|
269 | + header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp'))); |
|
270 | + } else |
|
266 | 271 | { |
267 | 272 | header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream')); |
268 | - if (isset($_REQUEST['image'])) |
|
269 | - unset($_REQUEST['image']); |
|
273 | + if (isset($_REQUEST['image'])) { |
|
274 | + unset($_REQUEST['image']); |
|
275 | + } |
|
270 | 276 | } |
271 | 277 | |
272 | 278 | // Convert the file to UTF-8, cuz most browsers dig that. |
@@ -274,24 +280,22 @@ discard block |
||
274 | 280 | $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline'; |
275 | 281 | |
276 | 282 | // Different browsers like different standards... |
277 | - if (isBrowser('firefox')) |
|
278 | - header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
279 | - |
|
280 | - elseif (isBrowser('opera')) |
|
281 | - header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
282 | - |
|
283 | - elseif (isBrowser('ie')) |
|
284 | - header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
285 | - |
|
286 | - else |
|
287 | - header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
283 | + if (isBrowser('firefox')) { |
|
284 | + header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name))); |
|
285 | + } elseif (isBrowser('opera')) { |
|
286 | + header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"'); |
|
287 | + } elseif (isBrowser('ie')) { |
|
288 | + header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"'); |
|
289 | + } else { |
|
290 | + header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"'); |
|
291 | + } |
|
288 | 292 | |
289 | 293 | // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE. |
290 | - if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) |
|
291 | - header('Cache-Control: no-cache'); |
|
292 | - |
|
293 | - else |
|
294 | - header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
294 | + if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) { |
|
295 | + header('Cache-Control: no-cache'); |
|
296 | + } else { |
|
297 | + header('Cache-Control: max-age=' . (525600 * 60) . ', private'); |
|
298 | + } |
|
295 | 299 | |
296 | 300 | // Multipart and resuming support |
297 | 301 | if (isset($_SERVER['HTTP_RANGE'])) |
@@ -299,9 +303,9 @@ discard block |
||
299 | 303 | header("HTTP/1.1 206 Partial Content"); |
300 | 304 | header("Content-Length: $new_length"); |
301 | 305 | header("Content-Range: bytes $range-$range_end/$size"); |
306 | + } else { |
|
307 | + header("Content-Length: " . $size); |
|
302 | 308 | } |
303 | - else |
|
304 | - header("Content-Length: " . $size); |
|
305 | 309 | |
306 | 310 | |
307 | 311 | // Try to buy some time... |
@@ -310,8 +314,9 @@ discard block |
||
310 | 314 | // For multipart/resumable downloads, send the requested chunk(s) of the file |
311 | 315 | if (isset($_SERVER['HTTP_RANGE'])) |
312 | 316 | { |
313 | - while (@ob_get_level() > 0) |
|
314 | - @ob_end_clean(); |
|
317 | + while (@ob_get_level() > 0) { |
|
318 | + @ob_end_clean(); |
|
319 | + } |
|
315 | 320 | |
316 | 321 | // 40 kilobytes is a good-ish amount |
317 | 322 | $chunksize = 40 * 1024; |
@@ -335,8 +340,9 @@ discard block |
||
335 | 340 | elseif ($size > 4194304) |
336 | 341 | { |
337 | 342 | // Forcibly end any output buffering going on. |
338 | - while (@ob_get_level() > 0) |
|
339 | - @ob_end_clean(); |
|
343 | + while (@ob_get_level() > 0) { |
|
344 | + @ob_end_clean(); |
|
345 | + } |
|
340 | 346 | |
341 | 347 | $fp = fopen($file['filePath'], 'rb'); |
342 | 348 | while (!feof($fp)) |
@@ -348,8 +354,9 @@ discard block |
||
348 | 354 | } |
349 | 355 | |
350 | 356 | // On some of the less-bright hosts, readfile() is disabled. It's just a faster, more byte safe, version of what's in the if. |
351 | - elseif (@readfile($file['filePath']) === null) |
|
352 | - echo file_get_contents($file['filePath']); |
|
357 | + elseif (@readfile($file['filePath']) === null) { |
|
358 | + echo file_get_contents($file['filePath']); |
|
359 | + } |
|
353 | 360 | |
354 | 361 | die(); |
355 | 362 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | if (!empty($modSettings['search_simple_fulltext'])) |
208 | 208 | { |
209 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
209 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
210 | 210 | { |
211 | 211 | $language_ftx = $smcFunc['db_search_language'](); |
212 | 212 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // remove any indexed words that are used in the complex body search terms |
225 | 225 | $words['indexed_words'] = array_diff($words['indexed_words'], $words['complex_words']); |
226 | 226 | |
227 | - if($smcFunc['db_title'] == "PostgreSQL"){ |
|
227 | + if ($smcFunc['db_title'] == "PostgreSQL") { |
|
228 | 228 | $row = 0; |
229 | 229 | foreach ($words['indexed_words'] as $fulltextWord) { |
230 | 230 | $query_params['boolean_match'] .= ($row <> 0 ? '&' : ''); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | |
241 | 241 | // if we have bool terms to search, add them in |
242 | 242 | if ($query_params['boolean_match']) { |
243 | - if($smcFunc['db_title'] == "PostgreSQL") |
|
243 | + if ($smcFunc['db_title'] == "PostgreSQL") |
|
244 | 244 | { |
245 | 245 | $language_ftx = $smcFunc['db_search_language'](); |
246 | 246 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | - $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? ( ' |
|
256 | + $ignoreRequest = $smcFunc['db_search_query']('insert_into_log_messages_fulltext', ($smcFunc['db_support_ignore'] ? (' |
|
257 | 257 | INSERT IGNORE INTO {db_prefix}' . $search_data['insert_into'] . ' |
258 | 258 | (' . implode(', ', array_keys($query_select)) . ')') : '') . ' |
259 | 259 | SELECT ' . implode(', ', $query_select) . ' |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -98,8 +99,9 @@ discard block |
||
98 | 99 | $smcFunc['db_free_result']($request); |
99 | 100 | } |
100 | 101 | // 4 is the MySQL default... |
101 | - else |
|
102 | - $min_word_length = 4; |
|
102 | + else { |
|
103 | + $min_word_length = 4; |
|
104 | + } |
|
103 | 105 | |
104 | 106 | return $min_word_length; |
105 | 107 | } |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | $wordsSearch['words'][] = trim($word, "/*- "); |
139 | 141 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
140 | 142 | } |
141 | - } |
|
142 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
143 | 144 | { |
144 | 145 | // short words have feelings too |
145 | 146 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -149,8 +150,9 @@ discard block |
||
149 | 150 | |
150 | 151 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
151 | 152 | $wordsSearch['indexed_words'][] = $fulltextWord; |
152 | - if ($isExcluded) |
|
153 | - $wordsExclude[] = $fulltextWord; |
|
153 | + if ($isExcluded) { |
|
154 | + $wordsExclude[] = $fulltextWord; |
|
155 | + } |
|
154 | 156 | } |
155 | 157 | |
156 | 158 | /** |
@@ -166,41 +168,50 @@ discard block |
||
166 | 168 | $query_where = array(); |
167 | 169 | $query_params = $search_data['params']; |
168 | 170 | |
169 | - if ($query_params['id_search']) |
|
170 | - $query_select['id_search'] = '{int:id_search}'; |
|
171 | + if ($query_params['id_search']) { |
|
172 | + $query_select['id_search'] = '{int:id_search}'; |
|
173 | + } |
|
171 | 174 | |
172 | 175 | $count = 0; |
173 | - if (empty($modSettings['search_simple_fulltext'])) |
|
174 | - foreach ($words['words'] as $regularWord) |
|
176 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
177 | + foreach ($words['words'] as $regularWord) |
|
175 | 178 | { |
176 | 179 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
180 | + } |
|
177 | 181 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
178 | 182 | } |
179 | 183 | |
180 | - if ($query_params['user_query']) |
|
181 | - $query_where[] = '{raw:user_query}'; |
|
182 | - if ($query_params['board_query']) |
|
183 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
184 | + if ($query_params['user_query']) { |
|
185 | + $query_where[] = '{raw:user_query}'; |
|
186 | + } |
|
187 | + if ($query_params['board_query']) { |
|
188 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
189 | + } |
|
184 | 190 | |
185 | - if ($query_params['topic']) |
|
186 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
187 | - if ($query_params['min_msg_id']) |
|
188 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
189 | - if ($query_params['max_msg_id']) |
|
190 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
191 | + if ($query_params['topic']) { |
|
192 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
193 | + } |
|
194 | + if ($query_params['min_msg_id']) { |
|
195 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
196 | + } |
|
197 | + if ($query_params['max_msg_id']) { |
|
198 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
199 | + } |
|
191 | 200 | |
192 | 201 | $count = 0; |
193 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
194 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
202 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
203 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
195 | 204 | { |
196 | 205 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
206 | + } |
|
197 | 207 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
198 | 208 | } |
199 | 209 | $count = 0; |
200 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
201 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
210 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
211 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
202 | 212 | { |
203 | 213 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
214 | + } |
|
204 | 215 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
205 | 216 | } |
206 | 217 | |
@@ -212,12 +223,11 @@ discard block |
||
212 | 223 | |
213 | 224 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:body_match})'; |
214 | 225 | $query_params['language_ftx'] = $language_ftx; |
226 | + } else { |
|
227 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
215 | 228 | } |
216 | - else |
|
217 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
218 | 229 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
219 | - } |
|
220 | - else |
|
230 | + } else |
|
221 | 231 | { |
222 | 232 | $query_params['boolean_match'] = ''; |
223 | 233 | |
@@ -231,10 +241,10 @@ discard block |
||
231 | 241 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
232 | 242 | $row++; |
233 | 243 | } |
234 | - } |
|
235 | - else |
|
236 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
244 | + } else { |
|
245 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
237 | 246 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
247 | + } |
|
238 | 248 | |
239 | 249 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
240 | 250 | |
@@ -246,9 +256,9 @@ discard block |
||
246 | 256 | |
247 | 257 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ to_tsquery({string:language_ftx},{string:boolean_match})'; |
248 | 258 | $query_params['language_ftx'] = $language_ftx; |
259 | + } else { |
|
260 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
249 | 261 | } |
250 | - else |
|
251 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
252 | 262 | } |
253 | 263 | |
254 | 264 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Get all birthdays within the given time range. |
@@ -60,8 +61,7 @@ discard block |
||
60 | 61 | 'max_year' => $year_high, |
61 | 62 | ) |
62 | 63 | ); |
63 | - } |
|
64 | - else |
|
64 | + } else |
|
65 | 65 | { |
66 | 66 | $result = $smcFunc['db_query']('birthday_array', ' |
67 | 67 | SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate |
@@ -91,10 +91,11 @@ discard block |
||
91 | 91 | $bday = array(); |
92 | 92 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
93 | 93 | { |
94 | - if ($year_low != $year_high) |
|
95 | - $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | - else |
|
97 | - $age_year = $year_low; |
|
94 | + if ($year_low != $year_high) { |
|
95 | + $age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low; |
|
96 | + } else { |
|
97 | + $age_year = $year_low; |
|
98 | + } |
|
98 | 99 | |
99 | 100 | $bday[$age_year . substr($row['birthdate'], 4)][] = array( |
100 | 101 | 'id' => $row['id_member'], |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | ksort($bday); |
109 | 110 | |
110 | 111 | // Set is_last, so the themes know when to stop placing separators. |
111 | - foreach ($bday as $mday => $array) |
|
112 | - $bday[$mday][count($array) - 1]['is_last'] = true; |
|
112 | + foreach ($bday as $mday => $array) { |
|
113 | + $bday[$mday][count($array) - 1]['is_last'] = true; |
|
114 | + } |
|
113 | 115 | |
114 | 116 | return $bday; |
115 | 117 | } |
@@ -157,8 +159,9 @@ discard block |
||
157 | 159 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
158 | 160 | { |
159 | 161 | // If the attached topic is not approved then for the moment pretend it doesn't exist |
160 | - if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) |
|
161 | - continue; |
|
162 | + if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) { |
|
163 | + continue; |
|
164 | + } |
|
162 | 165 | |
163 | 166 | // Force a censor of the title - as often these are used by others. |
164 | 167 | censorText($row['title'], $use_permissions ? false : true); |
@@ -167,8 +170,9 @@ discard block |
||
167 | 170 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
168 | 171 | |
169 | 172 | // Sanity check |
170 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
171 | - continue; |
|
173 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
174 | + continue; |
|
175 | + } |
|
172 | 176 | |
173 | 177 | // Get set up for the loop |
174 | 178 | $start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz)); |
@@ -232,8 +236,8 @@ discard block |
||
232 | 236 | ); |
233 | 237 | |
234 | 238 | // If we're using permissions (calendar pages?) then just ouput normal contextual style information. |
235 | - if ($use_permissions) |
|
236 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
239 | + if ($use_permissions) { |
|
240 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
237 | 241 | 'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
238 | 242 | 'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
239 | 243 | 'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')), |
@@ -241,9 +245,10 @@ discard block |
||
241 | 245 | 'can_export' => !empty($modSettings['cal_export']) ? true : false, |
242 | 246 | 'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'], |
243 | 247 | )); |
248 | + } |
|
244 | 249 | // Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info. |
245 | - else |
|
246 | - $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
250 | + else { |
|
251 | + $events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array( |
|
247 | 252 | 'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0', |
248 | 253 | 'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>', |
249 | 254 | 'can_edit' => false, |
@@ -253,6 +258,7 @@ discard block |
||
253 | 258 | 'poster' => $row['id_member'], |
254 | 259 | 'allowed_groups' => explode(',', $row['member_groups']), |
255 | 260 | )); |
261 | + } |
|
256 | 262 | |
257 | 263 | date_add($cal_date, date_interval_create_from_date_string('1 day')); |
258 | 264 | } |
@@ -262,8 +268,9 @@ discard block |
||
262 | 268 | // If we're doing normal contextual data, go through and make things clear to the templates ;). |
263 | 269 | if ($use_permissions) |
264 | 270 | { |
265 | - foreach ($events as $mday => $array) |
|
266 | - $events[$mday][count($array) - 1]['is_last'] = true; |
|
271 | + foreach ($events as $mday => $array) { |
|
272 | + $events[$mday][count($array) - 1]['is_last'] = true; |
|
273 | + } |
|
267 | 274 | } |
268 | 275 | |
269 | 276 | ksort($events); |
@@ -283,11 +290,12 @@ discard block |
||
283 | 290 | global $smcFunc; |
284 | 291 | |
285 | 292 | // Get the lowest and highest dates for "all years". |
286 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
287 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
293 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
294 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec} |
|
288 | 295 | OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}'; |
289 | - else |
|
290 | - $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
296 | + } else { |
|
297 | + $allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}'; |
|
298 | + } |
|
291 | 299 | |
292 | 300 | // Find some holidays... ;). |
293 | 301 | $result = $smcFunc['db_query']('', ' |
@@ -307,10 +315,11 @@ discard block |
||
307 | 315 | $holidays = array(); |
308 | 316 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
309 | 317 | { |
310 | - if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) |
|
311 | - $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
312 | - else |
|
313 | - $event_year = substr($low_date, 0, 4); |
|
318 | + if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) { |
|
319 | + $event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4); |
|
320 | + } else { |
|
321 | + $event_year = substr($low_date, 0, 4); |
|
322 | + } |
|
314 | 323 | |
315 | 324 | $holidays[$event_year . substr($row['event_date'], 4)][] = $row['title']; |
316 | 325 | } |
@@ -336,10 +345,12 @@ discard block |
||
336 | 345 | isAllowedTo('calendar_post'); |
337 | 346 | |
338 | 347 | // No board? No topic?!? |
339 | - if (empty($board)) |
|
340 | - fatal_lang_error('missing_board_id', false); |
|
341 | - if (empty($topic)) |
|
342 | - fatal_lang_error('missing_topic_id', false); |
|
348 | + if (empty($board)) { |
|
349 | + fatal_lang_error('missing_board_id', false); |
|
350 | + } |
|
351 | + if (empty($topic)) { |
|
352 | + fatal_lang_error('missing_topic_id', false); |
|
353 | + } |
|
343 | 354 | |
344 | 355 | // Administrator, Moderator, or owner. Period. |
345 | 356 | if (!allowedTo('admin_forum') && !allowedTo('moderate_board')) |
@@ -357,12 +368,14 @@ discard block |
||
357 | 368 | if ($row = $smcFunc['db_fetch_assoc']($result)) |
358 | 369 | { |
359 | 370 | // Not the owner of the topic. |
360 | - if ($row['id_member_started'] != $user_info['id']) |
|
361 | - fatal_lang_error('not_your_topic', 'user'); |
|
371 | + if ($row['id_member_started'] != $user_info['id']) { |
|
372 | + fatal_lang_error('not_your_topic', 'user'); |
|
373 | + } |
|
362 | 374 | } |
363 | 375 | // Topic/Board doesn't exist..... |
364 | - else |
|
365 | - fatal_lang_error('calendar_no_topic', 'general'); |
|
376 | + else { |
|
377 | + fatal_lang_error('calendar_no_topic', 'general'); |
|
378 | + } |
|
366 | 379 | $smcFunc['db_free_result']($result); |
367 | 380 | } |
368 | 381 | } |
@@ -450,14 +463,16 @@ discard block |
||
450 | 463 | if (!empty($calendarOptions['start_day'])) |
451 | 464 | { |
452 | 465 | $nShift -= $calendarOptions['start_day']; |
453 | - if ($nShift < 0) |
|
454 | - $nShift = 7 + $nShift; |
|
466 | + if ($nShift < 0) { |
|
467 | + $nShift = 7 + $nShift; |
|
468 | + } |
|
455 | 469 | } |
456 | 470 | |
457 | 471 | // Number of rows required to fit the month. |
458 | 472 | $nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7); |
459 | - if (($month_info['last_day']['day_of_month'] + $nShift) % 7) |
|
460 | - $nRows++; |
|
473 | + if (($month_info['last_day']['day_of_month'] + $nShift) % 7) { |
|
474 | + $nRows++; |
|
475 | + } |
|
461 | 476 | |
462 | 477 | // Fetch the arrays for birthdays, posted events, and holidays. |
463 | 478 | $bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array(); |
@@ -470,8 +485,9 @@ discard block |
||
470 | 485 | { |
471 | 486 | $calendarGrid['week_days'][] = $count; |
472 | 487 | $count++; |
473 | - if ($count == 7) |
|
474 | - $count = 0; |
|
488 | + if ($count == 7) { |
|
489 | + $count = 0; |
|
490 | + } |
|
475 | 491 | } |
476 | 492 | |
477 | 493 | // Iterate through each week. |
@@ -488,8 +504,9 @@ discard block |
||
488 | 504 | { |
489 | 505 | $nDay = ($nRow * 7) + $nCol - $nShift + 1; |
490 | 506 | |
491 | - if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) |
|
492 | - $nDay = 0; |
|
507 | + if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) { |
|
508 | + $nDay = 0; |
|
509 | + } |
|
493 | 510 | |
494 | 511 | $date = sprintf('%04d-%02d-%02d', $year, $month, $nDay); |
495 | 512 | |
@@ -507,8 +524,9 @@ discard block |
||
507 | 524 | } |
508 | 525 | |
509 | 526 | // What is the last day of the month? |
510 | - if ($is_previous === true) |
|
511 | - $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
527 | + if ($is_previous === true) { |
|
528 | + $calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month']; |
|
529 | + } |
|
512 | 530 | |
513 | 531 | // We'll use the shift in the template. |
514 | 532 | $calendarGrid['shift'] = $nShift; |
@@ -542,8 +560,9 @@ discard block |
||
542 | 560 | { |
543 | 561 | // Here we offset accordingly to get things to the real start of a week. |
544 | 562 | $date_diff = $day_of_week - $calendarOptions['start_day']; |
545 | - if ($date_diff < 0) |
|
546 | - $date_diff += 7; |
|
563 | + if ($date_diff < 0) { |
|
564 | + $date_diff += 7; |
|
565 | + } |
|
547 | 566 | $new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400; |
548 | 567 | $day = (int) strftime('%d', $new_timestamp); |
549 | 568 | $month = (int) strftime('%m', $new_timestamp); |
@@ -673,18 +692,20 @@ discard block |
||
673 | 692 | { |
674 | 693 | foreach ($date_events as $event_key => $event_val) |
675 | 694 | { |
676 | - if (in_array($event_val['id'], $temp)) |
|
677 | - unset($calendarGrid['events'][$date][$event_key]); |
|
678 | - else |
|
679 | - $temp[] = $event_val['id']; |
|
695 | + if (in_array($event_val['id'], $temp)) { |
|
696 | + unset($calendarGrid['events'][$date][$event_key]); |
|
697 | + } else { |
|
698 | + $temp[] = $event_val['id']; |
|
699 | + } |
|
680 | 700 | } |
681 | 701 | } |
682 | 702 | |
683 | 703 | // Give birthdays and holidays a friendly format, without the year |
684 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
685 | - $date_format = '%b %d'; |
|
686 | - else |
|
687 | - $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
704 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
705 | + $date_format = '%b %d'; |
|
706 | + } else { |
|
707 | + $date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]); |
|
708 | + } |
|
688 | 709 | |
689 | 710 | foreach (array('birthdays', 'holidays') as $type) |
690 | 711 | { |
@@ -779,8 +800,9 @@ discard block |
||
779 | 800 | // Holidays between now and now + days. |
780 | 801 | for ($i = $now; $i < $now + $days_for_index; $i += 86400) |
781 | 802 | { |
782 | - if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) |
|
783 | - $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
803 | + if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) { |
|
804 | + $return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]); |
|
805 | + } |
|
784 | 806 | } |
785 | 807 | |
786 | 808 | // Happy Birthday, guys and gals! |
@@ -789,8 +811,9 @@ discard block |
||
789 | 811 | $loop_date = strftime('%Y-%m-%d', $i); |
790 | 812 | if (isset($cached_data['birthdays'][$loop_date])) |
791 | 813 | { |
792 | - foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) |
|
793 | - $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
814 | + foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) { |
|
815 | + $cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date']; |
|
816 | + } |
|
794 | 817 | $return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]); |
795 | 818 | } |
796 | 819 | } |
@@ -802,8 +825,9 @@ discard block |
||
802 | 825 | $loop_date = strftime('%Y-%m-%d', $i); |
803 | 826 | |
804 | 827 | // No events today? Check the next day. |
805 | - if (empty($cached_data['events'][$loop_date])) |
|
806 | - continue; |
|
828 | + if (empty($cached_data['events'][$loop_date])) { |
|
829 | + continue; |
|
830 | + } |
|
807 | 831 | |
808 | 832 | // Loop through all events to add a few last-minute values. |
809 | 833 | foreach ($cached_data['events'][$loop_date] as $ev => $event) |
@@ -816,9 +840,9 @@ discard block |
||
816 | 840 | { |
817 | 841 | unset($cached_data['events'][$loop_date][$ev]); |
818 | 842 | continue; |
843 | + } else { |
|
844 | + $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
819 | 845 | } |
820 | - else |
|
821 | - $duplicates[$this_event['topic'] . $this_event['title']] = true; |
|
822 | 846 | |
823 | 847 | // Might be set to true afterwards, depending on the permissions. |
824 | 848 | $this_event['can_edit'] = false; |
@@ -826,15 +850,18 @@ discard block |
||
826 | 850 | $this_event['date'] = $loop_date; |
827 | 851 | } |
828 | 852 | |
829 | - if (!empty($cached_data['events'][$loop_date])) |
|
830 | - $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
853 | + if (!empty($cached_data['events'][$loop_date])) { |
|
854 | + $return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]); |
|
855 | + } |
|
831 | 856 | } |
832 | 857 | |
833 | 858 | // Mark the last item so that a list separator can be used in the template. |
834 | - for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) |
|
835 | - $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
836 | - for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) |
|
837 | - $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
859 | + for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) { |
|
860 | + $return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]); |
|
861 | + } |
|
862 | + for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) { |
|
863 | + $return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]); |
|
864 | + } |
|
838 | 865 | |
839 | 866 | return array( |
840 | 867 | 'data' => $return_data, |
@@ -882,37 +909,46 @@ discard block |
||
882 | 909 | if (isset($_POST['start_date'])) |
883 | 910 | { |
884 | 911 | $d = date_parse($_POST['start_date']); |
885 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
886 | - fatal_lang_error('invalid_date', false); |
|
887 | - if (empty($d['year'])) |
|
888 | - fatal_lang_error('event_year_missing', false); |
|
889 | - if (empty($d['month'])) |
|
890 | - fatal_lang_error('event_month_missing', false); |
|
891 | - } |
|
892 | - elseif (isset($_POST['start_datetime'])) |
|
912 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
913 | + fatal_lang_error('invalid_date', false); |
|
914 | + } |
|
915 | + if (empty($d['year'])) { |
|
916 | + fatal_lang_error('event_year_missing', false); |
|
917 | + } |
|
918 | + if (empty($d['month'])) { |
|
919 | + fatal_lang_error('event_month_missing', false); |
|
920 | + } |
|
921 | + } elseif (isset($_POST['start_datetime'])) |
|
893 | 922 | { |
894 | 923 | $d = date_parse($_POST['start_datetime']); |
895 | - if (!empty($d['error_count']) || !empty($d['warning_count'])) |
|
896 | - fatal_lang_error('invalid_date', false); |
|
897 | - if (empty($d['year'])) |
|
898 | - fatal_lang_error('event_year_missing', false); |
|
899 | - if (empty($d['month'])) |
|
900 | - fatal_lang_error('event_month_missing', false); |
|
924 | + if (!empty($d['error_count']) || !empty($d['warning_count'])) { |
|
925 | + fatal_lang_error('invalid_date', false); |
|
926 | + } |
|
927 | + if (empty($d['year'])) { |
|
928 | + fatal_lang_error('event_year_missing', false); |
|
929 | + } |
|
930 | + if (empty($d['month'])) { |
|
931 | + fatal_lang_error('event_month_missing', false); |
|
932 | + } |
|
901 | 933 | } |
902 | 934 | // The 2.0 way |
903 | 935 | else |
904 | 936 | { |
905 | 937 | // No month? No year? |
906 | - if (!isset($_POST['month'])) |
|
907 | - fatal_lang_error('event_month_missing', false); |
|
908 | - if (!isset($_POST['year'])) |
|
909 | - fatal_lang_error('event_year_missing', false); |
|
938 | + if (!isset($_POST['month'])) { |
|
939 | + fatal_lang_error('event_month_missing', false); |
|
940 | + } |
|
941 | + if (!isset($_POST['year'])) { |
|
942 | + fatal_lang_error('event_year_missing', false); |
|
943 | + } |
|
910 | 944 | |
911 | 945 | // Check the month and year... |
912 | - if ($_POST['month'] < 1 || $_POST['month'] > 12) |
|
913 | - fatal_lang_error('invalid_month', false); |
|
914 | - if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) |
|
915 | - fatal_lang_error('invalid_year', false); |
|
946 | + if ($_POST['month'] < 1 || $_POST['month'] > 12) { |
|
947 | + fatal_lang_error('invalid_month', false); |
|
948 | + } |
|
949 | + if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) { |
|
950 | + fatal_lang_error('invalid_year', false); |
|
951 | + } |
|
916 | 952 | } |
917 | 953 | } |
918 | 954 | |
@@ -922,8 +958,9 @@ discard block |
||
922 | 958 | // If they want to us to calculate an end date, make sure it will fit in an acceptable range. |
923 | 959 | if (isset($_POST['span'])) |
924 | 960 | { |
925 | - if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) |
|
926 | - fatal_lang_error('invalid_days_numb', false); |
|
961 | + if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) { |
|
962 | + fatal_lang_error('invalid_days_numb', false); |
|
963 | + } |
|
927 | 964 | } |
928 | 965 | |
929 | 966 | // There is no need to validate the following values if we are just deleting the event. |
@@ -933,24 +970,29 @@ discard block |
||
933 | 970 | if (empty($_POST['start_date']) && empty($_POST['start_datetime'])) |
934 | 971 | { |
935 | 972 | // No day? |
936 | - if (!isset($_POST['day'])) |
|
937 | - fatal_lang_error('event_day_missing', false); |
|
973 | + if (!isset($_POST['day'])) { |
|
974 | + fatal_lang_error('event_day_missing', false); |
|
975 | + } |
|
938 | 976 | |
939 | 977 | // Bad day? |
940 | - if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) |
|
941 | - fatal_lang_error('invalid_date', false); |
|
978 | + if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) { |
|
979 | + fatal_lang_error('invalid_date', false); |
|
980 | + } |
|
942 | 981 | } |
943 | 982 | |
944 | - if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) |
|
945 | - fatal_lang_error('event_title_missing', false); |
|
946 | - elseif (!isset($_POST['evtitle'])) |
|
947 | - $_POST['evtitle'] = $_POST['subject']; |
|
983 | + if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) { |
|
984 | + fatal_lang_error('event_title_missing', false); |
|
985 | + } elseif (!isset($_POST['evtitle'])) { |
|
986 | + $_POST['evtitle'] = $_POST['subject']; |
|
987 | + } |
|
948 | 988 | |
949 | 989 | // No title? |
950 | - if ($smcFunc['htmltrim']($_POST['evtitle']) === '') |
|
951 | - fatal_lang_error('no_event_title', false); |
|
952 | - if ($smcFunc['strlen']($_POST['evtitle']) > 100) |
|
953 | - $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
990 | + if ($smcFunc['htmltrim']($_POST['evtitle']) === '') { |
|
991 | + fatal_lang_error('no_event_title', false); |
|
992 | + } |
|
993 | + if ($smcFunc['strlen']($_POST['evtitle']) > 100) { |
|
994 | + $_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100); |
|
995 | + } |
|
954 | 996 | $_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']); |
955 | 997 | } |
956 | 998 | } |
@@ -977,8 +1019,9 @@ discard block |
||
977 | 1019 | ); |
978 | 1020 | |
979 | 1021 | // No results, return false. |
980 | - if ($smcFunc['db_num_rows'] === 0) |
|
981 | - return false; |
|
1022 | + if ($smcFunc['db_num_rows'] === 0) { |
|
1023 | + return false; |
|
1024 | + } |
|
982 | 1025 | |
983 | 1026 | // Grab the results and return. |
984 | 1027 | list ($poster) = $smcFunc['db_fetch_row']($request); |
@@ -1112,8 +1155,9 @@ discard block |
||
1112 | 1155 | call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters)); |
1113 | 1156 | |
1114 | 1157 | $column_clauses = array(); |
1115 | - foreach ($event_columns as $col => $crit) |
|
1116 | - $column_clauses[] = $col . ' = ' . $crit; |
|
1158 | + foreach ($event_columns as $col => $crit) { |
|
1159 | + $column_clauses[] = $col . ' = ' . $crit; |
|
1160 | + } |
|
1117 | 1161 | |
1118 | 1162 | $smcFunc['db_query']('', ' |
1119 | 1163 | UPDATE {db_prefix}calendar |
@@ -1198,8 +1242,9 @@ discard block |
||
1198 | 1242 | ); |
1199 | 1243 | |
1200 | 1244 | // If nothing returned, we are in poo, poo. |
1201 | - if ($smcFunc['db_num_rows']($request) === 0) |
|
1202 | - return false; |
|
1245 | + if ($smcFunc['db_num_rows']($request) === 0) { |
|
1246 | + return false; |
|
1247 | + } |
|
1203 | 1248 | |
1204 | 1249 | $row = $smcFunc['db_fetch_assoc']($request); |
1205 | 1250 | $smcFunc['db_free_result']($request); |
@@ -1207,8 +1252,9 @@ discard block |
||
1207 | 1252 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
1208 | 1253 | |
1209 | 1254 | // Sanity check |
1210 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
1211 | - return false; |
|
1255 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
1256 | + return false; |
|
1257 | + } |
|
1212 | 1258 | |
1213 | 1259 | $return_value = array( |
1214 | 1260 | 'boards' => array(), |
@@ -1345,24 +1391,27 @@ discard block |
||
1345 | 1391 | |
1346 | 1392 | // Set $span, in case we need it |
1347 | 1393 | $span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0); |
1348 | - if ($span > 0) |
|
1349 | - $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1394 | + if ($span > 0) { |
|
1395 | + $span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1; |
|
1396 | + } |
|
1350 | 1397 | |
1351 | 1398 | // Define the timezone for this event, falling back to the default if not provided |
1352 | - if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1353 | - $tz = $eventOptions['tz']; |
|
1354 | - elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1355 | - $tz = $_POST['tz']; |
|
1356 | - else |
|
1357 | - $tz = getUserTimezone(); |
|
1399 | + if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1400 | + $tz = $eventOptions['tz']; |
|
1401 | + } elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1402 | + $tz = $_POST['tz']; |
|
1403 | + } else { |
|
1404 | + $tz = getUserTimezone(); |
|
1405 | + } |
|
1358 | 1406 | |
1359 | 1407 | // Is this supposed to be an all day event, or should it have specific start and end times? |
1360 | - if (isset($eventOptions['allday'])) |
|
1361 | - $allday = $eventOptions['allday']; |
|
1362 | - elseif (empty($_POST['allday'])) |
|
1363 | - $allday = false; |
|
1364 | - else |
|
1365 | - $allday = true; |
|
1408 | + if (isset($eventOptions['allday'])) { |
|
1409 | + $allday = $eventOptions['allday']; |
|
1410 | + } elseif (empty($_POST['allday'])) { |
|
1411 | + $allday = false; |
|
1412 | + } else { |
|
1413 | + $allday = true; |
|
1414 | + } |
|
1366 | 1415 | |
1367 | 1416 | // Input might come as individual parameters... |
1368 | 1417 | $start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null); |
@@ -1389,10 +1438,12 @@ discard block |
||
1389 | 1438 | $end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null); |
1390 | 1439 | |
1391 | 1440 | // If the date and time were given in separate strings, combine them |
1392 | - if (empty($start_string) && isset($start_date_string)) |
|
1393 | - $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1394 | - if (empty($end_string) && isset($end_date_string)) |
|
1395 | - $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1441 | + if (empty($start_string) && isset($start_date_string)) { |
|
1442 | + $start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : ''); |
|
1443 | + } |
|
1444 | + if (empty($end_string) && isset($end_date_string)) { |
|
1445 | + $end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : ''); |
|
1446 | + } |
|
1396 | 1447 | |
1397 | 1448 | // If some form of string input was given, override individually defined options with it |
1398 | 1449 | if (isset($start_string)) |
@@ -1483,10 +1534,11 @@ discard block |
||
1483 | 1534 | if ($start_object >= $end_object) |
1484 | 1535 | { |
1485 | 1536 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1486 | - if ($span > 0) |
|
1487 | - date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1488 | - else |
|
1489 | - date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1537 | + if ($span > 0) { |
|
1538 | + date_add($end_object, date_interval_create_from_date_string($span . ' days')); |
|
1539 | + } else { |
|
1540 | + date_add($end_object, date_interval_create_from_date_string('1 hour')); |
|
1541 | + } |
|
1490 | 1542 | } |
1491 | 1543 | |
1492 | 1544 | // Is $end_object too late? |
@@ -1499,9 +1551,9 @@ discard block |
||
1499 | 1551 | { |
1500 | 1552 | $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz); |
1501 | 1553 | date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days')); |
1554 | + } else { |
|
1555 | + $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1502 | 1556 | } |
1503 | - else |
|
1504 | - $end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz); |
|
1505 | 1557 | } |
1506 | 1558 | } |
1507 | 1559 | |
@@ -1514,8 +1566,7 @@ discard block |
||
1514 | 1566 | $start_time = null; |
1515 | 1567 | $end_time = null; |
1516 | 1568 | $tz = null; |
1517 | - } |
|
1518 | - else |
|
1569 | + } else |
|
1519 | 1570 | { |
1520 | 1571 | $start_time = date_format($start_object, 'H:i:s'); |
1521 | 1572 | $end_time = date_format($end_object, 'H:i:s'); |
@@ -1536,16 +1587,18 @@ discard block |
||
1536 | 1587 | require_once($sourcedir . '/Subs.php'); |
1537 | 1588 | |
1538 | 1589 | // First, try to create a better date format, ignoring the "time" elements. |
1539 | - if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1540 | - $date_format = '%F'; |
|
1541 | - else |
|
1542 | - $date_format = $matches[0]; |
|
1590 | + if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1591 | + $date_format = '%F'; |
|
1592 | + } else { |
|
1593 | + $date_format = $matches[0]; |
|
1594 | + } |
|
1543 | 1595 | |
1544 | 1596 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
1545 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
1546 | - $time_format = '%k:%M'; |
|
1547 | - else |
|
1548 | - $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1597 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
1598 | + $time_format = '%k:%M'; |
|
1599 | + } else { |
|
1600 | + $time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
1601 | + } |
|
1549 | 1602 | |
1550 | 1603 | // Should this be an all day event? |
1551 | 1604 | $allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false; |
@@ -1554,8 +1607,9 @@ discard block |
||
1554 | 1607 | $span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d'); |
1555 | 1608 | |
1556 | 1609 | // We need to have a defined timezone in the steps below |
1557 | - if (empty($row['timezone'])) |
|
1558 | - $row['timezone'] = getUserTimezone(); |
|
1610 | + if (empty($row['timezone'])) { |
|
1611 | + $row['timezone'] = getUserTimezone(); |
|
1612 | + } |
|
1559 | 1613 | |
1560 | 1614 | // Get most of the standard date information for the start and end datetimes |
1561 | 1615 | $start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : '')); |
@@ -1607,8 +1661,9 @@ discard block |
||
1607 | 1661 | global $smcFunc, $context, $sourcedir, $user_info, $modSettings; |
1608 | 1662 | static $member_cache = array(); |
1609 | 1663 | |
1610 | - if (is_null($id_member) && $user_info['is_guest'] == false) |
|
1611 | - $id_member = $context['user']['id']; |
|
1664 | + if (is_null($id_member) && $user_info['is_guest'] == false) { |
|
1665 | + $id_member = $context['user']['id']; |
|
1666 | + } |
|
1612 | 1667 | |
1613 | 1668 | //check if the cache got the data |
1614 | 1669 | if (isset($id_member) && isset($member_cache[$id_member])) |
@@ -1630,11 +1685,13 @@ discard block |
||
1630 | 1685 | $smcFunc['db_free_result']($request); |
1631 | 1686 | } |
1632 | 1687 | |
1633 | - if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) |
|
1634 | - $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1688 | + if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) { |
|
1689 | + $timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get(); |
|
1690 | + } |
|
1635 | 1691 | |
1636 | - if (isset($id_member)) |
|
1637 | - $member_cache[$id_member] = $timezone; |
|
1692 | + if (isset($id_member)) { |
|
1693 | + $member_cache[$id_member] = $timezone; |
|
1694 | + } |
|
1638 | 1695 | |
1639 | 1696 | return $timezone; |
1640 | 1697 | } |
@@ -1663,8 +1720,9 @@ discard block |
||
1663 | 1720 | ) |
1664 | 1721 | ); |
1665 | 1722 | $holidays = array(); |
1666 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1667 | - $holidays[] = $row; |
|
1723 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1724 | + $holidays[] = $row; |
|
1725 | + } |
|
1668 | 1726 | $smcFunc['db_free_result']($request); |
1669 | 1727 | |
1670 | 1728 | return $holidays; |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $version = $smcFunc['db_get_version'](); |
39 | 39 | // if we got a Beta Version |
40 | 40 | if (stripos($version, 'beta') !== false) |
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
41 | + $version = substr($version, 0, stripos($version, 'beta')) . '.0'; |
|
42 | 42 | // or RC |
43 | 43 | if (stripos($version, 'rc') !== false) |
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
44 | + $version = substr($version, 0, stripos($version, 'rc')) . '.0'; |
|
45 | 45 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
46 | + if (version_compare($version, '9.5.0', '>=')) |
|
47 | 47 | $smcFunc['db_support_ignore'] = true; |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function smf_db_search_support($search_type) |
57 | 57 | { |
58 | - $supported_types = array('custom','fulltext'); |
|
58 | + $supported_types = array('custom', 'fulltext'); |
|
59 | 59 | |
60 | 60 | return in_array($search_type, $supported_types); |
61 | 61 | } |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 110 | { |
111 | 111 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | - if ($smcFunc['db_support_ignore']){ |
|
112 | + if ($smcFunc['db_support_ignore']) { |
|
113 | 113 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | - $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
|
114 | + $db_string = $db_string . ' ON CONFLICT DO NOTHING'; |
|
115 | 115 | } |
116 | 116 | else |
117 | 117 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $language_ftx = $modSettings['search_language']; |
169 | 169 | else |
170 | 170 | { |
171 | - $request = $smcFunc['db_query']('',' |
|
171 | + $request = $smcFunc['db_query']('', ' |
|
172 | 172 | SHOW default_text_search_config', |
173 | 173 | array() |
174 | 174 | ); |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Add the file functions to the $smcFunc array. |
@@ -23,29 +24,33 @@ discard block |
||
23 | 24 | { |
24 | 25 | global $smcFunc; |
25 | 26 | |
26 | - if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') |
|
27 | - $smcFunc += array( |
|
27 | + if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_search_query') { |
|
28 | + $smcFunc += array( |
|
28 | 29 | 'db_search_query' => 'smf_db_search_query', |
29 | 30 | 'db_search_support' => 'smf_db_search_support', |
30 | 31 | 'db_create_word_search' => 'smf_db_create_word_search', |
31 | 32 | 'db_support_ignore' => false, |
32 | 33 | 'db_search_language' => 'smf_db_search_language', |
33 | 34 | ); |
35 | + } |
|
34 | 36 | |
35 | 37 | db_extend(); |
36 | 38 | |
37 | 39 | //pg 9.5 got ignore support |
38 | 40 | $version = $smcFunc['db_get_version'](); |
39 | 41 | // if we got a Beta Version |
40 | - if (stripos($version, 'beta') !== false) |
|
41 | - $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
42 | + if (stripos($version, 'beta') !== false) { |
|
43 | + $version = substr($version, 0, stripos($version, 'beta')).'.0'; |
|
44 | + } |
|
42 | 45 | // or RC |
43 | - if (stripos($version, 'rc') !== false) |
|
44 | - $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
46 | + if (stripos($version, 'rc') !== false) { |
|
47 | + $version = substr($version, 0, stripos($version, 'rc')).'.0'; |
|
48 | + } |
|
45 | 49 | |
46 | - if (version_compare($version,'9.5.0','>=')) |
|
47 | - $smcFunc['db_support_ignore'] = true; |
|
48 | -} |
|
50 | + if (version_compare($version,'9.5.0','>=')) { |
|
51 | + $smcFunc['db_support_ignore'] = true; |
|
52 | + } |
|
53 | + } |
|
49 | 54 | |
50 | 55 | /** |
51 | 56 | * This function will tell you whether this database type supports this search type. |
@@ -104,16 +109,16 @@ discard block |
||
104 | 109 | ), |
105 | 110 | ); |
106 | 111 | |
107 | - if (isset($replacements[$identifier])) |
|
108 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
112 | + if (isset($replacements[$identifier])) { |
|
113 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
114 | + } |
|
109 | 115 | if (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
110 | 116 | { |
111 | 117 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
112 | 118 | if ($smcFunc['db_support_ignore']){ |
113 | 119 | //pg style "INSERT INTO.... ON CONFLICT DO NOTHING" |
114 | 120 | $db_string = $db_string.' ON CONFLICT DO NOTHING'; |
115 | - } |
|
116 | - else |
|
121 | + } else |
|
117 | 122 | { |
118 | 123 | // Don't error on multi-insert. |
119 | 124 | $db_values['db_error_skip'] = true; |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | //fix double quotes |
124 | - if ($identifier == 'insert_into_log_messages_fulltext') |
|
125 | - $db_values = str_replace('"', "'", $db_values); |
|
129 | + if ($identifier == 'insert_into_log_messages_fulltext') { |
|
130 | + $db_values = str_replace('"', "'", $db_values); |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $return = $smcFunc['db_query']('', $db_string, |
128 | 134 | $db_values, $connection |
@@ -164,9 +170,9 @@ discard block |
||
164 | 170 | |
165 | 171 | $language_ftx = 'english'; |
166 | 172 | |
167 | - if (!empty($modSettings['search_language'])) |
|
168 | - $language_ftx = $modSettings['search_language']; |
|
169 | - else |
|
173 | + if (!empty($modSettings['search_language'])) { |
|
174 | + $language_ftx = $modSettings['search_language']; |
|
175 | + } else |
|
170 | 176 | { |
171 | 177 | $request = $smcFunc['db_query']('',' |
172 | 178 | SHOW default_text_search_config', |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * !!!Compatibility!!! |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | { |
31 | 32 | global $modSettings; |
32 | 33 | |
33 | - if (!$compat_mode) |
|
34 | - return $text; |
|
34 | + if (!$compat_mode) { |
|
35 | + return $text; |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Turn line breaks back into br's. |
37 | 39 | $text = strtr($text, array("\r" => '', "\n" => '<br>')); |
@@ -48,8 +50,9 @@ discard block |
||
48 | 50 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
49 | 51 | { |
50 | 52 | // Value of 2 means we're inside the tag. |
51 | - if ($i % 4 == 2) |
|
52 | - $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
53 | + if ($i % 4 == 2) { |
|
54 | + $parts[$i] = strtr($parts[$i], array('[' => '[', ']' => ']', "'" => "'")); |
|
55 | + } |
|
53 | 56 | } |
54 | 57 | // Put our humpty dumpty message back together again. |
55 | 58 | $text = implode('', $parts); |
@@ -107,8 +110,9 @@ discard block |
||
107 | 110 | $text = preg_replace('~</p>\s*(?!<)~i', '</p><br>', $text); |
108 | 111 | |
109 | 112 | // Safari/webkit wraps lines in Wysiwyg in <div>'s. |
110 | - if (isBrowser('webkit')) |
|
111 | - $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
113 | + if (isBrowser('webkit')) { |
|
114 | + $text = preg_replace(array('~<div(?:\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br>', ''), $text); |
|
115 | + } |
|
112 | 116 | |
113 | 117 | // If there's a trailing break get rid of it - Firefox tends to add one. |
114 | 118 | $text = preg_replace('~<br\s?/?' . '>$~i', '', $text); |
@@ -123,8 +127,9 @@ discard block |
||
123 | 127 | for ($i = 0, $n = count($parts); $i < $n; $i++) |
124 | 128 | { |
125 | 129 | // Value of 2 means we're inside the tag. |
126 | - if ($i % 4 == 2) |
|
127 | - $parts[$i] = strip_tags($parts[$i]); |
|
130 | + if ($i % 4 == 2) { |
|
131 | + $parts[$i] = strip_tags($parts[$i]); |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br>')); |
@@ -150,18 +155,19 @@ discard block |
||
150 | 155 | { |
151 | 156 | $found = array_search($file, $smileysto); |
152 | 157 | // Note the weirdness here is to stop double spaces between smileys. |
153 | - if ($found) |
|
154 | - $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
155 | - else |
|
156 | - $matches[1][$k] = ''; |
|
158 | + if ($found) { |
|
159 | + $matches[1][$k] = '-[]-smf_smily_start#|#' . $smcFunc['htmlspecialchars']($smileysfrom[$found]) . '-[]-smf_smily_end#|#'; |
|
160 | + } else { |
|
161 | + $matches[1][$k] = ''; |
|
162 | + } |
|
157 | 163 | } |
158 | - } |
|
159 | - else |
|
164 | + } else |
|
160 | 165 | { |
161 | 166 | // Load all the smileys. |
162 | 167 | $names = array(); |
163 | - foreach ($matches[1] as $file) |
|
164 | - $names[] = $file; |
|
168 | + foreach ($matches[1] as $file) { |
|
169 | + $names[] = $file; |
|
170 | + } |
|
165 | 171 | $names = array_unique($names); |
166 | 172 | |
167 | 173 | if (!empty($names)) |
@@ -175,13 +181,15 @@ discard block |
||
175 | 181 | ) |
176 | 182 | ); |
177 | 183 | $mappings = array(); |
178 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
179 | - $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
184 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
185 | + $mappings[$row['filename']] = $smcFunc['htmlspecialchars']($row['code']); |
|
186 | + } |
|
180 | 187 | $smcFunc['db_free_result']($request); |
181 | 188 | |
182 | - foreach ($matches[1] as $k => $file) |
|
183 | - if (isset($mappings[$file])) |
|
189 | + foreach ($matches[1] as $k => $file) { |
|
190 | + if (isset($mappings[$file])) |
|
184 | 191 | $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#'; |
192 | + } |
|
185 | 193 | } |
186 | 194 | } |
187 | 195 | |
@@ -193,8 +201,9 @@ discard block |
||
193 | 201 | } |
194 | 202 | |
195 | 203 | // Only try to buy more time if the client didn't quit. |
196 | - if (connection_aborted() && $context['server']['is_apache']) |
|
197 | - @apache_reset_timeout(); |
|
204 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
205 | + @apache_reset_timeout(); |
|
206 | + } |
|
198 | 207 | |
199 | 208 | $parts = preg_split('~(<[A-Za-z]+\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
200 | 209 | $replacement = ''; |
@@ -205,9 +214,9 @@ discard block |
||
205 | 214 | if (preg_match('~(<([A-Za-z]+)\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) |
206 | 215 | { |
207 | 216 | // If it's being closed instantly, we can't deal with it...yet. |
208 | - if ($matches[5] === '/') |
|
209 | - continue; |
|
210 | - else |
|
217 | + if ($matches[5] === '/') { |
|
218 | + continue; |
|
219 | + } else |
|
211 | 220 | { |
212 | 221 | // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.) |
213 | 222 | $styles = explode(';', strtr($matches[3], array('"' => ''))); |
@@ -223,8 +232,9 @@ discard block |
||
223 | 232 | $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':')); |
224 | 233 | |
225 | 234 | // Something like 'font-weight: bold' is expected here. |
226 | - if (strpos($clean_type_value_pair, ':') === false) |
|
227 | - continue; |
|
235 | + if (strpos($clean_type_value_pair, ':') === false) { |
|
236 | + continue; |
|
237 | + } |
|
228 | 238 | |
229 | 239 | // Capture the elements of a single style item (e.g. 'font-weight' and 'bold'). |
230 | 240 | list ($style_type, $style_value) = explode(':', $type_value_pair); |
@@ -246,8 +256,7 @@ discard block |
||
246 | 256 | { |
247 | 257 | $curCloseTags .= '[/u]'; |
248 | 258 | $replacement .= '[u]'; |
249 | - } |
|
250 | - elseif ($style_value == 'line-through') |
|
259 | + } elseif ($style_value == 'line-through') |
|
251 | 260 | { |
252 | 261 | $curCloseTags .= '[/s]'; |
253 | 262 | $replacement .= '[s]'; |
@@ -259,13 +268,11 @@ discard block |
||
259 | 268 | { |
260 | 269 | $curCloseTags .= '[/left]'; |
261 | 270 | $replacement .= '[left]'; |
262 | - } |
|
263 | - elseif ($style_value == 'center') |
|
271 | + } elseif ($style_value == 'center') |
|
264 | 272 | { |
265 | 273 | $curCloseTags .= '[/center]'; |
266 | 274 | $replacement .= '[center]'; |
267 | - } |
|
268 | - elseif ($style_value == 'right') |
|
275 | + } elseif ($style_value == 'right') |
|
269 | 276 | { |
270 | 277 | $curCloseTags .= '[/right]'; |
271 | 278 | $replacement .= '[right]'; |
@@ -287,8 +294,9 @@ discard block |
||
287 | 294 | |
288 | 295 | case 'font-size': |
289 | 296 | // Sometimes people put decimals where decimals should not be. |
290 | - if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) |
|
291 | - $style_value = $dec_matches[1] . $dec_matches[2]; |
|
297 | + if (preg_match('~(\d)+\.\d+(p[xt])~i', $style_value, $dec_matches) === 1) { |
|
298 | + $style_value = $dec_matches[1] . $dec_matches[2]; |
|
299 | + } |
|
292 | 300 | |
293 | 301 | $curCloseTags .= '[/size]'; |
294 | 302 | $replacement .= '[size=' . $style_value . ']'; |
@@ -296,8 +304,9 @@ discard block |
||
296 | 304 | |
297 | 305 | case 'font-family': |
298 | 306 | // Only get the first freaking font if there's a list! |
299 | - if (strpos($style_value, ',') !== false) |
|
300 | - $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
307 | + if (strpos($style_value, ',') !== false) { |
|
308 | + $style_value = substr($style_value, 0, strpos($style_value, ',')); |
|
309 | + } |
|
301 | 310 | |
302 | 311 | $curCloseTags .= '[/font]'; |
303 | 312 | $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']'; |
@@ -306,13 +315,15 @@ discard block |
||
306 | 315 | // This is a hack for images with dimensions embedded. |
307 | 316 | case 'width': |
308 | 317 | case 'height': |
309 | - if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) |
|
310 | - $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
318 | + if (preg_match('~[1-9]\d*~i', $style_value, $dimension) === 1) { |
|
319 | + $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"'; |
|
320 | + } |
|
311 | 321 | break; |
312 | 322 | |
313 | 323 | case 'list-style-type': |
314 | - if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) |
|
315 | - $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
324 | + if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) { |
|
325 | + $extra_attr .= ' listtype="' . $listType[0] . '"'; |
|
326 | + } |
|
316 | 327 | break; |
317 | 328 | } |
318 | 329 | } |
@@ -325,18 +336,17 @@ discard block |
||
325 | 336 | } |
326 | 337 | |
327 | 338 | // If there's something that still needs closing, push it to the stack. |
328 | - if (!empty($curCloseTags)) |
|
329 | - array_push($stack, array( |
|
339 | + if (!empty($curCloseTags)) { |
|
340 | + array_push($stack, array( |
|
330 | 341 | 'element' => strtolower($curElement), |
331 | 342 | 'closeTags' => $curCloseTags |
332 | 343 | ) |
333 | 344 | ); |
334 | - elseif (!empty($extra_attr)) |
|
335 | - $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
345 | + } elseif (!empty($extra_attr)) { |
|
346 | + $replacement .= $precedingStyle . $extra_attr . $afterStyle; |
|
347 | + } |
|
336 | 348 | } |
337 | - } |
|
338 | - |
|
339 | - elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
349 | + } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) |
|
340 | 350 | { |
341 | 351 | // Is this the element that we've been waiting for to be closed? |
342 | 352 | if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) |
@@ -346,28 +356,32 @@ discard block |
||
346 | 356 | } |
347 | 357 | |
348 | 358 | // Must've been something else. |
349 | - else |
|
350 | - $replacement .= $part; |
|
359 | + else { |
|
360 | + $replacement .= $part; |
|
361 | + } |
|
351 | 362 | } |
352 | 363 | // In all other cases, just add the part to the replacement. |
353 | - else |
|
354 | - $replacement .= $part; |
|
364 | + else { |
|
365 | + $replacement .= $part; |
|
366 | + } |
|
355 | 367 | } |
356 | 368 | |
357 | 369 | // Now put back the replacement in the text. |
358 | 370 | $text = $replacement; |
359 | 371 | |
360 | 372 | // We are not finished yet, request more time. |
361 | - if (connection_aborted() && $context['server']['is_apache']) |
|
362 | - @apache_reset_timeout(); |
|
373 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
374 | + @apache_reset_timeout(); |
|
375 | + } |
|
363 | 376 | |
364 | 377 | // Let's pull out any legacy alignments. |
365 | 378 | while (preg_match('~<([A-Za-z]+)\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) |
366 | 379 | { |
367 | 380 | // Find the position in the text of this tag over again. |
368 | 381 | $start_pos = strpos($text, $matches[0]); |
369 | - if ($start_pos === false) |
|
370 | - break; |
|
382 | + if ($start_pos === false) { |
|
383 | + break; |
|
384 | + } |
|
371 | 385 | |
372 | 386 | // End tag? |
373 | 387 | if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) |
@@ -382,8 +396,7 @@ discard block |
||
382 | 396 | |
383 | 397 | // Put the tags back into the body. |
384 | 398 | $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos); |
385 | - } |
|
386 | - else |
|
399 | + } else |
|
387 | 400 | { |
388 | 401 | // Just get rid of this evil tag. |
389 | 402 | $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0])); |
@@ -396,8 +409,9 @@ discard block |
||
396 | 409 | // Find the position of this again. |
397 | 410 | $start_pos = strpos($text, $matches[0]); |
398 | 411 | $end_pos = false; |
399 | - if ($start_pos === false) |
|
400 | - break; |
|
412 | + if ($start_pos === false) { |
|
413 | + break; |
|
414 | + } |
|
401 | 415 | |
402 | 416 | // This must have an end tag - and we must find the right one. |
403 | 417 | $lower_text = strtolower($text); |
@@ -430,8 +444,9 @@ discard block |
||
430 | 444 | break; |
431 | 445 | } |
432 | 446 | } |
433 | - if ($end_pos === false) |
|
434 | - break; |
|
447 | + if ($end_pos === false) { |
|
448 | + break; |
|
449 | + } |
|
435 | 450 | |
436 | 451 | // Now work out what the attributes are. |
437 | 452 | $attribs = fetchTagAttributes($matches[1]); |
@@ -445,11 +460,11 @@ discard block |
||
445 | 460 | $v = (int) trim($v); |
446 | 461 | $v = empty($v) ? 1 : $v; |
447 | 462 | $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]'); |
463 | + } elseif ($s == 'face') { |
|
464 | + $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
465 | + } elseif ($s == 'color') { |
|
466 | + $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
448 | 467 | } |
449 | - elseif ($s == 'face') |
|
450 | - $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]'); |
|
451 | - elseif ($s == 'color') |
|
452 | - $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]'); |
|
453 | 468 | } |
454 | 469 | |
455 | 470 | // As before add in our tags. |
@@ -457,8 +472,9 @@ discard block |
||
457 | 472 | foreach ($tags as $tag) |
458 | 473 | { |
459 | 474 | $before .= $tag[0]; |
460 | - if (isset($tag[1])) |
|
461 | - $after = $tag[1] . $after; |
|
475 | + if (isset($tag[1])) { |
|
476 | + $after = $tag[1] . $after; |
|
477 | + } |
|
462 | 478 | } |
463 | 479 | |
464 | 480 | // Remove the tag so it's never checked again. |
@@ -469,8 +485,9 @@ discard block |
||
469 | 485 | } |
470 | 486 | |
471 | 487 | // Almost there, just a little more time. |
472 | - if (connection_aborted() && $context['server']['is_apache']) |
|
473 | - @apache_reset_timeout(); |
|
488 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
489 | + @apache_reset_timeout(); |
|
490 | + } |
|
474 | 491 | |
475 | 492 | if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) |
476 | 493 | { |
@@ -526,12 +543,13 @@ discard block |
||
526 | 543 | { |
527 | 544 | $inList = true; |
528 | 545 | |
529 | - if ($tag === 'ol') |
|
530 | - $listType = 'decimal'; |
|
531 | - elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) |
|
532 | - $listType = $listTypeMapping[$match[1]]; |
|
533 | - else |
|
534 | - $listType = null; |
|
546 | + if ($tag === 'ol') { |
|
547 | + $listType = 'decimal'; |
|
548 | + } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) { |
|
549 | + $listType = $listTypeMapping[$match[1]]; |
|
550 | + } else { |
|
551 | + $listType = null; |
|
552 | + } |
|
535 | 553 | |
536 | 554 | $listDepth++; |
537 | 555 | |
@@ -595,9 +613,7 @@ discard block |
||
595 | 613 | $parts[$i + 1] = ''; |
596 | 614 | $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]'; |
597 | 615 | $parts[$i + 3] = ''; |
598 | - } |
|
599 | - |
|
600 | - else |
|
616 | + } else |
|
601 | 617 | { |
602 | 618 | // We're in a list item. |
603 | 619 | if ($listDepth > 0) |
@@ -634,9 +650,7 @@ discard block |
||
634 | 650 | $parts[$i + 1] = ''; |
635 | 651 | $parts[$i + 2] = ''; |
636 | 652 | $parts[$i + 3] = ''; |
637 | - } |
|
638 | - |
|
639 | - else |
|
653 | + } else |
|
640 | 654 | { |
641 | 655 | // Remove the trailing breaks from the list item. |
642 | 656 | $parts[$i] = preg_replace('~\s*<br\s*' . '/?' . '>\s*$~', '', $parts[$i]); |
@@ -674,8 +688,9 @@ discard block |
||
674 | 688 | $text .= str_repeat("\t", $listDepth) . '[/list]'; |
675 | 689 | } |
676 | 690 | |
677 | - for ($i = $listDepth; $i > 0; $i--) |
|
678 | - $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
691 | + for ($i = $listDepth; $i > 0; $i--) { |
|
692 | + $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]'; |
|
693 | + } |
|
679 | 694 | |
680 | 695 | } |
681 | 696 | |
@@ -684,8 +699,9 @@ discard block |
||
684 | 699 | { |
685 | 700 | // Find the position of the image. |
686 | 701 | $start_pos = strpos($text, $matches[0]); |
687 | - if ($start_pos === false) |
|
688 | - break; |
|
702 | + if ($start_pos === false) { |
|
703 | + break; |
|
704 | + } |
|
689 | 705 | $end_pos = $start_pos + strlen($matches[0]); |
690 | 706 | |
691 | 707 | $params = ''; |
@@ -694,12 +710,13 @@ discard block |
||
694 | 710 | $attrs = fetchTagAttributes($matches[1]); |
695 | 711 | foreach ($attrs as $attrib => $value) |
696 | 712 | { |
697 | - if (in_array($attrib, array('width', 'height'))) |
|
698 | - $params .= ' ' . $attrib . '=' . (int) $value; |
|
699 | - elseif ($attrib == 'alt' && trim($value) != '') |
|
700 | - $params .= ' alt=' . trim($value); |
|
701 | - elseif ($attrib == 'src') |
|
702 | - $src = trim($value); |
|
713 | + if (in_array($attrib, array('width', 'height'))) { |
|
714 | + $params .= ' ' . $attrib . '=' . (int) $value; |
|
715 | + } elseif ($attrib == 'alt' && trim($value) != '') { |
|
716 | + $params .= ' alt=' . trim($value); |
|
717 | + } elseif ($attrib == 'src') { |
|
718 | + $src = trim($value); |
|
719 | + } |
|
703 | 720 | } |
704 | 721 | |
705 | 722 | $tag = ''; |
@@ -710,10 +727,11 @@ discard block |
||
710 | 727 | { |
711 | 728 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
712 | 729 | |
713 | - if (substr($src, 0, 1) === '/') |
|
714 | - $src = $baseURL . $src; |
|
715 | - else |
|
716 | - $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
730 | + if (substr($src, 0, 1) === '/') { |
|
731 | + $src = $baseURL . $src; |
|
732 | + } else { |
|
733 | + $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src; |
|
734 | + } |
|
717 | 735 | } |
718 | 736 | |
719 | 737 | $tag = '[img' . $params . ']' . $src . '[/img]'; |
@@ -891,20 +909,23 @@ discard block |
||
891 | 909 | }, |
892 | 910 | ); |
893 | 911 | |
894 | - foreach ($tags as $tag => $replace) |
|
895 | - $text = preg_replace_callback($tag, $replace, $text); |
|
912 | + foreach ($tags as $tag => $replace) { |
|
913 | + $text = preg_replace_callback($tag, $replace, $text); |
|
914 | + } |
|
896 | 915 | |
897 | 916 | // Please give us just a little more time. |
898 | - if (connection_aborted() && $context['server']['is_apache']) |
|
899 | - @apache_reset_timeout(); |
|
917 | + if (connection_aborted() && $context['server']['is_apache']) { |
|
918 | + @apache_reset_timeout(); |
|
919 | + } |
|
900 | 920 | |
901 | 921 | // What about URL's - the pain in the ass of the tag world. |
902 | 922 | while (preg_match('~<a\s+([^<>]*)>([^<>]*)</a>~i', $text, $matches) === 1) |
903 | 923 | { |
904 | 924 | // Find the position of the URL. |
905 | 925 | $start_pos = strpos($text, $matches[0]); |
906 | - if ($start_pos === false) |
|
907 | - break; |
|
926 | + if ($start_pos === false) { |
|
927 | + break; |
|
928 | + } |
|
908 | 929 | $end_pos = $start_pos + strlen($matches[0]); |
909 | 930 | |
910 | 931 | $tag_type = 'url'; |
@@ -918,8 +939,9 @@ discard block |
||
918 | 939 | $href = trim($value); |
919 | 940 | |
920 | 941 | // Are we dealing with an FTP link? |
921 | - if (preg_match('~^ftps?://~', $href) === 1) |
|
922 | - $tag_type = 'ftp'; |
|
942 | + if (preg_match('~^ftps?://~', $href) === 1) { |
|
943 | + $tag_type = 'ftp'; |
|
944 | + } |
|
923 | 945 | |
924 | 946 | // Or is this a link to an email address? |
925 | 947 | elseif (substr($href, 0, 7) == 'mailto:') |
@@ -933,28 +955,31 @@ discard block |
||
933 | 955 | { |
934 | 956 | $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']); |
935 | 957 | |
936 | - if (substr($href, 0, 1) === '/') |
|
937 | - $href = $baseURL . $href; |
|
938 | - else |
|
939 | - $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
958 | + if (substr($href, 0, 1) === '/') { |
|
959 | + $href = $baseURL . $href; |
|
960 | + } else { |
|
961 | + $href = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $href; |
|
962 | + } |
|
940 | 963 | } |
941 | 964 | } |
942 | 965 | |
943 | 966 | // External URL? |
944 | 967 | if ($attrib == 'target' && $tag_type == 'url') |
945 | 968 | { |
946 | - if (trim($value) == '_blank') |
|
947 | - $tag_type == 'iurl'; |
|
969 | + if (trim($value) == '_blank') { |
|
970 | + $tag_type == 'iurl'; |
|
971 | + } |
|
948 | 972 | } |
949 | 973 | } |
950 | 974 | |
951 | 975 | $tag = ''; |
952 | 976 | if ($href != '') |
953 | 977 | { |
954 | - if ($matches[2] == $href) |
|
955 | - $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
956 | - else |
|
957 | - $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
978 | + if ($matches[2] == $href) { |
|
979 | + $tag = '[' . $tag_type . ']' . $href . '[/' . $tag_type . ']'; |
|
980 | + } else { |
|
981 | + $tag = '[' . $tag_type . '=' . $href . ']' . $matches[2] . '[/' . $tag_type . ']'; |
|
982 | + } |
|
958 | 983 | } |
959 | 984 | |
960 | 985 | // Replace the tag |
@@ -993,17 +1018,18 @@ discard block |
||
993 | 1018 | // We're either moving from the key to the attribute or we're in a string and this is fine. |
994 | 1019 | if ($text[$i] == '=') |
995 | 1020 | { |
996 | - if ($tag_state == 0) |
|
997 | - $tag_state = 1; |
|
998 | - elseif ($tag_state == 2) |
|
999 | - $value .= '='; |
|
1021 | + if ($tag_state == 0) { |
|
1022 | + $tag_state = 1; |
|
1023 | + } elseif ($tag_state == 2) { |
|
1024 | + $value .= '='; |
|
1025 | + } |
|
1000 | 1026 | } |
1001 | 1027 | // A space is either moving from an attribute back to a potential key or in a string is fine. |
1002 | 1028 | elseif ($text[$i] == ' ') |
1003 | 1029 | { |
1004 | - if ($tag_state == 2) |
|
1005 | - $value .= ' '; |
|
1006 | - elseif ($tag_state == 1) |
|
1030 | + if ($tag_state == 2) { |
|
1031 | + $value .= ' '; |
|
1032 | + } elseif ($tag_state == 1) |
|
1007 | 1033 | { |
1008 | 1034 | $attribs[$key] = $value; |
1009 | 1035 | $key = $value = ''; |
@@ -1014,24 +1040,27 @@ discard block |
||
1014 | 1040 | elseif ($text[$i] == '"') |
1015 | 1041 | { |
1016 | 1042 | // Must be either going into or out of a string. |
1017 | - if ($tag_state == 1) |
|
1018 | - $tag_state = 2; |
|
1019 | - else |
|
1020 | - $tag_state = 1; |
|
1043 | + if ($tag_state == 1) { |
|
1044 | + $tag_state = 2; |
|
1045 | + } else { |
|
1046 | + $tag_state = 1; |
|
1047 | + } |
|
1021 | 1048 | } |
1022 | 1049 | // Otherwise it's fine. |
1023 | 1050 | else |
1024 | 1051 | { |
1025 | - if ($tag_state == 0) |
|
1026 | - $key .= $text[$i]; |
|
1027 | - else |
|
1028 | - $value .= $text[$i]; |
|
1052 | + if ($tag_state == 0) { |
|
1053 | + $key .= $text[$i]; |
|
1054 | + } else { |
|
1055 | + $value .= $text[$i]; |
|
1056 | + } |
|
1029 | 1057 | } |
1030 | 1058 | } |
1031 | 1059 | |
1032 | 1060 | // Anything left? |
1033 | - if ($key != '' && $value != '') |
|
1034 | - $attribs[$key] = $value; |
|
1061 | + if ($key != '' && $value != '') { |
|
1062 | + $attribs[$key] = $value; |
|
1063 | + } |
|
1035 | 1064 | |
1036 | 1065 | return $attribs; |
1037 | 1066 | } |
@@ -1047,15 +1076,17 @@ discard block |
||
1047 | 1076 | global $modSettings; |
1048 | 1077 | |
1049 | 1078 | // Don't care about the texts that are too short. |
1050 | - if (strlen($text) < 3) |
|
1051 | - return $text; |
|
1079 | + if (strlen($text) < 3) { |
|
1080 | + return $text; |
|
1081 | + } |
|
1052 | 1082 | |
1053 | 1083 | // A list of tags that's disabled by the admin. |
1054 | 1084 | $disabled = empty($modSettings['disabledBBC']) ? array() : array_flip(explode(',', strtolower($modSettings['disabledBBC']))); |
1055 | 1085 | |
1056 | 1086 | // Add flash if it's disabled as embedded tag. |
1057 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1058 | - $disabled['flash'] = true; |
|
1087 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1088 | + $disabled['flash'] = true; |
|
1089 | + } |
|
1059 | 1090 | |
1060 | 1091 | // Get a list of all the tags that are not disabled. |
1061 | 1092 | $all_tags = parse_bbc(false); |
@@ -1063,10 +1094,12 @@ discard block |
||
1063 | 1094 | $self_closing_tags = array(); |
1064 | 1095 | foreach ($all_tags as $tag) |
1065 | 1096 | { |
1066 | - if (!isset($disabled[$tag['tag']])) |
|
1067 | - $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1068 | - if (isset($tag['type']) && $tag['type'] == 'closed') |
|
1069 | - $self_closing_tags[] = $tag['tag']; |
|
1097 | + if (!isset($disabled[$tag['tag']])) { |
|
1098 | + $valid_tags[$tag['tag']] = !empty($tag['block_level']); |
|
1099 | + } |
|
1100 | + if (isset($tag['type']) && $tag['type'] == 'closed') { |
|
1101 | + $self_closing_tags[] = $tag['tag']; |
|
1102 | + } |
|
1070 | 1103 | } |
1071 | 1104 | |
1072 | 1105 | // Right - we're going to start by going through the whole lot to make sure we don't have align stuff crossed as this happens load and is stupid! |
@@ -1093,16 +1126,19 @@ discard block |
||
1093 | 1126 | $tagName = substr($match, $isClosingTag ? 2 : 1, -1); |
1094 | 1127 | |
1095 | 1128 | // We're closing the exact same tag that we opened. |
1096 | - if ($isClosingTag && $insideTag === $tagName) |
|
1097 | - $insideTag = null; |
|
1129 | + if ($isClosingTag && $insideTag === $tagName) { |
|
1130 | + $insideTag = null; |
|
1131 | + } |
|
1098 | 1132 | |
1099 | 1133 | // We're opening a tag and we're not yet inside one either |
1100 | - elseif (!$isClosingTag && $insideTag === null) |
|
1101 | - $insideTag = $tagName; |
|
1134 | + elseif (!$isClosingTag && $insideTag === null) { |
|
1135 | + $insideTag = $tagName; |
|
1136 | + } |
|
1102 | 1137 | |
1103 | 1138 | // In all other cases, this tag must be invalid |
1104 | - else |
|
1105 | - unset($matches[$i]); |
|
1139 | + else { |
|
1140 | + unset($matches[$i]); |
|
1141 | + } |
|
1106 | 1142 | } |
1107 | 1143 | |
1108 | 1144 | // The next one is gonna be the other one. |
@@ -1110,8 +1146,9 @@ discard block |
||
1110 | 1146 | } |
1111 | 1147 | |
1112 | 1148 | // We're still inside a tag and had no chance for closure? |
1113 | - if ($insideTag !== null) |
|
1114 | - $matches[] = '[/' . $insideTag . ']'; |
|
1149 | + if ($insideTag !== null) { |
|
1150 | + $matches[] = '[/' . $insideTag . ']'; |
|
1151 | + } |
|
1115 | 1152 | |
1116 | 1153 | // And a complete text string again. |
1117 | 1154 | $text = implode('', $matches); |
@@ -1120,8 +1157,9 @@ discard block |
||
1120 | 1157 | // Quickly remove any tags which are back to back. |
1121 | 1158 | $backToBackPattern = '~\\[(' . implode('|', array_diff(array_keys($valid_tags), array('td', 'anchor'))) . ')[^<>\\[\\]]*\\]\s*\\[/\\1\\]~'; |
1122 | 1159 | $lastlen = 0; |
1123 | - while (strlen($text) !== $lastlen) |
|
1124 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1160 | + while (strlen($text) !== $lastlen) { |
|
1161 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1162 | + } |
|
1125 | 1163 | |
1126 | 1164 | // Need to sort the tags my name length. |
1127 | 1165 | uksort($valid_tags, 'sort_array_length'); |
@@ -1158,8 +1196,9 @@ discard block |
||
1158 | 1196 | $isCompetingTag = in_array($tag, $competing_tags); |
1159 | 1197 | |
1160 | 1198 | // Check if this might be one of those cleaned out tags. |
1161 | - if ($tag === '') |
|
1162 | - continue; |
|
1199 | + if ($tag === '') { |
|
1200 | + continue; |
|
1201 | + } |
|
1163 | 1202 | |
1164 | 1203 | // Special case: inside [code] blocks any code is left untouched. |
1165 | 1204 | elseif ($tag === 'code') |
@@ -1170,8 +1209,9 @@ discard block |
||
1170 | 1209 | $inCode = false; |
1171 | 1210 | |
1172 | 1211 | // Reopen tags that were closed before the code block. |
1173 | - if (!empty($inlineElements)) |
|
1174 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1212 | + if (!empty($inlineElements)) { |
|
1213 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1214 | + } |
|
1175 | 1215 | } |
1176 | 1216 | |
1177 | 1217 | // We're outside a coding and nobbc block and opening it. |
@@ -1200,8 +1240,9 @@ discard block |
||
1200 | 1240 | $inNoBbc = false; |
1201 | 1241 | |
1202 | 1242 | // Some inline elements might've been closed that need reopening. |
1203 | - if (!empty($inlineElements)) |
|
1204 | - $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1243 | + if (!empty($inlineElements)) { |
|
1244 | + $parts[$i + 4] .= '[' . implode('][', array_keys($inlineElements)) . ']'; |
|
1245 | + } |
|
1205 | 1246 | } |
1206 | 1247 | |
1207 | 1248 | // We're outside a nobbc and coding block and opening it. |
@@ -1221,8 +1262,9 @@ discard block |
||
1221 | 1262 | } |
1222 | 1263 | |
1223 | 1264 | // So, we're inside one of the special blocks: ignore any tag. |
1224 | - elseif ($inCode || $inNoBbc) |
|
1225 | - continue; |
|
1265 | + elseif ($inCode || $inNoBbc) { |
|
1266 | + continue; |
|
1267 | + } |
|
1226 | 1268 | |
1227 | 1269 | // We're dealing with an opening tag. |
1228 | 1270 | if ($isOpeningTag) |
@@ -1263,8 +1305,9 @@ discard block |
||
1263 | 1305 | if ($parts[$j + 3] === $tag) |
1264 | 1306 | { |
1265 | 1307 | // If it's an opening tag, increase the level. |
1266 | - if ($parts[$j + 2] === '') |
|
1267 | - $curLevel++; |
|
1308 | + if ($parts[$j + 2] === '') { |
|
1309 | + $curLevel++; |
|
1310 | + } |
|
1268 | 1311 | |
1269 | 1312 | // A closing tag, decrease the level. |
1270 | 1313 | else |
@@ -1287,13 +1330,15 @@ discard block |
||
1287 | 1330 | { |
1288 | 1331 | if ($isCompetingTag) |
1289 | 1332 | { |
1290 | - if (!isset($competingElements[$tag])) |
|
1291 | - $competingElements[$tag] = array(); |
|
1333 | + if (!isset($competingElements[$tag])) { |
|
1334 | + $competingElements[$tag] = array(); |
|
1335 | + } |
|
1292 | 1336 | |
1293 | 1337 | $competingElements[$tag][] = $parts[$i + 4]; |
1294 | 1338 | |
1295 | - if (count($competingElements[$tag]) > 1) |
|
1296 | - $parts[$i] .= '[/' . $tag . ']'; |
|
1339 | + if (count($competingElements[$tag]) > 1) { |
|
1340 | + $parts[$i] .= '[/' . $tag . ']'; |
|
1341 | + } |
|
1297 | 1342 | } |
1298 | 1343 | |
1299 | 1344 | $inlineElements[$elementContent] = $tag; |
@@ -1314,15 +1359,17 @@ discard block |
||
1314 | 1359 | $addClosingTags = array(); |
1315 | 1360 | while ($element = array_pop($blockElements)) |
1316 | 1361 | { |
1317 | - if ($element === $tag) |
|
1318 | - break; |
|
1362 | + if ($element === $tag) { |
|
1363 | + break; |
|
1364 | + } |
|
1319 | 1365 | |
1320 | 1366 | // Still a block tag was open not equal to this tag. |
1321 | 1367 | $addClosingTags[] = $element['type']; |
1322 | 1368 | } |
1323 | 1369 | |
1324 | - if (!empty($addClosingTags)) |
|
1325 | - $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1370 | + if (!empty($addClosingTags)) { |
|
1371 | + $parts[$i + 1] = '[/' . implode('][/', array_reverse($addClosingTags)) . ']' . $parts[$i + 1]; |
|
1372 | + } |
|
1326 | 1373 | |
1327 | 1374 | // Apparently the closing tag was not found on the stack. |
1328 | 1375 | if (!is_string($element) || $element !== $tag) |
@@ -1332,8 +1379,7 @@ discard block |
||
1332 | 1379 | $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
1333 | 1380 | continue; |
1334 | 1381 | } |
1335 | - } |
|
1336 | - else |
|
1382 | + } else |
|
1337 | 1383 | { |
1338 | 1384 | // Get rid of this closing tag! |
1339 | 1385 | $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
@@ -1362,53 +1408,62 @@ discard block |
||
1362 | 1408 | unset($inlineElements[$tagContentToBeClosed]); |
1363 | 1409 | |
1364 | 1410 | // Was this the tag we were looking for? |
1365 | - if ($tagToBeClosed === $tag) |
|
1366 | - break; |
|
1411 | + if ($tagToBeClosed === $tag) { |
|
1412 | + break; |
|
1413 | + } |
|
1367 | 1414 | |
1368 | 1415 | // Nope, close it and look further! |
1369 | - else |
|
1370 | - $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1416 | + else { |
|
1417 | + $parts[$i] .= '[/' . $tagToBeClosed . ']'; |
|
1418 | + } |
|
1371 | 1419 | } |
1372 | 1420 | |
1373 | 1421 | if ($isCompetingTag && !empty($competingElements[$tag])) |
1374 | 1422 | { |
1375 | 1423 | array_pop($competingElements[$tag]); |
1376 | 1424 | |
1377 | - if (count($competingElements[$tag]) > 0) |
|
1378 | - $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1425 | + if (count($competingElements[$tag]) > 0) { |
|
1426 | + $parts[$i + 5] = '[' . $tag . $competingElements[$tag][count($competingElements[$tag]) - 1] . $parts[$i + 5]; |
|
1427 | + } |
|
1379 | 1428 | } |
1380 | 1429 | } |
1381 | 1430 | |
1382 | 1431 | // Unexpected closing tag, ex-ter-mi-nate. |
1383 | - else |
|
1384 | - $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1432 | + else { |
|
1433 | + $parts[$i + 1] = $parts[$i + 2] = $parts[$i + 3] = $parts[$i + 4] = ''; |
|
1434 | + } |
|
1385 | 1435 | } |
1386 | 1436 | } |
1387 | 1437 | } |
1388 | 1438 | |
1389 | 1439 | // Close the code tags. |
1390 | - if ($inCode) |
|
1391 | - $parts[$i] .= '[/code]'; |
|
1440 | + if ($inCode) { |
|
1441 | + $parts[$i] .= '[/code]'; |
|
1442 | + } |
|
1392 | 1443 | |
1393 | 1444 | // The same for nobbc tags. |
1394 | - elseif ($inNoBbc) |
|
1395 | - $parts[$i] .= '[/nobbc]'; |
|
1445 | + elseif ($inNoBbc) { |
|
1446 | + $parts[$i] .= '[/nobbc]'; |
|
1447 | + } |
|
1396 | 1448 | |
1397 | 1449 | // Still inline tags left unclosed? Close them now, better late than never. |
1398 | - elseif (!empty($inlineElements)) |
|
1399 | - $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1450 | + elseif (!empty($inlineElements)) { |
|
1451 | + $parts[$i] .= '[/' . implode('][/', array_reverse($inlineElements)) . ']'; |
|
1452 | + } |
|
1400 | 1453 | |
1401 | 1454 | // Now close the block elements. |
1402 | - if (!empty($blockElements)) |
|
1403 | - $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1455 | + if (!empty($blockElements)) { |
|
1456 | + $parts[$i] .= '[/' . implode('][/', array_reverse($blockElements)) . ']'; |
|
1457 | + } |
|
1404 | 1458 | |
1405 | 1459 | $text = implode('', $parts); |
1406 | 1460 | } |
1407 | 1461 | |
1408 | 1462 | // Final clean up of back to back tags. |
1409 | 1463 | $lastlen = 0; |
1410 | - while (strlen($text) !== $lastlen) |
|
1411 | - $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1464 | + while (strlen($text) !== $lastlen) { |
|
1465 | + $lastlen = strlen($text = preg_replace($backToBackPattern, '', $text)); |
|
1466 | + } |
|
1412 | 1467 | |
1413 | 1468 | return $text; |
1414 | 1469 | } |
@@ -1437,22 +1492,25 @@ discard block |
||
1437 | 1492 | $context['template_layers'] = array(); |
1438 | 1493 | // Lets make sure we aren't going to output anything nasty. |
1439 | 1494 | @ob_end_clean(); |
1440 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
1441 | - @ob_start('ob_gzhandler'); |
|
1442 | - else |
|
1443 | - @ob_start(); |
|
1495 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
1496 | + @ob_start('ob_gzhandler'); |
|
1497 | + } else { |
|
1498 | + @ob_start(); |
|
1499 | + } |
|
1444 | 1500 | |
1445 | 1501 | // If we don't have any locale better avoid broken js |
1446 | - if (empty($txt['lang_locale'])) |
|
1447 | - die(); |
|
1502 | + if (empty($txt['lang_locale'])) { |
|
1503 | + die(); |
|
1504 | + } |
|
1448 | 1505 | |
1449 | 1506 | $file_data = '(function ($) { |
1450 | 1507 | \'use strict\'; |
1451 | 1508 | |
1452 | 1509 | $.sceditor.locale[' . javaScriptEscape($txt['lang_locale']) . '] = {'; |
1453 | - foreach ($editortxt as $key => $val) |
|
1454 | - $file_data .= ' |
|
1510 | + foreach ($editortxt as $key => $val) { |
|
1511 | + $file_data .= ' |
|
1455 | 1512 | ' . javaScriptEscape($key) . ': ' . javaScriptEscape($val) . ','; |
1513 | + } |
|
1456 | 1514 | |
1457 | 1515 | $file_data .= ' |
1458 | 1516 | dateFormat: "day.month.year" |
@@ -1520,8 +1578,9 @@ discard block |
||
1520 | 1578 | ) |
1521 | 1579 | ); |
1522 | 1580 | $icon_data = array(); |
1523 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1524 | - $icon_data[] = $row; |
|
1581 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1582 | + $icon_data[] = $row; |
|
1583 | + } |
|
1525 | 1584 | $smcFunc['db_free_result']($request); |
1526 | 1585 | |
1527 | 1586 | $icons = array(); |
@@ -1536,9 +1595,9 @@ discard block |
||
1536 | 1595 | } |
1537 | 1596 | |
1538 | 1597 | cache_put_data('posting_icons-' . $board_id, $icons, 480); |
1598 | + } else { |
|
1599 | + $icons = $temp; |
|
1539 | 1600 | } |
1540 | - else |
|
1541 | - $icons = $temp; |
|
1542 | 1601 | } |
1543 | 1602 | call_integration_hook('integrate_load_message_icons', array(&$icons)); |
1544 | 1603 | |
@@ -1579,8 +1638,9 @@ discard block |
||
1579 | 1638 | { |
1580 | 1639 | // Some general stuff. |
1581 | 1640 | $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set']; |
1582 | - if (!empty($context['drafts_autosave'])) |
|
1583 | - $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1641 | + if (!empty($context['drafts_autosave'])) { |
|
1642 | + $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000; |
|
1643 | + } |
|
1584 | 1644 | |
1585 | 1645 | // This really has some WYSIWYG stuff. |
1586 | 1646 | loadCSSFile('jquery.sceditor.css', array('force_current' => false, 'validate' => true), 'smf_jquery_sceditor'); |
@@ -1596,8 +1656,9 @@ discard block |
||
1596 | 1656 | var bbc_quote = \'' . addcslashes($txt['quote'], "'") . '\'; |
1597 | 1657 | var bbc_search_on = \'' . addcslashes($txt['search_on'], "'") . '\';'); |
1598 | 1658 | // editor language file |
1599 | - if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') |
|
1600 | - loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1659 | + if (!empty($txt['lang_locale']) && $txt['lang_locale'] != 'en_US') { |
|
1660 | + loadJavaScriptFile($scripturl . '?action=loadeditorlocale', array('external' => true), 'sceditor_language'); |
|
1661 | + } |
|
1601 | 1662 | |
1602 | 1663 | $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) ? '_drafts' : '') . (stripos($_SERVER['HTTP_USER_AGENT'], 'Macintosh') !== false ? '_mac' : (isBrowser('is_firefox') ? '_firefox' : ''))]; |
1603 | 1664 | $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv')))); |
@@ -1606,11 +1667,12 @@ discard block |
||
1606 | 1667 | loadJavaScriptFile('spellcheck.js', array(), 'smf_spellcheck'); |
1607 | 1668 | |
1608 | 1669 | // Some hidden information is needed in order to make the spell checking work. |
1609 | - if (!isset($_REQUEST['xml'])) |
|
1610 | - $context['insert_after_template'] .= ' |
|
1670 | + if (!isset($_REQUEST['xml'])) { |
|
1671 | + $context['insert_after_template'] .= ' |
|
1611 | 1672 | <form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck"> |
1612 | 1673 | <input type="hidden" name="spellstring" value=""> |
1613 | 1674 | </form>'; |
1675 | + } |
|
1614 | 1676 | } |
1615 | 1677 | } |
1616 | 1678 | |
@@ -1776,10 +1838,12 @@ discard block |
||
1776 | 1838 | |
1777 | 1839 | // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. |
1778 | 1840 | $disabled_tags = array(); |
1779 | - if (!empty($modSettings['disabledBBC'])) |
|
1780 | - $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1781 | - if (empty($modSettings['enableEmbeddedFlash'])) |
|
1782 | - $disabled_tags[] = 'flash'; |
|
1841 | + if (!empty($modSettings['disabledBBC'])) { |
|
1842 | + $disabled_tags = explode(',', $modSettings['disabledBBC']); |
|
1843 | + } |
|
1844 | + if (empty($modSettings['enableEmbeddedFlash'])) { |
|
1845 | + $disabled_tags[] = 'flash'; |
|
1846 | + } |
|
1783 | 1847 | |
1784 | 1848 | foreach ($disabled_tags as $tag) |
1785 | 1849 | { |
@@ -1789,9 +1853,10 @@ discard block |
||
1789 | 1853 | $context['disabled_tags']['orderedlist'] = true; |
1790 | 1854 | } |
1791 | 1855 | |
1792 | - foreach ($editor_tag_map as $thisTag => $tagNameBBC) |
|
1793 | - if ($tag === $thisTag) |
|
1856 | + foreach ($editor_tag_map as $thisTag => $tagNameBBC) { |
|
1857 | + if ($tag === $thisTag) |
|
1794 | 1858 | $context['disabled_tags'][$tagNameBBC] = true; |
1859 | + } |
|
1795 | 1860 | |
1796 | 1861 | $context['disabled_tags'][trim($tag)] = true; |
1797 | 1862 | } |
@@ -1801,19 +1866,21 @@ discard block |
||
1801 | 1866 | $context['bbc_toolbar'] = array(); |
1802 | 1867 | foreach ($context['bbc_tags'] as $row => $tagRow) |
1803 | 1868 | { |
1804 | - if (!isset($context['bbc_toolbar'][$row])) |
|
1805 | - $context['bbc_toolbar'][$row] = array(); |
|
1869 | + if (!isset($context['bbc_toolbar'][$row])) { |
|
1870 | + $context['bbc_toolbar'][$row] = array(); |
|
1871 | + } |
|
1806 | 1872 | $tagsRow = array(); |
1807 | 1873 | foreach ($tagRow as $tag) |
1808 | 1874 | { |
1809 | 1875 | if ((!empty($tag['code'])) && empty($context['disabled_tags'][$tag['code']])) |
1810 | 1876 | { |
1811 | 1877 | $tagsRow[] = $tag['code']; |
1812 | - if (isset($tag['image'])) |
|
1813 | - $bbcodes_styles .= ' |
|
1878 | + if (isset($tag['image'])) { |
|
1879 | + $bbcodes_styles .= ' |
|
1814 | 1880 | .sceditor-button-' . $tag['code'] . ' div { |
1815 | 1881 | background: url(\'' . $settings['default_theme_url'] . '/images/bbc/' . $tag['image'] . '.png\'); |
1816 | 1882 | }'; |
1883 | + } |
|
1817 | 1884 | if (isset($tag['before'])) |
1818 | 1885 | { |
1819 | 1886 | $context['bbcodes_handlers'] .= ' |
@@ -1827,8 +1894,7 @@ discard block |
||
1827 | 1894 | });'; |
1828 | 1895 | } |
1829 | 1896 | |
1830 | - } |
|
1831 | - else |
|
1897 | + } else |
|
1832 | 1898 | { |
1833 | 1899 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1834 | 1900 | $tagsRow = array(); |
@@ -1839,14 +1905,16 @@ discard block |
||
1839 | 1905 | { |
1840 | 1906 | $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
1841 | 1907 | $tagsRow = array(); |
1842 | - if (!isset($context['disabled_tags']['font'])) |
|
1843 | - $tagsRow[] = 'font'; |
|
1844 | - if (!isset($context['disabled_tags']['size'])) |
|
1845 | - $tagsRow[] = 'size'; |
|
1846 | - if (!isset($context['disabled_tags']['color'])) |
|
1847 | - $tagsRow[] = 'color'; |
|
1848 | - } |
|
1849 | - elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1908 | + if (!isset($context['disabled_tags']['font'])) { |
|
1909 | + $tagsRow[] = 'font'; |
|
1910 | + } |
|
1911 | + if (!isset($context['disabled_tags']['size'])) { |
|
1912 | + $tagsRow[] = 'size'; |
|
1913 | + } |
|
1914 | + if (!isset($context['disabled_tags']['color'])) { |
|
1915 | + $tagsRow[] = 'color'; |
|
1916 | + } |
|
1917 | + } elseif ($row == 1 && empty($modSettings['disable_wysiwyg'])) |
|
1850 | 1918 | { |
1851 | 1919 | $tmp = array(); |
1852 | 1920 | $tagsRow[] = 'removeformat'; |
@@ -1857,13 +1925,15 @@ discard block |
||
1857 | 1925 | } |
1858 | 1926 | } |
1859 | 1927 | |
1860 | - if (!empty($tagsRow)) |
|
1861 | - $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1928 | + if (!empty($tagsRow)) { |
|
1929 | + $context['bbc_toolbar'][$row][] = implode(',', $tagsRow); |
|
1930 | + } |
|
1862 | 1931 | } |
1863 | - if (!empty($bbcodes_styles)) |
|
1864 | - $context['html_headers'] .= ' |
|
1932 | + if (!empty($bbcodes_styles)) { |
|
1933 | + $context['html_headers'] .= ' |
|
1865 | 1934 | <style>' . $bbcodes_styles . ' |
1866 | 1935 | </style>'; |
1936 | + } |
|
1867 | 1937 | } |
1868 | 1938 | |
1869 | 1939 | // Initialize smiley array... if not loaded before. |
@@ -1875,8 +1945,8 @@ discard block |
||
1875 | 1945 | ); |
1876 | 1946 | |
1877 | 1947 | // Load smileys - don't bother to run a query if we're not using the database's ones anyhow. |
1878 | - if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') |
|
1879 | - $context['smileys']['postform'][] = array( |
|
1948 | + if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') { |
|
1949 | + $context['smileys']['postform'][] = array( |
|
1880 | 1950 | 'smileys' => array( |
1881 | 1951 | array( |
1882 | 1952 | 'code' => ':)', |
@@ -1962,7 +2032,7 @@ discard block |
||
1962 | 2032 | ), |
1963 | 2033 | 'isLast' => true, |
1964 | 2034 | ); |
1965 | - elseif ($user_info['smiley_set'] != 'none') |
|
2035 | + } elseif ($user_info['smiley_set'] != 'none') |
|
1966 | 2036 | { |
1967 | 2037 | if (($temp = cache_get_data('posting_smileys', 480)) == null) |
1968 | 2038 | { |
@@ -1985,17 +2055,19 @@ discard block |
||
1985 | 2055 | |
1986 | 2056 | foreach ($context['smileys'] as $section => $smileyRows) |
1987 | 2057 | { |
1988 | - foreach ($smileyRows as $rowIndex => $smileys) |
|
1989 | - $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2058 | + foreach ($smileyRows as $rowIndex => $smileys) { |
|
2059 | + $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true; |
|
2060 | + } |
|
1990 | 2061 | |
1991 | - if (!empty($smileyRows)) |
|
1992 | - $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2062 | + if (!empty($smileyRows)) { |
|
2063 | + $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true; |
|
2064 | + } |
|
1993 | 2065 | } |
1994 | 2066 | |
1995 | 2067 | cache_put_data('posting_smileys', $context['smileys'], 480); |
2068 | + } else { |
|
2069 | + $context['smileys'] = $temp; |
|
1996 | 2070 | } |
1997 | - else |
|
1998 | - $context['smileys'] = $temp; |
|
1999 | 2071 | } |
2000 | 2072 | } |
2001 | 2073 | |
@@ -2021,8 +2093,9 @@ discard block |
||
2021 | 2093 | loadTemplate('GenericControls'); |
2022 | 2094 | |
2023 | 2095 | // Some javascript ma'am? |
2024 | - if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) |
|
2025 | - loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2096 | + if (!empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']))) { |
|
2097 | + loadJavaScriptFile('captcha.js', array(), 'smf_captcha'); |
|
2098 | + } |
|
2026 | 2099 | |
2027 | 2100 | $context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); |
2028 | 2101 | |
@@ -2035,8 +2108,8 @@ discard block |
||
2035 | 2108 | $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]); |
2036 | 2109 | |
2037 | 2110 | // Log this into our collection. |
2038 | - if ($isNew) |
|
2039 | - $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2111 | + if ($isNew) { |
|
2112 | + $context['controls']['verification'][$verificationOptions['id']] = array( |
|
2040 | 2113 | 'id' => $verificationOptions['id'], |
2041 | 2114 | 'empty_field' => empty($verificationOptions['no_empty_field']), |
2042 | 2115 | 'show_visual' => !empty($verificationOptions['override_visual']) || (!empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])), |
@@ -2047,13 +2120,15 @@ discard block |
||
2047 | 2120 | 'questions' => array(), |
2048 | 2121 | 'can_recaptcha' => !empty($modSettings['recaptcha_enabled']) && !empty($modSettings['recaptcha_site_key']) && !empty($modSettings['recaptcha_secret_key']), |
2049 | 2122 | ); |
2123 | + } |
|
2050 | 2124 | $thisVerification = &$context['controls']['verification'][$verificationOptions['id']]; |
2051 | 2125 | |
2052 | 2126 | // Is there actually going to be anything? |
2053 | - if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) |
|
2054 | - return false; |
|
2055 | - elseif (!$isNew && !$do_test) |
|
2056 | - return true; |
|
2127 | + if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions']) && empty($thisVerification['can_recaptcha'])) { |
|
2128 | + return false; |
|
2129 | + } elseif (!$isNew && !$do_test) { |
|
2130 | + return true; |
|
2131 | + } |
|
2057 | 2132 | |
2058 | 2133 | // Sanitize reCAPTCHA fields? |
2059 | 2134 | if ($thisVerification['can_recaptcha']) |
@@ -2066,11 +2141,12 @@ discard block |
||
2066 | 2141 | } |
2067 | 2142 | |
2068 | 2143 | // Add javascript for the object. |
2069 | - if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) |
|
2070 | - $context['insert_after_template'] .= ' |
|
2144 | + if ($context['controls']['verification'][$verificationOptions['id']]['show_visual']) { |
|
2145 | + $context['insert_after_template'] .= ' |
|
2071 | 2146 | <script> |
2072 | 2147 | var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . '); |
2073 | 2148 | </script>'; |
2149 | + } |
|
2074 | 2150 | |
2075 | 2151 | // If we want questions do we have a cache of all the IDs? |
2076 | 2152 | if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) |
@@ -2093,8 +2169,9 @@ discard block |
||
2093 | 2169 | unset ($row['id_question']); |
2094 | 2170 | // Make them all lowercase. We can't directly use $smcFunc['strtolower'] with array_walk, so do it manually, eh? |
2095 | 2171 | $row['answers'] = smf_json_decode($row['answers'], true); |
2096 | - foreach ($row['answers'] as $k => $v) |
|
2097 | - $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2172 | + foreach ($row['answers'] as $k => $v) { |
|
2173 | + $row['answers'][$k] = $smcFunc['strtolower']($v); |
|
2174 | + } |
|
2098 | 2175 | |
2099 | 2176 | $modSettings['question_id_cache']['questions'][$id_question] = $row; |
2100 | 2177 | $modSettings['question_id_cache']['langs'][$row['lngfile']][] = $id_question; |
@@ -2105,35 +2182,42 @@ discard block |
||
2105 | 2182 | } |
2106 | 2183 | } |
2107 | 2184 | |
2108 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) |
|
2109 | - $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2185 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) { |
|
2186 | + $_SESSION[$verificationOptions['id'] . '_vv'] = array(); |
|
2187 | + } |
|
2110 | 2188 | |
2111 | 2189 | // Do we need to refresh the verification? |
2112 | - if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) |
|
2113 | - $force_refresh = true; |
|
2114 | - else |
|
2115 | - $force_refresh = false; |
|
2190 | + if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) { |
|
2191 | + $force_refresh = true; |
|
2192 | + } else { |
|
2193 | + $force_refresh = false; |
|
2194 | + } |
|
2116 | 2195 | |
2117 | 2196 | // This can also force a fresh, although unlikely. |
2118 | - if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) |
|
2119 | - $force_refresh = true; |
|
2197 | + if (($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code'])) || ($thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q']))) { |
|
2198 | + $force_refresh = true; |
|
2199 | + } |
|
2120 | 2200 | |
2121 | 2201 | $verification_errors = array(); |
2122 | 2202 | // Start with any testing. |
2123 | 2203 | if ($do_test) |
2124 | 2204 | { |
2125 | 2205 | // This cannot happen! |
2126 | - if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) |
|
2127 | - fatal_lang_error('no_access', false); |
|
2206 | + if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) { |
|
2207 | + fatal_lang_error('no_access', false); |
|
2208 | + } |
|
2128 | 2209 | // ... nor this! |
2129 | - if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) |
|
2130 | - fatal_lang_error('no_access', false); |
|
2210 | + if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) { |
|
2211 | + fatal_lang_error('no_access', false); |
|
2212 | + } |
|
2131 | 2213 | // Hmm, it's requested but not actually declared. This shouldn't happen. |
2132 | - if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
|
2133 | - fatal_lang_error('no_access', false); |
|
2214 | + if ($thisVerification['empty_field'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) { |
|
2215 | + fatal_lang_error('no_access', false); |
|
2216 | + } |
|
2134 | 2217 | // While we're here, did the user do something bad? |
2135 | - if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) |
|
2136 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2218 | + if ($thisVerification['empty_field'] && !empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field']) && !empty($_REQUEST[$_SESSION[$verificationOptions['id'] . '_vv']['empty_field']])) { |
|
2219 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2220 | + } |
|
2137 | 2221 | |
2138 | 2222 | if ($thisVerification['can_recaptcha']) |
2139 | 2223 | { |
@@ -2144,22 +2228,25 @@ discard block |
||
2144 | 2228 | { |
2145 | 2229 | $resp = $reCaptcha->verify($_POST['g-recaptcha-response'], $user_info['ip']); |
2146 | 2230 | |
2147 | - if (!$resp->isSuccess()) |
|
2148 | - $verification_errors[] = 'wrong_verification_code'; |
|
2231 | + if (!$resp->isSuccess()) { |
|
2232 | + $verification_errors[] = 'wrong_verification_code'; |
|
2233 | + } |
|
2234 | + } else { |
|
2235 | + $verification_errors[] = 'wrong_verification_code'; |
|
2149 | 2236 | } |
2150 | - else |
|
2151 | - $verification_errors[] = 'wrong_verification_code'; |
|
2152 | 2237 | } |
2153 | - if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) |
|
2154 | - $verification_errors[] = 'wrong_verification_code'; |
|
2238 | + if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) { |
|
2239 | + $verification_errors[] = 'wrong_verification_code'; |
|
2240 | + } |
|
2155 | 2241 | if ($thisVerification['number_questions']) |
2156 | 2242 | { |
2157 | 2243 | $incorrectQuestions = array(); |
2158 | 2244 | foreach ($_SESSION[$verificationOptions['id'] . '_vv']['q'] as $q) |
2159 | 2245 | { |
2160 | 2246 | // We don't have this question any more, thus no answers. |
2161 | - if (!isset($modSettings['question_id_cache']['questions'][$q])) |
|
2162 | - continue; |
|
2247 | + if (!isset($modSettings['question_id_cache']['questions'][$q])) { |
|
2248 | + continue; |
|
2249 | + } |
|
2163 | 2250 | // This is quite complex. We have our question but it might have multiple answers. |
2164 | 2251 | // First, did they actually answer this question? |
2165 | 2252 | if (!isset($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) || trim($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) == '') |
@@ -2171,24 +2258,28 @@ discard block |
||
2171 | 2258 | else |
2172 | 2259 | { |
2173 | 2260 | $given_answer = trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]))); |
2174 | - if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) |
|
2175 | - $incorrectQuestions[] = $q; |
|
2261 | + if (!in_array($given_answer, $modSettings['question_id_cache']['questions'][$q]['answers'])) { |
|
2262 | + $incorrectQuestions[] = $q; |
|
2263 | + } |
|
2176 | 2264 | } |
2177 | 2265 | } |
2178 | 2266 | |
2179 | - if (!empty($incorrectQuestions)) |
|
2180 | - $verification_errors[] = 'wrong_verification_answer'; |
|
2267 | + if (!empty($incorrectQuestions)) { |
|
2268 | + $verification_errors[] = 'wrong_verification_answer'; |
|
2269 | + } |
|
2181 | 2270 | } |
2182 | 2271 | } |
2183 | 2272 | |
2184 | 2273 | // Any errors means we refresh potentially. |
2185 | 2274 | if (!empty($verification_errors)) |
2186 | 2275 | { |
2187 | - if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) |
|
2188 | - $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2276 | + if (empty($_SESSION[$verificationOptions['id'] . '_vv']['errors'])) { |
|
2277 | + $_SESSION[$verificationOptions['id'] . '_vv']['errors'] = 0; |
|
2278 | + } |
|
2189 | 2279 | // Too many errors? |
2190 | - elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) |
|
2191 | - $force_refresh = true; |
|
2280 | + elseif ($_SESSION[$verificationOptions['id'] . '_vv']['errors'] > $thisVerification['max_errors']) { |
|
2281 | + $force_refresh = true; |
|
2282 | + } |
|
2192 | 2283 | |
2193 | 2284 | // Keep a track of these. |
2194 | 2285 | $_SESSION[$verificationOptions['id'] . '_vv']['errors']++; |
@@ -2221,8 +2312,9 @@ discard block |
||
2221 | 2312 | // Are we overriding the range? |
2222 | 2313 | $character_range = !empty($verificationOptions['override_range']) ? $verificationOptions['override_range'] : $context['standard_captcha_range']; |
2223 | 2314 | |
2224 | - for ($i = 0; $i < 6; $i++) |
|
2225 | - $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2315 | + for ($i = 0; $i < 6; $i++) { |
|
2316 | + $_SESSION[$verificationOptions['id'] . '_vv']['code'] .= $character_range[array_rand($character_range)]; |
|
2317 | + } |
|
2226 | 2318 | } |
2227 | 2319 | |
2228 | 2320 | // Getting some new questions? |
@@ -2230,8 +2322,9 @@ discard block |
||
2230 | 2322 | { |
2231 | 2323 | // Attempt to try the current page's language, followed by the user's preference, followed by the site default. |
2232 | 2324 | $possible_langs = array(); |
2233 | - if (isset($_SESSION['language'])) |
|
2234 | - $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2325 | + if (isset($_SESSION['language'])) { |
|
2326 | + $possible_langs[] = strtr($_SESSION['language'], array('-utf8' => '')); |
|
2327 | + } |
|
2235 | 2328 | if (!empty($user_info['language'])); |
2236 | 2329 | $possible_langs[] = $user_info['language']; |
2237 | 2330 | $possible_langs[] = $language; |
@@ -2250,8 +2343,7 @@ discard block |
||
2250 | 2343 | } |
2251 | 2344 | } |
2252 | 2345 | } |
2253 | - } |
|
2254 | - else |
|
2346 | + } else |
|
2255 | 2347 | { |
2256 | 2348 | // Same questions as before. |
2257 | 2349 | $questionIDs = !empty($_SESSION[$verificationOptions['id'] . '_vv']['q']) ? $_SESSION[$verificationOptions['id'] . '_vv']['q'] : array(); |
@@ -2261,8 +2353,9 @@ discard block |
||
2261 | 2353 | // If we do have an empty field, it would be nice to hide it from legitimate users who shouldn't be populating it anyway. |
2262 | 2354 | if (!empty($_SESSION[$verificationOptions['id'] . '_vv']['empty_field'])) |
2263 | 2355 | { |
2264 | - if (!isset($context['html_headers'])) |
|
2265 | - $context['html_headers'] = ''; |
|
2356 | + if (!isset($context['html_headers'])) { |
|
2357 | + $context['html_headers'] = ''; |
|
2358 | + } |
|
2266 | 2359 | $context['html_headers'] .= '<style>.vv_special { display:none; }</style>'; |
2267 | 2360 | } |
2268 | 2361 | |
@@ -2288,11 +2381,13 @@ discard block |
||
2288 | 2381 | $_SESSION[$verificationOptions['id'] . '_vv']['count'] = empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) ? 1 : $_SESSION[$verificationOptions['id'] . '_vv']['count'] + 1; |
2289 | 2382 | |
2290 | 2383 | // Return errors if we have them. |
2291 | - if (!empty($verification_errors)) |
|
2292 | - return $verification_errors; |
|
2384 | + if (!empty($verification_errors)) { |
|
2385 | + return $verification_errors; |
|
2386 | + } |
|
2293 | 2387 | // If we had a test that one, make a note. |
2294 | - elseif ($do_test) |
|
2295 | - $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2388 | + elseif ($do_test) { |
|
2389 | + $_SESSION[$verificationOptions['id'] . '_vv']['did_pass'] = true; |
|
2390 | + } |
|
2296 | 2391 | |
2297 | 2392 | // Say that everything went well chaps. |
2298 | 2393 | return true; |
@@ -2317,8 +2412,9 @@ discard block |
||
2317 | 2412 | call_integration_hook('integrate_autosuggest', array(&$searchTypes)); |
2318 | 2413 | |
2319 | 2414 | // If we're just checking the callback function is registered return true or false. |
2320 | - if ($checkRegistered != null) |
|
2321 | - return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2415 | + if ($checkRegistered != null) { |
|
2416 | + return isset($searchTypes[$checkRegistered]) && function_exists('AutoSuggest_Search_' . $checkRegistered); |
|
2417 | + } |
|
2322 | 2418 | |
2323 | 2419 | checkSession('get'); |
2324 | 2420 | loadTemplate('Xml'); |
@@ -2469,24 +2565,27 @@ discard block |
||
2469 | 2565 | foreach ($possible_versions as $ver) |
2470 | 2566 | { |
2471 | 2567 | $ver = trim($ver); |
2472 | - if (strpos($ver, 'SMF') === 0) |
|
2473 | - $versions[] = $ver; |
|
2568 | + if (strpos($ver, 'SMF') === 0) { |
|
2569 | + $versions[] = $ver; |
|
2570 | + } |
|
2474 | 2571 | } |
2475 | 2572 | } |
2476 | 2573 | $smcFunc['db_free_result']($request); |
2477 | 2574 | |
2478 | 2575 | // Just in case we don't have ANYthing. |
2479 | - if (empty($versions)) |
|
2480 | - $versions = array('SMF 2.0'); |
|
2576 | + if (empty($versions)) { |
|
2577 | + $versions = array('SMF 2.0'); |
|
2578 | + } |
|
2481 | 2579 | |
2482 | - foreach ($versions as $id => $version) |
|
2483 | - if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2580 | + foreach ($versions as $id => $version) { |
|
2581 | + if (strpos($version, strtoupper($_REQUEST['search'])) !== false) |
|
2484 | 2582 | $xml_data['items']['children'][] = array( |
2485 | 2583 | 'attributes' => array( |
2486 | 2584 | 'id' => $id, |
2487 | 2585 | ), |
2488 | 2586 | 'value' => $version, |
2489 | 2587 | ); |
2588 | + } |
|
2490 | 2589 | |
2491 | 2590 | return $xml_data; |
2492 | 2591 | } |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
110 | 111 | |
111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
112 | 113 | |
113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
116 | + } |
|
115 | 117 | |
116 | 118 | $context['colspan'] = 0; |
117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
148 | 150 | |
149 | 151 | // Jump to the sub action. |
150 | - if (isset($subActions[$context['listing_by']])) |
|
151 | - call_helper($subActions[$context['listing_by']][1]); |
|
152 | - |
|
153 | - else |
|
154 | - call_helper($subActions['all'][1]); |
|
155 | -} |
|
152 | + if (isset($subActions[$context['listing_by']])) { |
|
153 | + call_helper($subActions[$context['listing_by']][1]); |
|
154 | + } else { |
|
155 | + call_helper($subActions['all'][1]); |
|
156 | + } |
|
157 | + } |
|
156 | 158 | |
157 | 159 | /** |
158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
177 | 179 | if ($use_cache) |
178 | 180 | { |
179 | 181 | // Maybe there's something cached already. |
180 | - if (!empty($modSettings['memberlist_cache'])) |
|
181 | - $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
183 | + $memberlist_cache = smf_json_decode($modSettings['memberlist_cache'], true); |
|
184 | + } |
|
182 | 185 | |
183 | 186 | // The chunk size for the cached index. |
184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
234 | 237 | } |
235 | 238 | |
236 | 239 | // Set defaults for sort (real_name) and start. (0) |
237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
238 | - $_REQUEST['sort'] = 'real_name'; |
|
240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
241 | + $_REQUEST['sort'] = 'real_name'; |
|
242 | + } |
|
239 | 243 | |
240 | 244 | if (!is_numeric($_REQUEST['start'])) |
241 | 245 | { |
242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
243 | - fatal_error('Hacker?', false); |
|
246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
247 | + fatal_error('Hacker?', false); |
|
248 | + } |
|
244 | 249 | |
245 | 250 | $_REQUEST['start'] = $match[0]; |
246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
259 | 264 | } |
260 | 265 | |
261 | 266 | $context['letter_links'] = ''; |
262 | - for ($i = 97; $i < 123; $i++) |
|
263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
267 | + for ($i = 97; $i < 123; $i++) { |
|
268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
269 | + } |
|
264 | 270 | |
265 | 271 | // Sort out the column information. |
266 | 272 | foreach ($context['columns'] as $col => $column_details) |
267 | 273 | { |
268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
269 | 275 | |
270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
278 | + } |
|
272 | 279 | |
273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
318 | 325 | { |
319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
320 | - if ($first_offset < 0) |
|
321 | - $first_offset = 0; |
|
327 | + if ($first_offset < 0) { |
|
328 | + $first_offset = 0; |
|
329 | + } |
|
322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
323 | 331 | |
324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -328,8 +336,9 @@ discard block |
||
328 | 336 | } |
329 | 337 | |
330 | 338 | $custom_fields_qry = ''; |
331 | - if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) |
|
332 | - $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
339 | + if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) { |
|
340 | + $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
341 | + } |
|
333 | 342 | |
334 | 343 | // Select the members from the database. |
335 | 344 | $request = $smcFunc['db_query']('', ' |
@@ -399,12 +408,13 @@ discard block |
||
399 | 408 | ) |
400 | 409 | ); |
401 | 410 | $context['custom_search_fields'] = array(); |
402 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
403 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
411 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
412 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
404 | 413 | 'colname' => $row['col_name'], |
405 | 414 | 'name' => $row['field_name'], |
406 | 415 | 'desc' => $row['field_desc'], |
407 | 416 | ); |
417 | + } |
|
408 | 418 | $smcFunc['db_free_result']($request); |
409 | 419 | |
410 | 420 | // They're searching.. |
@@ -417,23 +427,27 @@ discard block |
||
417 | 427 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
418 | 428 | |
419 | 429 | // No fields? Use default... |
420 | - if (empty($_POST['fields'])) |
|
421 | - $_POST['fields'] = array('name'); |
|
430 | + if (empty($_POST['fields'])) { |
|
431 | + $_POST['fields'] = array('name'); |
|
432 | + } |
|
422 | 433 | |
423 | 434 | // Set defaults for how the results are sorted |
424 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
425 | - $_REQUEST['sort'] = 'real_name'; |
|
435 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
436 | + $_REQUEST['sort'] = 'real_name'; |
|
437 | + } |
|
426 | 438 | |
427 | 439 | // Build the column link / sort information. |
428 | 440 | foreach ($context['columns'] as $col => $column_details) |
429 | 441 | { |
430 | 442 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
431 | 443 | |
432 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
433 | - $context['columns'][$col]['href'] .= ';desc'; |
|
444 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
445 | + $context['columns'][$col]['href'] .= ';desc'; |
|
446 | + } |
|
434 | 447 | |
435 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
436 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
448 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
449 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
450 | + } |
|
437 | 451 | |
438 | 452 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
439 | 453 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -456,8 +470,7 @@ discard block |
||
456 | 470 | { |
457 | 471 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
458 | 472 | $search_fields[] = 'name'; |
459 | - } |
|
460 | - else |
|
473 | + } else |
|
461 | 474 | { |
462 | 475 | $fields = array(); |
463 | 476 | $search_fields = array(); |
@@ -482,9 +495,10 @@ discard block |
||
482 | 495 | $search_fields[] = 'email'; |
483 | 496 | } |
484 | 497 | |
485 | - if ($smcFunc['db_case_sensitive']) |
|
486 | - foreach ($fields as $key => $field) |
|
498 | + if ($smcFunc['db_case_sensitive']) { |
|
499 | + foreach ($fields as $key => $field) |
|
487 | 500 | $fields[$key] = 'LOWER(' . $field . ')'; |
501 | + } |
|
488 | 502 | |
489 | 503 | $customJoin = array(); |
490 | 504 | $customCount = 10; |
@@ -503,8 +517,9 @@ discard block |
||
503 | 517 | } |
504 | 518 | |
505 | 519 | // No search fields? That means you're trying to hack things |
506 | - if (empty($search_fields)) |
|
507 | - fatal_lang_error('invalid_search_string', false); |
|
520 | + if (empty($search_fields)) { |
|
521 | + fatal_lang_error('invalid_search_string', false); |
|
522 | + } |
|
508 | 523 | |
509 | 524 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
510 | 525 | |
@@ -542,8 +557,7 @@ discard block |
||
542 | 557 | ); |
543 | 558 | printMemberListRows($request); |
544 | 559 | $smcFunc['db_free_result']($request); |
545 | - } |
|
546 | - else |
|
560 | + } else |
|
547 | 561 | { |
548 | 562 | // These are all the possible fields. |
549 | 563 | $context['search_fields'] = array( |
@@ -558,14 +572,14 @@ discard block |
||
558 | 572 | { |
559 | 573 | unset($context['search_fields']['email']); |
560 | 574 | $context['search_defaults'] = array('name'); |
561 | - } |
|
562 | - else |
|
575 | + } else |
|
563 | 576 | { |
564 | 577 | $context['search_defaults'] = array('name', 'email'); |
565 | 578 | } |
566 | 579 | |
567 | - foreach ($context['custom_search_fields'] as $field) |
|
568 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
580 | + foreach ($context['custom_search_fields'] as $field) { |
|
581 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
582 | + } |
|
569 | 583 | |
570 | 584 | $context['sub_template'] = 'search'; |
571 | 585 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -607,12 +621,14 @@ discard block |
||
607 | 621 | $smcFunc['db_free_result']($result); |
608 | 622 | |
609 | 623 | // Avoid division by zero... |
610 | - if ($most_posts == 0) |
|
611 | - $most_posts = 1; |
|
624 | + if ($most_posts == 0) { |
|
625 | + $most_posts = 1; |
|
626 | + } |
|
612 | 627 | |
613 | 628 | $members = array(); |
614 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
615 | - $members[] = $row['id_member']; |
|
629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
630 | + $members[] = $row['id_member']; |
|
631 | + } |
|
616 | 632 | |
617 | 633 | // Load all the members for display. |
618 | 634 | loadMemberData($members); |
@@ -620,8 +636,9 @@ discard block |
||
620 | 636 | $context['members'] = array(); |
621 | 637 | foreach ($members as $member) |
622 | 638 | { |
623 | - if (!loadMemberContext($member)) |
|
624 | - continue; |
|
639 | + if (!loadMemberContext($member)) { |
|
640 | + continue; |
|
641 | + } |
|
625 | 642 | |
626 | 643 | $context['members'][$member] = $memberContext[$member]; |
627 | 644 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -638,20 +655,21 @@ discard block |
||
638 | 655 | continue; |
639 | 656 | } |
640 | 657 | |
641 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
642 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
643 | - |
|
644 | - elseif ($column['type'] == 'check') |
|
645 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
658 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
659 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
660 | + } elseif ($column['type'] == 'check') { |
|
661 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
662 | + } |
|
646 | 663 | |
647 | 664 | // Enclosing the user input within some other text? |
648 | - if (!empty($column['enclose'])) |
|
649 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
665 | + if (!empty($column['enclose'])) { |
|
666 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
650 | 667 | '{SCRIPTURL}' => $scripturl, |
651 | 668 | '{IMAGES_URL}' => $settings['images_url'], |
652 | 669 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
653 | 670 | '{INPUT}' => $context['members'][$member]['options'][$key], |
654 | 671 | )); |
672 | + } |
|
655 | 673 | } |
656 | 674 | } |
657 | 675 | } |
@@ -692,17 +710,17 @@ discard block |
||
692 | 710 | ); |
693 | 711 | |
694 | 712 | // Get the right sort method depending on the cust field type. |
695 | - if ($row['field_type'] != 'check') |
|
696 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
713 | + if ($row['field_type'] != 'check') { |
|
714 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
697 | 715 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, \'\') DESC', |
698 | 716 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, \'\') ASC' |
699 | 717 | ); |
700 | - |
|
701 | - else |
|
702 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
718 | + } else { |
|
719 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
703 | 720 | 'down' => 't' . $row['col_name'] . '.value DESC', |
704 | 721 | 'up' => 't' . $row['col_name'] . '.value ASC' |
705 | 722 | ); |
723 | + } |
|
706 | 724 | |
707 | 725 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
708 | 726 | } |